I'm looking for a function that does the same as list
, but puts the names of the input variables into the element names of the list:
a <- 2
b <- c("foo","bar")
betterlist(a,b)
[[a]]
[1] 2
[[b]]
[1] "foo" "bar"
In the output of list(a,b)
, the names "a"
and "b"
would not appear. Does it already exist in any package?