I have two variables, key
and value
, and I want to add them as a key/value pair to a list:
key = "width"
value = 32
mylist = list()
mylist$key = value
The result is this:
mylist
# $key
# [1] 32
But I would like this instead:
mylist
# $width
# [1] 32
How can I do this?