R/date2winter.r

Defines functions date2winter

Documented in date2winter

date2winter<-function(x,first=10,last=4){
  if(!first%in%1:12) stop("'first' must be a month number")
  if(!last%in%1:12) stop("'last' must be a month number")
  if (inherits(x,"POSIXct")) x<-as.POSIXlt(x) 
  if (!inherits(x,"POSIXlt")) stop("x must be of class POSIXct or POSIXlt")
  res<-ifelse((x$mon+1)>last & (x$mon+1)<first,"Excluded",ifelse((x$mon+1)>=first,paste(x$year+1900,"-",x$year+1900+1,sep=""),paste(x$year+1900-1,"-",x$year+1900,sep="")))
  attributes(res)$span<-c(first=first,last=last)
  res
}

Try the pgirmess package in your browser

Any scripts or data that you put into this service are public.

pgirmess documentation built on April 8, 2023, 1:12 a.m.