Introduction to R Programming
2025-02-03
Chapter 1 Introduction
Welcome to this introductory R programming course, specifically designed for Health Economics students to quickly give them a glimse of R. In today’s data-driven healthcare environment, the ability to analyze and visualize health economic data effectively is crucial. This 8 hours course will equip you with the essential skills to use R for data analysis, and visualization using R Markdown.
1.1 Learning Objectives
By the end of this course, you will be able to:
- Master the fundamentals of R programming and RStudio environment
- Understand data wrangling techniques using tidyverse packages
- Create professional visualizations with ggplot2
- Apply these skills to real-world health economics scenarios througth exercices
1.2 Why R and R Markdown?
R has become an essential tool in health economics for several reasons:
- Open-source and Free: Access to powerful statistical and analytical tools without licensing costs
- Reproducibility: Your analyses can be easily shared and reproduced by others
- Extensive Package Ecosystem: Specialized packages for health economics and statistics
- Data Visualization: Professional-quality graphics and interactive visualizations
- Integration with Other Tools: Seamless integration with databases, other statistical software, and reporting tools
1.3 Course Structure
Our course is organized into several modules:
1.3.1 R basics and data manipulations (2h)
- Introduction to R and RStudio
- Data types and objects
- Importing data and basic data manipulations
- Exercices
1.4 Prerequisites
No prior programming experience is required Basic statistical knowledge Laptop with R and RStudio installed
1.5 Course Materials
All course materials will be provided at the end of the course in an R Markdown book format, allowing you to:
- Follow along with interactive examples
- Execute code in real-time
- Create your own annotations
- Test your leaning through exercices
1.6 Practical Applications in Health Economics
Throughout the course, we’ll work with real-world examples relevant to health economics, such as:
using the medicaldata library.
1.8 Getting Started
Before our first session, please:
- Install R from https://cran.r-project.org/
- Install RStudio Desktop from https://posit.co/download/rstudio-desktop/
- Test your installation by running basic R commands
RStudio is a free software tool that makes working with the R programming language much easier. Think of it as a specialized workspace for R - like having a well-organized desk with all your tools in the right place. While you can use R by itself, RStudio gives you helpful features like:
- A cleaner way to write and run your code
- Better organization of your data
- Simple ways to manage R add-ons (called packages)
- Easy viewing of your results
There’s also a paid professional version available from the company Posit, but the free version has everything most people need. If you’re planning to work with R, using RStudio is highly recommended since it’s specifically designed to make R programming more user-friendly.

1.8.1 Understanding the RStudio Interface
When you first open RStudio, you’ll encounter three main sections:
Console :This is where the actual work happens in R. You can type R commands directly here and press Enter to execute them. Think of it as R’s command center.
Environment: Shows all your current R objects (variables, data, functions) like a workspace overview where you can see everything you’ve created.
Files/Plots/Packages/Help: a multi-purpose area that shows: your computer’s files and folders, graphs and visualizations you create, installed R packages, help documentation.
Editor : opens when you create a new R script (File > New File > R Script). This is where you write and save your R code Files are saved with a .R extension. *To run code from the editor: Select the code you want to run; Click the “Run” button (▹) in the top-right of the editor Or use the shortcut Ctrl+Enter (Windows) / Cmd+Enter (Mac)
Note: While you write code in the editor, it always executes in the console. Think of the editor as your notebook and the console as where the actual computation happens.
1.9 Support and Resources
- Office number: 404
- Office hours: 8AM-8PM
- Email: habibou.ibrahim_kassoum@doctorant.uca.fr
- Online forum for questions and discussions (stackoverflow)
Some online resources and reading materials: - Bookdown
Remember, learning to program is like learning a new language - it takes practice and patience. Don’t hesitate to ask questions and collaborate with your peers throughout this journey.
Let’s begin this exciting journey into the world of R programming for health economics!