【问题标题】:including object name from list with tukey test results in "for" loop graph包括列表中的对象名称和“for”循环图中的 tukey 测试结果
【发布时间】:2019-02-08 18:07:41
【问题描述】:

我有一个嵌套列表 (tukey_full),其中包含我运行的各种 TukeyHSD 测试的结果,并且希望将列表中每个对象的名称作为副标题包含在情节中。我已经成功地使用了

 lapply(tukey_full, plot)

 for(i in tukey_full) {
      plot(i)
    }

但是,我不知道如何在副标题中添加对象的名称,我可以通过使用 names 函数看到,与

> names(tukey_full)
 [1] "protein_6289_03860"                                            
 [2] "protein_6289_01870"                                            
 [3] "protein_2945_03380_5751_03109"                                 
 [4] "protein_6289_01021"                                            
 [5] "protein_6289_03009"                                            

我尝试过使用

  for(i in tukey_full) {
  plot(i, sub=(i))

for(i in tukey_full) {
  plot(i, sub=names(i))
}

打印列表让我为每个条目获得以下之一

$protein_6289_01751
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = .x ~ datos_significativos_unknown$cepas)

$`datos_significativos_unknown$cepas`
               diff       lwr        upr     p adj
A-C   -5.1771274 -8.357472 -1.9967829 0.0025429
B-C -4.8750794 -8.770190 -0.9799687 0.0150836
A-B   0.3020481 -2.878296  3.4823926 0.9653298

粘贴(打印())得到我

[1] "list(`datos_significativos_unknown$cepas` = c(2.00490288888889, 2.62596766666667, 0.621064777777779, 0.714833966082775, 1.04596236971821, -0.669004145028336, 3.294971811695, 4.20597296361513, 1.91113370058389, 0.00358339105839034, 0.00217233503326419, 0.429956321252804))"

但这些似乎不起作用。有任何想法吗?谢谢。

【问题讨论】:

    标签: r list tukey


    【解决方案1】:

    你真的很亲密!

    c <- 1
    for(i in tukey_full) {
        plot(i, sub=names(tukey_full[c]))
        c <- c + 1
    }
    

    【讨论】:

      【解决方案2】:

      如果你想使用lapply,你可以试试这个:

      lapply(1:length(tukey_full), function(x) plot(tukey_full[[x]], sub=names(tukey_full)[x]))

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-06-25
        • 2020-06-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-02
        • 2017-05-13
        • 1970-01-01
        相关资源
        最近更新 更多