era is an R package that provides a consistent vector representation of years with an associated calendar era or time scale. It includes built-in definitions of many contemporary and historic calendars; time scales commonly used in archaeology, astronomy, geology, and other palaeosciences (e.g. Before Present, SI-prefixed annus); and support for arbitrary user-defined eras. Functions for converting between eras and for type-stable arithmetic with years are also provided.
You can install the development version of era from GitHub with the remotes package.
# install.packages("remotes") remotes::install_github("joeroe/era")
yr() defines the era associated with a vector of years:
yr is a vector class is based on vctrs. This means it behaves in a consistent, type-stable way across base R and other packages, and fits neatly into tibbles and data frames. Many common calendar systems and time scales are built into the package (see
?eras()) and can be referenced by simply passing their abbreviated label to
yr(). Other eras can be defined using the
era() function directly.
yr_transform() to convert between eras:
yr(10010:10001, "cal BP") %>% yr_transform(era("BCE")) #> # BCE years <yr>: #>  8060 8059 8058 8057 8056 8055 8054 8053 8052 8051 #> # Era: Before Common Era (BCE): calendar years, counted backwards from 0