R for EHR: From Zero to Machine Learning

A free, hands-on course that teaches R and machine learning with health data, starting from zero.

Start with Chapter 01 Read the welcome page

For education only. All data in this course is synthetic (fabricated). Nothing here is clinical advice, and nothing here shows that any model is medically valid.

Your progress

Progress is stored only in this browser on this device.

Level
Beginner to intermediate. No coding background needed.
Scope
Six parts and four appendices, taught on a dataset of 600 fabricated examples: R foundations, a complete supervised machine learning workflow, more supervised methods, unsupervised learning, other kinds of learning, and choosing and comparing methods, ending in a capstone.
Prerequisites
None. You install R and RStudio in Chapter 02.
Updated
Attribution
A revision of Jaewon Kim’s R Guide by the IHC/EHR Training Team.

What you will be able to do

Practice files

The lessons ask you to open an RStudio project and run scripts. Download the practice bundle: the project file, the synthetic dataset and the R scripts. It contains synthetic data only.

Download practice bundle (.zip)

Lessons

Start here

  1. Welcomereading3 min

Part I — R foundations and data

  1. 01Orientation: What Are We Learning?hands-on8 min
  2. 02Set Up R and RStudiohands-on14 min
  3. 03Your First R Instructionshands-on32 min
  4. 04Vectors, Missing Values, and Conditionshands-on42 min
  5. 05Data Frames and CSV Fileshands-on39 min
  6. 06Clean, Filter, and Summarizehands-on32 min
  7. 07Visualize and Explore Datahands-on27 min
  8. 08Functions, Decisions, and Debugginghands-on30 min

Part II — Supervised learning: the complete workflow

  1. 09Define the Research Question and Labelhands-on13 min
  2. 10Statistics and Baselines for MLhands-on11 min
  3. 11Split the Data Before Modelinghands-on13 min
  4. 12Prepare Inputs Without Leakagehands-on18 min
  5. 13Regression: Predict a Numberhands-on11 min
  6. 14Classification: Predict a Categoryhands-on13 min
  7. 15Evaluate a Classifierhands-on14 min
  8. 16Cross-Validation, Tuning, and Thresholdshands-on13 min
  9. 17Decision Trees and Random Forestshands-on14 min
  10. 18Capstone: A Complete ML Projecthands-on17 min

Part III — Supervised learning: more methods

  1. 19Supervised Regression: From Lines to Ensembleshands-on15 min
  2. 20Classification: From Logistic Regression to Neural Networkshands-on18 min
  3. 21Evaluation for Multiclass, Multilabel, and Imbalanced Datahands-on13 min
  4. 22Special Supervised Tasks: Time Series and Survivalhands-on13 min

Part IV — Unsupervised learning

  1. 23Unsupervised Learning: PCA and Clusteringhands-on22 min
  2. 24Unsupervised Clustering: Five Major Familieshands-on30 min
  3. 25Unsupervised Dimensionality Reduction and Representationhands-on29 min
  4. 26Association Rules and Anomaly Detectionhands-on26 min

Part V — Other kinds of learning

  1. 27Beyond Conventional Supervised and Unsupervised Learninghands-on19 min
  2. 28Positive–Unlabeled EHR Labelshands-on10 min

Part VI — Choosing and comparing methods

  1. 29Methods Map: Which Kind of Learning?hands-on11 min
  2. 30Selecting an Algorithm Without Overfitting the Research Processhands-on14 min
  3. 31Advanced Capstone: Compare Families, Not Just Scoreshands-on22 min

Appendices

  1. Exercise solutions: where to find them (Chapters 1 to 18)reading1 min
  2. Methods exercise solutions: where to find them (Chapters 19 to 31)reading2 min
  3. Glossary and Quick Referencereading4 min
  4. EHR Data Governance and Model Limitationsreading4 min

About this course

A revision of Jaewon Kim’s R Guide by the IHC/EHR Training Team. All examples use synthetic data and the course is for educational use only. See About.