トップ 履歴 一覧 Farm ソース 検索 ヘルプ PDF RSS ログイン

相関のグラフ

*disclaimer
1170425

R

相関のグラフ

  • サンプル dmu02shd
> head(dmu02shd)
  SL      MHD      MDD
1  5 1.500000 1.500000
2  4 1.000000 2.000000
5  7 2.000000 1.500000
6  5 1.250000 1.750000
7  4 1.333333 1.666667
8  4 1.333333 1.333333

 plot() で散布図

  • pairs() でも同じ
    • オプション , panel = panel.smooth をつけると線を引いてくれる
> pairs(dmu02shd, panel = panel.smooth)

 psychライブラリーを使う

library(psych)
psych::pairs.panels(dmu02shd)

 PerformanceAnalytics::chart.Correlation

library(PerformanceAnalytics)
chart.Correlation(dmu02shd)

chart.Correlation

  • method = c("pearson", "kendall", "spearman")
    • pearsonがデフォルト
    • タイトルは別途 title()で追加する
      • main="タイトル"
      • line=何行分上にずらすか
      • cex.main=フォントの倍率
chart.Correlation(tmp.C2, method="p")
title(main="C2 by sentence", line = 3, cex.main = 1.5)

 ggpairs()

install.packages("GGally", dependencies=T)
library(ggplot2)
library(GGally)
ggpairs(dmu02shd)