我正在尝试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"