1
votes

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.

1

1 Answers

2
votes

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")))