【发布时间】:2018-10-27 03:22:43
【问题描述】:
如何在 R 中使用散列以使键值具有其他散列?
在python中我会有这样的东西:
hash = {}
hash["other_hash"] = {}
hash["other_hash"]["value"] = 5
在 R 中,我尝试使用散列库和 env 结构来创建散列,但我无法在其他散列的键值内创建一个散列。
【问题讨论】:
如何在 R 中使用散列以使键值具有其他散列?
在python中我会有这样的东西:
hash = {}
hash["other_hash"] = {}
hash["other_hash"]["value"] = 5
在 R 中,我尝试使用散列库和 env 结构来创建散列,但我无法在其他散列的键值内创建一个散列。
【问题讨论】:
您可以使用list():
hash <- list(other_hash = list(value = 5))
hash$other_hash$value #5
【讨论】:
hash[["other_hash"]][["value"]] 将产生相同的结果