list_of_packages <- c("tidyverse", "janitor", "readxl", "ggthemes", "knitr", "kableExtra", "lubridate", "sf", "terra")
install.packages(list_of_packages)Zambia R Training Workshop 2025
Preface
Welcome
The following tutorials and problem sets have been compiled for the purpose of training new R users in routine data analysis, using simulated versions of datasets retrieved from DHIS2. These data are for training purposes only and will not produce the same results as would be found using the data directly from DHIS2. The data used in the regression sections has been simulated and is not based on real-world clinical data.
If you have any questions or issues going through these materials, please feel free to reach out to the PATH training team:
- Justin Millar - jmillar@path.org
- Benson Mwelwa - bmwelwa@path.org
Getting started
Before starting the workshop, make sure you have R installed on your computer. If you don’t have R installed, you can download it here. RStudio is an IDE (Integrated Development Environment) that is also required to use this workshop. If you don’t have it installed, you can download it here.
If you are using a Windows PC you will also want to install Rtools. If you don’t have it installed, you can download it here.
Once you have R, RStudio and Rtools installed, you should install the R packages that we will use in the workshop by copy and pasting the following code into the console. You only need to do this once, but it may take several minutes if you have a slow internet connection.
Create an R Project
Once you have R and RStudio installed, it is a good idea to create an R Project for the workshop. This will help you keep your files organized and make it easier to work with the data. We will do this together in the first session, but if you want to do it now, you can follow these steps:
- Open RStudio.
- Click on the “New Project” button in the top right corner of the RStudio window.
- Select “New Directory” and then “New Project”.
- Choose a name for your project and a location on your computer to save it. It is a good idea to create a new folder for the workshop and save the project there.
- Click “Create Project”.
- RStudio will create a new project and open it in a new window. You should see a new folder with the name of your project in the Files pane on the bottom right of the RStudio window.
Once you have a new project, you should create subfolders for “data”, “scripts”, and “output”. You can do this by right-clicking in the Files pane and selecting “New Folder”. Name the folders “data”, “scripts”, and “output” respectively. This will help you keep your files organized and make it easier to work with the data. Then copy and paste the data files from the workshop folder into the “data” folder. You can do this by dragging and dropping the files from the workshop folder into the “data” folder in RStudio. You should see the files appear in the Files pane.
The benefit of using R projects is that you can use relative paths to access your data files. This means that you don’t have to worry about the absolute path to the files on your computer. You can just use the name of the file and R will find it in the “data” folder. Also, R Project help maintain all of the relevant files in one place, so you don’t have to worry about losing them or forgetting where they are.