R:wilcoxon 检验错误:分组因子必须恰好有 2 个水平

标签 r compiler-errors statistics

我读了this SO questionthat 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/

相关文章:

r - 用成对的行旋转更宽

python - 从带时间戳的流量计数器创建摘要统计信息

r - 将列添加到 R 中的空数据框中

r - 按列索引号 data.table R 过滤

R ggplot log 对数刻度

node.js - npm stats 中的依赖项是否算作下载

sqlite - SQLite 足够好用于统计吗?

C、 "conflicting types for... "错误

scala - sc.textFile Scala错误

lambda - 组合对特定类型的任意对象的实例方法的引用