Here I have a list with different length vectors. And I'd want to get a data.frame. I've seen lots of posts about it in SO (see ref), but none of them are as simple as I expected because this is really a common task in data preprocessing. Thank you.
Here simplest means as.data.frame(aa) if it works. So one function from the base package of R will be great. sapply(aa, "length<-", max(lengths(aa))) has four functions actually.
An example is shown below.
aa <- list(A=c(1, 3, 4), B=c(3,5,7,7,8))
A and B are the colnames of the data.frame.
One answer is sapply(aa, '[', seq(max(sapply(aa, length)))), but it's also complex.
How to convert a list consisting of vector of different lengths to a usable data frame in R?
Combining (cbind) vectors of different length