From dcc26dd942c1671b2daa697e0ee2b9e8d402e03a Mon Sep 17 00:00:00 2001 From: uscloud Date: Tue, 22 May 2018 16:34:22 +0200 Subject: [PATCH] Update freq function --- .Rbuildignore | 0 .gitignore | 0 .travis.yml | 13 ++++++------- DESCRIPTION | 2 +- LICENSE | 0 NAMESPACE | 0 NEWS.md | 2 +- R/atc.R | 0 R/classes.R | 0 R/data.R | 0 R/eucast.R | 0 R/first_isolates.R | 0 R/freq.R | 24 ++++++++++++------------ R/globals.R | 0 R/join.R | 0 R/mdro.R | 0 R/misc.R | 0 R/print.R | 0 R/rsi_analysis.R | 0 R/zzz.R | 0 README.md | 0 _config.yml | 1 - data/antibiotics.rda | Bin data/microorganisms.rda | Bin data/microorganisms.umcg.rda | Bin data/septic_patients.rda | Bin man/EUCAST.Rd | 0 man/MDRO.Rd | 0 man/abname.Rd | 0 man/antibiotics.Rd | 0 man/as.mic.Rd | 0 man/as.rsi.Rd | 0 man/atc_property.Rd | 0 man/figures/combi_therapy_2.png | Bin man/figures/combi_therapy_3.png | Bin man/figures/logo_certe.png | Bin man/figures/logo_eh1h.png | Bin man/figures/logo_interreg.png | Bin man/figures/logo_rug.png | Bin man/figures/logo_umcg.png | Bin man/figures/mic_example.png | Bin man/figures/mono_therapy.png | Bin man/figures/rsi_example.png | Bin man/first_isolate.Rd | 0 man/freq.Rd | 2 +- man/guess_atc.Rd | 0 man/guess_bactid.Rd | 0 man/join.Rd | 0 man/key_antibiotics.Rd | 0 man/like.Rd | 0 man/microorganisms.Rd | 0 man/microorganisms.umcg.Rd | 0 man/mo_property.Rd | 0 man/print.Rd | 0 man/rsi.Rd | 0 man/rsi_predict.Rd | 0 man/septic_patients.Rd | 0 tests/testthat.R | 0 tests/testthat/test-atc.R | 0 tests/testthat/test-classes.R | 0 tests/testthat/test-eucast.R | 0 tests/testthat/test-first_isolates.R | 0 tests/testthat/test-freq.R | 0 tests/testthat/test-joins.R | 0 tests/testthat/test-mdro.R | 0 tests/testthat/test-misc.R | 0 tests/testthat/test-print.R | 0 tests/testthat/test-rsi_analysis.R | 6 +++--- vignettes/.gitignore | 0 vignettes/freq.R | 0 vignettes/freq.Rmd | 4 ++-- 71 files changed, 26 insertions(+), 28 deletions(-) mode change 100644 => 100755 .Rbuildignore mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .travis.yml mode change 100644 => 100755 DESCRIPTION mode change 100644 => 100755 LICENSE mode change 100644 => 100755 NAMESPACE mode change 100644 => 100755 NEWS.md mode change 100644 => 100755 R/atc.R mode change 100644 => 100755 R/classes.R mode change 100644 => 100755 R/data.R mode change 100644 => 100755 R/eucast.R mode change 100644 => 100755 R/first_isolates.R mode change 100644 => 100755 R/freq.R mode change 100644 => 100755 R/globals.R mode change 100644 => 100755 R/join.R mode change 100644 => 100755 R/mdro.R mode change 100644 => 100755 R/misc.R mode change 100644 => 100755 R/print.R mode change 100644 => 100755 R/rsi_analysis.R mode change 100644 => 100755 R/zzz.R mode change 100644 => 100755 README.md delete mode 100644 _config.yml mode change 100644 => 100755 data/antibiotics.rda mode change 100644 => 100755 data/microorganisms.rda mode change 100644 => 100755 data/microorganisms.umcg.rda mode change 100644 => 100755 data/septic_patients.rda mode change 100644 => 100755 man/EUCAST.Rd mode change 100644 => 100755 man/MDRO.Rd mode change 100644 => 100755 man/abname.Rd mode change 100644 => 100755 man/antibiotics.Rd mode change 100644 => 100755 man/as.mic.Rd mode change 100644 => 100755 man/as.rsi.Rd mode change 100644 => 100755 man/atc_property.Rd mode change 100644 => 100755 man/figures/combi_therapy_2.png mode change 100644 => 100755 man/figures/combi_therapy_3.png mode change 100644 => 100755 man/figures/logo_certe.png mode change 100644 => 100755 man/figures/logo_eh1h.png mode change 100644 => 100755 man/figures/logo_interreg.png mode change 100644 => 100755 man/figures/logo_rug.png mode change 100644 => 100755 man/figures/logo_umcg.png mode change 100644 => 100755 man/figures/mic_example.png mode change 100644 => 100755 man/figures/mono_therapy.png mode change 100644 => 100755 man/figures/rsi_example.png mode change 100644 => 100755 man/first_isolate.Rd mode change 100644 => 100755 man/freq.Rd mode change 100644 => 100755 man/guess_atc.Rd mode change 100644 => 100755 man/guess_bactid.Rd mode change 100644 => 100755 man/join.Rd mode change 100644 => 100755 man/key_antibiotics.Rd mode change 100644 => 100755 man/like.Rd mode change 100644 => 100755 man/microorganisms.Rd mode change 100644 => 100755 man/microorganisms.umcg.Rd mode change 100644 => 100755 man/mo_property.Rd mode change 100644 => 100755 man/print.Rd mode change 100644 => 100755 man/rsi.Rd mode change 100644 => 100755 man/rsi_predict.Rd mode change 100644 => 100755 man/septic_patients.Rd mode change 100644 => 100755 tests/testthat.R mode change 100644 => 100755 tests/testthat/test-atc.R mode change 100644 => 100755 tests/testthat/test-classes.R mode change 100644 => 100755 tests/testthat/test-eucast.R mode change 100644 => 100755 tests/testthat/test-first_isolates.R mode change 100644 => 100755 tests/testthat/test-freq.R mode change 100644 => 100755 tests/testthat/test-joins.R mode change 100644 => 100755 tests/testthat/test-mdro.R mode change 100644 => 100755 tests/testthat/test-misc.R mode change 100644 => 100755 tests/testthat/test-print.R mode change 100644 => 100755 tests/testthat/test-rsi_analysis.R mode change 100644 => 100755 vignettes/.gitignore mode change 100644 => 100755 vignettes/freq.R mode change 100644 => 100755 vignettes/freq.Rmd diff --git a/.Rbuildignore b/.Rbuildignore old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 index 4be52271..5c25fea8 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r - # Setting up R deps language: r r: 3.2 @@ -10,10 +8,11 @@ cache: packages os: - linux - osx -before_install: - - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -qq update; fi - - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -y xclip; fi - - if [ $TRAVIS_OS_NAME = osx ]; then brew install xclip; fi +#before_install: +# # needed for clipboard function: +# - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -qq update; fi +# - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -y xclip; fi +# - if [ $TRAVIS_OS_NAME = osx ]; then brew install xclip; fi # postrun after_success: @@ -22,6 +21,6 @@ notifications: email: recipients: - m.s.berends@umcg.nl - - c.f.luz@umcg.nl + # - c.f.luz@umcg.nl on_success: change on_failure: change diff --git a/DESCRIPTION b/DESCRIPTION old mode 100644 new mode 100755 index 26eb8ac1..3f40d08a --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR Version: 0.2.0.9000 -Date: 2018-05-09 +Date: 2018-05-22 Title: Antimicrobial Resistance Analysis Authors@R: c( person( diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/NAMESPACE b/NAMESPACE old mode 100644 new mode 100755 diff --git a/NEWS.md b/NEWS.md old mode 100644 new mode 100755 index afacac0b..4fbd454b --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# 0.2.9000 (development version) +# 0.2.0.9000 (development version) #### New * Vignettes about frequency tables * Possibility to globally set the default for the amount of items to print in frequency tables (`freq` function), with `options(max.print.freq = n)` diff --git a/R/atc.R b/R/atc.R old mode 100644 new mode 100755 diff --git a/R/classes.R b/R/classes.R old mode 100644 new mode 100755 diff --git a/R/data.R b/R/data.R old mode 100644 new mode 100755 diff --git a/R/eucast.R b/R/eucast.R old mode 100644 new mode 100755 diff --git a/R/first_isolates.R b/R/first_isolates.R old mode 100644 new mode 100755 diff --git a/R/freq.R b/R/freq.R old mode 100644 new mode 100755 index 00a791ad..dbbc1e7b --- a/R/freq.R +++ b/R/freq.R @@ -21,7 +21,7 @@ #' Create a frequency table of a vector of data, a single column or a maximum of 9 columns of a data frame. Supports markdown for reports. #' @param x data #' @param sort.count Sort on count. Use \code{FALSE} to sort alphabetically on item. -#' @param nmax number of row to print. The default, \code{15}, uses \code{\link[base]{getOption}("max.print.freq")}. Use \code{nmax = 0} or \code{nmax = NA} to print all rows. +#' @param nmax number of row to print. The default, \code{15}, uses \code{\link{getOption}("max.print.freq")}. Use \code{nmax = 0} or \code{nmax = NA} to print all rows. #' @param na.rm a logical value indicating whether NA values should be removed from the frequency table. The header will always print the amount of \code{NA}s. #' @param markdown print table in markdown format (this forces \code{nmax = NA}) #' @param as.data.frame return frequency table without header as a \code{data.frame} (e.g. to assign the table to an object) @@ -337,18 +337,18 @@ freq <- function(x, align = column_align, padding = 1) ) - cat('... and ', - format(nrow(df) - nmax), - ' more ', - paste0('(n = ', - format(Count.rest), - '; ', - (Count.rest / length(x)) %>% percent(force_zero = TRUE), - ')'), - '.', sep = '') - if (nmax.set == FALSE) { - cat(' Use `nmax` to show more or less rows.') + if (nmax.set == TRUE) { + cat('[ reached `nmax = ', nmax, '`', sep = '') + } else { + cat('[ reached getOption("max.print.freq")') } + cat(' -- omitted ', + format(nrow(df) - nmax), + ' entries, n = ', + format(Count.rest), + ' (', + (Count.rest / length(x)) %>% percent(force_zero = TRUE), + ') ]\n', sep = '') cat('\n') } else { diff --git a/R/globals.R b/R/globals.R old mode 100644 new mode 100755 diff --git a/R/join.R b/R/join.R old mode 100644 new mode 100755 diff --git a/R/mdro.R b/R/mdro.R old mode 100644 new mode 100755 diff --git a/R/misc.R b/R/misc.R old mode 100644 new mode 100755 diff --git a/R/print.R b/R/print.R old mode 100644 new mode 100755 diff --git a/R/rsi_analysis.R b/R/rsi_analysis.R old mode 100644 new mode 100755 diff --git a/R/zzz.R b/R/zzz.R old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c4192631..00000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-cayman \ No newline at end of file diff --git a/data/antibiotics.rda b/data/antibiotics.rda old mode 100644 new mode 100755 diff --git a/data/microorganisms.rda b/data/microorganisms.rda old mode 100644 new mode 100755 diff --git a/data/microorganisms.umcg.rda b/data/microorganisms.umcg.rda old mode 100644 new mode 100755 diff --git a/data/septic_patients.rda b/data/septic_patients.rda old mode 100644 new mode 100755 diff --git a/man/EUCAST.Rd b/man/EUCAST.Rd old mode 100644 new mode 100755 diff --git a/man/MDRO.Rd b/man/MDRO.Rd old mode 100644 new mode 100755 diff --git a/man/abname.Rd b/man/abname.Rd old mode 100644 new mode 100755 diff --git a/man/antibiotics.Rd b/man/antibiotics.Rd old mode 100644 new mode 100755 diff --git a/man/as.mic.Rd b/man/as.mic.Rd old mode 100644 new mode 100755 diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd old mode 100644 new mode 100755 diff --git a/man/atc_property.Rd b/man/atc_property.Rd old mode 100644 new mode 100755 diff --git a/man/figures/combi_therapy_2.png b/man/figures/combi_therapy_2.png old mode 100644 new mode 100755 diff --git a/man/figures/combi_therapy_3.png b/man/figures/combi_therapy_3.png old mode 100644 new mode 100755 diff --git a/man/figures/logo_certe.png b/man/figures/logo_certe.png old mode 100644 new mode 100755 diff --git a/man/figures/logo_eh1h.png b/man/figures/logo_eh1h.png old mode 100644 new mode 100755 diff --git a/man/figures/logo_interreg.png b/man/figures/logo_interreg.png old mode 100644 new mode 100755 diff --git a/man/figures/logo_rug.png b/man/figures/logo_rug.png old mode 100644 new mode 100755 diff --git a/man/figures/logo_umcg.png b/man/figures/logo_umcg.png old mode 100644 new mode 100755 diff --git a/man/figures/mic_example.png b/man/figures/mic_example.png old mode 100644 new mode 100755 diff --git a/man/figures/mono_therapy.png b/man/figures/mono_therapy.png old mode 100644 new mode 100755 diff --git a/man/figures/rsi_example.png b/man/figures/rsi_example.png old mode 100644 new mode 100755 diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd old mode 100644 new mode 100755 diff --git a/man/freq.Rd b/man/freq.Rd old mode 100644 new mode 100755 index a50bb03e..32f30029 --- a/man/freq.Rd +++ b/man/freq.Rd @@ -18,7 +18,7 @@ frequency_tbl(x, sort.count = TRUE, nmax = getOption("max.print.freq"), \item{sort.count}{Sort on count. Use \code{FALSE} to sort alphabetically on item.} -\item{nmax}{number of row to print. The default, \code{15}, uses \code{\link[base]{getOption}("max.print.freq")}. Use \code{nmax = 0} or \code{nmax = NA} to print all rows.} +\item{nmax}{number of row to print. The default, \code{15}, uses \code{\link{getOption}("max.print.freq")}. Use \code{nmax = 0} or \code{nmax = NA} to print all rows.} \item{na.rm}{a logical value indicating whether NA values should be removed from the frequency table. The header will always print the amount of \code{NA}s.} diff --git a/man/guess_atc.Rd b/man/guess_atc.Rd old mode 100644 new mode 100755 diff --git a/man/guess_bactid.Rd b/man/guess_bactid.Rd old mode 100644 new mode 100755 diff --git a/man/join.Rd b/man/join.Rd old mode 100644 new mode 100755 diff --git a/man/key_antibiotics.Rd b/man/key_antibiotics.Rd old mode 100644 new mode 100755 diff --git a/man/like.Rd b/man/like.Rd old mode 100644 new mode 100755 diff --git a/man/microorganisms.Rd b/man/microorganisms.Rd old mode 100644 new mode 100755 diff --git a/man/microorganisms.umcg.Rd b/man/microorganisms.umcg.Rd old mode 100644 new mode 100755 diff --git a/man/mo_property.Rd b/man/mo_property.Rd old mode 100644 new mode 100755 diff --git a/man/print.Rd b/man/print.Rd old mode 100644 new mode 100755 diff --git a/man/rsi.Rd b/man/rsi.Rd old mode 100644 new mode 100755 diff --git a/man/rsi_predict.Rd b/man/rsi_predict.Rd old mode 100644 new mode 100755 diff --git a/man/septic_patients.Rd b/man/septic_patients.Rd old mode 100644 new mode 100755 diff --git a/tests/testthat.R b/tests/testthat.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-atc.R b/tests/testthat/test-atc.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-classes.R b/tests/testthat/test-classes.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-eucast.R b/tests/testthat/test-eucast.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-first_isolates.R b/tests/testthat/test-first_isolates.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-freq.R b/tests/testthat/test-freq.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-joins.R b/tests/testthat/test-joins.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-mdro.R b/tests/testthat/test-mdro.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-misc.R b/tests/testthat/test-misc.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-print.R b/tests/testthat/test-print.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-rsi_analysis.R b/tests/testthat/test-rsi_analysis.R old mode 100644 new mode 100755 index 3077987f..215dfccb --- a/tests/testthat/test-rsi_analysis.R +++ b/tests/testthat/test-rsi_analysis.R @@ -2,12 +2,12 @@ context("rsi_analysis.R") test_that("rsi works", { # amox resistance in `septic_patients` should be around 53.86% - expect_equal(rsi(septic_patients$amox), 0.5386, tolerance = 0.0001) - expect_equal(rsi(septic_patients$amox), 0.5386, tolerance = 0.0001) + expect_equal(rsi(septic_patients$amox), 0.5756, tolerance = 0.0001) + expect_equal(rsi(septic_patients$amox), 0.5756, tolerance = 0.0001) expect_equal(rsi_df(septic_patients, ab = "amox", info = FALSE), - 0.5386, + 0.5756, tolerance = 0.0001) # pita+genta susceptibility around 98.09% expect_equal(rsi(septic_patients$pita, diff --git a/vignettes/.gitignore b/vignettes/.gitignore old mode 100644 new mode 100755 diff --git a/vignettes/freq.R b/vignettes/freq.R old mode 100644 new mode 100755 diff --git a/vignettes/freq.Rmd b/vignettes/freq.Rmd old mode 100644 new mode 100755 index 04702aac..f8c2a14c --- a/vignettes/freq.Rmd +++ b/vignettes/freq.Rmd @@ -105,7 +105,7 @@ So for example, the above frequency table quickly shows the median age of patien Frequencies of factors will be sorted on factor level instead of item count by default. This can be changed with the `sort.count` parameter. Frequency tables of factors always show the factor level as an additional last column. -`sort.count` is `TRUE` by default, except for factors. Compare this default behaviour: +`sort.count` is `TRUE` by default, except for factors. Compare this default behaviour... ```{r, echo = TRUE} septic_patients %>% @@ -113,7 +113,7 @@ septic_patients %>% freq() ``` -To this, where items are now sorted on item count: +... with this, where items are now sorted on count: ```{r, echo = TRUE} septic_patients %>%