I'd like to aggregate time-series data to get weekly data, but doing so the class of the temporal variable becomes "character" instead of "Date", losing therefore any cool features of being a date.
This is quite annoying, especially when I need to plot data and play with breaks and labels.
Here is a short example of what I'm facing
# Storing some random daily data
require(plyr)
require(dplyr)
df = data.frame(date = seq.Date(from = as.Date('2013-01-01'),
to = as.Date('2014-12-31'),
by = 'day'),
data = rnorm(365*2))
Aggregating the data into some weekly data
wdf = df %>%
mutate(week = strftime(df$date, format = '%Y-%U')) %>%
group_by(week) %>%
summarise(wdata = max(data))
Unfortunately now the variable week is not of class "Date". Any idea about the possibility of keeping the class date for objects of the format %Y-%V?
Thanks in advance!
EB