ฝึกใช้งาน grouped summaries
เราสามารถใช้ pivot_wider() ร่วมกับผลลัพธ์จาก grouped summaries ได้เช่นกัน
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การวิเคราะห์ข้อความเบื้องต้นใน R
คำแนะนำการฝึกหัด
- เชื่อม
tidy_twitterเข้ากับพจนานุกรม sentiment แบบ afinn - จัดกลุ่มตาม complaint label และสถานะการยืนยันตัวตนของผู้ใช้
- สรุปข้อมูลโดยสร้างคอลัมน์ใหม่ชื่อ
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`)