If you have two dataframes
df_A<-data.frame(AA =c(1,2,3), AB =c(1,4,9)
df_B<-data.frame(BA =c(4,5), BB = c(16,25))
if I do df_C<-df_A[1,] + df_B[1,]
then I get AA = 5
and AB = 17
Basically it is adding the first row from the two data frames.
But if I do df_D<-df_A[3,]+df_B[3,]
then I get AA = NA
and BB = NA
The reason for the NA
is because I don't have a third row in the df_B
.
Is there any way where no values are present you just get the sum of whatever is available? In the above example, I would like to get df_D
as AA = 3
and AB = 9
.