3.8 Practice (OPTIONAL)
Practice the following operations. Type the directly into the console and execute them. Also write them in a script in the script editor and run them.
Square roots
sqrt(42)
## [1] 6.480741
The date Some functions in R can be executed within nothing in the parentheses.
date()
## [1] "Thu Sep 13 00:19:52 2018"
Exponents The ^ is used for exponents
42^2
## [1] 1764
A series of numbers A colon between two numbers creates a series of numbers.
1:42
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
## [24] 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
logs The default for the log() function is the natural log.
log(42)
## [1] 3.73767
log10() gives the base-10 log.
log10(42)
## [1] 1.623249
exp() raises e to a power
exp(3.73767)
## [1] 42.00002
Multiple commands can be nested
sqrt(42)^2
log(sqrt(42)^2)
exp(log(sqrt(42)^2))