r - How to insert list of vector to a data frame -
i want insert list of vector (have same element) dataframe.
this code:
library(data.table) // create data frame , list myframe <- data.frame() mylist <- list() indexrow <- 1 //to make list of 100 vectors for(i in 1:100) { mylist[[indexrow]] <- c(i,i,i) indexrow <- indexrow + 1 } // last inset mylist myframe myframe <- rbindlist(list(myframe,mylist))
i hope frame be
x1 x2 x3 1 1 1 2 2 2 3 3 3 ... 100 100 100
but inserting column, not row:
x1 x2 ... x100 1 2 100 1 2 100 1 2 100
can me?
if transpose matrix, should fine:
t(myframe)
as pointed out in comments inefficient generate data this.
Comments
Post a Comment