> On Mar 5, 2018, at 9:07 PM, <alexander.h...@csiro.au> > <alexander.h...@csiro.au> wrote: > > It works if you use as.Date. But this defeates the purpose for the yearmon > notion... > > require(raster) > require(rts) > require(stringr) > r <- raster(ncol=100, nrow=100) > values(r) <- runif(ncell(r)) > stack(r)->s > r->rs > for(i in 1:23){ > rs[]<-r[]*i > addLayer(s,rs)->s > print(nlayers(s)) > } > dt<-list(ID=seq(1:24),month=rep(formatC(1:12,flag=0,width=2),2), > year=sort(rep(2016:2017,12))) > timelst<-paste0(unlist(dt['year']),'-',unlist(dt['month']),"-01") > strptime(timelst,format="%Y-%m-%d")->t1 > > > rts(s,time=as.yearmon(t1))->rsts > subset(rsts,'2017')->r2017 > class(r2017@time) > class(rsts@time) > apply.monthly(rsts,mean) # this creates error > > rts(s,time=as.Date(t1))->rsts1 > apply.monthly(rsts1,mean) # this creates output
So it appears that you have shown that apply.monthly doesn't work with 'yearmon'-classed vectors in the endpoints of a RasterStackTS. It's not documented as doing so after all. So this is really a feature request for the maintainer. You should contact the responsible individual. maintainer('rts') [1] "Babak Naimi <naim...@gmail.com>" > > > -----Original Message----- > From: Jim Lemon [mailto:drjimle...@gmail.com] > Sent: Tuesday, 6 March 2018 11:40 AM > To: Herr, Alexander (L&W, Black Mountain) <alexander.h...@csiro.au> > Cc: David Winsemius <dwinsem...@comcast.net>; r-help mailing list > <r-help@r-project.org> > Subject: Re: [R] raster time series statistics > David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.