2.3 Using R
R is very simple. There is a console where you type commands and get responses. Like the classic command-line interfaces you see when the stereotypical nerd has to hack into the FBI database, you type commands, one at a time into the console, R processes it, and then produces a response if appropriate. For example, if you type
2 + 2 into the R console and hit enter, you'll get
Writing commands out one at a time can be quite time consuming if you want to make changes however. So we use scripts to store multiple lines of code that can then be run altogether. When you execute a script, each line gets passed one by one to the console and executed. For example, I might make a script with this code:
variable1 <- 2 + 2 variable1 / 10
##  0.4
So when I run the script, it will run the first line, then the second without me having to type anything else in.