I have two data frames that I need to subtract the same columns per time and store the results in a different data frame:
dput(t)
structure(list(time = structure(c(2L, 1L, 3L), .Label = c("1/13/15 1:18 PM",
"1/13/15 12:18 PM", "1/13/15 2:18 PM"), class = "factor"), web01 = c(24083L,
24083L, 24083L), web03 = c(24083L, 24083L, 24083L)), .Names = c("time",
"web01", "web03"), class = "data.frame", row.names = c(NA, -3L
))
dput(d)
structure(list(time = structure(c(2L, 1L, 3L), .Label = c("1/13/15 1:18 PM",
"1/13/15 12:18 PM", "1/13/15 2:18 PM"), class = "factor"), web01 = c(7764.8335,
7725, 7711.5), web03 = c(10885.5, 10582.333, 10104.5)), .Names = c("time",
"web01", "web03"), class = "data.frame", row.names = c(NA, -3L
))
Data frame t and d are just sample, my actual data frames have 20 columns. Data frame t and d in this case have the same column names and time will the same for each row for both data frames.
I need to subtract d from d for the same time period and store the result in a different data frame. Any ideas how I could do this in R