Now let's write some code that actually executes something:
1 + 2
2 + 5 * 4
3 ^ 4
sqrt(81)
pi
This code first evaluates three mathematical expressions using the basic operators. As you might expect, R evaluates the expressions using the mathematical operator precedence. The code calls the sqrt() function to calculate and checks the value of the constant for the number pi (π). The base R installation, or the base package, has many built-in constants. You can search the help for all pages that mention constants with ??"constants".
There are many ways to generate sequences of numbers, as you can see from the following code:
rep(1, 5)
4:8
seq(4, 8)
seq(4, 20, by = 3)
The first command replicates the number 1 five times with the help of the rep() function. You can generate a sequence of numbers with the help of the...