将长列表转换为数据帧

时间:2019-10-16 19:48:47

标签: r correlation pearson-correlation

我有这么长的对象列表(有683行,但我省略了它们作为示例):

    >cor

                 statistic     parameter p.value      estimate      null.value alternative method                                
    correlazione 0.9363251     6         0.3852444    0.3570561     0          "two.sided" "Pearson's product-moment correlation"
    correlazione 0.7242781     6         0.4961539    0.2835497     0          "two.sided" "Pearson's product-moment correlation"
    correlazione 4.14294       6         0.006058678  0.8608001     0          "two.sided" "Pearson's product-moment correlation"
    correlazione 0.8672409     6         0.4191373    0.3337491     0          "two.sided" "Pearson's product-moment correlation"
    correlazione -0.7009853    6         0.5095706    -0.2751315    0          "two.sided" "Pearson's product-moment correlation"
    correlazione -0.8861072    6         0.4096661    -0.3401773    0          "two.sided" "Pearson's product-moment correlation"
    correlazione 5.747207      6         0.00120747   0.9199313     0          "two.sided" "Pearson's product-moment correlation"
    correlazione 2.057056      6         0.0854038    0.6430975     0          "two.sided" "Pearson's product-moment correlation"
    correlazione 3.415748      6         0.01421782   0.8126439     0          "two.sided" "Pearson's product-moment correlation"
    correlazione 3.56135       6         0.01190775   0.8239272     0          "two.sided" "Pearson's product-moment correlation"
    correlazione 0.7368482     6         0.4890134    0.2880656     0          "two.sided" "Pearson's product-moment correlation"



    str(cor)

 List of 6147

     $ : Named num 1.46
      ..- attr(*, "names")= chr "t"
     $ : Named num 0.646
      ..- attr(*, "names")= chr "t"
     $ : Named num -0.243
      ..- attr(*, "names")= chr "t"
     $ : Named num 0.195
      ..- attr(*, "names")= chr "t"
      [list output truncated]
     - attr(*, "dim")= int [1:2] 683 9
     - attr(*, "dimnames")=List of 2
      ..$ : chr [1:683] "correlazione" "correlazione" "correlazione" "correlazione" ...
      ..$ : chr [1:9] "statistic" "parameter" "p.value" "estimate" ...

我需要683个元素的p.value,因此我需要创建一个数据框683x1。 如何创建它?

1 个答案:

答案 0 :(得分:0)

如果我理解正确,cor是一个列表,并且列表的第一个元素(它是一个数据框)包含您要提取的p值?

data.frame(p_val = cor[1]$p.value)