Is there a command/other way to get the value of a variable that is identical to a character string?
For instance, in the code below I would like to be able to get the value 2
from the call letters[2]
, because the second element of letters
("b"
) is the "same" as the variable name b
.
b <- 2
letters[2]
[1] "b"
Is there a command that does this? Apologies if this has been asked before, I'm new to R.