我读了this SO question和 that one ,但仍然无法解决我的问题。我有以下 data.table,其中仅包含我的 data.table 的总列和行的一部分。
library(data.table)
structure(list(Patient = c("MB108", "MB108", "MB108", "MB108",
"MB108", "MB108", "MB108", "MB108", "MB108", "MB108"), Visit = c(1,
1, 1, 1, 9, 9, 9, 9, 12, 12), Stimulation = c("NC", "SEB", "PPD",
"E6C10", "NC", "SEB", "PPD", "E6C10", "NC", "SEB"), `CD38 ` = c(83.3,
63.4, 83.2, 91.5, 90.9, 70.9, 71, 88.4, 41.7, 47.9)), .Names = c("Patient",
"Visit", "Stimulation", "CD38 "), class = c("data.table", "data.frame"
), row.names = c(NA, -10L), .internal.selfref = <pointer: 0x102806578>)
我想在访问为 1 和访问为 9 时对第 4 列进行 t.test。 我检查了 NA 以及两列的长度。
感谢您的帮助!
#na.omit(boolean_dt3)
#print(length(unlist(boolean_dt3[Visit== 1,4, with = FALSE])))
#print(length(unlist(boolean_dt3[Visit== 9,4, with = FALSE])))
wilcox.test( unlist(boolean_dt3[Visit== 1,4, with = FALSE])~ unlist(boolean_dt3[Visit== 9,4, with = FALSE]) , paired = T, correct=FALSE)
最佳答案
我刚刚发现 ,
而不是 ~
可以解决我的问题。
关于R:wilcoxon 检验错误:分组因子必须恰好有 2 个水平,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44828059/