I have searched various R aggregation questions here on stackoverflow (e.g Aggregating hourly data into daily aggregates) but none addresses multivariate table in long format.
My table is hourly table of observed and modeled values (for a whole year), for each site (up to eight) as shown below:
date obs mod site
2017-01-01 00:00:00 1.2 -0.7 Carib
2017-01-01 01:00:00 3.1 -0.9 Carib
2017-01-01 02:00:00 2.1 -0.3 Carib
..
..
2017-02-17 10:00:00 2 1.5 Halley
2017-02-17 11:00:00 2.7 1.8 Halley
2017-02-17 12:00:00 3 2.2 Halley
..
..
2017-03-13 13:00:00 5.6 5.6 Yules
2017-03-13 14:00:00 6.5 5.0 Yules
2017-03-13 15:00:00 7.5 4.6 Yules
Below is the result I would like to have (excluding missing data)
date max_obs max_mod mean_obs mean_mod site
2017-01-01 -0.7 3.1 -0.9 0.9 Carib
2017-01-02 0.2 -1.5 -0.3 0.5 Carib
..
..
2017-02-17 2.2 1.5 1.1 0.8 Halley
2017-02-18 1.6 1.9 1.2 0.9 Halley
..
..
2017-03-13 5.6 5.2 4.7 5.0 Yules
2017-03-14 5.0 5.2 4.9 5.2 Yules
..
I imported my data as table, and tried daily averaging with date <- as.Date(DT$date,"%Y-%m-%d")
but not getting what I want. Any help will be appreciated.