从列表名称中创建嵌套列表(Create a nested list out of list names)
list1 <- 1:3
list2 <- letters[1:3]
我想将它们组合在一个列表中,但不是简单地将它们列在list(list1, list2) ,而是以更通用的方式。
例如,通过使用ls(pattern = "^list*") 。 但是,这只是组合名称而不是实际列表。 您如何访问,替换或引用实际列表?
list1 <- 1:3 list2 <- letters[1:3]I'd like to combine them in a list but not by simple listing them in list(list1, list2), but in a more generalized fashion.
For example, by using ls(pattern = "^list*"). However, that only combines the names and not the actual lists. How do you access, substitute, or refer to the actual lists?
最满意答案
听起来你正在寻找mget :
list1 <- 1:3 list2 <- letters[1:3] mget(ls(pattern = "list\\d")) # $list1 # [1] 1 2 3 # # $list2 # [1] "a" "b" "c"It sounds like you're looking for mget:
list1 <- 1:3 list2 <- letters[1:3] mget(ls(pattern = "list\\d")) # $list1 # [1] 1 2 3 # # $list2 # [1] "a" "b" "c"更多推荐
发布评论