Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 3.51 KB

2018-03-28_time.md

File metadata and controls

45 lines (29 loc) · 3.51 KB

Working with dates/time in R ⏰ ⌛ ⌚

NCEAS Hacky Hour 2018-03-28

The CRAN time series task view gives an overview of the R packages that deal with dates and times, particularly for time series analysis.

This 2014 blogpost on Using Dates and Times in R describes several common classes of dates, summarized here:

  • Date: if you have only dates, but no times, in your data
  • POSIXct (calendar time): if you have times in your data, this is usually the best class to use
  • POSIXlt (local time, lists): enables easy extraction of specific componants of a time
  • chron: good option when you don’t need to deal with timezones or daylight savings
  • lubridate: a wrapper for POSIXct with more intuitive syntax (cheatsheet here)
    • distinguishes between four types of objects: instants, intervals, durations, and periods. An instant is a specific moment in time. Intervals, durations, and periods are all ways of recording time spans

NEON has a tutorial series that works through various time types, and includes sample datasets for us to use.

The package tibbletime was developed for business/finance, but was specifically built to work well with the tidyverse.

Example data

Data packages on the Arctic Data Center:

Miscellaneous datasets:

Hacky Hour highlights

Top resources: