as_year: Year Conversion from _Rata Die_

as_yearR Documentation

Year Conversion from Rata Die

Description

Year Conversion from Rata Die

Usage

as_year(object, calendar, ...)

## S4 method for signature 'numeric,JulianCalendar'
as_year(object, calendar, ...)

## S4 method for signature 'numeric,GregorianCalendar'
as_year(object, calendar, decimal = TRUE, ...)

Arguments

object

A RataDie object (see fixed()).

calendar

A TimeScale object specifying the target calendar (see calendar()).

...

Currently not used.

decimal

A logical scalar: should decimal years be returned? If FALSE, the decimal part is dropped.

Value

A numeric vector of (decimal) years.

Author(s)

N. Frerebeau

References

Reingold, E. M. and Dershowitz, N. (2018). Calendrical Calculations: The Ultimate Edition. Cambridge University Press. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1017/9781107415058")}.

See Also

Other fixed date tools: arithmetic, as_date(), as_decimal(), as_fixed(), fixed(), fixed_gregorian, fixed_julian, format(), pretty()

Examples

## R 1.0.0
(y <- fixed(year = 2000, month = 02, day = 29, calendar = CE()))
as_date(y, calendar = CE())
as_year(y, calendar = CE())

## Create a vector of years BP (Gregorian)
## (every two years starting from 2000 BP)
(years <- seq(from = 2000, by = -2, length.out = 10))
## Convert years to rata die
(rd <- fixed(years, calendar = BP()))
## Convert back to Gregorian years BP
as_year(rd, calendar = BP())

## More convenient
(rd <- fixed_from_BP(years))
fixed_to_BP(rd)

aion documentation built on Oct. 4, 2024, 5:07 p.m.