Is it possible to access items from a list using a string containing the items name? Example:
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]
I'm trying to access some plots I have stored in a list using strings returned from a shiny input box. If it isnt possible I'll have to think of a better way of generating the list, but I feel I'm missing something simple but hard to search for without knowing the correct terms.