简体   繁体   English

将每个单元格中带有 data.frames 的列表列添加到 data.frame

[英]add list-column with data.frames in each cell to a data.frame

I am trying to add a list-column containing data.frames in each position/cell of the list to a main data.frame我正在尝试将列表的每个位置/单元格中包含 data.frames 的列表列添加到主 data.frame

meta <- data.frame(n=1:2,
           d = list(iris,mtcars))

but this yields an error message:但这会产生一条错误消息:

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 150, 32

MY desired output is the meta data.frame with 2 rows and two columns.我想要的 output 是具有 2 行和 2 列的元数据帧。

The data.frame function doesn't handle list arguments the way you want, but you can add a list column after the fact data.frame function 不会按照您想要的方式处理列表 arguments,但您可以在事后添加列表列

meta <- data.frame(n = 1:2)
meta$d <- list(iris, mtcars)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 R 将列添加到 data.frame 中,即在 data.frames 列表中 - R Add column into data.frame, that is in list of data.frames 向 data.frames 列表中的每个 data.frame 添加新列 - Add new column to each data.frame in list of data.frames 将重叠的data.frames列表转换为单个data.frame - Convert list of overlapping data.frames into single data.frame 如何将data.frame列表追加到data.frame进行合并? - How to append a list of data.frames to a data.frame for merge? 将列表中的data.frames堆叠到单个data.frame中,并保留名称(列表)作为额外的列 - Stacking data.frames in a list into a single data.frame, maintaining names(list) as an extra column 在 R 的 data.frames 列表中使用一个 data.frame 的指定列 - Use a specified column of one data.frame within a list of data.frames in R 将列的名称更改为 data.frames 列表中的 data.frame 的名称 - Changing the names of a column to the name of a data.frame in a list of data.frames R {dplyr}: `rowwise` 列表列中的`rename` 或`mutate` data.frames 在LHS 上有不同的列名 - R {dplyr}: `rename` or `mutate` data.frames in `rowwise` list-column with different column names on LHS 将 data.frames 列表(nx 2 data.frames)更整洁地重塑为单个 data.frame(nx 3 列) - Tidier reshape for list of data.frames (n x 2 data.frames) to single data.frame (n x 3 columns) 合并列表列数据框 - Merging list-column data frames
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM