我正在嘗試執行與cor()函數的Pearson相關性,但輸出結果只給出了1和-1,而不是係數本身。所以當我用corrplot()繪製矩陣時,我只能看到那些1和-1值。我該如何解決? 我的數據集可以發現here,看看我的腳本樓下:爲什麼我只能從R中的cor()函數中獲取1和-1?
##Must load the libraries we will need! IF you have not installed the packages, do that before you start.
library("corrplot")
##Load in your datasets
D1=BPT5test
##if you don't have a Y (i.e, you want the same thing to be in both axis), leave this blank
D2=
##Run the spearman correlation. If you want to do a Pearson, change "spearman to "pearson"
##If you have 0s in your dataset, set use = "complete.obs", if you have no 0s, set use = "everything"
CorTest=cor(D1, use = "everything", method = "pearson")
##Let's get to plotting!
##Lots of changing you can do!
#Method can be "circle" "square" "pie" "color"
#ColorRampPalette can be changed, "blue" being the negative, "White" being '0', and "red" being the positive
#Change the title to whatever you want it to be
#tl.col is the color of your labels, this can be set to anything.. default is red
CorGraph=corrplot(CorTest, method = "circle", col = colorRampPalette(c("blue","white","red"))(200), title = "Pearson's Correlation of High-Fat Sugar at 8 weeks", tl.cex = .5, tl.col = "Black",diag = TRUE, cl.ratio = 0.2)
謝謝你,顯然我對統計學的知識缺乏了我最好的。 – Haley