R中的配对T测试错误并非所有参数都具有相同的长度
Paired-T test error in R not all arguments have the same length
当我要进行配对t检验时出现如下错误:
t.test(materix_first_timepoint[,1], materix_second_timepoint[0,1], paired=TRUE)
Error in complete.cases(x, y) : not all arguments have the same length
这是我的矩阵的 str:
str(materix_first_timepoint)
num [1:35, 1:4] 23.28 12 3.81 28.63 10.25 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:4] "1 hour" "2 hours" "3 hours" "4 hours"
str(materix_second_timepoint)
num [1:35, 1:4] 13.9 25.5 17.8 18.9 22.7 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:4] "1 hour" "2 hours" "3 hours" "4 hours"
如果我使用 paired=FALSE
执行 t 检验,它会起作用。我不明白出了什么问题。
基本上,您试图将第一个 matrix
(materix_first_timepoint[,1]
) 的一列与 materix_second_timepoint[0,1]
中的 0 个值进行比较,因此它无法工作。
改为尝试 t.test(materix_first_timepoint[,1], materix_second_timepoint[,1], paired = T)
。
当我要进行配对t检验时出现如下错误:
t.test(materix_first_timepoint[,1], materix_second_timepoint[0,1], paired=TRUE)
Error in complete.cases(x, y) : not all arguments have the same length
这是我的矩阵的 str:
str(materix_first_timepoint)
num [1:35, 1:4] 23.28 12 3.81 28.63 10.25 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:4] "1 hour" "2 hours" "3 hours" "4 hours"
str(materix_second_timepoint)
num [1:35, 1:4] 13.9 25.5 17.8 18.9 22.7 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:4] "1 hour" "2 hours" "3 hours" "4 hours"
如果我使用 paired=FALSE
执行 t 检验,它会起作用。我不明白出了什么问题。
基本上,您试图将第一个 matrix
(materix_first_timepoint[,1]
) 的一列与 materix_second_timepoint[0,1]
中的 0 个值进行比较,因此它无法工作。
改为尝试 t.test(materix_first_timepoint[,1], materix_second_timepoint[,1], paired = T)
。