Created
August 18, 2015 20:58
-
-
Save ateucher/7ee9982c10d854631402 to your computer and use it in GitHub Desktop.
Summarise hourly data by date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(dplyr) | |
| ## Make some mock data for illustration: | |
| date_time <- seq(as.POSIXct("2014-01-01"), as.POSIXct("2015-08-18"), by = "1 hour") | |
| value <- rnorm(length(date_time)) | |
| my_data <- data.frame(date_time, value) | |
| # Create a date column (remove time) | |
| my_data$date <- as.Date(my_data$date_time, tz = "Canada/Pacific") | |
| # Group by date and summarise values | |
| my_data_summarized <- group_by(my_data, date) %>% | |
| summarise(daily_mean = mean(value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment