【发布时间】:2021-09-13 10:04:51
【问题描述】:
我运行了一系列方差分析,检查组成员资格与一系列因变量之间的联系,生成的数据框包含每个方差分析模型的结果(一行 = 一个方差分析模型)。我现在想根据我生成的因变量-自变量组合列表运行一系列事后测试,这些组合在多重比较校正中幸存下来。我尝试编写一个函数,将这些 DV-IV 组合中的每一个提交到 pairwise.t.test,尽管我的代码目前没有按预期工作。请在下面查看这段代码的摘录和模拟数据:
# simulated data
df = data.frame(ID = c(1001, 1002, 1003, 1004, 1005, 1006,1007, 1008, 1009, 1010, 1011),
Group = as.numeric(c('0','1','2','0','2','1','0','2','0','1','0')),
testscore_1 = as.numeric(c('23','28','30','15','7','18','29','27','14','22','24')),
testscore_2 = as.numeric(c('1','3','2','5','8','2','5','6','7','8','2')),
testscore_3 = as.numeric(c('18','20','19','15','20','23','19','25','10','14','12')))
# df containing combination of IV and DV that survived multiple comparison correction
df_results = data.frame(Independent_variable = c("Group", "Group"), Dependent_variable=c("testscore_1", "testscore_2"))
dvs_ivs <- paste0("x = df$", df_results$Group, "g = df$", df_results$Dependent_variable)
posthoc_t_test_results <- lapply(dvs_ivs, function(x) {
pairwise.t.test(print.noquote(x), p.adjust.method = "none")
})
Error message : Error in factor(g) : argument "g" is missing, with no default "
有什么建议吗?
【问题讨论】: