DaTax R Course
Master R for Tax Administration Analytics
Welcome
This course teaches you practical R programming for tax administration. You’ll learn to analyze taxpayer data, automate reports, and create professional visualizations—no programming experience required.
Built by the World Bank DaTax team for tax administrators worldwide.
What You’ll Learn
By the end of this course, you will be able to:
Why Learn R for Tax Administration?
- Free & Open Source: No licensing costs for your organization
- Powerful: Handle datasets with millions of taxpayer records
- Reproducible: Every analysis step is documented and repeatable
- Efficient: Automate monthly reports and routine analyses
- Growing: Large community of users in government and research
Prerequisites
This course is designed for complete beginners. If you can work with Excel, you can learn R.
Course Structure
The course consists of 5 sequential modules designed to build your skills progressively:
Module 1: Introduction to R — Learn R basics, RStudio interface, variables, and fundamental data types.
Module 2: Data Import & Export — Master reading CSV and Excel files, handle different file formats, and export results.
Module 3: Data Wrangling with dplyr — Transform datasets with filtering, selecting, creating variables, and summarizing.
Module 4: Reshaping & Joining Data — Reshape data between wide and long formats. Combine multiple datasets.
Module 5: Data Visualization with ggplot2 — Create professional charts and communicate insights effectively.
Each module includes step-by-step explanations, hands-on exercises with real tax data, template scripts, and complete solutions.
Getting Started
Step 1: Install R and RStudio
You need to install two pieces of software: R (the programming language) and RStudio (the interface that makes R easy to use).
Always install R first, then RStudio. RStudio needs R to be already installed on your computer.
Installing R
Visit the R website
Go to https://cloud.r-project.org/Click “Download R for Windows”
You’ll see this link near the top of the pageClick “base” or “install R for the first time”
This takes you to the download page for the basic R installationClick “Download R-4.x.x for Windows”
(The version number will be different, e.g., R-4.4.1)
This downloads an.exefile (usually to your Downloads folder)Run the installer
- Double-click the downloaded
.exefile - If Windows asks “Do you want to allow this app to make changes?”, click Yes
- Choose English (or your preferred language)
- Click Next through all screens, accepting the default options
- Click Finish when installation completes
- Double-click the downloaded
Verify installation
- Look for the R icon on your desktop or in your Start menu
- You don’t need to open R directly—you’ll use RStudio instead
Visit the R website
Go to https://cloud.r-project.org/Click “Download R for macOS”
You’ll see this link near the top of the pageChoose the correct version for your Mac
- For newer Macs (M1, M2, M3 chips): Download the file that says “Apple silicon arm64”
- For older Macs (Intel processors): Download the file that says “Intel 64-bit”
- If you’re not sure which you have, click the Apple menu () → “About This Mac” → look under “Chip” or “Processor”
Download the
.pkgfile
Click the appropriate link (e.g.,R-4.4.1-arm64.pkgorR-4.4.1-x86_64.pkg)
The file will download to your Downloads folderRun the installer
- Double-click the downloaded
.pkgfile - Click Continue through the introduction screens
- Click Agree to the license
- Click Install (you may need to enter your Mac password)
- Click Close when installation completes
- Double-click the downloaded
Install XQuartz (may be required)
- Some R packages need XQuartz
- Download it from https://www.xquartz.org/
- Install it the same way (double-click the
.pkgfile) - Restart your computer after installing XQuartz
Verify installation
- Look for R in your Applications folder
- You don’t need to open R directly—you’ll use RStudio instead
Visit the R website
Go to https://cloud.r-project.org/Click “Download R for Linux”
Choose your Linux distribution (Ubuntu, Debian, Fedora, etc.)Follow your distribution’s instructions
For Ubuntu/Debian:
# Update package list sudo apt update # Install R sudo apt install r-base r-base-devFor Fedora:
sudo dnf install RVerify installation
Open a terminal and typeR --version
You should see the R version information
Installing RStudio
Now that R is installed, you can install RStudio:
Visit the RStudio website
Go to https://posit.co/download/rstudio-desktop/Scroll down to “All Installers”
Look for the table showing different versionsClick the Windows installer
Find the row that says “Windows 10/11” and click the download link
This downloads a.exefile (e.g.,RStudio-2024.xx.x-xxx.exe)Run the installer
- Double-click the downloaded
.exefile - If Windows asks permission, click Yes
- Click Next through all screens, accepting defaults
- Click Install
- Click Finish when complete
- Double-click the downloaded
Launch RStudio
- Find the RStudio icon on your desktop or Start menu
- Double-click to open RStudio
- You should see a window with multiple panels—that’s RStudio!
Visit the RStudio website
Go to https://posit.co/download/rstudio-desktop/Scroll down to “All Installers”
Look for the table showing different versionsClick the macOS installer
Find the row that says “macOS 11+” and click the download link
This downloads a.dmgfileInstall RStudio
- Double-click the downloaded
.dmgfile - A window opens showing the RStudio icon and Applications folder
- Drag the RStudio icon into the Applications folder
- Wait for the copy to complete
- Eject the RStudio disk image (if it appears on your desktop)
- Double-click the downloaded
Launch RStudio
- Go to Applications folder
- Double-click RStudio
- If Mac says “RStudio cannot be opened because it is from an unidentified developer”:
- Open System Preferences → Security & Privacy
- Click “Open Anyway” next to the RStudio message
- Click Open in the confirmation dialog
- You should see RStudio open with multiple panels
Visit the RStudio website
Go to https://posit.co/download/rstudio-desktop/Download the installer for your distribution
For Ubuntu/Debian:
- Download the
.debfile - Install with:
sudo dpkg -i rstudio-2024.xx.x-amd64.deb - If you get dependency errors, run:
sudo apt-get install -f
For Fedora/RedHat:
- Download the
.rpmfile
- Install with:
sudo dnf install rstudio-2024.xx.x-x86_64.rpm
- Download the
Launch RStudio
Typerstudioin the terminal or find it in your applications menu
Verify Everything Works
Open RStudio (not R—you’ll always use RStudio)
You should see 4 panels:
- Console (left or bottom-left)
- Environment/History (top-right)
- Files/Plots/Help (bottom-right)
- Script editor (top-left, may not appear until you open a file)
Test R by typing in the Console:
2 + 2Press Enter. You should see
[1] 4If you see the result, congratulations! R and RStudio are working correctly.
If you saw [1] 4 appear in your console, you’re ready to start learning!
Having problems? Common issues: - RStudio won’t open: Make sure you installed R first - Console says “R not found”: Reinstall R, then restart RStudio - Mac security blocks RStudio: Go to System Preferences → Security & Privacy → click “Open Anyway”
Step 2: Download Course Materials
Visit the Teaching Materials page to download: - Exercise templates (.R files) - Solution scripts (.R files)
- Sample tax datasets - Quick reference guides
Step 3: Start Learning
Click “1. Introduction to R” in the left sidebar to begin your first module.
Work through modules sequentially—each builds on concepts from previous lessons.
Ready to Begin?
Developed by The World Bank DaTax Team | View on GitHub