Converting a list to a data frame making each nested element a column in the df using r -


using r:

i have list of 100 this:

[[1]]          b st1   2   3 st2   4  10 st3   5   6  [[2]]           b st1    4   8 st2    5   2 st3   20  10 

until 100... in same structure. know how combine them df fall 3 columns vertically. however, want this:

      a1   b1   a2  b2... a100  b100 st1   2   3      4   8 st2   4  10      5   2 st3   5   6     20  10 

does know how this?

thanks lot!

we can use do.call(cbind convert list of data.frames single data.frame

df1 <- do.call(cbind, lst) colnames(df1) <- make.unique(colnames(df1)) 

or

colnames(df1) <- paste0(colnames(df1), rep(seq_along(lst), each=length(lst))) df1 #    a1 b1 a2 b2 #st1  2  3  4  8 #st2  4 10  5  2 #st3  5  6 20 10 

or simply

df1 <- data.frame(lst) 

and change column names.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -