At it’s simplest, R is a very fancy calculator
1 + 1[1] 2
2 - 3[1] -1
6 / 2[1] 3
3 * 4[1] 12
These basic operators form the basis for more complex calculations that are expressed slightly differently.
sqrt(9)[1] 3
log10(100)[1] 2
R can also string numbers together
1:10 [1] 1 2 3 4 5 6 7 8 9 10
And groups of numbers can be calculated if the groups are multiples of each other
1:10 + 11:20 [1] 12 14 16 18 20 22 24 26 28 30
2 * 1:10 [1] 2 4 6 8 10 12 14 16 18 20
1:2 * 1:10 [1] 1 4 3 8 5 12 7 16 9 20
Calculate the result of 3 + 2 * 6, calculating the
addition before multiplication
Take the square root of 20 * 5
Calculate the log base 2 of 16
Take the square root of the numbers 1 through 10
(3 + 2) * 6[1] 30
sqrt(20 * 5)[1] 10
log2(16)[1] 4