zoo
The ts
object has its limitations in representing the time series. It is used for representing equally spaced data. It cannot be used to represent the daily level stock prices as stock prices are equally spaced between Monday to Friday, but it is not the same case for Friday to Monday and in case there is market holidays on weekdays. This type of unequally spaced data cannot be represented by a ts
object.
zoo
is flexible and fully equipped to handle unequally spaced data, equally spaced data, and numerically indexed data.
Let us first install and load the zoo
library. This can be done by executing the following code:
> install.packages("zoo") > library(zoo)
Now we will discuss how to represent different time series scenarios using zoo
.
Please note we will be using a common dataset for all the examples.
Constructing a zoo object
In order to create a zoo
object, an ordered time index and data are required. So we are going to construct a zoo
object.
Let us first import a few rows of our...