[R] Time series: xts/zoo object at annual (yearly) frequency
Eric Berger
ericjberger at gmail.com
Fri Oct 6 09:26:59 CEST 2017
Hi John,
Here's one way to do it:
vec <- c(2,4,5)
yrs <- seq(from=as.Date("1991-01-01"),by="1 year",length=length(vec))
a <- xts(x=vec, order.by=yrs)
HTH,
Eric
On Fri, Oct 6, 2017 at 9:56 AM, John <miaojpm at gmail.com> wrote:
> Hi,
>
> I'd like to make a time series at an annual frequency.
>
> > a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993"))
> Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) :
> order.by requires an appropriate time-based object
> > a<-xts(x=c(2,4,5), order.by=1991:1993)
> Error in xts(x = c(2, 4, 5), order.by = 1991:1993) :
> order.by requires an appropriate time-based object
>
> How should I do it? I know that to do for quarterly or monthly time
> series, we use as.yearqtr or as.yearmon. What about annual?
>
> Thanks,
>
> John
>
> [[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.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list