Skip to content
Prev 361299 / 398503 Next

Trimming time series to only include complete years

Sorry, I put too many bugs (opportunities for excellence!) in this on my 
first pass on this to leave it alone :-(

isPartialWaterYear2 <- function( d ) {
   dtl <- as.POSIXlt( d )
   wy1 <- cumsum( ( 9 == dtl$mon ) & ( 1 == dtl$mday ) )
   # any 0 in wy1 corresponds to first partial water year
   result <- 0 == wy1
   # if last day is not Sep 30, mark last water year as partial
   if ( 8 != dtl$mon[ length( d ) ]
      | 30 != dtl$mday[ length( d ) ] ) {
         result[ wy1[ length( d ) ] == wy1 ] <- TRUE
   }
   result
}

dat2 <- dat[ !isPartialWaterYear( dat$Date ), ]
On Sat, 28 May 2016, Jeff Newmiller wrote:

            
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k