mirror of
https://github.com/msberends/AMR.git
synced 2025-07-10 23:01:58 +02:00
(v0.7.1.9092) as.ab() improvements
This commit is contained in:
@ -53,6 +53,9 @@ test_that("as.ab works", {
|
||||
|
||||
expect_equal(suppressWarnings(as.character(as.ab(c("Bacteria", "Bacterial")))),
|
||||
c(NA, "TMP"))
|
||||
|
||||
expect_equal(as.character(as.ab("Amoxy + clavulaanzuur")),
|
||||
"AMC")
|
||||
|
||||
# assigning and subsetting
|
||||
x <- antibiotics$ab
|
||||
|
@ -21,6 +21,16 @@
|
||||
|
||||
context("misc.R")
|
||||
|
||||
test_that("percentages works", {
|
||||
expect_equal(percentage(0.25), "25%")
|
||||
expect_equal(percentage(0.5), "50%")
|
||||
expect_equal(percentage(0.500, digits = 1), "50.0%")
|
||||
expect_equal(percentage(0.1234), "12.3%")
|
||||
# round up 0.5
|
||||
expect_equal(percentage(0.0054), "0.5%")
|
||||
expect_equal(percentage(0.0055), "0.6%")
|
||||
})
|
||||
|
||||
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"))
|
||||
|
Reference in New Issue
Block a user