【问题标题】:How to get the name of a named num in R?如何在 R 中获取命名 num 的名称?
【发布时间】:2020-03-23 16:36:54
【问题描述】:

我正在尝试访问 R 中命名 num 的名称。我的列表如下所示:

correlationCoeffs

Line          H.points.per.game  V.points.per.game  H.fg.made.per.game  V.fg.made.per.game
0.3724764838  0.2315726001       0.2315726001       0.2156721183        0.2156721183 

我知道如何访问特定数字和特定条目:

correlationCoeffs[["Line"]]
    0.3724764838
correlationCoeffs["Line"]
    Line
    0.3724764838

但我希望访问给定索引的实际名称(例如,给定索引 1,我希望得到“Line”作为结果)。

【问题讨论】:

    标签: r vector named


    【解决方案1】:

    使用 names() 并提供索引可以帮助解决这个问题。

    names(correlationCoeffs[index]) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-04
      • 1970-01-01
      相关资源
      最近更新 更多