https://github.com/joeroe/era
R package for year-based time scales
https://github.com/joeroe/era
archaeology geology paleoclimate paleontology r r-package vctrs
Last synced: about 2 months ago
JSON representation
R package for year-based time scales
- Host: GitHub
- URL: https://github.com/joeroe/era
- Owner: joeroe
- License: other
- Created: 2020-11-09T16:04:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-12T12:53:55.000Z (over 2 years ago)
- Last Synced: 2024-10-12T22:33:53.646Z (about 1 year ago)
- Topics: archaeology, geology, paleoclimate, paleontology, r, r-package, vctrs
- Language: R
- Homepage: https://era.joeroe.io
- Size: 794 KB
- Stars: 11
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.Rmd
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```[](https://www.repostatus.org/#active)
[](https://CRAN.R-project.org/package=era)
[](https://cran.r-project.org/web/checks/check_results_era.html)
[](https://github.com/joeroe/era/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/joeroe/era)**era** is an R package that provides a consistent representation of year-based time scales as a numeric vector with an associated *era* – the [yr class](https://era.joeroe.io/reference/yr.html).
It includes built-in [era definitions](https://era.joeroe.io/reference/eras.html) for many year numbering systems used in contemporary and historic calendars (e.g. Common Era, Islamic 'Hijri' years); year-based time scales used in archaeology, astronomy, geology, and other palaeosciences (e.g. Before Present, SI-prefixed *annus*); and support for [arbitrary user-defined eras](https://era.joeroe.io/reference/era.html). Years can converted from any one era to another using the generalised transformation function [yr_transform()](https://era.joeroe.io/reference/yr_transform.html).
era's classes are based on [vctrs](https://vctrs.r-lib.org/), and come with methods for robust casting and coercion between years and other numeric types, type-stable arithmetic with years, and pretty-printing in tables.
## Installation
You can install the released version of era [from CRAN](https://cran.r-project.org/package=era) with:
```{r install, eval=FALSE}
install.packages("era")
```Or the development version from [GitHub](https://github.com/joeroe/era) using the [remotes](https://remotes.r-lib.org/) package:
```{r install-dev, eval=FALSE}
# install.packages("remotes")
remotes::install_github("joeroe/era")
```## Basic usage
`yr()` defines the era associated with a vector of years:
```{r eg-yr}
library(era)
x <- yr(c(9000, 8000, 7000), "cal BP")
x
```Use `yr_transform()` to convert between eras:
```{r eg-transform}
yr_transform(x, "BCE")
```Many common calendar systems and time scales are predefined (see `?eras()`) and can be referenced by their abbreviated labels.
Other eras can be defined using the `era()` function directly.For further usage, see the [package introduction](https://era.joeroe.io/articles/era.html) (`vignette("era")`).