Skip to content

monthly median in a daily dataset

2 messages · Krishna Kumar, Uwe Ligges

2 days later
#
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