Teaching exercise
This code computes the answer to one plus one, change it so it computes two plus two:
1 + 1
Aside from computing sums, we can also ask R to help us with divisions and multiplications:
9 / 3
4 * 5
A key feature of R—in fact, programming languages more generally—is that it works with objects that contain some type of information. In the following we store the the integer 5 in the object a. We’re not limited to storing numbers in objects, we can also assign a character, word or even a sentence in an object. In the example below, we store the sentence “Hello world!” in the object b.
a <- 5
a
## [1] 5
b <- "Hello world"
b
## [1] "Hello world"