diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html index bf9bffc7..32cddd86 100644 --- a/docs/articles/WHONET.html +++ b/docs/articles/WHONET.html @@ -199,30 +199,31 @@ Import of data
This tutorial assumes you already imported the WHONET data with e.g. the readxl
package. In RStudio, this can be done using the menu button ‘Import Dataset’ in the tab ‘Environment’. Choose the option ‘From Excel’ and select your exported file. Make sure date fields are imported correctly.
An example syntax could look like this:
- +library(readxl)
+data <- read_excel(path = "path/to/your/file.xlsx")
This package comes with an example data set WHONET
. We will use it for this analysis.
First, load the relevant packages if you did not yet did this. I use the tidyverse for all of my analyses. All of them. If you don’t know it yet, I suggest you read about it on their website: https://www.tidyverse.org/.
- +library(dplyr) # part of tidyverse
+library(ggplot2) # part of tidyverse
+library(AMR) # this package
We will have to transform some variables to simplify and automate the analysis:
mo
) using the ITIS reference data set, which contains all ~20,000 microorganisms from the taxonomic kingdoms Bacteria, Fungi and Protozoa. We do the tranformation with as.mo()
."S"
, "I"
or "R"
. That is exactly where the as.rsi()
function is for.# transform variables
-data <- WHONET %>%
- # get microbial ID based on given organism
- mutate(mo = as.mo(Organism)) %>%
- # transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class
- mutate_at(vars(AMP_ND10:CIP_EE), as.rsi)
# transform variables
+data <- WHONET %>%
+ # get microbial ID based on given organism
+ mutate(mo = as.mo(Organism)) %>%
+ # transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class
+ mutate_at(vars(AMP_ND10:CIP_EE), as.rsi)
No errors or warnings, so all values are transformed succesfully. Let’s check it though, with a couple of frequency tables:
- +# our newly created `mo` variable
+data %>% freq(mo, nmax = 10)
Frequency table of mo
from a data.frame
(500 x 54)
(omitted 46 entries, n = 112 [22.4%])
-
-# our transformed antibiotic columns
-# amoxicillin/clavulanic acid (J01CR02) as an example
-data %>% freq(AMC_ND2)
+# our transformed antibiotic columns
+# amoxicillin/clavulanic acid (J01CR02) as an example
+data %>% freq(AMC_ND2)
Frequency table of AMC_ND2
from a data.frame
(500 x 54)