1

First, new to programming.

I built a table with 3 columns and I want to evaluate based on time series, so I'm playing around with the ts() function. The first column of my table is DATE as.date in the format "yyyy-mm-dd". I have one observation per variable per day. I've apply ts() to the table and tried start=1 (first observation?) and checked head(df) and the DATE column is sending back loose sequence of numbers that I can't identify (12591, 12592, 12593, 12594, 12597, 12598).

Could it be that the as.date is messing things up?

The line I use is:

ts(dy2, start=1, frequency= 1)

I've also been playing with the deltat argument. In the help file it suggests 1/12 for monthly data. Naturally, I tried 1/365 (for daily data), but have yet to be successful.

efridge
  • 85
  • 1
  • 6
  • Please include some sample data (possibly the `head()` of the data.frame you created) to create a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). This will make it easier for others to help you. – MrFlick Jun 27 '14 at 15:10
  • 1
    `ts` is not suitable for daily series. Use the zoo and xts packages instead. – G. Grothendieck Jun 27 '14 at 15:14

1 Answers1

1

As suggested by G. Grothendieck you can use the zoo package. Try this:

require(zoo)
dates <- as.Date(dy2[,1], format = "%Y-%m-%d")
x1 <- zoo(dy2[,2], dates)
plot(x2)
x2 <- zoo(dy2[,3], dates)
plot(x1)

If this does not work, please provide further details about your data as requested by MrFlick. For example, print the output of dput(dy2) or at least head(dy2).

javlacalle
  • 1,029
  • 7
  • 15