1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 08:06:12 +01:00

freq/age fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-04-11 00:54:48 +02:00
parent f867d11598
commit 73f1ee1159
4 changed files with 11 additions and 6 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.6.1.9002
Date: 2019-04-09
Date: 2019-04-11
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(

View File

@ -8,6 +8,7 @@
* Removed all hardcoded EUCAST rules and replaced them with a new reference file: `./inst/eucast/eucast.tsv`.
* Added ceftazidim intrinsic resistance to *Streptococci*
* Changed default settings for `age_groups()`, to let groups of fives and tens end with 100+ instead of 120+.
* Fix for `freq()` for when all values are `NA`.
#### Other
* Prevented [staged install](https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html) in R 3.6.0 and later by adding `StagedInstall: false` to the DESCRIPTION file

View File

@ -64,11 +64,11 @@ age <- function(x, reference = Sys.Date()) {
#'
#' Split ages into age groups defined by the \code{split} parameter. This allows for easier demographic (antimicrobial resistance) analysis.
#' @param x age, e.g. calculated with \code{\link{age}}
#' @param split_at values to split \code{x} at, defaults to age groups 0-11, 12-24, 26-54, 55-74 and 75+. See Details.
#' @param split_at values to split \code{x} at, defaults to age groups 0-11, 12-24, 25-54, 55-74 and 75+. See Details.
#' @details To split ages, the input can be:
#' \itemize{
#' \item{A numeric vector. A vector of e.g. \code{c(10, 20)} will split on 0-9, 10-19 and 20+. A value of only \code{50} will split on 0-49 and 50+.
#' The default is to split on young children (0-11), youth (12-24), young adults (26-54), middle-aged adults (55-74) and elderly (75+).}
#' The default is to split on young children (0-11), youth (12-24), young adults (25-54), middle-aged adults (55-74) and elderly (75+).}
#' \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+.}

View File

@ -666,7 +666,7 @@ format_header <- function(x, markdown = FALSE, decimal.mark = ".", big.mark = ",
# format all numeric values
header <- lapply(header, function(x) {
if (is.numeric(x)) {
if (any(x < 1000)) {
if (any(x < 1000, na.rm = TRUE)) {
format(round2(x, digits = digits), decimal.mark = decimal.mark, big.mark = big.mark)
} else {
format(x, digits = digits, decimal.mark = decimal.mark, big.mark = big.mark)
@ -885,8 +885,12 @@ print.frequency_tbl <- function(x,
cat(title, "\n\n")
if (NROW(x) == 0) {
cat("No observations.\n")
if (NROW(x) == 0 | isTRUE(all(is.na(x$item)))) {
cat("No observations")
if (isTRUE(all(is.na(x$item)))) {
cat(" - all values are missing (<NA>)")
}
cat(".\n")
if (opt$tbl_format == "markdown") {
cat("\n")
}