0

我正在尝试df1使用 psych 包中的 corr.test 找到数据帧()中变量之间的相关性和 p 值。数据帧中的变量都是整数,没有 NA。但是当我运行时corr.test(df1),总是有一条错误消息。

Error in data.frame(lower = lower, r = r[lower.tri(r)], upper = upper,  : 
  arguments imply differing number of rows: 0, 28

我尝试运行corr.test(sat.act)psych 包中的示例 ( ) 并且没有错误。我是 R 新手,有人能告诉我数据框有什么问题吗?

> head(df1)
  S1.pre S2.pre S1.post S2.post V1.pre V2.pre V1.post V2.post
1     21     31      25      35      7      1      19       4
2     15     26      21      29     13     11      16      14
3     18     27      23      31      8      2       3       3
4     17     31      18      39     13     11      15      14
5     15     26      16      29     26     15      32      20
6     17     28      16      28      2      4       2       7

> dput(head(df1))
structure(list(S1.pre = c(21L, 15L, 18L, 17L, 15L, 17L), S2.pre = c(31L, 
26L, 27L, 31L, 26L, 28L), S1.post = c(25L, 21L, 23L, 18L, 16L, 
16L), S2.post = c(35L, 29L, 31L, 39L, 29L, 28L), V1.pre = c(7L, 
13L, 8L, 13L, 26L, 2L), V2.pre = c(1L, 11L, 2L, 11L, 15L, 4L), 
V1.post = c(19L, 16L, 3L, 15L, 32L, 2L), V2.post = c(4L, 
14L, 3L, 14L, 20L, 7L)), .Names = c("S1.pre", "S2.pre", "S1.post", 
"S2.post", "V1.pre", "V2.pre", "V1.post", "V2.post"), row.names = c(NA, 
6L), class = "data.frame")

> sapply(df1, class)
S1.pre    S2.pre   S1.post   S2.post    V1.pre    V2.pre   V1.post   V2.post 
"integer" "integer" "integer" "integer" "integer" "integer" "integer" "integer" 
4

1 回答 1

1

我联系了 William Revelle - psych 软件包的作者,他是这样说的:

马克,不幸的是,您发现了 1.4.3 中引入的错误。1.4.4 将于本周末前往 Cran。与此同时,您可以在http://personality-project.org/r (如果您使用的是 mac,请从其他存储库中选择源代码)或 http://personality-project.org/r/src/contrib 和如果您使用的是 PC,请获取 zip 文件。否则,等到下周。对不起这个问题。只要您有不相等数量的主题或一些缺失的数据,它仍然可以工作。

于 2014-04-12T01:03:36.910 回答