Chapter 2: The R User Interface
Shih Chien University
2026-08-02
You presumably have a problem you hope R will solve. Typical examples:
R is a software environment for statistical computing and graphics, made of many components: the language, its interpreter, a graphics system, and the desktop application that bundles them. This chapter tours the parts you physically interact with — the graphical user interface (GUI) on each platform, and then the most important part of all: the R console.
If you have never used an interactive language before, this chapter teaches the survival skills; if you have, it will still tell you where everything lives.
%ProgramFiles%\R (usually C:\Program Files\R) with a Start-menu entry in the group R.R at the prompt.Start R from the command line by typing:
$ is the Unix prompt; don’t type it.)R -g Tk &, which launched R in its own Tk window (menu bar but no toolbar) running in the background. Modern Linux users wanting a windowed experience generally use RStudio instead.Note
A surprise for desktop users: the standard R GUI implements only rudimentary menu functionality — reading help, managing graphics windows, editing some source and data files. There are no menus, buttons, or palettes for loading data, transforming it, plotting it, or building models. Commercial packages like SAS and SPSS ship far richer interfaces.
All real work in plain R happens by typing commands. That is not a defect — it is a design choice with real benefits, as we will see. But it explains why several projects built friendlier front ends…
Several projects layer an easier interface on top of R:
These slides don’t cover the front ends in detail — but everything in this course works in all of them, because they all sit on the same R functions underneath.
The console is where you type commands and watch R respond.
cmd.exe, a Unix shell) or an interactive interpreter such as LISP, this will feel familiar. (R and LISP are genuine relatives: both can compute on the language itself, both use similar internal structures for data, and both love parentheses.)Tip
Why command lines win for data analysis. After finishing a problem you want a record of every step — how the data was loaded, whether a random sample was taken and how, which variables were created, which model parameters were used. A typed transcript gives you exactly that, and lets you re-create the analysis later.
Launching R prints a banner like this (modern version shown):
R version 4.4.2 (2024-10-31) -- "Pile of Leaves"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin20
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
It tells you: the version you are running, license information, quick reminders for getting help — and then hands you a command prompt.
When R is waiting for input, it shows a greater-than sign at the start of an empty line: the prompt >. Type 17 + 3 and press Enter:
Reading the exchange:
17 + 3 at the prompt;[1] 20 (the meaning of [1] is explained in Chapter 3).In the textbook’s convention, boldface marks what the user typed; everything else is R’s output. Your own terminal won’t bold your input — but it may color it.
+ PromptWhen an expression doesn’t fit on one line, R notices it is incomplete and switches the prompt to a plus sign (+), inviting you to finish:
+ prompt — easy to confuse with addition in long sums or inequalities, so watch for it.| Platform | Command prompt | User input | R output |
|---|---|---|---|
| macOS | Purple | Blue | Black |
| Windows | Red | Red | Blue |
| Linux | Black | Black | Black |
R saves you typing with line-editing tools:
history() lists previously typed commands.readline library, which supports a large set of editing commands; Windows supports a smaller set.Interactive mode suits ad hoc analysis, but suppose you must repeat the same pipeline — load experiment data, transform it, emit three PDF plots, quit — many times. Batch mode runs a whole file of commands in sequence and saves the results.
From the system command line (not the R console):
generate_graphs.R and writes the output to generate_graphs.Rout.R --help.R CMD BATCH has one notable limitation: the script cannot read the system’s standard input. The second batch command, Rscript, lifts that restriction:
You can even make R scripts directly executable (Linux/macOS). Create hello_world.R:
then mark it executable and run it like any program:
Finally, batch execution is available from inside R too: the source() function runs the commands in a file within your current session — see ?source.
For heavy Excel users on Windows, the RExcel software (from the rcom project) let you run R directly inside Excel. The project is no longer maintained and does not work with current Excel/R — shown for historical interest. The book’s sequence (its original code omitted the c() wrapper — a bug, corrected here):
The workflow: enter values in a column → Put R Var → Array names them as an R object (say v) → select a blank cell → Get R Value → Array and enter an expression such as (v - mean(v)) / sd(v) → the rescaled values land back in Excel. You can also call R from Excel formulas and macros, and plot R graphics inside Excel.
Warning
Dated technology. RExcel was Windows-only and is no longer actively maintained. The modern route runs the other way: read and write Excel files from R with packages like readxl and openxlsx (Chapter 11).
RStudio is a free, open-source integrated development environment (IDE) for R — and today the most popular way to run it.
We will use RStudio throughout this course: it wraps everything from this chapter — console, history, tab completion, script execution — in one coherent window.
Open-source projects connect R to other applications:
Whatever the wrapper, it is the same interpreter underneath — which is why one reference book covers them all.
> vs. +), and how to save keystrokes (history, Tab).Tip
Try it now. Open R (or RStudio), type a few arithmetic expressions, press the up arrow, edit, re-run. Five minutes of play makes the next chapter twice as easy.
Copyright. These slides are adapted from R in a Nutshell: A Desktop Quick Reference (2nd ed.) by Joseph Adler, O’Reilly Media. All rights reserved by the original author and publisher.
Non-commercial use only. These materials are strictly for educational purposes and may not be used for commercial gain.
Attribution. Any reproduction, distribution, or use of these materials must properly credit the original source.
R in a Nutshell: A Desktop Quick Reference