R Basics

R as a Calculator

1. You can use R as a calculator. In your script type the following: 2+2

2. With your cursor still on this line, hit command+enter (or for Windows, ctrl+enter), which is the keyboard shortcut for "run"). In the bottom left quadrant of RStudio, you'll now see a new line, in blue >2+2 and then, in black, the output [1] 4.

3. You have just executed your first R command! The top left portion is the script. This is a placeholder for the various commands. When you want to run a command, RStudio will send it down to the console and execute it.

4. The bottom left of the quadrant is the console. Once RStudio sends down the commands and executes it, the next line in the console will be the output, which in this case is 4.

5. You can try to do other arithmetic in R as well: 10*(5-2)/3+1