File: as.Date.yrs.Rd

package info (click to toggle)
r-cran-popepi 0.4.13%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,656 kB
  • sloc: sh: 13; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,337 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% 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
}