This question is related to an earlier one, except the answer there (use c()
function) is precisely what was not working for me.
First I create a list of vectors and then an additional vector.
a_list <- lapply(mtcars, as.integer)
junk <- c(1:length(a_list[[1]]))
Now, if use c(a_list, junk)
(as suggested in the answer to the earlier question), I get a completely different answer from what I get if I say a_list[["junk"]] <- junk
(the latter yielding the desired result). It seems that what gets added by the former approach is as.list(junk)
.
How can I add junk
using c()
without it being converted to the result of as.list(junk)
?