1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 18:41:58 +02:00

cfta streptococci

This commit is contained in:
2019-04-09 10:34:40 +02:00
parent 30b559827c
commit cffb7787d8
22 changed files with 190 additions and 190 deletions

18
R/age.R
View File

@ -72,9 +72,9 @@ age <- function(x, reference = Sys.Date()) {
#' \item{A character:}
#' \itemize{
#' \item{\code{"children"}, equivalent of: \code{c(0, 1, 2, 4, 6, 13, 18)}. This will split on 0, 1, 2-3, 4-5, 6-12, 13-17 and 18+.}
#' \item{\code{"elderly"} or \code{"seniors"}, equivalent of: \code{c(65, 75, 85, 95)}. This will split on 0-64, 65-74, 75-84, 85-94 and 95+.}
#' \item{\code{"fives"}, equivalent of: \code{1:24 * 5}. This will split on 0-4, 5-9, 10-14, 15-19 and so forth, until 120.}
#' \item{\code{"tens"}, equivalent of: \code{1:12 * 10}. This will split on 0-9, 10-19, 20-29 and so forth, until 120.}
#' \item{\code{"elderly"} or \code{"seniors"}, equivalent of: \code{c(65, 75, 85)}. This will split on 0-64, 65-74, 75-84, 85+.}
#' \item{\code{"fives"}, equivalent of: \code{1:20 * 5}. This will split on 0-4, 5-9, 10-14, ..., 90-94, 95-99, 100+.}
#' \item{\code{"tens"}, equivalent of: \code{1:10 * 10}. This will split on 0-9, 10-19, 20-29, ... 80-89, 90-99, 100+.}
#' }
#' }
#' @keywords age_group age
@ -92,11 +92,11 @@ age <- function(x, reference = Sys.Date()) {
#' age_groups(ages, c(20, 50))
#'
#' # split into groups of ten years
#' age_groups(ages, 1:12 * 10)
#' age_groups(ages, 1:10 * 10)
#' age_groups(ages, split_at = "tens")
#'
#' # split into groups of five years
#' age_groups(ages, 1:24 * 5)
#' age_groups(ages, 1:20 * 5)
#' age_groups(ages, split_at = "fives")
#'
#' # split specifically for children
@ -117,14 +117,14 @@ age <- function(x, reference = Sys.Date()) {
age_groups <- function(x, split_at = c(12, 25, 55, 75)) {
if (is.character(split_at)) {
split_at <- split_at[1L]
if (split_at %like% "^child") {
if (split_at %like% "^(child|kid)") {
split_at <- c(0, 1, 2, 4, 6, 13, 18)
} else if (split_at %like% "^(elder|senior)") {
split_at <- c(65, 75, 85, 95)
split_at <- c(65, 75, 85)
} else if (split_at %like% "^five") {
split_at <- 1:24 * 5
split_at <- 1:20 * 5
} else if (split_at %like% "^ten") {
split_at <- 1:12 * 10
split_at <- 1:10 * 10
}
}
split_at <- as.integer(split_at)