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

Update freq function

This commit is contained in:
uscloud 2018-05-22 16:34:22 +02:00
parent 0d80647d41
commit dcc26dd942
71 changed files with 26 additions and 28 deletions

0
.Rbuildignore Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

13
.travis.yml Normal file → Executable file
View File

@ -1,5 +1,3 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
# Setting up R deps # Setting up R deps
language: r language: r
r: 3.2 r: 3.2
@ -10,10 +8,11 @@ cache: packages
os: os:
- linux - linux
- osx - osx
before_install: #before_install:
- if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -qq update; fi # # needed for clipboard function:
- if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -y xclip; fi # - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -qq update; fi
- if [ $TRAVIS_OS_NAME = osx ]; then brew install xclip; 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 # postrun
after_success: after_success:
@ -22,6 +21,6 @@ notifications:
email: email:
recipients: recipients:
- m.s.berends@umcg.nl - m.s.berends@umcg.nl
- c.f.luz@umcg.nl # - c.f.luz@umcg.nl
on_success: change on_success: change
on_failure: change on_failure: change

2
DESCRIPTION Normal file → Executable file
View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 0.2.0.9000 Version: 0.2.0.9000
Date: 2018-05-09 Date: 2018-05-22
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(
person( person(

0
LICENSE Normal file → Executable file
View File

0
NAMESPACE Normal file → Executable file
View File

2
NEWS.md Normal file → Executable file
View File

@ -1,4 +1,4 @@
# 0.2.9000 (development version) # 0.2.0.9000 (development version)
#### New #### New
* Vignettes about frequency tables * 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)` * Possibility to globally set the default for the amount of items to print in frequency tables (`freq` function), with `options(max.print.freq = n)`

0
R/atc.R Normal file → Executable file
View File

0
R/classes.R Normal file → Executable file
View File

0
R/data.R Normal file → Executable file
View File

0
R/eucast.R Normal file → Executable file
View File

0
R/first_isolates.R Normal file → Executable file
View File

24
R/freq.R Normal file → Executable file
View File

@ -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. #' 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 x data
#' @param sort.count Sort on count. Use \code{FALSE} to sort alphabetically on item. #' @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 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 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) #' @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, align = column_align,
padding = 1) padding = 1)
) )
cat('... and ', if (nmax.set == TRUE) {
format(nrow(df) - nmax), cat('[ reached `nmax = ', nmax, '`', sep = '')
' more ', } else {
paste0('(n = ', cat('[ reached getOption("max.print.freq")')
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.')
} }
cat(' -- omitted ',
format(nrow(df) - nmax),
' entries, n = ',
format(Count.rest),
' (',
(Count.rest / length(x)) %>% percent(force_zero = TRUE),
') ]\n', sep = '')
cat('\n') cat('\n')
} else { } else {

0
R/globals.R Normal file → Executable file
View File

0
R/join.R Normal file → Executable file
View File

0
R/mdro.R Normal file → Executable file
View File

0
R/misc.R Normal file → Executable file
View File

0
R/print.R Normal file → Executable file
View File

0
R/rsi_analysis.R Normal file → Executable file
View File

0
R/zzz.R Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

View File

@ -1 +0,0 @@
theme: jekyll-theme-cayman

0
data/antibiotics.rda Normal file → Executable file
View File

0
data/microorganisms.rda Normal file → Executable file
View File

0
data/microorganisms.umcg.rda Normal file → Executable file
View File

0
data/septic_patients.rda Normal file → Executable file
View File

0
man/EUCAST.Rd Normal file → Executable file
View File

0
man/MDRO.Rd Normal file → Executable file
View File

0
man/abname.Rd Normal file → Executable file
View File

0
man/antibiotics.Rd Normal file → Executable file
View File

0
man/as.mic.Rd Normal file → Executable file
View File

0
man/as.rsi.Rd Normal file → Executable file
View File

0
man/atc_property.Rd Normal file → Executable file
View File

0
man/figures/combi_therapy_2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

0
man/figures/combi_therapy_3.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

0
man/figures/logo_certe.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

0
man/figures/logo_eh1h.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

0
man/figures/logo_interreg.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

0
man/figures/logo_rug.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

0
man/figures/logo_umcg.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

0
man/figures/mic_example.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

0
man/figures/mono_therapy.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

0
man/figures/rsi_example.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

0
man/first_isolate.Rd Normal file → Executable file
View File

2
man/freq.Rd Normal file → Executable file
View File

@ -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{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.} \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.}

0
man/guess_atc.Rd Normal file → Executable file
View File

0
man/guess_bactid.Rd Normal file → Executable file
View File

0
man/join.Rd Normal file → Executable file
View File

0
man/key_antibiotics.Rd Normal file → Executable file
View File

0
man/like.Rd Normal file → Executable file
View File

0
man/microorganisms.Rd Normal file → Executable file
View File

0
man/microorganisms.umcg.Rd Normal file → Executable file
View File

0
man/mo_property.Rd Normal file → Executable file
View File

0
man/print.Rd Normal file → Executable file
View File

0
man/rsi.Rd Normal file → Executable file
View File

0
man/rsi_predict.Rd Normal file → Executable file
View File

0
man/septic_patients.Rd Normal file → Executable file
View File

0
tests/testthat.R Normal file → Executable file
View File

0
tests/testthat/test-atc.R Normal file → Executable file
View File

0
tests/testthat/test-classes.R Normal file → Executable file
View File

0
tests/testthat/test-eucast.R Normal file → Executable file
View File

0
tests/testthat/test-first_isolates.R Normal file → Executable file
View File

0
tests/testthat/test-freq.R Normal file → Executable file
View File

0
tests/testthat/test-joins.R Normal file → Executable file
View File

0
tests/testthat/test-mdro.R Normal file → Executable file
View File

0
tests/testthat/test-misc.R Normal file → Executable file
View File

0
tests/testthat/test-print.R Normal file → Executable file
View File

6
tests/testthat/test-rsi_analysis.R Normal file → Executable file
View File

@ -2,12 +2,12 @@ context("rsi_analysis.R")
test_that("rsi works", { test_that("rsi works", {
# amox resistance in `septic_patients` should be around 53.86% # 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.5756, 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_df(septic_patients, expect_equal(rsi_df(septic_patients,
ab = "amox", ab = "amox",
info = FALSE), info = FALSE),
0.5386, 0.5756,
tolerance = 0.0001) tolerance = 0.0001)
# pita+genta susceptibility around 98.09% # pita+genta susceptibility around 98.09%
expect_equal(rsi(septic_patients$pita, expect_equal(rsi(septic_patients$pita,

0
vignettes/.gitignore vendored Normal file → Executable file
View File

0
vignettes/freq.R Normal file → Executable file
View File

4
vignettes/freq.Rmd Normal file → Executable file
View File

@ -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. 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} ```{r, echo = TRUE}
septic_patients %>% septic_patients %>%
@ -113,7 +113,7 @@ septic_patients %>%
freq() freq()
``` ```
To this, where items are now sorted on item count: ... with this, where items are now sorted on count:
```{r, echo = TRUE} ```{r, echo = TRUE}
septic_patients %>% septic_patients %>%