Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s-fleck/dint
A toolkit for working year-quarter and year-month dates
https://github.com/s-fleck/dint
date dates month period quarter r week
Last synced: 10 days ago
JSON representation
A toolkit for working year-quarter and year-month dates
- Host: GitHub
- URL: https://github.com/s-fleck/dint
- Owner: s-fleck
- License: other
- Created: 2018-04-18T09:38:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-20T17:15:34.000Z (22 days ago)
- Last Synced: 2024-12-01T12:47:16.780Z (11 days ago)
- Topics: date, dates, month, period, quarter, r, week
- Language: R
- Homepage: https://s-fleck.github.io/dint/
- Size: 3.15 MB
- Stars: 14
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - s-fleck/dint - A toolkit for working year-quarter and year-month dates (R)
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# dint[![CRAN status](https://www.r-pkg.org/badges/version/dint)](https://cran.r-project.org/package=dint)
[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)A Toolkit for Year-Quarter, Year-Month and Year-Isoweek Dates
S3 classes and methods to create and work with year-quarter and year-month
vectors. Basic arithmetic operations (such as adding and subtracting) are
supported, as well as formatting and converting to and from standard R
Date types. For more info please refer to the
[package vignette](https://CRAN.R-project.org/package=dint/vignettes/dint.html)
or the [documentation](https://s-fleck.github.io/dint/)## Dependencies
dint is implemented strictly in base R and will **always stay free of hard dependencies**.
The optional dependencies of dint are just there to facilitate interoperability
these packages if you are already using them; for example by providing ggplot2
scales.## Installation
Install the release version of dint from CRAN:
```{r cran-installation, eval = FALSE}
install.packages("dint")
```Or install the development version from GitHub with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("s-fleck/dint")
```## Example
```{r example}
library(dint)# creation
q <- date_yq(2014, 4)
m <- as_date_ym(201412)
w <- as_date_yw(as.Date("2017-01-01"))# printing
print(q)
print(m)
print(w) # isoweeks do not follow calendar years!# arithmetic operations
# quarters
q
q + 1
seq(q -2, q + 2)# months
m
m + 1
seq(m -2, m + 2)# formatting
format(q)
format(q, "%Y.%q")
format(q, "%y.%q")
format(m)# get start and end of period
last_of_quarter(q)
first_of_quarter(q)
first_of_month(Sys.Date())
first_of_isoweek(w)
last_of_isoweek(w)```