グループ化集計の練習
pivot_wider() は、グループ化集計の結果に対しても組み合わせて使うことができます。
この演習はコースの一部です
Rで始めるテキスト分析
演習の手順
tidy_twitterを afinn 感情辞書に結合します。- クレームの有無を示すラベルと、ユーザーが認証済みかどうかの両方でグループ化します。
- データを要約して、新しい列
aggregate_valueを作成し、valueの合計を入れます。 complaint_label列とaggregate_value列をワイドに展開します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
tidy_twitter %>%
# Append the afinn sentiment dictionary
___(___) %>%
# Group by both complaint label and whether or not the user is verified
___(___) %>%
# Summarize the data with an aggregate_value = sum(value)
___(___) %>%
# Spread the complaint_label and aggregate_value columns
___(___) %>%
mutate(overall_sentiment = Complaint + `Non-Complaint`)