Update freq function
0
.Rbuildignore
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
13
.travis.yml
Normal file → Executable file
@ -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
|
||||
|
2
DESCRIPTION
Normal file → Executable file
@ -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(
|
||||
|
2
NEWS.md
Normal file → Executable file
@ -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)`
|
||||
|
0
R/classes.R
Normal file → Executable file
0
R/eucast.R
Normal file → Executable file
0
R/first_isolates.R
Normal file → Executable file
24
R/freq.R
Normal file → Executable 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.
|
||||
#' @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 {
|
||||
|
0
R/globals.R
Normal file → Executable file
0
R/rsi_analysis.R
Normal file → Executable file
@ -1 +0,0 @@
|
||||
theme: jekyll-theme-cayman
|
0
data/antibiotics.rda
Normal file → Executable file
0
data/microorganisms.rda
Normal file → Executable file
0
data/microorganisms.umcg.rda
Normal file → Executable file
0
data/septic_patients.rda
Normal file → Executable file
0
man/EUCAST.Rd
Normal file → Executable file
0
man/MDRO.Rd
Normal file → Executable file
0
man/abname.Rd
Normal file → Executable file
0
man/antibiotics.Rd
Normal file → Executable file
0
man/as.mic.Rd
Normal file → Executable file
0
man/as.rsi.Rd
Normal file → Executable file
0
man/atc_property.Rd
Normal file → Executable file
0
man/figures/combi_therapy_2.png
Normal file → Executable 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
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
0
man/figures/logo_certe.png
Normal file → Executable file
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
0
man/figures/logo_eh1h.png
Normal file → Executable file
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
0
man/figures/logo_interreg.png
Normal file → Executable file
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
0
man/figures/logo_rug.png
Normal file → Executable 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
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
0
man/figures/mic_example.png
Normal file → Executable 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
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
0
man/figures/rsi_example.png
Normal file → Executable file
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
0
man/first_isolate.Rd
Normal file → Executable file
2
man/freq.Rd
Normal file → Executable 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{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.}
|
||||
|
||||
|
0
man/guess_atc.Rd
Normal file → Executable file
0
man/guess_bactid.Rd
Normal file → Executable file
0
man/join.Rd
Normal file → Executable file
0
man/key_antibiotics.Rd
Normal file → Executable file
0
man/like.Rd
Normal file → Executable file
0
man/microorganisms.Rd
Normal file → Executable file
0
man/microorganisms.umcg.Rd
Normal file → Executable file
0
man/mo_property.Rd
Normal file → Executable file
0
man/print.Rd
Normal file → Executable file
0
man/rsi.Rd
Normal file → Executable file
0
man/rsi_predict.Rd
Normal file → Executable file
0
man/septic_patients.Rd
Normal file → Executable file
0
tests/testthat.R
Normal file → Executable file
0
tests/testthat/test-atc.R
Normal file → Executable file
0
tests/testthat/test-classes.R
Normal file → Executable file
0
tests/testthat/test-eucast.R
Normal file → Executable file
0
tests/testthat/test-first_isolates.R
Normal file → Executable file
0
tests/testthat/test-freq.R
Normal file → Executable file
0
tests/testthat/test-joins.R
Normal file → Executable file
0
tests/testthat/test-mdro.R
Normal file → Executable file
0
tests/testthat/test-misc.R
Normal file → Executable file
0
tests/testthat/test-print.R
Normal file → Executable file
6
tests/testthat/test-rsi_analysis.R
Normal file → Executable file
@ -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,
|
||||
|
0
vignettes/.gitignore
vendored
Normal file → Executable file
0
vignettes/freq.R
Normal file → Executable file
4
vignettes/freq.Rmd
Normal file → Executable 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.
|
||||
|
||||
`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 %>%
|
||||
|