mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 08:32:04 +02:00
rlang dependency, new fungi
This commit is contained in:
@ -315,7 +315,7 @@ data_1st %>%
|
||||
|
||||
## Resistance percentages
|
||||
|
||||
The functions `portion_R`, `portion_RI`, `portion_I`, `portion_IS` and `portion_S` can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:
|
||||
The functions `portion_R()`, `portion_RI()`, `portion_I()`, `portion_IS()` and `portion_S()` can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:
|
||||
|
||||
```{r}
|
||||
data_1st %>% portion_IR(amox)
|
||||
@ -351,21 +351,21 @@ data_1st %>%
|
||||
knitr::kable(align = "c", big.mark = ",")
|
||||
```
|
||||
|
||||
These functions can also be used to get the portion of multiple antibiotics, to calculate co-resistance very easily:
|
||||
These functions can also be used to get the portion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:
|
||||
|
||||
```{r, eval = FALSE}
|
||||
data_1st %>%
|
||||
group_by(genus) %>%
|
||||
summarise(amoxicillin = portion_S(amcl),
|
||||
summarise(amoxiclav = portion_S(amcl),
|
||||
gentamicin = portion_S(gent),
|
||||
"amox + gent" = portion_S(amcl, gent))
|
||||
amoxiclav_genta = portion_S(amcl, gent))
|
||||
```
|
||||
```{r, echo = FALSE}
|
||||
data_1st %>%
|
||||
group_by(genus) %>%
|
||||
summarise(amoxicillin = portion_S(amcl),
|
||||
summarise(amoxiclav = portion_S(amcl),
|
||||
gentamicin = portion_S(gent),
|
||||
"amox + gent" = portion_S(amcl, gent)) %>%
|
||||
amoxiclav_genta = portion_S(amcl, gent)) %>%
|
||||
knitr::kable(align = "c", big.mark = ",")
|
||||
```
|
||||
|
||||
@ -374,9 +374,9 @@ To make a transition to the next part, let's see how this difference could be pl
|
||||
```{r plot 1}
|
||||
data_1st %>%
|
||||
group_by(genus) %>%
|
||||
summarise("1. Amoxicillin" = portion_S(amcl),
|
||||
summarise("1. Amoxi/clav" = portion_S(amcl),
|
||||
"2. Gentamicin" = portion_S(gent),
|
||||
"3. Amox + gent" = portion_S(amcl, gent)) %>%
|
||||
"3. Amoxi/clav + gent" = portion_S(amcl, gent)) %>%
|
||||
tidyr::gather("Antibiotic", "S", -genus) %>%
|
||||
ggplot(aes(x = genus,
|
||||
y = S,
|
||||
@ -397,9 +397,9 @@ ggplot(data = a_data_set,
|
||||
x = "My X axis",
|
||||
y = "My Y axis")
|
||||
|
||||
ggplot(a_data_set,
|
||||
aes(year, value) +
|
||||
geom_bar()
|
||||
# or as short as:
|
||||
ggplot(a_data_set) +
|
||||
geom_bar(aes(year))
|
||||
```
|
||||
|
||||
The `AMR` package contains functions to extend this `ggplot2` package, for example `geom_rsi()`. It automatically transforms data with `count_df()` or `portion_df()` and show results in stacked bars. Its simplest and shortest example:
|
||||
|
@ -38,17 +38,17 @@ As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major
|
||||
|
||||
* **R is extremely flexible.**
|
||||
|
||||
Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. It may be a bit flexible, but you can never create that very specific publication-ready plot without using other (paid) software.
|
||||
Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. They may be a bit flexible, but you can probably never create that very specific publication-ready plot without using other (paid) software.
|
||||
|
||||
* **R can be easily automated.**
|
||||
|
||||
Over the last years, [R Markdown](https://rmarkdown.rstudio.com/) has really made an interesting development. With R Markdown, you can very easily reproduce your reports, whether it's to Word, Powerpoint, a website, a PDF document or just the raw data to Excel. I use this a lot to generate monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like.
|
||||
|
||||
For an even more professional environment, you could create [Shiny apps](https://shiny.rstudio.com/): live manipulation of data using a custom made website. The webdesign knowledge needed (Javascript, CSS, HTML) is almost *zero*.
|
||||
For an even more professional environment, you could create [Shiny apps](https://shiny.rstudio.com/): live manipulation of data using a custom made website. The webdesign knowledge needed (JavaScript, CSS, HTML) is almost *zero*.
|
||||
|
||||
* **R has a huge community.**
|
||||
|
||||
Many R users just ask questions on website like [stackoverflow.com](https://stackoverflow.com), the largest online community for programmers. At the time of writing, around [275,000 R questions](https://stackoverflow.com/questions/tagged/r?sort=votes) have been asked on this platform (which covers questions and answer for any programming language). In my own experience, most questions are answered within a couple of minutes.
|
||||
Many R users just ask questions on websites like [StackOverflow.com](https://stackoverflow.com), the largest online community for programmers. At the time of writing, more than [275,000 R-related questions](https://stackoverflow.com/questions/tagged/r?sort=votes) have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.
|
||||
|
||||
* **R understands any data type, including SPSS/SAS/Stata.**
|
||||
|
||||
|
@ -89,7 +89,7 @@ Uncommon microorganisms take a lot more time than common microorganisms. To reli
|
||||
|
||||
### Repetitive results
|
||||
|
||||
Repetitive results mean that unique values are present more than once. Unique values will only be calculated once by `as.mo()`. We will use `mo_fullname()` for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses `as.mo()` internally.
|
||||
Repetitive results are unique values that are present more than once. Unique values will only be calculated once by `as.mo()`. We will use `mo_fullname()` for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses `as.mo()` internally.
|
||||
|
||||
```{r, message = FALSE}
|
||||
library(dplyr)
|
||||
|
Reference in New Issue
Block a user