Installing R and Choosing an Editor
A new volunteer installs RStudio, opens it, and is told that R cannot be found. This happens so often because R setup is really two installs: the language itself, and the program you type into. Once you see them as separate pieces, every setup problem gets easier to diagnose.
The rule
Install the engine from CRAN, then pick a dashboard to drive it.
The engine is R. It is the program that actually reads and runs your code. You download it from CRAN, the Comprehensive R Archive Network, a set of mirror servers around the world that hosts R and its packages (cran.r-project.org):
- Windows: run the installer from the "base" download.
- macOS: pick the installer that matches your chip: the arm64 build for Apple silicon (M-series) Macs, the x86_64 build for older Intel Macs.
- Linux: use your distribution's package manager, such as
sudo apt install r-baseon Ubuntu or Debian.
Opening R gives you the console: a > prompt where you type an expression and see the answer.
> 1 + 1
[1] 2
> R.version.string
[1] "R version 4.x.y (...)"The [1] is not part of the answer. It tells you that the first value on that line is element number 1, which helps when a long vector wraps over several lines.
If the prompt changes to +, R thinks your expression is not finished, usually because of a missing bracket or quote. Finish it, or press Esc to start again.
The dashboard is an editor, a program that holds your scripts and sends lines to R:
- RStudio (by Posit): the classic choice, with four panes for scripts, the console, the environment (your variables) and files, plots and help.
- Positron (also by Posit): a newer data-science editor built on the same open-source base as VS Code, working with both R and Python.
- VS Code with the R extension: handy if you already use VS Code for other languages.
None of these include R. Each one looks for the R you installed.
The shortcut
When something goes wrong, ask: "Is this an engine problem or a dashboard problem?" Anything about versions, errors in your code or missing packages belongs to R. Anything about panes, buttons, themes or shortcuts belongs to the editor.
Download the engine
From CRAN, choose macOS and the arm64 installer, then run it.
The volunteer at the top had a dashboard with no engine. Installing R from CRAN and restarting RStudio fixes it.
Drills
Answer fast — trust the rule.
RStudio on a new laptop reports that it cannot find R. What is the most likely cause?
Where do you download R itself?
You type mean(c(12.5, 8) and press Enter. The prompt changes from > to +. What does that mean?
In the output [1] 9, what does [1] mean?
Remember
- Install the engine (R) from CRAN, then pick a dashboard: RStudio, Positron or VS Code.
- Shortcut: engine problem or dashboard problem? Code, versions and packages belong to R.
- Trap: an editor never includes R, and the
+prompt means "unfinished", not "broken".
