R Tutorial
Master R from scratch with our comprehensive, interactive curriculum — 50 lessons from Beginner to Advanced, focused on real statistics and data analysis.
Learn R from scratch — vectors, data frames, dplyr, tidyr, ggplot2, statistics and linear models — free interactive lessons for data science.
Part of the free R course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
Start with Lesson 1 and build real data-analysis skills step by step — at your own pace.
Lessons in this course
- Introduction to R — What R is, why it dominates statistics, and running your first line of code
- RStudio & Running Code — Set up RStudio, use the console and scripts, and run code interactively
- Vectors — R's core data structure — create, index, and do math on vectors
- Operators — Arithmetic, comparison, and logical operators with vectorized behaviour
- Factors — Represent categorical data with levels — essential for stats and plots
- Functions — Write reusable functions with arguments, defaults, and return values
- Control Flow — Make decisions and repeat work with if/else, for, and while
- Lists — Hold mixed types and nested data in R's flexible list structure
- Matrices — Two-dimensional numeric data and matrix operations
- Data Frames — R's spreadsheet-like table — the workhorse of data analysis
- Reading Data (CSV) — Load real datasets from CSV files into data frames
- The apply Family — Apply functions over rows, columns, and lists without loops
- dplyr Basics — Filter, select, mutate, and arrange data the tidyverse way
- tidyr & Pipes — Reshape messy data into tidy form and chain steps with the pipe
- Strings & Dates — Clean text and work with real dates and times
- ggplot2 Fundamentals — Build publication-quality charts with the grammar of graphics
- group_by & summarise — Split-apply-combine: compute grouped statistics with dplyr
- Joining Data — Combine multiple tables with inner, left, and other joins
- Statistical Functions — Means, distributions, correlation, and hypothesis tests in base R
- Data Types & Classes — numeric, character, logical and complex — plus class(), typeof() and coercion
- Subsetting & Indexing ([ ], [[ ]], $) — Positional, logical and name-based indexing for vectors and lists
- Missing Data (NA, na.rm) — Detect, drop and handle NA with is.na, na.rm and complete.cases
- Vectorization vs Loops — Write fast idiomatic R with vectorized operations, recycling and ifelse
- Regular Expressions (grepl, gsub) — Match and replace text with grepl, gsub, and regmatches
- Frequency Tables (table, prop.table) — Count and cross-tabulate categories with table and prop.table
- Error Handling (tryCatch) — Catch errors and warnings safely with tryCatch, try, and stopifnot
- Environments & Scoping — Lexical scoping, the global environment, and the <<- super-assignment
- Checkpoint: R Basics — Combine subsetting, NA handling, regex and tables in a build — then a quiz
- Tibbles (Modern Data Frames) — The tidyverse data frame — nicer printing and no surprising conversions
- Reshaping: pivot_longer & pivot_wider — Move between wide and long (tidy) data with tidyr
- Functional Programming with purrr — Iterate cleanly with map, map_dbl, the ~.x shorthand, and reduce
- Dates with lubridate — Parse, extract from and do arithmetic with dates the easy way
- ggplot2: Facets, Themes & Scales — Small multiples with facets, custom themes, and scale control
- Probability Distributions — The d/p/q/r functions, set.seed reproducibility, and sampling
- Hypothesis Testing (t.test, chisq.test) — Run and interpret t-tests, chi-squared tests, and p-values
- Generalized Linear Models (glm) — Fit logistic regression and other GLMs and interpret the coefficients
- Checkpoint: Data Analysis — Combine tibbles, pivots and a tidyverse pipeline in a build — then a quiz
- Linear Models (lm) — Fit, interpret, and predict from linear regression models
- Writing Functions & Packages — Package reusable code, document it, and share it with others
- Matrix Algebra (%*%, solve, t) — Multiply, transpose, invert, and solve linear systems with matrices
- Text Wrangling with stringr — Detect, extract, and replace text the tidyverse way with str_* functions
- ANOVA & Model Comparison — Compare group means and nested models with aov and anova()
- Time Series (ts & forecasting basics) — Build ts objects, decompose trend and seasonality, and forecast
- Fast Data with data.table — Filter, aggregate, and update huge datasets fast with dt[i, j, by]
- Interactive Apps with Shiny — Build reactive web apps with a ui, a server, and inputs/outputs
- Reports with R Markdown — Mix prose, code chunks, and results into reproducible HTML/PDF reports
- Closures & Function Factories — Return functions that remember their environment for reusable behavior
- Debugging R (browser, traceback) — Find and fix bugs with traceback, browser, debug, and tryCatch
- Checkpoint: Statistical Modeling — Fit and interpret a model on a small dataset — then a quiz
- Capstone: A Data Analysis Report — Tie it all together: import, clean, analyse, visualise, and report
- Machine Learning with caret — Train, tune and evaluate models with caret's unified train() interface
- Bayesian Statistics in R — Priors, posteriors and credible intervals with brms and rstanarm
- Cross-Validation & ROC — k-fold CV, overfitting, and the ROC curve / AUC for honest model evaluation
- Interactive Plots with plotly — Add hover, zoom and interactivity with plot_ly() and ggplotly()
- Parallel Computing in R — Use every core with parallel, foreach + doParallel, and the future framework