將列表轉換爲數據框 - Convert a list to a data frame

問題:

I have a nested list of data.我有一個嵌套的數據列表。 Its length is 132 and each item is a list of length 20. Is there a quick way to convert this structure into a data frame that has 132 rows and 20 columns of data?它的長度是 132,每一項都是一個長度爲 20 的列表。有沒有一種快速的方法可以把這個結構轉換成一個有 132 行和 20 列數據的數據框?

Here is some sample data to work with:以下是一些可以使用的示例數據:

l <- replicate(
  132,
  as.list(sample(letters, 20)),
  simplify = FALSE
)

解決方案:

參考一: https://en.stackoom.com/question/Hjh1
參考二: https://stackoom.com/question/Hjh1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章