Screen prompt

The screen prompt > is an invitation to put R to work. You can either use one of the many facilities which are the subject of this book, including the built-in functions discussed on p. 11, or do ordinary calculations:

> log(42/7.3)

[1]  1.749795

Each line can have at most 128 characters, so if you want to give a lengthy instruction or evaluate a complicated expression, you can continue it on one or more further lines simply by ending the line at a place where the line is obviously incomplete (e.g. with a trailing comma, operator, or with more left parentheses than right parentheses, implying that more right parentheses will follow). When continuation is expected, the prompt changes from > to +

> 5+6+3+6+4+2+4+8+
    +         3+2+7

[1] 50

Note that the + continuation prompt does not carry out arithmetic plus. If you have made a mistake, and you want to get rid of the + prompt and return to the > prompt, then either press the Esc key or use the Up arrow to edit the last (incomplete) line.

Two or more expressions can be placed on a single line so long as they are separated by semi-colons:

2+3; 5*7; 3-7

[1] 5
[1] 35
[1] −4

From here onwards and throughout the book, the prompt character > will be omitted. The material that you should type on the command line is shown in Arial font. Just press the Return key to see the answer. The output from R is shown in Courier New font, which uses absolute rather than proportional spacing, so that columns of numbers remain neatly aligned ...

Get The R Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.