R Get Started
Getting started with R means installing R itself, adding RStudio as your editor, and running your first lines of code.
Installing R
R is free to download from CRAN (the Comprehensive R Archive Network) at cran.r-project.org. Installers are available for Windows, macOS, and Linux, and the base installation includes the R console, the core language, and a standard set of built-in packages.
Installing RStudio
R by itself only gives you a bare console. Almost everyone pairs it with RStudio, a free integrated development environment (IDE) that adds a code editor, a file browser, a variable viewer, and a panel for viewing plots, all in one window. You install R first, then install RStudio, which detects your existing R installation automatically.
- Download and install R from CRAN for your operating system
- Download and install RStudio Desktop (the free edition)
- Open RStudio — it will locate your R installation automatically
- Open the Console pane and try typing a command
Running Your First Command
You can type code directly into the Console and press Enter to run it immediately, which is great for quick experiments. For anything you want to save and reuse later, write it in a script file with a .R extension in the Source pane instead.
Example
print("Hello, World!")
1 + 1Save your code in a file such as my_script.R, then run the whole file with the Source button in RStudio, or run just the current line and move to the next with Ctrl+Enter (Cmd+Enter on macOS).
Exercise: R Get Started
What best describes RStudio in relation to R?