1

I have a dataset having multiple variables. My first column is date (date is reported daily but it's missing for few days randomly) and rest are other variables. I want to convert this dataframe to time-series (ts) type. I tried ts() function but it didn't work as ts() is useful for regularly spaced time series.

Please suggest.

Pafnucy
  • 608
  • 1
  • 13
  • 17
Rajan
  • 453
  • 4
  • 22

1 Answers1

2

zoo, from the zoo package, can be used to represent multivariate time-series.

Install it using:

install.packages("zoo")

Example of a two column zoo:

library(zoo)

zoo(matrix(c(1, 20, 3, 91, 3, 15, 8, 33), ncol = 2), order.by = as.POSIXct(c("2015-01-01", "2015-01-02", "2015-01-05", "2015-01-06")))
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
  • I suggest using xts package instead of directly using zoo because it offers greater performance and functionality. – cyberj0g May 26 '15 at 12:54