![](/img/trans.png)
[英]how to output the corr.test r and p value togather into dataframe?
[英]Can corr.test be used for any dataframe?
我正在嘗試使用psych包中的corr.test查找數據幀( df1
)中變量之間的相關性和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
我嘗試在psych軟件包中運行示例( corr.test(sat.act)
),並且沒有錯誤。 我是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"
我聯系了心理一攬子計划的作者威廉·雷維爾(William Revelle),他說的是:
馬克,很不幸,您發現了1.4.3中引入的錯誤。 1.4.4將在本周末外出前往Cran。 同時,您可以在http://personality-project.org/r (如果使用的是Mac,請從其他存儲庫選擇源)或http://personality-project.org/r/src/contrib上獲得此修復程序,並如果您使用的是PC,請獲取zip文件。 否則,請等到下周。 對不起,這個問題。 只要主題數不相等或缺少某些數據,它仍將起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.