Learn R Programming

popEpi (version 0.3.1)

as.Date.yrs: Coerce Fractional Year Values to Date Values

Description

Coerces an yrs object to a Date object. Some loss of information comes if year.length = "approx" was set when using get.yrs, so the transformation back to Date will not be perfect there. With year.length = "actual" the original values are perfectly retrieved.

Usage

"as.Date"(x, ...)

Arguments

x
an yrs object created by get.yrs
...
unused, included for compatibility with other as.Date methods

Examples

Run this code

test <- copy(sire)

## approximate year lengths: here 20 % have an extra day added
test$dg_yrs <- get.yrs(test$dg_date)
summary(test$dg_yrs)
dg_date2 <- as.Date(test$dg_yrs)
summary(as.numeric(dg_date2 - test$dg_date))

## using actual year lengths
test$dg_yrs <- get.yrs(test$dg_date, year.length = "actual")
summary(test$dg_yrs)
dg_date2 <- as.Date(test$dg_yrs)
summary(as.numeric(dg_date2 - test$dg_date))

Run the code above in your browser using DataLab