r - List of different length vectors to dataframe -
this question has answer here:
i trying convert list of vectors differing lengths dataframe using sapply -
lst = list(c(1, 2, 3), c(4, 5), c(2, 7, 3)) rand = sapply(lst, function(x) {length(x) = 3})
but gives me output -
rand [1] 3 3 3
whereas want -
[[1]] [1] 1 2 3 [[2]] [1] 4 5 na [[3]] [1] 2 7 3
Comments
Post a Comment