Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Exploratory: 順序付きカテゴリーを扱うための「ファクター」データタイプの紹介

Kan Nishida
August 30, 2019

Exploratory: 順序付きカテゴリーを扱うための「ファクター」データタイプの紹介

Rには「ファクター」という順序付きカテゴリーのためのデータタイプがあります。この順序付きのカテゴリーというのはデータ分析を行ったり、データを可視化したりする時に重要なコンセプトなのですが、それを可能にしてくれるのがこの「ファクター」というデータタイプです。

このセミナーでは、「ファクター」型の紹介と使い方、さらに様々な順序の設定の仕方の紹介をデモを交えて行います。

Kan Nishida

August 30, 2019
Tweet

More Decks by Kan Nishida

Other Decks in Science

Transcript

  1. 3 εϐʔΧʔ ੢ా צҰ࿠ CEO EXPLORATORY ུྺ 2016೥ɺσʔλαΠΤϯεͷຽओԽͷͨΊɺExploratory, Inc Λ

    ্ཱͪ͛Δɻ Exploratory, Inc.ͰCEOΛ຿ΊΔ͔ͨΘΒɺσʔλαΠΤϯεɾ ϒʔτΩϟϯϓɾτϨʔχϯάͳͲΛ௨ͯ͠γϦίϯόϨʔͰ ߦΘΕ͍ͯΔ࠷ઌ୺ͷσʔλαΠΤϯεͷීٴͱڭҭʹऔΓ૊ Ήɻ ถΦϥΫϧຊࣾͰɺ16೥ʹΘͨΓσʔλαΠΤϯεͷ։ൃνʔ ϜΛ཰͍ɺػցֶशɺϏοάɾσʔλɺϏδωεɾΠϯςϦδΣ ϯεɺσʔλϕʔεʹؔ͢Δ਺ଟ͘ͷ੡඼ΛੈʹૹΓग़ͨ͠ɻ @KanAugust
  2. ୈ1ͷ೾ ୈ̎ͷ೾ ୈ̏ͷ೾ ϓϥΠϕʔτ(ߴ͍/ݹ͍) Φʔϓϯɾιʔε(ແྉ/࠷ઌ୺) UI & ϓϩάϥϛϯά ϓϩάϥϛϯά 2016

    2000 1976 ϚωλΠθʔγϣϯ ίϞσΟςΟԽ ຽओԽ ౷ܭֶऀ σʔλαΠΤϯςΟετ Exploratory ΞϧΰϦζϜ Ϣʔβʔɾ ମݧ πʔϧ Φʔϓϯɾιʔε(ແྉ/࠷ઌ୺) UI & ࣗಈԽ ϏδωεɾϢʔβʔ ςʔϚ σʔλαΠΤϯεͷຽओԽ
  3. 13 ෼ੳʹ͓͚ΔσʔλͷλΠϓ σʔλλΠϓ in R / Exploratory ਺஋ numeric ΧςΰϦʔ

    character ॱং෇͖ͷΧςΰϦʔ factor ࿦ཧ஋ logical ೔෇ɺ࣌ؒ Date, POSIXct
  4. ਺஋ 0 10 20 30 40 50 11 22 45

    14 ࿈ଓੑ͕͋Δ ॱংؔ܎͕͋Δ
  5. ΧςΰϦʔ ͘͢͝ѱ͍ ѱ͍ ͲͪΒͱ΋͍͑ͳ͍ ྑ͍ ͘͢͝ྑ͍ ΧςΰϦʔ (character) ΧςΰϦʔ Ϩϕϧ

    ͘͢͝ѱ͍ 1 ѱ͍ 2 ͲͪΒͱ΋͍͑ͳ͍ 3 ྑ͍ 4 ͘͢͝ྑ͍ 5 vs. ॱং෇͖ΧςΰϦʔ (factor)
  6. forcats ؔ਺ • fct_relevel • fct_inorder • fct_infreq • fct_reorder

    • fct_rev (reverse) • fct_lump • and more…
  7. fct_relevel(`Online learning platforms and MOOCs`, "Much worse", "Slightly worse", "Neither

    better nor worse", "Slightly better", "Much better") ϨϕϧΛઃఆ͍ͨ͠஋ΛϦετ͍ͯ͘͠ɻ
  8. ΧςΰϦʔ Much Worse Slightly Worse Neither better or worse Slightly

    Better Much Better No Opinions ΧςΰϦʔ Ϩϕϧ Much Worse 1 Slightly Worse 2 Neither better or worse 3 Slightly Better 4 Much Better 5 No Opinions
  9. Category Much Worse Slightly Worse Neither better or worse Slightly

    Better Much Better No Opinions Category Level Much Worse 1 Slightly Worse 2 Neither better or worse 3 Slightly Better 4 Much Better 5 No Opinions 6 ϨϕϧΛઃఆ͠ͳ͔ͬͨ΋ͷ͸ΞϧϑΝϕοτॱͰࣗಈͰઃఆ͞ΕΔɻ
  10. Category Research Director Healthcare Rep Human Resources Laboratory Technician Manager

    Manufacturing Director Category Healthcare Rep Human Resources Laboratory Technician Manager Manufacturing Director Research Director Research DirectorΛ࠷ॳͷϨϕϧʹ࣋ͬͯ͘Ε͹Α͍ɻ
  11. Category Healthcare Rep Human Resources Laboratory Technician Manager Manufacturing Director

    Research Director Category Level Healthcare Rep Human Resources Laboratory Technician Manager Manufacturing Director Research Director 1 Character ϑΝΫλʔ Research DirectorͷϨϕϧΛ̍ʹ͢Δɻ
  12. Category Level Research Director 1 Healthcare Rep 2 Human Resources

    3 Laboratory Technician 4 Manager 5 Manufacturing Director 6 Category Level Healthcare Rep Human Resources Laboratory Technician Manager Manufacturing Director Research Director 1 ଞͷ৬छͷϨϕϧΛࢦఆ͠ͳ͍৔߹͸ɺ ΞϧϑΝϕοτॱʹϨϕϧ͕ࣗಈͰܾ·Δɻ
  13. Category Level Research Director 1 Healthcare Rep 2 Human Resources

    3 Laboratory Technician 4 Manager 5 Manufacturing Director 6 ϕʔεϨϕϧ