Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tidyverse/lubridate
Make working with dates in R just that little bit easier
https://github.com/tidyverse/lubridate
date date-time r
Last synced: 4 days ago
JSON representation
Make working with dates in R just that little bit easier
- Host: GitHub
- URL: https://github.com/tidyverse/lubridate
- Owner: tidyverse
- License: gpl-3.0
- Created: 2009-03-11T01:18:52.000Z (almost 16 years ago)
- Default Branch: main
- Last Pushed: 2024-08-05T19:52:46.000Z (4 months ago)
- Last Synced: 2024-12-01T18:08:20.562Z (11 days ago)
- Topics: date, date-time, r
- Language: R
- Homepage: https://lubridate.tidyverse.org
- Size: 13.9 MB
- Stars: 734
- Watchers: 46
- Forks: 207
- Open Issues: 102
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Support: .github/SUPPORT.md
Awesome Lists containing this project
- awesome-starred - lubridate - Make working with dates in R just that little bit easier (R)
- jimsghstars - tidyverse/lubridate - Make working with dates in R just that little bit easier (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures"
)
```# lubridate
[![CRAN version](http://www.r-pkg.org/badges/version/lubridate)](https://cran.r-project.org/package=lubridate)
[![R build status](https://github.com/tidyverse/lubridate/workflows/R-CMD-check/badge.svg)](https://github.com/tidyverse/lubridate/actions)
[![Coverage Status](https://app.codecov.io/gh/tidyverse/lubridate/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/lubridate)
[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/lubridate)](https://cran.r-project.org/package=lubridate)
[![Development version](https://img.shields.io/badge/devel-1.7.4.9000-orange.svg)](https://github.com/tidyverse/lubridate)
[![R-CMD-check](https://github.com/tidyverse/lubridate/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidyverse/lubridate/actions/workflows/R-CMD-check.yaml)## Overview
Date-time data can be frustrating to work with in R. R commands for date-times are generally unintuitive and change depending on the type of date-time object being used. Moreover, the methods we use with date-times must be robust to time zones, leap days, daylight savings times, and other time related quirks, and R lacks these capabilities in some situations. Lubridate makes it easier to do the things R does with date-times and possible to do the things R does not.
If you are new to lubridate, the best place to start is the
[date and times chapter](https://r4ds.had.co.nz/dates-and-times.html) in R
for data science.## Installation
```{r, eval = FALSE}
# The easiest way to get lubridate is to install the whole tidyverse:
install.packages("tidyverse")# Alternatively, install just lubridate:
install.packages("lubridate")# Or the development version from GitHub:
# install.packages("devtools")
devtools::install_github("tidyverse/lubridate")
```## Cheatsheet
## Features
```{r}
library(lubridate, warn.conflicts = FALSE)
```* Easy and fast parsing of date-times: `ymd()`, `ymd_hms`, `dmy()`, `dmy_hms`,
`mdy()`, ...```{r}
ymd(20101215)
mdy("4/1/17")
```* Simple functions to get and set components of a date-time, such as `year()`,
`month()`, `mday()`, `hour()`, `minute()` and `second()`:```{r}
bday <- dmy("14/10/1979")
month(bday)
wday(bday, label = TRUE)year(bday) <- 2016
wday(bday, label = TRUE)
```* Helper functions for handling time zones: `with_tz()`, `force_tz()`
```{r}
time <- ymd_hms("2010-12-13 15:30:30")
time# Changes printing
with_tz(time, "America/Chicago")# Changes time
force_tz(time, "America/Chicago")
```Lubridate also expands the type of mathematical operations that can be performed with date-time objects. It introduces three new time span classes borrowed from https://www.joda.org.
* `durations`, which measure the exact amount of time between two points
* `periods`, which accurately track clock times despite leap years, leap
seconds, and day light savings time* `intervals`, a protean summary of the time information between two points
## Code of Conduct
Please note that the lubridate project is released with a [Contributor Code of Conduct](https://lubridate.tidyverse.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.