简体   繁体   English

使用Hmisc包在R中找到与p值的相关性

[英]Finding correlation with p-value in R using Hmisc package

I am trying to find the correlation between variables of a dataframe in R. My head of the dataframe is below. 我试图在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

The code I'm using to find the data frame is below 我用来查找数据框的代码如下

#correlation
install.packages("Hmisc")
library(Hmisc)
rcorr(as.matrix(datafile))

I'm getting the following error when i tried that. 我尝试时遇到以下错误。

> 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

kindly help. 请帮助。

Yes, Just like the comment said. 是的,就像评论中所说的那样。 I had to exclude the variable Taxon, which is not numeric. 我必须排除不是数字的变量Taxon。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM