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.

Preparation

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:

  • Microorganisms should be transformed to our own microorganism IDs (called an 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(). This function also recognises almost all WHONET abbreviations of microorganisms.
  • Antimicrobial results or interpretations have to be clean and valid. In other words, they should only contain values "S", "I" or "R". That is exactly where the as.rsi() function is for.

No errors or warnings, so all values are transformed succesfully. Let’s check it though, with a couple of frequency tables:

Frequency table of mo from a data.frame (500 x 54)
Class: mo (character)
Length: 500 (of which NA: 0 = 0.00%)
Unique: 39

Families: 9
Genera: 16
Species: 36

Item Count Percent Cum. Count Cum. Percent
1 B_ESCHR_COL 245 49.0% 245 49.0%
2 B_STPHY_CNS 74 14.8% 319 63.8%
3 B_STPHY_EPI 38 7.6% 357 71.4%
4 B_STRPTC_PNE 31 6.2% 388 77.6%
5 B_STPHY_HOM 21 4.2% 409 81.8%
6 B_PROTS_MIR 9 1.8% 418 83.6%
7 B_ENTRC_IUM 8 1.6% 426 85.2%
8 B_STPHY_CAP 8 1.6% 434 86.8%
9 B_ENTRB_CLO 5 1.0% 439 87.8%
10 B_ENTRC 4 0.8% 443 88.6%

(omitted 29 entries, n = 57 [11.4%])

Frequency table of AMC_ND2 from a data.frame (500 x 54)
Class: factor > ordered > rsi (numeric)
Levels: S < I < R
Length: 500 (of which NA: 19 = 3.80%)
Unique: 3

%IR: 25.99% (ratio S : IR = 1.0 : 0.4)

Item Count Percent Cum. Count Cum. Percent
1 S 356 74.0% 356 74.0%
2 R 103 21.4% 459 95.4%
3 I 22 4.6% 481 100.0%

Analysis

(more will be available soon)