如何在带有'for'循环的列表中执行pairwise.t.test?
我的列表(如何在带有'for'循环的列表中执行pairwise.t.test?,r,R,我的列表(lt): 但是,错误消息是: lista[,i]中的错误:维度数不正确 有什么问题吗?我们不需要拆分 pairwise.t.test(unlist(df_1[1:2]), g = rep(df_1$y, 2), p.adj = 'bonferroni') #Pairwise comparisons using t tests with pooled SD #data: unlist(df_1[1:2]) and rep(df_1$y, 2) # 1 2 #2 1
lt
):
但是,错误消息是:
lista[,i]中的错误:维度数不正确
有什么问题吗?我们不需要拆分
pairwise.t.test(unlist(df_1[1:2]), g = rep(df_1$y, 2), p.adj = 'bonferroni')
#Pairwise comparisons using t tests with pooled SD
#data: unlist(df_1[1:2]) and rep(df_1$y, 2)
# 1 2
#2 1.00 -
#3 0.91 1.00
结果是
?@对不起,我想我测试的数据是错误的。出于好奇,您已经将数据拆分为一个列表
,使用列表(lt
)查看lappy
。@因为只有一个组,所以g
可以应用于此
for (i in vars) {
for (i in i) {
print(pairwise.t.test(x = lt[, i], g = lt[['y']], p.adj = 'bonferroni'))
}
}
pairwise.t.test(unlist(df_1[1:2]), g = rep(df_1$y, 2), p.adj = 'bonferroni')
#Pairwise comparisons using t tests with pooled SD
#data: unlist(df_1[1:2]) and rep(df_1$y, 2)
# 1 2
#2 1.00 -
#3 0.91 1.00