从多个表的$:chr行中的5个(假名)列表中选择特定行数据(数字)

时间:2019-02-12 13:19:13

标签: r dataframe

大家好。我有点喜欢简单的代码。实际上,我有以下输出:

roc_value

, , MAXENT.Phillips, RUN1, PA1

         Testing.data Cutoff Sensitivity Specificity
KAPPA           0.558  484.0      63.713      90.667
TSS             0.555  354.0      73.840      81.667
ROC             0.863  369.5      72.996      83.000
ACCURACY        0.788  484.0      63.713      90.667
BIAS            0.996  344.0      73.840      79.667

, , GLM, RUN1, PA1

         Testing.data Cutoff Sensitivity Specificity
KAPPA           0.565    422      83.122      74.333
TSS             0.575    422      83.122      74.333
ROC             0.843    420      83.122      74.333
ACCURACY        0.782    422      83.122      74.333
BIAS            0.979    518      72.574      79.667

, , GAM, RUN1, PA1

         Testing.data Cutoff Sensitivity Specificity
KAPPA           0.664  554.0      81.435      85.000
TSS             0.664  554.0      81.435      85.000
ROC             0.885  557.5      81.435      85.333
ACCURACY        0.834  595.0      76.793      88.667
BIAS            0.996  554.0      81.435      85.000

, , RF, RUN1, PA1

         Testing.data Cutoff Sensitivity Specificity
KAPPA           0.768    404      83.544      92.000
TSS             0.762    404      83.544      92.000
ROC             0.950    406      83.544      92.667
ACCURACY        0.886    485      81.435      94.333
BIAS            0.987    343      84.810      89.000

, , MAXENT.Tsuruoka, RUN1, PA1

         Testing.data Cutoff Sensitivity Specificity
KAPPA           0.509    368      86.498      66.000
TSS             0.527    321      90.717      61.667
ROC             0.838    372      86.498      66.333
ACCURACY        0.756    479      74.262      76.333
BIAS            0.970    488      70.464      78.667

str(roc_value)是:

num [1:5, 1:4, 1:5, 1, 1] 0.558 0.555 0.863 0.788 0.996 ...
 - attr(*, "dimnames")=List of 5
  ..$ : chr [1:5] "KAPPA" "TSS" "ROC" "ACCURACY" ...
  ..$ : chr [1:4] "Testing.data" "Cutoff" "Sensitivity" "Specificity"
  ..$ : chr [1:5] "MAXENT.Phillips" "GLM" "GAM" "RF" ...
  ..$ : chr "RUN1"
  ..$ : Named chr "PA1"
  .. ..- attr(*, "names")= chr ""

我想从单个对象的Testing.data列中仅选择ROC值(以继续执行脚本),例如:

whatidlike <- c(0.863,0.843,0.885,0.950,0.838) # only a single object with ROC values. 

尝试了dplyrsubset等,因此无法继续。有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

您列出的对象名称看起来很奇怪', , RF, RUN1, PA1',但是您应该能够使用索引访问它们。例如roc_value [[1]],roc_value [[2]] ...等等

因此,然后进一步选择Testing.data就像 roc_value[[1]]['Testing.data']