<2.3 Visualizing two or more variables> verbs.xtabs = xtabs( ~ AnimacyOfRec + RealizationOfRec, data = verbs[verbs$AnimacyOfTheme != "animate", ]) #independent variable : AnimacyOfRec, dependent variable : RealizationOfRec #!= "animate" : inaminateの項のみ含む verbs.xtabs par(mfrow = c(1, 2))#☆ barplot(verbs.xtabs, legend.text=c("anim", "inanim")) barplot(verbs.xtabs, beside = T, legend.text = rownames(verbs.xtabs)) par(mfrow =c(1, 1))#☆ verbs.xtabs = xtabs( ~ AnimacyOfRec + AccessOfRec + RealizationOfRecipient, data = dative) verbs.xtabs mosaicplot(verbs.xtabs, main = "dative") plot(ratings$Frequency, ratings$FamilySize) #横軸ratings$Frequency, 縦軸ratings$FamilySizeの散布図 lines(lowess(ratings$Frequency, ratings$FamilySize), col="darkgrey") #グラフに曲線を描く plot(ratings$Frequency, ratings$FamilySize, type = "n", xlab = "Frequency", ylab = "Family Size") #type = "n" : 結果を出力しない text(ratings$Frequency, ratings$FamilySize, as.character(ratings$Word), cex = 0.7) #text() : 文字列をx,yで指定される位置に出力 #as.character() : 因子扱い→文字列扱い #cex = 0.7 : 70%のフォントサイズで出力 pairs(ratings[ , -c(1, 6:8, 10:14)]) #pairwise scatterplot matrix #-c() : 含めない行を指定 <2.4 Trellis graphics> library(lattice) bwplot(RT ~ Correct | NativeLanguage, data = lexdec) #縦軸RT、横軸Correct内のlevels、グループNativeLanguage内のlevels weightRatings[1:5,] xylowess.fnc(Rating ~ Frequency | Subject, data = weightRatings, xlab = "log Frequency", ylab = "Weight Rating") #縦軸Rating,横軸Frequencyの数値を用いた、被験者ごとの散布図+曲線 xyplot(Rating ~ Frequency | Subject, data = weightRatings, xlab = "log Frequency", ylab = "Weight Rating") #上記の曲線なし版 #~追加 english = english[english$AgeSubject == "young", ] #AgeSubjectがyoungのデータのみを抽出 nrow(english) colnames(english) xylowess.fnc(FamilySize ~ NumberComplexSynsets | equal.count(WrittenFrequency), data = english) #縦軸FamilySize、横軸NumberComplexSynsets、WrittenFrequencyの数値が同じWordについて #曲線付散布図 equal.count(english$WrittenFrequency) warlpiri[1:5,] colnames(warlpiri) warlpiri.xtabs = xtabs( ~ CaseMarking + AnimacyOfSubject + WordOrder + AgeGroup, data = warlpiri) warlpiri.xtabs mosaicplot(warlpiri.xtabs, main = "ergative") heid2 = aggregate(heid$RT, list(heid$Word), mean)#各語についてRT値の平均を求める heid2[1:5,] colnames(heid2) = c("Word", "MeanRT") #heid2内のコラムの名前付け items = heid[, c("Word", "BaseFrequency")] items = unique(items) heid2 = merge(heid2, items, by.x = "Word", by.y = "Word") heid2 [1:5,] RT.exp = exp(heid$RT) BaseFrequency.exp = exp(heid$BaseFrequency) plot(RT.exp, BaseFrequency.exp) plot(heid$RT, heid$BaseFrequency)