Calculator in R

Basic Arthimatic operations

4+6 #addition
## [1] 10
6-4 #subtraction
## [1] 2
2*6  #multiplication
## [1] 12
8/2  #division
## [1] 4
8^3  #exponentiation
## [1] 512
8%%3 #remainder
## [1] 2
(2^3)*(3^2)   #evaluate 23 X 32
## [1] 72

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"