是否可以使用包含项目名称的字符串从列表中访问项目? 例如:
myList <- list( a = list (b = rnorm(10)), c = 'more stuff')
first <- 'a'
second <- 'b'
# do something like this
x <- myList$first$second
# to acheive the same result as this
y <- myList$a$b
# this sort of works
myList$a[second]
#but I cant get it too work with two strings
myList$[first][second]
# ive also tried using a dplyr style
myList$[first] %>% .[second]
我正在尝试使用从闪亮输入框返回的字符串访问我存储在列表中的一些图表。如果不可能,我将不得不考虑一种更好的生成列表的方法,但我觉得我错过了一些简单但很难在不知道正确术语的情况下搜索的内容。