[R] raster time series statistics

David Winsemius dwinsemius at comcast.net
Tue Mar 6 01:10:18 CET 2018


> On Mar 5, 2018, at 3:28 PM, <Alexander.Herr at csiro.au> <Alexander.Herr at csiro.au> wrote:
> 
> Hi List,
> 
> The following code returns an "Error in as.POSIXlt.character(x, tz, ...) :   character string is not in a standard unambiguous format"

I'm unable to produce that error. Which function was being evaluated to produce the error? I don't see where as.POSIXlt would have been called. You don't have any Date or POSIXt-classed variables. (I did need to also load the stringr package to get str_pad into my workspace.)

> 
> require(raster)
> require(rts)
> require(stringi)
> r <- raster(ncol=100, nrow=100)
> values(r) <- runif(ncell(r))
> list(ID=seq(1:24),month=rep(str_pad(1:12, pad = 0,width = 2 , "left"),2),year=sort(rep(2016:2017,12)))->dt
> stack(r)->s
> r->rs
> for(i in 1:23){
> rs[]<-r[]*i
>  addLayer(s,rs)->s
> print(nlayers(s))
> }
> timelst<-paste0(unlist(dt['year']),'-',unlist(dt['month']))
> rts(s,time=as.yearmon(timelst))->rsts
> str(rsts at time)
> apply.monthly(rsts,mean)
> 
> I was expecting that the statistics accept the yearmonth format of the timeslot, as it allows subsetting.
> Any suggestions?
> Thanks
> Herry
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   -Gehm's Corollary to Clarke's Third Law



More information about the R-help mailing list