简体   繁体   English

plyr如何合并两列具有相同名称但不同值的不同data.frames

[英]How does plyr merge two columns of different data.frames with same names but different values

While merging 3 data.frames using plyr library, I encounter some values with the same name but with different values each in different data.frames.在使用plyr库合并 3 个 data.frames 时,我遇到了一些具有相同名称但在不同 data.frames 中具有不同值的值。

How does the do.call(rbind.fill,list) treat this problem: by arithmetic or geometric average? do.call(rbind.fill,list)如何处理这个问题:通过算术平均还是几何平均?

From the help page for rbind.fill:从 rbind.fill 的帮助页面:

Combine data.frames by row, filling in missing columns. rbinds a list of data frames 
filling missing columns with NA.

So I'd expect it to fill columns that do not match with NA.所以我希望它能够填充与 NA 不匹配的列。 It is also not necessary to use do.call() here.这里也没有必要使用do.call()

dat1 <- data.frame(a = 1:2, b = 4:5)
dat2 <- data.frame(b = 3:2, c = 8:9)
dat3 <- data.frame(a = 5:6, c = 1:2)

rbind.fill(dat1, dat2, dat3)
   a  b  c
1  1  4 NA
2  2  5 NA
3 NA  3  8
4 NA  2  9
5  5 NA  1
6  6 NA  2

Are you expecting something different?你期待不同的东西吗?

暂无
暂无

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

相关问题 如何比较R中不同data.frames中的两列 - How to compare two columns in different data.frames within R 如何合并具有相同列名但列顺序不同的两个数据框 - How to merge two data frames with same column names but columns in different order 通过不同的列名称合并data.frames并返回用于匹配的BOTH列 - Merge data.frames by different column names and return BOTH columns used for matching 如何使用 base 或 dplyr 通过不同列中的相同值合并 R 中的两个数据框? - How can i merge two data frames in R by the same values in different columns using base or dplyr? 在 R 中通过不同的 row.names 合并两个 data.frames - merging two data.frames by different row.names in R 如何通过列的名称的第一部分合并两个data.frame? - How to merge two data.frames by the first part of a names in a column? 匹配两个不同data.frames的两列 - Match two columns of two different data.frames 绘制具有不同行号和相同列名的 data.frames。 如何添加图例和标题? - plotting data.frames with different row numbers and same col names. How to add legend and titles? R 如何合并 3 列上的 2 个数据框,所有这些数据框都具有不同的列名 - R how to merge 2 data frames on 3 columns all with different column names 如何在四个不同的数据框中添加相同列名但列数不同的值 - How to add values of same column names across four different data frames but with different number of columns
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM