ファクターとは?

金融のためのR入門

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

株式か債券か?

投資
株式
債券
債券
株式
金融のためのR入門

株式か債券か?

投資
株式 = 2
債券 = 1
債券 = 1
株式 = 2
金融のためのR入門

株式か債券か?

投資
株式
債券
債券
株式
金融のためのR入門

ファクターの作成

answers <- c("stock", "bond", "bond", "stock")
investment <- factor(answers)
investment
stock bond  bond  stock
Levels: bond stock
class(investment)
"factor"
金融のためのR入門

ファクターの作成

as.integer(investment)
2 1 1 2
levels(investment)
"bond"  "stock"
金融のためのR入門

cut() で区分け

  • ランキング: 1〜50
  • 1が最悪、50が最良
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]
金融のためのR入門

Ayo berlatih!

金融のためのR入門

Preparing Video For Download...