as_decimal: Converts a Date to a Decimal of its Year

as_decimalR Documentation

Converts a Date to a Decimal of its Year

Description

Converts a Date to a Decimal of its Year

Usage

as_decimal(year, month, day, calendar)

## S4 method for signature 'numeric,numeric,numeric,TimeScale'
as_decimal(year, month, day, calendar)

Arguments

year

A numeric vector of years. If month and day are missing, decimal years are expected.

month

A numeric vector of months.

day

A numeric vector of days.

calendar

A TimeScale object specifying the calendar of year, month and day (see calendar()).

Value

A numeric vector of (ecimal years.

Author(s)

N. Frerebeau

See Also

Other fixed date tools: arithmetic, as_date(), as_fixed(), as_year(), 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.