Professional Documents
Culture Documents
Emily Atkins
6/14/2017
# Addition!
3 + 5
## [1] 8
## [1] 8
# Subtraction!
6-4
## [1] 2
## [1] 2
Arithmetic in R (1)
# Addition
2 + 2
## [1] 4
# Subtraction
4 - 1
## [1] 3
# Multiplication
3 * 4
## [1] 12
# Division
4 /2
## [1] 2
# Exponentiation
2^4
## [1] 16
# Modulo
7 %% 3
## [1] 1
Financial returns
We learned about the multiplier equation which is : $multiplier = 1 + (return / 100)
# Print post_jan_cash
post_jan_cash
## [1] 210
## [1] 210
# Print post_jan_cash_10
post_jan_cash_10
## [1] 220
## [1] 220
Financial Returns 2
# Starting cash and returns
starting_cash <- 200
jan_ret <- 4 # 4% interest rate
feb_ret <- 5
# Multipliers
jan_mult <- 1 + 4 / 100
feb_mult <- 1 + 5 / 100
# Total cash at the end of the two months
total_cash <- starting_cash * jan_mult * feb_mult
# Print total_cash
total_cash
## [1] 218.4
## [1] 218.4
# Print my_answer
my_answer
## [1] TRUE
## [1] TRUE
b <- 5.5
class(b)
## [1] "numeric"
## [1] "numeric"
c <- "Hello World"
class(c)
## [1] "character"
## [1] "character"