% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fractional_years.R
\name{as.Date.yrs}
\alias{as.Date.yrs}
\title{Coerce Fractional Year Values to Date Values}
\usage{
\method{as.Date}{yrs}(x, ...)
}
\arguments{
\item{x}{an \code{yrs} object created by \code{get.yrs}}

\item{...}{unused, included for compatibility with other \code{as.Date}
methods}
}
\value{
A vector of \code{Date} values based on the input fractional years.
}
\description{
Coerces an \code{yrs} object to a \code{Date} object.
Some loss of information comes if \code{year.length = "approx"}
was set when using \verb{[get.yrs]}, so the transformation back
to \code{Date} will not be perfect there. With \code{year.length = "actual"}
the original values are perfectly retrieved.
}
\examples{
data("sire", package = "popEpi")

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

## using actual year lengths
sire$dg_yrs <- get.yrs(sire$dg_date, year.length = "actual")
summary(sire$dg_yrs)
dg_date2 <- as.Date(sire$dg_yrs)
summary(as.numeric(dg_date2 - as.Date(sire$dg_date)))
}
\seealso{
\verb{[get.yrs]}
}
\author{
Joonas Miettinen
}
