Skip to content
Prev 350885 / 398502 Next

Mean rain per rain day

Hi Frederic,
It looks like you have a number of daily rainfall values and you want
to get the mean rainfall on days where there was some rain. What you
probably want is:

daily_rainfall<-rpois(50,2)
mean(daily_rainfall[daily_rainfall>0])

You may have to add na.rm=TRUE if there are NAs in your data.

Jim
On Wed, May 13, 2015 at 4:38 PM, Frederic Ntirenganya <ntfredo at gmail.com> wrote: