I have child_sequences as list in R
child = c("a","b","c")
I generate this child sequence over and over again based on some logic using a for loop, let say -
child1 = c("a","b","c")
child2 = c("b","a","c")
child3 = c("a","a","b")
and so on.
I want all this lists to be stored as a dataframe so that I can save it to csv and analyze it later.
How do I do it efficiently in R? How can I keep appending this list to dataframe using the same for loop?
My dataframe should look like -
a , b ,c
b, a, c
a, a, b
is.list()to see if something is a list. But building a data.frame row-by-row in R is one of the most inefficient things you can do in R. It's much better to build the data frame column-by-column. What's the actual scenario you are dealing with.