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

(v0.7.0.9008) T. vaginalis, rsi_df

This commit is contained in:
2019-06-13 14:28:46 +02:00
parent 699e87ab4a
commit 254745061c
32 changed files with 382 additions and 259 deletions

View File

@ -136,6 +136,9 @@ age <- function(x, reference = Sys.Date(), exact = FALSE) {
#' select(age_group, CIP) %>%
#' ggplot_rsi(x = "age_group")
age_groups <- function(x, split_at = c(12, 25, 55, 75)) {
if (!is.numeric(x)) {
stop("`x` and must be numeric, not a ", paste0(class(x), collapse = "/"), ".")
}
if (is.character(split_at)) {
split_at <- split_at[1L]
if (split_at %like% "^(child|kid|junior)") {
@ -148,11 +151,7 @@ age_groups <- function(x, split_at = c(12, 25, 55, 75)) {
split_at <- 1:10 * 10
}
}
split_at <- as.integer(split_at)
if (!is.numeric(x) | !is.numeric(split_at)) {
stop("`x` and `split_at` must both be numeric.")
}
split_at <- sort(unique(split_at))
split_at <- sort(unique(as.integer(split_at)))
if (!split_at[1] == 0) {
# add base number 0
split_at <- c(0, split_at)