Re: [R] Time series: xts/zoo object at annual (yearly) frequency

2017-10-06 Thread Gabor Grothendieck
Maybe one of these are close enough:

  xts(c(2, 4, 5), yearqtr(1991:1993))

  as.xts(ts(c(2, 4, 5), 1991))

of if you want only a plain year as the index then then use zoo,
zooreg or ts class:

  library(zoo)
  zoo(c(2, 4, 5), 1991:1993)

  zooreg(c(2, 4, 5), 1991)

  ts(c(2, 4, 5), 1991)

On Fri, Oct 6, 2017 at 2:56 AM, John  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@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.



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
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.


Re: [R] Time series: xts/zoo object at annual (yearly) frequency

2017-10-06 Thread Eric Berger
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  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@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]]

__
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.


[R] Time series: xts/zoo object at annual (yearly) frequency

2017-10-06 Thread John
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@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.