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

(v2.1.1.9233) chore: make all argument texts full sentences

This commit is contained in:
2025-03-31 14:53:24 +02:00
parent 63099cd81e
commit 1fdab84103
91 changed files with 720 additions and 701 deletions

View File

@ -44,11 +44,15 @@ Our goal is to build a predictive model using the `tidymodels` framework to dete
We begin by loading the required libraries and preparing the `example_isolates` dataset from the `AMR` package.
```{r}
```{r lib packages, message = FALSE, warning = FALSE, results = 'asis'}
# Load required libraries
library(AMR) # For AMR data analysis
library(tidymodels) # For machine learning workflows, and data manipulation (dplyr, tidyr, ...)
```
Prepare the data:
```{r}
# Your data could look like this:
example_isolates
@ -242,6 +246,7 @@ data_time
```
**Explanation:**
- `mo_name(mo)`: Converts microbial codes into proper species names.
- `resistance()`: Converts AMR results into numeric values (proportion of resistant isolates).
- `group_by(year, ward, species)`: Aggregates resistance rates by year and ward.
@ -263,6 +268,7 @@ resistance_recipe_time
```
**Explanation:**
- `step_dummy()`: Encodes categorical variables (`ward`, `species`) as numerical indicators.
- `step_normalize()`: Normalises the `year` variable.
- `step_nzv()`: Removes near-zero variance predictors.
@ -280,6 +286,7 @@ lm_model
```
**Explanation:**
- `linear_reg()`: Defines a linear regression model.
- `set_engine("lm")`: Uses Rs built-in linear regression engine.
@ -324,6 +331,7 @@ metrics_time
```
**Explanation:**
- `initial_split()`: Splits data into training and testing sets.
- `fit()`: Trains the workflow.
- `predict()`: Generates resistance predictions.