Wat is een factor?

Introductie tot R voor Financiën

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

Aandelen of obligaties?

Belegging
aandeel
obligatie
obligatie
aandeel
Introductie tot R voor Financiën

Aandelen of obligaties?

Belegging
aandeel = 2
obligatie = 1
obligatie = 1
aandeel = 2
Introductie tot R voor Financiën

Aandelen of obligaties?

Belegging
aandeel
obligatie
obligatie
aandeel
Introductie tot R voor Financiën

Factor maken

answers <- c("stock", "bond", "bond", "stock")
investment <- factor(answers)
investment
stock bond  bond  stock
Levels: bond stock
class(investment)
"factor"
Introductie tot R voor Financiën

Factor maken

as.integer(investment)
2 1 1 2
levels(investment)
"bond"  "stock"
Introductie tot R voor Financiën

cut() toepassen

  • Ranking: 1-50
  • 1 is slechtst, 50 is best
head(ranking)
36 45 32 10 42  8
buckets <- c(0, 10, 20, 30, 40, 50)
ranking_grouped <- cut(ranking, breaks = buckets)
head(ranking_grouped)
(30,40] (40,50] (30,40] (0,10]  (40,50] (0,10] 
Levels: (0,10] (10,20] (20,30] (30,40] (40,50]
Introductie tot R voor Financiën

Laten we oefenen!

Introductie tot R voor Financiën

Preparing Video For Download...