say that I have
df1$name <- c('A','B','C','D','E')
df1$val <- c(1, 2, 3, 4, 5)
and
df2$name <- c('A','B')
df2$val <-c(6,7)
I want to calculate df2 - df1
s.t. df3
will be
df3$name <- df2$name
df3$val <- df2$val-df1$val[df1$name==df2$name]
and "match" the names so that
df3$val<-c(6-1,7-2)
would be the output. I tried doing this but I couldn't get the syntax correct, thanks in advance!