[英]R for loop stopping at 27 of 67 variables(columns) in for-loop Dunn Test
I've been doing Dunns tests as post-hoc and corrections for my thesis data and I've run into an issue.我一直在对我的论文数据进行事后和更正 Dunns 测试,但我遇到了一个问题。 I have 67 variables and 3 groupings that I'm running through, so loops just easily solve the tons of data analysis.我有 67 个变量和 3 个分组,所以循环很容易解决大量的数据分析。
ind1 ind1 | var1(6)变量 1(6) | var...变种... | var67(73)变量 67(73) |
---|---|---|---|
a一种 | value价值 | value价值 | value价值 |
b b | value价值 | value价值 | value价值 |
c c | value价值 | value价值 | value价值 |
I've done a normal kruskal.test for all my variables and groups with no issue, but "dunnTest" and dunn_test" both stop at 27 variables我已经为我的所有变量和组做了一个正常的 kruskal.test 没有问题,但是“dunnTest”和 dunn_test”都在 27 个变量处停止
library(FSA)
Dunn_df = list()
for(i in names(df[,6:73])){
Dunn_df[[i]] <- dunnTest(formula(paste(i, "~ ind1")), data = df, method = "bonferroni")
}
and和
library(rstatix)
Dunn_df = list()
for(i in names(df[,6:73])){
Dunn_df[[i]] <- dunn_test(formula(paste(i, "~ ind1")), data = df, p.adjust.method="BH")
}
both output a nested list that I've able to read with print(Dunn_df), but only do the dunn test on columns 6:32. output 都是一个嵌套列表,我可以使用 print(Dunn_df) 读取它,但只对第 6:32 列进行 dunn 测试。
Without any reproducible example it is very difficult to help you.没有任何可重现的例子,很难帮助你。 Using the example data mtcars
, the function works just fine on a large number of variables, eg使用示例数据mtcars
, function 在大量变量上工作得很好,例如
library(rstatix)
library(purrr)
rep(colnames(mtcars),10) |>
purrr::map(
~dunn_test(formula(paste(.x, "~mpg")), data = mtcars, p.adjust.method="BH")
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.