Qu'est-ce qu'un facteur ?

Introduction à R pour la finance

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

Actions ou obligations ?

Placement
action
obligation
obligation
action
Introduction à R pour la finance

Actions ou obligations ?

Placement
action = 2
obligation = 1
obligation = 1
action = 2
Introduction à R pour la finance

Actions ou obligations ?

Placement
action
obligation
obligation
action
Introduction à R pour la finance

Création d'un facteur

answers <- c("stock", "bond", "bond", "stock")
investment <- factor(answers)
investment
stock bond  bond  stock
Levels: bond stock
class(investment)
"factor"
Introduction à R pour la finance

Création d'un facteur

as.integer(investment)
2 1 1 2
levels(investment)
"bond"  "stock"
Introduction à R pour la finance

Découper avec cut()

  • Classement : 1-50
  • 1 est le pire, 50 le meilleur
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]
Introduction à R pour la finance

Passons à la pratique !

Introduction à R pour la finance

Preparing Video For Download...