Re: [R] monthly mean for each month and each year in the data frame

2020-09-14 Thread Stefano Sofia
-mail: stefano.so...@regione.marche.it ---Oo-oO Da: Rui Barradas [ruipbarra...@sapo.pt] Inviato: lunedì 14 settembre 2020 12.53 A: Stefano Sofia; r-help mailing list Oggetto: Re: [R] monthly mean for each month and each year in the data

Re: [R] monthly mean for each month and each year in the data frame

2020-09-14 Thread Rui Barradas
Hello, Here are two aggregate options, the first base R only, the second one with package zoo. year_month <- format(df$data_POSIX, "%Y-%m") aggregate(value ~ year_month, df, mean)# or even value ~ format(etc) # year_monthvalue #12019-01 6.430922 #22019-02 4.846731 #32019-

Re: [R] monthly mean for each month and each year in the data frame

2020-09-14 Thread Stefano Sofia
Da: Jim Lemon [drjimle...@gmail.com] Inviato: lunedì 14 settembre 2020 12.29 A: Stefano Sofia Cc: r-help mailing list Oggetto: Re: [R] monthly mean for each month and each year in the data frame Hi Stefano, What about this? df$months<-format

Re: [R] monthly mean for each month and each year in the data frame

2020-09-14 Thread Jim Lemon
Hi Stefano, What about this? df$months<-format(df$data_POSIX,"%Y-%m") snow_means<-by(df$value,df$months,mean) Jim On Mon, Sep 14, 2020 at 8:19 PM Stefano Sofia wrote: > > Dear R-list users, > I know that this is a trivial question, but I already wasted quite a large > amount of time on that. >

[R] monthly mean for each month and each year in the data frame

2020-09-14 Thread Stefano Sofia
Dear R-list users, I know that this is a trivial question, but I already wasted quite a large amount of time on that. I have a data frame with daily data of snow fall. I need to evaluate the monthly mean for each month and each year in the data frame. Could you help me to find an eficient way for