Re: [R] Managing NA values in aggregate

2021-09-04 Thread Jeff Newmiller
Literal translation... aggregate( mydf$value , mydf[ , "year_month", drop=FALSE ] , function( x ) if ( all( is.na( x ) ) ) NA else sum( x, na.rm = TRUE ) ) On September 4, 2021 9:06:57 AM PDT, Stefano Sofia wrote: >Dear R-list users, >I encountered a silly problem usi

[R] Managing NA values in aggregate

2021-09-04 Thread Stefano Sofia
Dear R-list users, I encountered a silly problem using aggregate, but I am not able to get rid of it. I read the manual quite carefully, probaby not enough. Suppose I have the following data frame: mydf <- data.frame(year_month=rep(c("2003-12", "2004-12", "2005-12"), 3), station_number=c(rep(181