r - Converting list of varying-length elements to dataframe -


consider following list of vector elements varying length:

test = list(c(a = 1, b = 2), c(a = 3, c = 1), c(a = 9), c(a = 6, b = 7, c = 8)) 

i convert list dataframe, while matching names of elements in following fashion:

 #   b  c  #  1  2 na  #  3 na  1  #  9 na na  #  6  7  8 

any appreciated. thanks!

library(plyr)  rbind.fill(lapply(test, function(x) as.data.frame(t(x)))) #   b  c #1 1  2 na #2 3 na  1 #3 9 na na #4 6  7  8 

Comments

Popular posts from this blog

mongodb - Struggling to get ordered results from the last retrieved article, given array of elements to search in -

c# - Pausing a storyboard on TabItem mouse over -

c# - Attribute value in root node of xml Linq to XML -