Skip to the workspace
Pebellslearn by building
Introduction and Setup  ›  Lesson

R vs Python — Picking the Right Tool

R vs Python 10 minR is a language built around data and statistics, where every value is a vector and analysis tools come built in, while Python is a general-purpose language that reaches data work through libraries.

Set up R and run your first file

Install the R engine first, then RStudio as an optional but useful editor. Learn which pane saves your script and which pane executes R expressions.

Already set up? Continue to the lesson

New to coding? Meet the tools and find the terminal
R
The language engine that evaluates expressions.
RStudio
An editor and workspace around R; it does not replace the R installation.
Source and Console panes
Source saves multi-line scripts. Console evaluates commands in the current R session.

A terminal is a window for commands. Its shell interprets those commands. PATH is the list of folders the shell searches for programs. An editor extension adds editing help; it usually does not install the language itself.

In VS Code, open your project folder, then choose View → Terminal. Type at the cursor in the Terminal panel, not in Output, the source file, or the browser address bar. Our command blocks omit prompt symbols such as $ and >; do not add them.

Official VS Code screenshot: the Terminal tab is selected below the editor, with the PowerShell shell name at the right and a command prompt at the left.
Find the Terminal tab and shell name. Open full-size screenshot (new tab).

The dropdown next to the plus button selects a shell. Choose the shell named in your operating-system instructions below. Available choices depend on what you installed.

Official VS Code screenshot: the arrow beside the terminal plus button opens a list containing PowerShell, Command Prompt, Git Bash and Ubuntu WSL.
Official documentation screenshots by Microsoft, VS Code terminal guide, CC BY 3.0 US. Unmodified; your version may look different.

Choose a system to see its installation steps. A computer is needed for these local setup instructions.

Official documentation and illustrated guides

Instructions reviewed 2026-10-27. Use the linked installer page for current versions and supported operating systems.

Continue to the lesson

r programming / R vs Python — Picking the Right Tool

Explore each scene at your own pace.

01 · The rule

The rule

R vs Python — Picking the Right Tool

R is a language built around data and statistics, where every value is a vector and analysis tools come built in, while Python is a general-purpose language that reaches data work through libraries.

Compare analysis tasks, libraries and deployment needs before choosing an environment.

The Riverside community garden keeps a harvest log: five plots, the crop in each, how many kilograms it gave, and whether it was watered. The volunteers want averages, comparisons and a chart for the newsletter. Both R and Python could do this job, so before you learn R it helps to know what it was built around and where it feels at home.

The rule

R was built for data first; Python was built for everything, then data.

R began in the early 1990s at the University of Auckland, where Ross Ihaka and Robert Gentleman wrote a free language modelled on S, a statistics language from Bell Labs. It was designed by statisticians for statisticians, and it shows:

  • Every value is a vector. A single number is just a vector of length one, so arithmetic runs on whole columns of data at once.
  • Statistics are built in. mean(), median(), sd(), summary(), t.test() and lm() (linear models) come with R itself, with no imports.
  • Plotting is built in, and packages such as ggplot2 make publication-quality charts.
  • Counting starts at 1, the way people count, not at 0.

Here is the garden's harvest, in kilograms:

kg <- c(12.5, 8, 15, 3.5, 6)   # plots A to E

mean(kg)       # 9
kg * 1000      # 12500 8000 15000 3500 6000, every value at once
kg[1]          # 12.5, the first plot

c() combines values into a vector and <- stores it under a name. In plain Python, multiplying a list by 1000 would repeat the list 1000 times; you need a loop or the NumPy library to get what R does by default.

Python is a general-purpose language. It builds websites, automates chores and runs production systems, and it reaches data work through libraries such as pandas and NumPy. Machine-learning teams lean towards Python; statistics, research and reporting teams lean towards R. Many teams use both.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.