Essentially, I would like to do a - b
, which results in c
below.
In a not-so-simplified scenario:
-
a
has millions of rows and columns -
b
has only one row, but matching number of columns and column names -
c
should be same dimensions asa
a = data.frame(a = c(1, 2, 3, 4),
b = c(2, 3, 4, 5),
c = c(3, 4, 5, 6))
b = data.frame(a = 1,
b = 2,
c = 3)
c = data.frame(a = c(0, 1, 2, 3),
b = c(0, 1, 2, 3),
c = c(0, 1, 2, 3))
I know that this isn't really a tidyverse
problem, but I would like to use tidyverse
functions as much as possible, if at all possible. I tried to convert them into matrices first, as well as trying something funky with rowwise()
with no luck.
Would some subtraction be apply
-able (applicable?) for matching column names between the dataframes?
Any solutions out there?