เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การยุบ level ด้วยตนเอง

ในแบบสำรวจนี้มีตำแหน่งงาน 16 ตำแหน่ง (รวม "Other") ให้ผู้ตอบเลือก มาลองยุบตำแหน่งเหล่านี้ให้เหลือเพียงไม่กี่หมวดหลัก ได้แก่ "Computer Scientist", "Data analyst/scientist/engineer", "Researcher" และ "Other" โดยมีการโหลดชุดข้อมูล multiple_choice_responses ไว้ให้แล้ว

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

ข้อมูลเชิงหมวดหมู่ใน Tidyverse

ดูคอร์ส

คำแนะนำการฝึกหัด

  • ยุบ level ของ CurrentJobTitleSelect ให้เป็นตัวแปรใหม่ชื่อ grouped_titles
  • จากนั้นนำ grouped_titles มาจัดกลุ่ม โดยให้ทุก level ที่ไม่ใช่สามหมวดที่กำหนดรวมอยู่ใน "Other Title"
  • สุดท้าย นับจำนวนของแต่ละ grouped title

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

multiple_choice_responses %>%
    # Create new variable, grouped_titles, by collapsing levels in CurrentJobTitleSelect
    ___(grouped_titles = ___(CurrentJobTitleSelect, 
        "Computer Scientist" = c("Programmer", "Software Developer/Software Engineer"), 
        "Researcher" = "Scientist/Researcher", 
        "Data Analyst/Scientist/Engineer" = c("DBA/Database Engineer", "Data Scientist", 
                                              "Business Analyst", "Data Analyst", 
                                              "Data Miner", "Predictive Modeler"))) %>%
    # Keep all the new titles and turn every other title into "Other"
    ___(grouped_titles = ___(grouped_titles, 
                             ___ = c("Computer Scientist", 
                                     "Researcher", 
                                     "Data Analyst/Scientist/Engineer"))) %>% 
    # Get a count of the grouped titles
    ___(___)
แก้ไขและรันโค้ด