TC Technology Knowledge Base

Use R as a calculator in RStudio

Updated on

1. In your script type the following: 2+2

2. With your cursor still on this line, hit command+enter or for Windows, ctrl+enter. 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.

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.

3. 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.

4. Here is a list of basic mathematical operations in R.

Previous Article Identify the Panes in RStudio
Next Article Use Help in RStudio