Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which R time/date class and package to use? [closed]

I have a limited time series exposure in R. So, I wonder which time/date class (and associated package) would be most appropriate to start with.

Among the plethora of packages available at CRAN task view, I so far favor the timeDate, which is a S4 oriented and has nice support for location dependent particularities such as holidays and daylight saving times.

The community apparently favors the zoo package. chron is also popular.
[edit: Here is a list of time/date implementations which lubridate package refers to: POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, timeDate, xts, its, ti, jul, timeSeries, fts. Also lubridate itself has handy time classes duration, period and interval.]

Would really appreciate if somebody with experience with multiple packages would share his opinion on how the available time/date classes compare in terms of usability and extensibility.

Some points of interest (in random order):

  • internationalization (holidays, timezones etc)
  • readily available statistical modeling procedures
  • readily available visualization tools
  • ease of use
  • compatibility with builtin date/time-series classes (POSIX,ts)
  • extensibility (S4 is desirable)
  • best to use with lubridate

Thanks.

like image 925
VitoshKa Avatar asked Dec 04 '10 18:12

VitoshKa


People also ask

Which R package is useful and easier to work with date and times?

This chapter will focus on the lubridate package, which makes it easier to work with dates and times in R.

What class should time be in R?

R has developed a special representation for dates and times. Dates are represented by the Date class and times are represented by the POSIXct or the POSIXlt class. Dates are stored internally as the number of days since 1970-01-01 while times are stored internally as the number of seconds since 1970-01-01.

What types of date time data does R use to declare instances in time?

The month and date separated by - . This default format used in R is the ISO 8601 standard for date/time. ISO 8601 is the internationally accepted way to represent dates and times and uses the 24 hour clock system. Let us create the release date using another function ISOdate() .

What is the default date format in R?

Note that the default date format is YYYY-MM-DD; therefore, if your string is of different format you must incorporate the format argument. There are multiple formats that dates can be in; for a complete list of formatting code options in R type ? strftime in your console.


2 Answers

(I am moving this from the comments to the answer portion of stackoverflow at the request of the original poster.)

There is an article in R News 4/1 ("R Help Desk", p. 29) that specifically compares Date, POSIXct and chron. (The 1st two are in core of R and chron is a package.)

timeDate class (in the timeDate package) is based on POSIXct but has extra time zone/financial center support.

For regularly spaced series the the tis package supports many notions of dates.

The mondate package supports accounting dates.

The zoo time series package supports just about any date/time class and also has yearmon and yearqtr for ts compatibility.

The xts time series package works on top of zoo and handles the most common date/time classes by translating them to POSIXct and back again.

There is also information in the Time Series CRAN Task View.

like image 20
G. Grothendieck Avatar answered Oct 19 '22 01:10

G. Grothendieck


Use POSIXct and lubridate.

like image 182
hadley Avatar answered Oct 19 '22 02:10

hadley