I have two tables as follow:
a<-data.frame("Task"=c("A","B","C","D","E"),"FC"=c(100,NA,300,500,400),"FH"=c(NA,100,200,NA,300))
Task FC FH
1 A 100 NA
2 B NA 100
3 C 300 200
4 D 500 NA
5 E 400 300
b<-data.frame("Task"=c("A","B","C"),FC=c(10,20,30),FH=c(20,10,30))
Task FC FH
1 A 10 20
2 B 20 10
3 C 30 30
I want the output with sum
of the corresponding values from table a
and table b
but if the value is NA
the output is NA
The output is like this:
Task FC FH
1 A 110 NA
2 B NA 110
3 C 330 230