1. 学ぶ
  2. /
  3. コース
  4. /
  5. tidyverse で学ぶカテゴリ型データ

Connected

演習

fct_relevel() の小ワザ

前の演習では、因子の並び替えを明示するために各レベル名をすべて書き出しました。しかし、レベルが多くて一部だけを動かしたいこともあります。そんなときは、fct_relevel() の補助的な引数を使うと入力を減らせます。multiple_choice_responses の変数 FormalEducation で試してみましょう。まずはコンソールで multiple_choice_responses$FormalEducation のレベルを確認してください。

指示

100 XP
  • 3 回の mutate 呼び出しで、FormalEducation を次のように変更してください。
    • "I did not complete any formal education past high school" と "Some college/university study without earning a bachelor's degree" を先頭に移動する。
    • "I prefer not to answer" を最後のレベルに移動する。
    • "Doctoral degree" を6番目のレベル(5番目の後)に移動する。