Search code examples
rdatetime-seriesraster

R: How to extract dates from a time series


How can I extract dates from a times series? Here is a time series:

x = seq (1, 768)
myts <- ts(x, start=1982, frequency=24)

Originally I needed to create a vector holding date/time data for the rts function, The observations start 1982 with 2 measurements per month going till 2013.


Solution

  • Try:

    time(myts)
    

    or perhaps:

    library(zoo)
    as.yearmon(time(myts))