1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 11:51:59 +02:00

(v0.7.1.9070) na.rm for age(), age_groups()

This commit is contained in:
2019-09-02 15:17:41 +02:00
parent c7be72f0ce
commit 06b6266366
19 changed files with 120 additions and 87 deletions

View File

@ -4,7 +4,7 @@
\alias{age}
\title{Age in years of individuals}
\usage{
age(x, reference = Sys.Date(), exact = FALSE)
age(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE)
}
\arguments{
\item{x}{date(s), will be coerced with \code{\link{as.POSIXlt}}}
@ -12,6 +12,8 @@ age(x, reference = Sys.Date(), exact = FALSE)
\item{reference}{reference date(s) (defaults to today), will be coerced with \code{\link{as.POSIXlt}} and cannot be lower than \code{x}}
\item{exact}{a logical to indicate whether age calculation should be exact, i.e. with decimals. It divides the number of days of \href{https://en.wikipedia.org/wiki/Year-to-date}{year-to-date} (YTD) of \code{x} by the number of days in a year of \code{reference} (either 365 or 366).}
\item{na.rm}{a logical to indicate whether missing values should be removed}
}
\value{
An integer (no decimals) if \code{exact = FALSE}, a double (with decimals) otherwise
@ -35,5 +37,5 @@ df$age_exact <- age(df$birth_date, exact = TRUE)
df
}
\seealso{
\code{\link{age_groups}} to split age into age groups
To split ages into groups, use the \code{\link{age_groups}} function.
}

View File

@ -4,12 +4,14 @@
\alias{age_groups}
\title{Split ages into age groups}
\usage{
age_groups(x, split_at = c(12, 25, 55, 75))
age_groups(x, split_at = c(12, 25, 55, 75), na.rm = FALSE)
}
\arguments{
\item{x}{age, e.g. calculated with \code{\link{age}}}
\item{split_at}{values to split \code{x} at, defaults to age groups 0-11, 12-24, 25-54, 55-74 and 75+. See Details.}
\item{na.rm}{a logical to indicate whether missing values should be removed}
}
\value{
Ordered \code{\link{factor}}
@ -68,7 +70,7 @@ example_isolates \%>\%
ggplot_rsi(x = "age_group")
}
\seealso{
\code{\link{age}} to determine ages based on one or more reference dates
To determine ages, based on one or more reference dates, use the \code{\link{age}} function.
}
\keyword{age}
\keyword{age_group}