Just write
df1-df2[colnames(df1)]
# a b c
# 1 1 -3 1
# 2 2 -5 8
# 3 3 -6 -1
2
solved Subtract two data sets where column names are same [closed]
Just write
df1-df2[colnames(df1)]
# a b c
# 1 1 -3 1
# 2 2 -5 8
# 3 3 -6 -1
2
solved Subtract two data sets where column names are same [closed]