← Dashboard

data science / r

Learn R for Data Science Free: The Tidyverse Route, With a pandas Translation

R is the better first language for some data work and the wrong one for other work. This page sets out which is which, shows the same analysis in R and in pandas side by side, lists exactly what to install and what it costs (nothing), and puts the free books in a reading order.

updated Nov 2026·a 10-minute read·R 4.6, dplyr 1.2, ggplot2 4.0

R was built by statisticians for data analysis, and it shows: data frames, missing values, statistical models and publication-quality graphics are first-class features rather than libraries bolted on. Python is the more general language, with a wider job market around software and machine learning engineering. Plenty of working analysts know both. If your first goal is statistics, research, reporting or visualization, R is a direct path, and the modern way to learn it, the tidyverse, reads closer to English than the older base-R style that gave the language its reputation for being awkward.

01 · THE SAME ANALYSIS TWICE

A five-line tidyverse pipeline and its pandas equivalent

R's built-in teaching dataset mpg (from ggplot2) holds fuel economy figures for 234 car models. The question: for 2008 models, how many cars are in each class and what is the average highway mileage, from best to worst?

mpg-by-class.Rtidyverse
library(tidyverse)

mpg |>
  filter(year == 2008) |>
  group_by(class) |>
  summarise(cars = n(), mean_hwy = mean(hwy)) |>
  arrange(desc(mean_hwy))

ggplot(mpg, aes(displ, hwy, colour = class)) +
  geom_point()

Read the pipe |> as "and then". Each verb takes a table and returns a table, so a pipeline is a recipe you read from top to bottom. The same verbs map onto pandas, which helps if you are coming from the Python guide or planning to learn both:

dplyr verb and pandas counterpart
TaskR (dplyr)Python (pandas)
Keep rowsfilter(year == 2008)df.query("year == 2008")
Keep columnsselect(class, hwy)df[["class", "hwy"]]
New columnmutate(ratio = hwy / cty)df.assign(ratio=df.hwy / df.cty)
Group and summarizegroup_by(class) |> summarise(m = mean(hwy))df.groupby("class").agg(m=("hwy", "mean"))
Sortarrange(desc(m)).sort_values("m", ascending=False)
TIPLearn the verbs, not the syntax. The five dplyr verbs above cover most day-to-day data wrangling, and the official dplyr introduction lists them with examples. Once you can say what you want in verbs, translating between R and pandas is mechanical.

02 · WHEN TO CHOOSE R

R or Python: a decision by task

Which language fits the work
Your goalLean towardReason
Academic statistics, survey or biomedical analysisRR is a long-standing standard in statistics teaching; MIT 18.05 and Harvard's Data Science: Probability course both use it.
Reports and figures for publicationRggplot2 and Quarto are built for exactly this; R4DS ends with chapters on Quarto.
Production machine learning, deep learningPythonThe deep learning frameworks target Python. See the deep learning guide.
Scripts that glue systems and serve web appsPythonGeneral-purpose language with a broader software ecosystem.
Not sure yetWhichever your course or team usesThe concepts transfer; the table above is the proof.

03 · INSTALL AND COST

What to install, and what is free

Everything needed is free. Install R itself first, then an editor. R4DS recommends R 4.2.0 or later and RStudio 2022.02.0 or later; the current Windows download page on CRAN offers R 4.6.2.

Setup options
OptionWhat you getLimits to know
R from CRANThe language itselfConsole only; no editor
RStudio Desktop (open source)The standard R editor, running on Windows 11, macOS 15+ and LinuxThe open-source edition is AGPL-licensed; commercial editions exist but are not needed
Posit Cloud, Free planRStudio in the browser, $0 forever per the plan page25 compute hours a month, 1 GB RAM, 1 CPU, 25 projects

Posit Cloud is useful if you cannot install software on your machine. Its free plan is generous for learning but small for real data. Once a project nears 1 GB of RAM, switch to a local install.

04 · THE FREE LIBRARY

Free books and tutorials, in reading order

Start with an interactive tutorial to get over the syntax, then read R for Data Science, which is the backbone of most learning paths.

05 · TRY IT

Reproduce the example, then break it

TRY ITInstall R and RStudio, run install.packages("tidyverse"), and paste the pipeline from section 01. Then change it: filter to cyl == 4, group by drv instead of class, or add median(hwy) next to the mean. Finish by reading R4DS chapter 1 and recreating its first plot with your own dataset.
WATCHOld R code uses old habits. Many tutorials online predate the native pipe |> and use %>% from the magrittr package, which still works. Copying a mix of both styles into one script is fine, but keep one for your own code. R4DS 2e uses the native pipe.

06 · FAQ

Frequently asked questions

Should I learn R or Python for data science?

Learn R if your focus is statistics, academic research, reporting or visualization, and Python if you want machine learning engineering or general programming. The data wrangling concepts transfer between them, and many analysts end up using both.

Is R for Data Science really free?

Yes. The second edition is published online at r4ds.hadley.nz, which states that the website is and will always be free under a CC BY-NC-ND 3.0 license. A printed copy is sold separately.

Do I need to pay for RStudio?

No. The open-source RStudio Desktop is free and licensed under the AGPL. If you cannot install software, Posit Cloud has a free plan with 25 compute hours a month and 1 GB of RAM.

What is the tidyverse?

The tidyverse is a collection of R packages for data science that share a design, including dplyr for transforming data, tidyr for reshaping it and ggplot2 for graphics. Learning R this way is easier than starting with base R.

Keep going

Pair R with statistics and graphics, or compare it with Python.