Skip to content
Prev 361627 / 398506 Next

create an empty data frame and then fill in it (and then evaluate the mean of semi-hourly data for each day)

On 10/06/2016 6:45 AM, Stefano Sofia wrote:
lapply() returns a list.  Petr's solution is probably better, but you 
could likely get what you want using vapply() instead:

df_snow_day$snow <- vapply(df_snow_day$day, function(x) 
round(mean(df_snow$snow[df_snow$day == x], na.rm=T)), 0)

The 0 at the end is an example of the numeric function result you want, 
so that vapply() knows to create a numeric vector.

Duncan Murdoch