Using Inbuilt Functions
pi
## [1] 3.141593
exp(3) ## provides the cube of e
## [1] 20.08554
log(1.4) ## provides the natural logarithm of the number 1.4
## [1] 0.3364722
log10(1.4) ## provides the log to the base of 10
## [1] 0.146128
sqrt(16) ## provides the square root of 16
## [1] 4
Using variables
x <- 2.5 # <-assignment operator in R
x
## [1] 2.5
y <- 3*exp(x)
y
## [1] 36.54748
# Declare variables of different types:
my_numeric <- 42
my_character <- "forty-two"
my_logical <- FALSE
# Check which type these variables have:using class()
class(my_numeric)
## [1] "numeric"
class(my_character)
## [1] "character"
class(my_logical)
## [1] "logical"