【发布时间】:2019-02-17 14:02:31
【问题描述】:
无论如何我可以根据列表形式的列合并 R 中的两个数据框以获得其他列的总和。下面的一些示例数据:
df1 <- structure(list(id = c("1", "2"),
band = list(c("c1", "c2", "c3"), "c4"),
samples = list(c(32, 2, 61), 20),
time = list(c(307, 2, 238), 74)),
.Names = c("id", "band", "samples", "time"),
row.names = 0:1, class = "data.frame")
df2 <- structure(list(id = c("1", "3"),
band = list(c("c1", "c4"), "c1"),
samples = list(c(1, 2), 2),
time = list(c(4, 2), 7)),
.Names = c("id", "band", "samples", "time"),
row.names = 0:1, class = "data.frame")
我想根据 id 和 band 列从 df1 和 df2 获取合并数据。不幸的是,bands 列是列表形式,我需要根据bands 列中的元素对样本和时间列求和,该列在列表中。我期待下面的
【问题讨论】: