So I have a data frame that has a date column, an hour column and a series of other numerical columns. Each row in the data frame is 1 hour of 1 day for an entire year.
This could be another way to do this using data.table
library(data.table)
# Edited as per Arun's comment
out = setDT(data)[, lapply(.SD, sum), by=Date]
#>out
# Date Hour Melbourne Southern Flagstaff
#1: 2009-05-01 21 0 496 715
or by using dplyr
library(dplyr)
out = data %>% group_by(Date) %>% summarise_each(funs(sum))
#>out
#Source: local data frame [1 x 5]
# Date Hour Melbourne Southern Flagstaff
#1 2009-05-01 21 0 496 715