I have a list
myList = list(a = 1, b = 2)
names(myList)
# [1] "a" "b"
I want to select element from 'myList' by name stored in as string.
for (name in names(myList)){
print (myList$name)
}
This is not working because name = "a", "b". My selecting line actually saying myList$"a"
and myList$"b"
. I also tried:
print(myList$get(name))
print(get(paste(myList$, name, sep = "")))
but didn't work. Thank you very much if you could tell me how to do it.