【问题标题】:How to use hash into hashes in R如何在R中使用散列到散列中
【发布时间】:2018-10-27 03:22:43
【问题描述】:

如何在 R 中使用散列以使键值具有其他散列?

在python中我会有这样的东西:

hash = {} hash["other_hash"] = {} hash["other_hash"]["value"] = 5

在 R 中,我尝试使用散列库和 env 结构来创建散列,但我无法在其他散列的键值内创建一个散列。

【问题讨论】:

    标签: r hash hashtable


    【解决方案1】:

    您可以使用list()

    hash <- list(other_hash = list(value = 5))
    hash$other_hash$value #5
    

    【讨论】:

    • 或者如果 Python 语法感觉很熟悉,hash[["other_hash"]][["value"]] 将产生相同的结果
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 2010-12-31
    • 1970-01-01
    • 2014-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多