Hello,

I believe this solves your problem


fun <- function(x){
        f <- function(x, n){
                if(length(x) < n) x <- c(x, rep(NA, n-length(x)))
                return(x)
        }
        lapply(x, f, max(unlist(lapply(x, length))))
}

fun(result)         # the 'result' list above

list2 <- list(x=1:3, y=1:5, z="abc")
fun(list2)


The function returns a list, then it can be made a matrix, a data.frame or
whatever.

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/Convert-components-of-a-list-to-separate-columns-in-a-data-frame-or-matrix-XXXX-tp4275790p4276510.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to