Skip to content
Prev 245671 / 398506 Next

monthly median in a daily dataset

On 21.12.2010 08:15, SNV Krishna wrote:
The error message is quite helpful, you need a list of all the elements 
you'd have after the "~" in a formula, in this case only the date:

aggregate(df$value, by = list(date = months(df$date)), FUN = median)
Just use Year-Month as the grouping criterion as follows:

aggregate(x=df$value, by = list(date = format(df$date, "%Y-%m")), FUN = 
median)

Uwe Ligges