I have been struggling to do a conditional sum between two dataframes. I tried to recreate the data (in the exact form I recreated it in my real work problem), so I now have to run something that could be a very simple sumif between different worksheets in Excel. I am a newbie on R, so any help would be much appreciated!
x1 <- data.frame("ClientID" = c("75","85","95", "75","85","95", "75","85","95"), "Jan2014" = c(80.25, 96.47, 94.44, 85.29, 97.66, 82.33, 35.44, 55.56, 88.88), "Feb2014" = c(90.25, 46.44, 54.54, 86.29, 87.66, 52.33, 55.44, 44.56, 78.87))
column.names <- c("ClientID", "Jan2014", "Feb2014")
ClientID <- x1$ClientID
ClientID <- unique(ClientID)
rows.no <- length(ClientID)
column.no <- length(column.names)
x2 <- data.frame(matrix(nrow=rows.no, ncol = column.no))
colnames(x2) <- column.names
x2$ClientID <- ClientID
#I want to have the totals for each of the Jan2014 and Feb2014 columsn at the x2 data table, based on the x1 table (sumifs equivalent)
x2$Jan2014 <-
x2$Feb2014 <-