How to convert a huge list-of-vector to a matrix more efficiently?

后端 未结 5 988
别那么骄傲
别那么骄傲 2020-12-07 14:44

I have a list of length 130,000 where each element is a character vector of length 110. I would like to convert this list to a matrix with dimension 1,430,000*10. How can I

5条回答
  •  佛祖请我去吃肉
    2020-12-07 15:23

    You can also use,

    output <- as.matrix(as.data.frame(z))
    

    The memory usage is very similar to

    output <- matrix(unlist(z), ncol = 10, byrow = TRUE)
    

    Which can be verified, with mem_changed() from library(pryr).

提交回复
热议问题