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

Try to support older R versions

This commit is contained in:
dr. M.S. (Matthijs) Berends 2018-04-18 15:19:00 +02:00
parent a814d82b4b
commit 4b5530ed64
4 changed files with 57 additions and 32 deletions

62
NEWS.md
View File

@ -1,38 +1,38 @@
## 0.2.0 # 0.2.0
#### New #### New
- Full support for Windows, Linux and macOS * Full support for Windows, Linux and macOS
- Function `guess_bactid` to determine the ID of a microorganism based on genus/species or known abbreviations like MRSA * Function `guess_bactid` to determine the ID of a microorganism based on genus/species or known abbreviations like MRSA
- Functions `clipboard_import` and `clipboard_export` as helper functions to quickly copy and paste from/to software like Excel and SPSS * Functions `clipboard_import` and `clipboard_export` as helper functions to quickly copy and paste from/to software like Excel and SPSS
- Function `MDRO` to determine Multi Drug Resistant Organisms (MDRO) with support for country-specific guidelines. Suggest your own via https://github.com/msberends/AMR/issues/new. Functions `BRMO` and `MRGN` are wrappers for Dutch and German guidelines, respectively * Function `MDRO` to determine Multi Drug Resistant Organisms (MDRO) with support for country-specific guidelines. Suggest your own via [this link](https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E). Functions `BRMO` and `MRGN` are wrappers for Dutch and German guidelines, respectively
- Function `freq` to create frequency tables, with additional info in a header * Function `freq` to create frequency tables, with additional info in a header
- New algorithm to determine weighted isolates, can now be `"points"` or `"keyantibiotics"`, see `?first_isolate` * New algorithm to determine weighted isolates, can now be `"points"` or `"keyantibiotics"`, see `?first_isolate`
- New print format for tibbles and data.tables * New print format for tibbles and data.tables
#### Changed #### Changed
- Support for older R versions, only R 3.1.0 and later is needed * Support for older R versions, only R 3.1.0 and later is needed
- Renamed dataset `ablist` to `antibiotics` * Renamed dataset `ablist` to `antibiotics`
- Renamed dataset `bactlist` to `microorganisms` * Renamed dataset `bactlist` to `microorganisms`
- Added more microorganisms to `bactlist` * Added more microorganisms to `bactlist`
- Added analysis examples on help page of dataset `septic_patients` * Added analysis examples on help page of dataset `septic_patients`
- Added support for character vector in `join` functions * Added support for character vector in `join` functions
- Added warnings when a join results in more rows after than before the join * Added warnings when a join results in more rows after than before the join
- Altered `%like%` to make it case insensitive * Altered `%like%` to make it case insensitive
- For parameters of functions `first_isolate` and `EUCAST_rules` the column names are now case-insensitive * For parameters of functions `first_isolate` and `EUCAST_rules` the column names are now case-insensitive
- Functions `as.rsi` and `as.mic` now add the package name and version as attribute * Functions `as.rsi` and `as.mic` now add the package name and version as attribute
#### Other #### Other
- Expanded README.md with more examples * Expanded README.md with more examples
- Added ORC IDs of authors to DESCRIPTION file * Added ORC IDs of authors to DESCRIPTION file
- Added unit testing with the `testthat` package * Added unit testing with the `testthat` package
- Added build tests for Linux and macOS using Travis CI (https://travis-ci.org/msberends/AMR) * Added build tests for Linux and macOS using Travis CI (https://travis-ci.org/msberends/AMR)
- Added Line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R) * Added Line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R)
## 0.1.1 # 0.1.1
- `EUCAST_rules` applies for amoxicillin even if ampicillin is missing * `EUCAST_rules` applies for amoxicillin even if ampicillin is missing
- Edited column names to comply with GLIMS, the laboratory information system * Edited column names to comply with GLIMS, the laboratory information system
- Added more valid MIC values * Added more valid MIC values
- Renamed 'Daily Defined Dose' to 'Defined Daily Dose' * Renamed 'Daily Defined Dose' to 'Defined Daily Dose'
- Added barplots for `rsi` and `mic` classes * Added barplots for `rsi` and `mic` classes
## 0.1.0 # 0.1.0
- First submission to CRAN. * First submission to CRAN.

View File

@ -112,11 +112,23 @@ size_humanreadable <- function(bytes, decimals = 1) {
out out
} }
# Support for older R versions --------------------------------------------
# strrep is only available in R 3.3 and later # strrep is only available in R 3.3 and later
# and we want to support R 3.2 too, so:
strrep <- function(x, times) { strrep <- function(x, times) {
for (i in 1:length(x)) { for (i in 1:length(x)) {
x[i] <- paste(rep(x[i], times[i]), collapse = "") x[i] <- paste(rep(x[i], times[i]), collapse = "")
} }
x x
} }
# trimws is only available in R 3.2 and later
trimws <- function(x, which = "both") {
if (which %in% c("left", "both", "l", "b")) {
x <- gsub('^ {1,255}', '', x)
}
if (which %in% c("right", "both", "r", "b")) {
x <- gsub(' {1,255}$', '', x)
}
x
}

View File

@ -10,6 +10,8 @@ This R package contains functions to make microbiological, epidemiological data
With AMR you can also apply EUCAST rules to isolates, identify first isolates of every patient, translate antibiotic codes from the lab (like `"AMOX"`) or the [WHO](https://www.whocc.no/atc_ddd_index/?code=J01CA04&showdescription=no) (like `"J01CA04"`) to trivial names (like `"amoxicillin"`), or predict antimicrobial resistance for the nextcoming years with the `rsi_predict` function. With AMR you can also apply EUCAST rules to isolates, identify first isolates of every patient, translate antibiotic codes from the lab (like `"AMOX"`) or the [WHO](https://www.whocc.no/atc_ddd_index/?code=J01CA04&showdescription=no) (like `"J01CA04"`) to trivial names (like `"amoxicillin"`), or predict antimicrobial resistance for the nextcoming years with the `rsi_predict` function.
With the `MDRO` function (abbreviation of mutli-drug resistant organisms), you can check your isolates for exceptional resistance with country-specific guidelines. Currently guidelines for Germany and the Netherlands are supported. Please suggest addition of your own country here: [https://github.com/msberends/AMR/issues](https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E).
For regular AMR analysis, the `rsi` function can be used. This function als works with the `dplyr` package (e.g. in conjunction with `summarise`) to calculate the resistance percentages of different antibiotic columns of a table. For regular AMR analysis, the `rsi` function can be used. This function als works with the `dplyr` package (e.g. in conjunction with `summarise`) to calculate the resistance percentages of different antibiotic columns of a table.
This package contains an example data set `septic_patients`, consisting of 2000 isolates from anonymised septic patients between 2001 and 2017. This package contains an example data set `septic_patients`, consisting of 2000 isolates from anonymised septic patients between 2001 and 2017.

View File

@ -14,3 +14,14 @@ test_that("percentages works", {
expect_equal(percent(0.1234), "12.3%") expect_equal(percent(0.1234), "12.3%")
}) })
test_that("size format works", {
expect_equal(size_humanreadable(123456), "121 kB")
})
test_that("functions missing in older R versions work", {
expect_equal(strrep("A", 5), "AAAAA")
expect_equal(strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))
expect_equal(trimws(" test "), "test")
expect_equal(trimws(" test ", "l"), "test ")
expect_equal(trimws(" test ", "r"), " test")
})