Data frame manipulation

Introduction to R for Finance

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

Data frame subsets

debt[3:6,]
  name payment
3  Dan     150
4  Rob      50
5  Rob      75
6  Rob     100
debt[1:3, 2]
100 200 150
debt[1:3, 2, drop = FALSE]
  payment
1     100
2     200
3     150
debt$payment
100 200 150  50  75 100
Introduction to R for Finance

Subset() for more power

# This works, but is not informative nor robust
debt[1:3,]

# Much more informative! subset(debt, name == "Dan")
  name payment
1  Dan     100
2  Dan     200
3  Dan     150
subset(debt, payment == 100)
  name payment
1  Dan     100
6  Rob     100
Introduction to R for Finance

Let's practice!

Introduction to R for Finance

Preparing Video For Download...