[R] taking daily modes from hourly data
jim at bitwrit.com.au
Wed Sep 24 10:37:14 CEST 2014
On Tue, 23 Sep 2014 01:40:22 PM maria cabello wrote:
> Dear all,
> I have a data frame (datos) of hourly wind speed and direction with
> (1st date, 2nd hour, 3rd wind speed and 4rth wind direction). I have
> able to do the daily mean of the wind speed, but when I try to get the
> frequent wind direction of every day, it doesn't work. I have tried to do
> it with aggregate function, but it only works for mean, max, min...
> mean_wind<- aggregate(datos[range_of_dates,col_wind_speed],
> %Y")), FUN=mean, na.rm=TRUE) #it works perfectly
> mode_wind<- aggregate(datos[range_of_dates,col_wind_direction],
> /%Y")), FUN=mode) #it tells me "numeric"
> Can anyone help me? My data have not the same length for each day,
> for example it is possible that for 1st of January I have 20 hours of
> but for the 2nd of January I have 24, or the 3rd of January I have 18...so
> I need to aggregate the data to calculate the mean and the mode
> column of my date... Thanks in advance
Have a look at the Mode function in the prettyR package.
More information about the R-help