Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在带有'for'循环的列表中执行pairwise.t.test?_R - Fatal编程技术网

如何在带有'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