Having installed the R and RStudio systems, you are now ready to begin to learn the art of statistical programming. The first step is to learn the syntax of the language that you will be programming in; you need to know the rules of the language. This chapter will give you an introduction to the syntax of R. Most of what we discuss here relates to what you would type into the R console or into the RStudio script window.
Having opened R or RStudio, you may begin entering and executing commands, usually interactively. Normally, you will use the Source Pane to type in your commands, but you may occasionally use the Console Pane directly. The greater-than sign (>) is the prompt symbol which appears in the Console Pane.
R can be used as a calculator
Anything that can be computed on a pocket calculator can be computed at the R prompt. The basic operations are + (add), - (subtract), * (multiply), and / (divide). For example, try
Upon pressing the Enter key (or CTRL-Enter), the result of the above division operation, 42, appears in the Console Pane, preceded by the command you executed, and prefixed by the number 1 in square brackets:
##  42
The  indicates that this is the first (and in this case only) result from the command. Many commands return multiple values, and each line of results will be labeled to aid the user in deciphering the output. For example, the sequence of integers from 17 to 58 may be displayed as follows:
##  17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
##  39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
The first line starts with the first return value, so it is labeled ; the second line starts with the 23rd, so it is labeled .
Everything that you type after a # sign is assumed to be a comment and is ignored by R.