list of lists with different lengths to data.frame in R

前端 未结 2 1951
悲哀的现实
悲哀的现实 2021-01-12 10:47

I have read many answers in SO about converting list of lists to df. But, I have noticed that they all have the length of lists (within the main big list) to be the same. I

2条回答
  •  耶瑟儿~
    2021-01-12 11:21

    You can convert a list to a matrix, where every element of the matrix will be a list.

    d1 <- data.frame(country_name=names(h1), list=matrix(h1))
    

    That said, I recommend against doing this because it does not fit the R paradigm. Most R functions assume a matrix contains elements from one atomic type.

提交回复
热议问题