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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -