This is horribly basic but I can't seem to figure it out
Suppose I have a list of variable entries:
lst <- list(a=1:4, b=rep('k', 5), c=3)
If I want to add a vector to this with a specified name I should be able to do so by:
c(f=1:5, lst)
But instead of creating an entry called 'f' containing 1 2 3 4 5 it creates five entries (f1 - f5) containing one of the numbers each.
How do I supress this behavior?
I know I can use
lst$f <- 1:5
but I would like to append the list within a function call...
Turn f
into a list of one, and then concatenate it:
c(list(f=1:5), lst)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With