mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 02:20:49 +01:00
(v3.1.0.9017) Add labels_taxonomy() for taxonomic names in italics in plot labels, add type = "plotmath" to italicise_taxonomy(), and only italicise species names after a genus
This commit is contained in:
1 parent
db7377f517
commit
cfb55a4c3e
14 files changed
+272
-79
No files matched your search
@@ -48,4 +48,29 @@ test_that("test-italicise_taxonomy.R", {
|
||||
italicise_taxonomy("test for E. coli", "html"),
|
||||
"test for <i>E. coli</i>"
|
||||
)
|
||||
|
||||
# species only after a genus or abbreviated genus, punctuation outside the italics
|
||||
expect_identical(
|
||||
italicise_taxonomy(c(
|
||||
"Escherichia coli", "coli bacteria", "(S. aureus)", "E. coli,", "Other",
|
||||
"Salmonella Typhimurium", "Streptococcus group A", "Staphylococcus spp.",
|
||||
"Klebsiella pneumoniae subsp. ozaenae", "K. pneumoniae ozaenae", "Enterobacteriaceae", "", NA
|
||||
)),
|
||||
c(
|
||||
"*Escherichia coli*", "coli bacteria", "(*S. aureus*)", "*E. coli*,", "Other",
|
||||
"*Salmonella* Typhimurium", "*Streptococcus* group A", "*Staphylococcus* spp.",
|
||||
"*Klebsiella pneumoniae* subsp. *ozaenae*", "*K. pneumoniae ozaenae*", "*Enterobacteriaceae*", "", NA
|
||||
)
|
||||
)
|
||||
|
||||
# plotmath, also used by labels_taxonomy()
|
||||
expect_identical(
|
||||
italicise_taxonomy(c("E. coli", "Other", "test for E. coli", NA), type = "plotmath"),
|
||||
expression(italic("E. coli"), "Other", paste("test for ", italic("E. coli")), NA_character_)
|
||||
)
|
||||
expect_identical(
|
||||
labels_taxonomy(factor(c("E. coli", "Other"))),
|
||||
expression(italic("E. coli"), "Other")
|
||||
)
|
||||
expect_identical(labels_taxonomy(character(0)), expression())
|
||||
})
|
||||
Reference in new issue
Block a user