【发布时间】:2023-03-09 14:17:01
【问题描述】:
我正在尝试在 R 中查找数据框变量之间的相关性。我的数据框头部如下。
> head(datafile)
Taxon Petals Internode Sepal Bract Petiole Leaf Fruit
1 I 5.621498 29.48060 2.462107 18.20341 11.27910 1.128033 7.876151
2 I 4.994617 28.36025 2.429321 17.65205 11.04084 1.197617 7.025416
3 I 4.767505 27.25432 2.570497 19.40838 10.49072 1.003808 7.817479
4 I 6.299446 25.92424 2.066051 18.37915 11.80182 1.614052 7.672492
5 I 6.489375 25.21131 2.901583 17.31305 10.12159 1.813333 7.758443
6 I 5.785868 25.52433 2.655643 17.07216 10.55816 1.955524 7.880880
我用来查找数据框的代码如下
#correlation
install.packages("Hmisc")
library(Hmisc)
rcorr(as.matrix(datafile))
我尝试这样做时遇到以下错误。
> rcorr(as.matrix(datafile))
Error in rcorr(as.matrix(datafile)) :
NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning message:
In storage.mode(x) <- "double" : NAs introduced by coercion
请帮忙。
【问题讨论】:
-
您可能需要排除名为
Taxon的第一列。对我来说看起来不是很数字。
标签: r dataframe correlation hmisc