R 合并问题。fix.by(by.x,x)中的错误:';由';必须指定唯一有效的列
各位 合并两个数据帧时,我面临一个问题。我有两个相框。我已经为每个数据帧包含了行/列(原始数据相当大)方面的有限数据,如下所示:R 合并问题。fix.by(by.x,x)中的错误:';由';必须指定唯一有效的列,r,merge,type-conversion,R,Merge,Type Conversion,各位 合并两个数据帧时,我面临一个问题。我有两个相框。我已经为每个数据帧包含了行/列(原始数据相当大)方面的有限数据,如下所示: DF1 Cost.Centre.Code GBP 322018 0.00000 400629 0.00000 400629 163.60005 400629 0.00000 400629 28.00001 400629 0.00000 D
DF1
Cost.Centre.Code GBP
322018 0.00000
400629 0.00000
400629 163.60005
400629 0.00000
400629 28.00001
400629 0.00000
DF2
Cost.Centre.Code Function
400629 Global Functions
570001 Business Manages Services
570002 Business Manages Services
570003 Global Functions
570004 Business Manages Services
570005 OTHER
我试图从DF1中的DF2中获取值。我已经对DF2中的Cost.center.Code进行了类型转换(类和模式),以使其与DF1中的内容相匹配
DF2$Cost.Centre.Code <- as.numeric(as.character(DF2$Cost.Centre.Code))
DF2 <- data.frame(lapply(DF2, factor))
DF2$Cost.Center.code您在df和Cost.Center.code中都有Cost.Center.code
参数。(tre
与ter
)你有一个打字中心/centreThank you@Moody\u mudscappper。我真傻,竟然错过了:)…它现在起作用了。你的df中都有Cost.Center.code
,你的by
参数中都有Cost.Center.code
。(tre
与ter
)你有一个打字中心/centreThank you@Moody\u mudscappper。我真傻,竟然错过了:)……它现在正在工作。
DF3 <- merge(x = DF1, y = DF2, by.x = 'Cost.Center.Code', by.y = 'Cost.Center.Code', all.x = TRUE)