mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 07:26:12 +01:00
import from graphics
This commit is contained in:
parent
53959d40c7
commit
46db3f7b13
@ -65,6 +65,8 @@ importFrom(dplyr,slice)
|
||||
importFrom(dplyr,summarise)
|
||||
importFrom(dplyr,tibble)
|
||||
importFrom(dplyr,vars)
|
||||
importFrom(graphics,axis)
|
||||
importFrom(graphics,barplot)
|
||||
importFrom(graphics,plot)
|
||||
importFrom(graphics,text)
|
||||
importFrom(reshape2,dcast)
|
||||
|
21
R/classes.R
21
R/classes.R
@ -28,7 +28,8 @@
|
||||
#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
|
||||
#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C"))
|
||||
#' is.rsi(rsi_data)
|
||||
#' plot(rsi_data)
|
||||
#' plot(rsi_data) # for percentages
|
||||
#' barplot(rsi_data) # for frequencies
|
||||
#'
|
||||
#' \donttest{
|
||||
#' library(dplyr)
|
||||
@ -166,17 +167,18 @@ plot.rsi <- function(x, ...) {
|
||||
#' @exportMethod barplot.rsi
|
||||
#' @export
|
||||
#' @importFrom dplyr %>% group_by summarise filter mutate if_else n_distinct
|
||||
#' @importFrom graphics plot text
|
||||
#' @importFrom graphics barplot axis
|
||||
#' @noRd
|
||||
barplot.rsi <- function(x, ...) {
|
||||
x_name <- deparse(substitute(x))
|
||||
barplot.rsi <- function(height, ...) {
|
||||
x <- height
|
||||
x_name <- deparse(substitute(height))
|
||||
|
||||
data <- data.frame(rsi = x, cnt = 1) %>%
|
||||
group_by(rsi) %>%
|
||||
summarise(cnt = sum(cnt)) %>%
|
||||
droplevels()
|
||||
|
||||
barplot(table(rsi_data),
|
||||
barplot(table(x),
|
||||
col = c('green3', 'orange2', 'red3'),
|
||||
xlab = 'Antimicrobial Interpretation',
|
||||
main = paste('Susceptibilty Analysis of', x_name),
|
||||
@ -395,13 +397,14 @@ plot.mic <- function(x, ...) {
|
||||
#' @exportMethod barplot.mic
|
||||
#' @export
|
||||
#' @importFrom dplyr %>% group_by summarise
|
||||
#' @importFrom graphics plot text
|
||||
#' @importFrom graphics barplot axis
|
||||
#' @noRd
|
||||
barplot.mic <- function(x, ...) {
|
||||
x_name <- deparse(substitute(x))
|
||||
create_barplot_mic(x, x_name, ...)
|
||||
barplot.mic <- function(height, ...) {
|
||||
x_name <- deparse(substitute(height))
|
||||
create_barplot_mic(height, x_name, ...)
|
||||
}
|
||||
|
||||
#' @importFrom graphics barplot axis
|
||||
create_barplot_mic <- function(x, x_name, ...) {
|
||||
data <- data.frame(mic = x, cnt = 1) %>%
|
||||
group_by(mic) %>%
|
||||
|
@ -13,28 +13,29 @@ EUCAST Expert Rules Version 2.0: \cr
|
||||
\url{http://www.eucast.org/expert_rules_and_intrinsic_resistance}
|
||||
}
|
||||
\usage{
|
||||
EUCAST_rules(tbl, col_bactcode, info = TRUE, amcl = "amcl", amik = "amik",
|
||||
amox = "amox", ampi = "ampi", azit = "azit", aztr = "aztr",
|
||||
cefa = "cefa", cfra = "cfra", cfep = "cfep", cfot = "cfot",
|
||||
cfox = "cfox", cfta = "cfta", cftr = "cftr", cfur = "cfur",
|
||||
chlo = "chlo", cipr = "cipr", clar = "clar", clin = "clin",
|
||||
clox = "clox", coli = "coli", czol = "czol", dapt = "dapt",
|
||||
doxy = "doxy", erta = "erta", eryt = "eryt", fosf = "fosf",
|
||||
fusi = "fusi", gent = "gent", imip = "imip", kana = "kana",
|
||||
levo = "levo", linc = "linc", line = "line", mero = "mero",
|
||||
mino = "mino", moxi = "moxi", nali = "nali", neom = "neom",
|
||||
neti = "neti", nitr = "nitr", novo = "novo", norf = "norf",
|
||||
oflo = "oflo", peni = "peni", pita = "pita", poly = "poly",
|
||||
qida = "qida", rifa = "rifa", roxi = "roxi", siso = "siso",
|
||||
teic = "teic", tetr = "tetr", tica = "tica", tige = "tige",
|
||||
tobr = "tobr", trim = "trim", trsu = "trsu", vanc = "vanc")
|
||||
EUCAST_rules(tbl, col_bactcode = "bactid", info = TRUE, amcl = "amcl",
|
||||
amik = "amik", amox = "amox", ampi = "ampi", azit = "azit",
|
||||
aztr = "aztr", cefa = "cefa", cfra = "cfra", cfep = "cfep",
|
||||
cfot = "cfot", cfox = "cfox", cfta = "cfta", cftr = "cftr",
|
||||
cfur = "cfur", chlo = "chlo", cipr = "cipr", clar = "clar",
|
||||
clin = "clin", clox = "clox", coli = "coli", czol = "czol",
|
||||
dapt = "dapt", doxy = "doxy", erta = "erta", eryt = "eryt",
|
||||
fosf = "fosf", fusi = "fusi", gent = "gent", imip = "imip",
|
||||
kana = "kana", levo = "levo", linc = "linc", line = "line",
|
||||
mero = "mero", mino = "mino", moxi = "moxi", nali = "nali",
|
||||
neom = "neom", neti = "neti", nitr = "nitr", novo = "novo",
|
||||
norf = "norf", oflo = "oflo", peni = "peni", pita = "pita",
|
||||
poly = "poly", qida = "qida", rifa = "rifa", roxi = "roxi",
|
||||
siso = "siso", teic = "teic", tetr = "tetr", tica = "tica",
|
||||
tige = "tige", tobr = "tobr", trim = "trim", trsu = "trsu",
|
||||
vanc = "vanc")
|
||||
|
||||
interpretive_reading(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{tbl}{table with antibiotic columns, like e.g. \code{amox} and \code{amcl}}
|
||||
|
||||
\item{col_bactcode}{column name of the bacteria ID in \code{tbl} - should also be present in \code{bactlist$bactid}, see \code{\link{bactlist}}.}
|
||||
\item{col_bactcode}{column name of the bacteria ID in \code{tbl} - values of this column should be present in \code{bactlist$bactid}, see \code{\link{bactlist}}}
|
||||
|
||||
\item{info}{print progress}
|
||||
|
||||
@ -49,15 +50,19 @@ table with edited variables of antibiotics.
|
||||
Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
|
||||
}
|
||||
\examples{
|
||||
a <- data.frame(bactid = c("STAAUR", "ESCCOL", "KLEPNE", "PSEAER"),
|
||||
vanc = "-",
|
||||
amox = "-",
|
||||
coli = "-",
|
||||
cfta = "-",
|
||||
cfur = "-",
|
||||
a <- data.frame(bactid = c("STAAUR", # Staphylococcus aureus
|
||||
"ENCFAE", # Enterococcus faecalis
|
||||
"ESCCOL", # Escherichia coli
|
||||
"KLEPNE", # Klebsiella pneumoniae
|
||||
"PSEAER"), # Pseudomonas aeruginosa
|
||||
vanc = "-", # Vancomycin
|
||||
amox = "-", # Amoxicillin
|
||||
coli = "-", # Colistin
|
||||
cfta = "-", # Ceftazidime
|
||||
cfur = "-", # Cefuroxime
|
||||
stringsAsFactors = FALSE)
|
||||
a
|
||||
|
||||
b <- EUCAST_rules(a, "bactid")
|
||||
b <- EUCAST_rules(a)
|
||||
b
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ This transforms a vector to a new class \code{rsi}, which is an ordered factor w
|
||||
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
|
||||
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C"))
|
||||
is.rsi(rsi_data)
|
||||
plot(rsi_data)
|
||||
plot(rsi_data) # for percentages
|
||||
barplot(rsi_data) # for frequencies
|
||||
|
||||
\donttest{
|
||||
library(dplyr)
|
||||
|
Loading…
Reference in New Issue
Block a user