I have a variable whose name and value are both determined dynamically. I want to append that variable to a list, so I need to express it in the form list(x)
. My difficulty is defining what x
should be.
So, for example, if the value of the name is given by the variable a
, and the value is b
, I have both
a <- "name"
b <- 3
But then I get this result:
list(a = b)
$a [1] 3
The value is correct but the name is not. I want the list to look behind the variable a
to its current value, which is "name".
How do I do that, please?