我有两个表,如下所示:
A<-data.frame("Task"=c("a","b","c","d","e"),"FC"=(c(100,120,200,300,400)))
B<-data.frame("Task"=c("a","b","c"),"FC"=(c(20,50,30)))
Task FC
1 a 100
2 b 120
3 c 200
4 d 300
5 e 400
Task FC
1 a 20
2 b 50
3 c 30
如何创建带有输出的table C
是Task
和A
中B
的核心构成的总结?
Task FC
1 a 120
2 b 170
3 c 230
答案 0 :(得分:1)
合并dfs
df=merge(A,B,by="Task",all=F)
汇总数据
df$sum=apply(df[,2:3],1,sum)#sum, sd, min, max or ...
> df
Task FC.x FC.y sum
1 a 100 20 120
2 b 120 50 170
3 c 200 30 230