Tips for More Date and Time Functionality in R
Once you have a really good grip on using date and time, you may want to explore additional functionality available in R and add-on packages by looking at the following:
chron: R has the simpler chron class for datetime objects that don’t have a time zone. To investigate this class, first load the chron package with library(“chron”) and then read the Help file ?chron.
lubridate: You can download the add-on package lubridate from CRAN. This package provides many functions to make it easier to work with dates. You can download and find more information at CRAN.
R also has very good support for objects that represent time series data. Time series data usually refers to information that was recorded at fixed intervals, such as days, months, or years:
ts: In R, you use the ts() function to create time series objects. These are vector or matrix objects that contain information about the observations, together with information about the start, frequency, and end of each observation period. With ts class data you can use powerful R functions to do modeling and forecasting — for example, arima() is a general model for time series data.
zoo and xts: The add-on package zoo extends time series objects by allowing observations that don’t have such strictly fixed intervals. You can download it from CRAN. The add-on package xts provides additional extensions to time series data and builds on the functionality of ts as well as zoo objects. You can also download xts from CRAN.