1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-10 12:21:53 +02:00

bring back antibiogram(), without deps

This commit is contained in:
2023-02-10 16:18:00 +01:00
parent 70a7ba0206
commit bc434db835
42 changed files with 11307 additions and 4734 deletions

View File

@ -157,7 +157,7 @@ Using the `left_join()` function from the `dplyr` package, we can 'map' the gend
data <- data %>% left_join(patients_table)
```
The resulting data set contains `r format(nrow(data), big.mark = ",")` blood culture isolates. With the `head()` function we can preview the first 6 rows of this data set:
The resulting data set contains `r format(nrow(data), big.mark = " ")` blood culture isolates. With the `head()` function we can preview the first 6 rows of this data set:
```{r preview data set 1, eval = FALSE}
head(data)
@ -251,7 +251,7 @@ data_1st <- data %>%
filter_first_isolate()
```
So we end up with `r format(nrow(data_1st), big.mark = ",")` isolates for analysis. Now our data looks like:
So we end up with `r format(nrow(data_1st), big.mark = " ")` isolates for analysis. Now our data looks like:
```{r preview data set 3, eval = FALSE}
head(data_1st)
@ -362,7 +362,7 @@ data_1st %>%
data_1st %>%
group_by(hospital) %>%
summarise(amoxicillin = resistance(AMX)) %>%
knitr::kable(align = "c", big.mark = ",")
knitr::kable(align = "c", big.mark = " ")
```
Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the `n_sir()` can be used, which works exactly like `n_distinct()` from the `dplyr` package. It counts all isolates available for every group (i.e. values S, I or R):
@ -382,7 +382,7 @@ data_1st %>%
amoxicillin = resistance(AMX),
available = n_sir(AMX)
) %>%
knitr::kable(align = "c", big.mark = ",")
knitr::kable(align = "c", big.mark = " ")
```
These functions can also be used to get the proportion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:
@ -404,7 +404,7 @@ data_1st %>%
gentamicin = susceptibility(GEN),
amoxiclav_genta = susceptibility(AMC, GEN)
) %>%
knitr::kable(align = "c", big.mark = ",")
knitr::kable(align = "c", big.mark = " ")
```
Or if you are curious for the resistance within certain antibiotic classes, use a antibiotic class selector such as `penicillins()`, which automatically will include the columns `AMX` and `AMC` of our data:

View File

@ -49,7 +49,7 @@ As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major
* **R has a huge community.**
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, [`r format(suppressWarnings(read.csv("https://data.stackexchange.com/stackoverflow/csv/1674647", quote = '"'))[[1]], big.mark = ",")` R-related questions](https://stackoverflow.com/questions/tagged/r?sort=votes) have already been asked on this platform (that covers questions and answers 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, [`r format(suppressWarnings(read.csv("https://data.stackexchange.com/stackoverflow/csv/1674647", quote = '"'))[[1]], big.mark = " ")` R-related questions](https://stackoverflow.com/questions/tagged/r?sort=votes) have already been asked on this platform (that 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.**

View File

@ -126,7 +126,7 @@ run_it <- microbenchmark(mo_name(x),
print(run_it, unit = "ms", signif = 3)
```
So getting official taxonomic names of `r format(length(x), big.mark = ",")` (!!) items consisting of `r n_distinct(x)` unique values only takes `r round(median(run_it$time, na.rm = TRUE) / 1e9, 3)` seconds. That is `r round(median(run_it$time, na.rm = TRUE) / length(x), 0)` nanoseconds on average. You only lose time on your unique input values.
So getting official taxonomic names of `r format(length(x), big.mark = " ")` (!!) items consisting of `r n_distinct(x)` unique values only takes `r round(median(run_it$time, na.rm = TRUE) / 1e9, 3)` seconds. That is `r round(median(run_it$time, na.rm = TRUE) / length(x), 0)` nanoseconds on average. You only lose time on your unique input values.
### Precalculated results

View File

@ -30,7 +30,7 @@ options(knitr.kable.NA = "")
structure_txt <- function(dataset) {
paste0(
"A data set with ",
format(nrow(dataset), big.mark = ","), " rows and ",
format(nrow(dataset), big.mark = " "), " rows and ",
ncol(dataset), " columns, containing the following column names: \n",
AMR:::vector_or(colnames(dataset), quotes = "*", last_sep = " and ", sort = FALSE), "."
)
@ -142,7 +142,7 @@ Included (sub)species per taxonomic kingdom:
```{r, echo = FALSE}
microorganisms %>%
count(kingdom) %>%
mutate(n = format(n, big.mark = ",")) %>%
mutate(n = format(n, big.mark = " ")) %>%
setNames(c("Kingdom", "Number of (sub)species")) %>%
print_df()
```