【问题标题】:Create a nested list out of list names从列表名称中创建嵌套列表
【发布时间】:2014-10-24 10:38:23
【问题描述】:
list1 <- 1:3
list2 <- letters[1:3]

我想将它们组合在一个列表中,但不是,只需在 list(list1, list2) 中简单地列出它们,而是以更通用的方式。

例如,使用ls(pattern = "^list*")。但是,这仅结合了名称而不是实际列表。您如何访问、替换或参考实际列表?

【问题讨论】:

    标签: r list merge nested


    【解决方案1】:

    听起来你在找mget

    list1 <- 1:3
    list2 <- letters[1:3]
    mget(ls(pattern = "list\\d"))
    # $list1
    # [1] 1 2 3
    # 
    # $list2
    # [1] "a" "b" "c"
    

    【讨论】:

    • @Rico,那是你要找的吗?
    猜你喜欢
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 2020-10-22
    • 2021-09-15
    • 1970-01-01
    • 2022-01-11
    • 1970-01-01
    相关资源
    最近更新 更多