Vector manipulation

Introduction to R for Finance

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

Vectors and friends

dan <- 100
rob <- 50
total <- dan + rob
dan <- c(100, 200, 150)
rob <- c(50, 75, 100)

monthly_total <- dan + rob
monthly_total
150 275 250
sum(monthly_total)
675
Introduction to R for Finance

More examples

a <- c(2.2, 12, 7)
b <- c(11.5, 8, 3.4)

# Subtraction!
c <- a - b
c
-9.3 4.0  3.6
# Multiplication!
d <- a * b
d
25.3 96.0 23.8
# Recycling!
e <- 2
f <- a * e
f
4.4 24.0 14.0
Introduction to R for Finance

Let's practice!

Introduction to R for Finance

Preparing Video For Download...