Levels को मैन्युअली collapse करना
सर्वे में लोग 16 job titles ("Other" सहित) चुन सकते थे. आइए इन्हें कुछ बड़ी categories में मिलाएँ: "Computer Scientist", "Data analyst/scientist/engineer", "Researcher," और "Other." आपके लिए multiple_choice_responses डेटासेट लोड कर दिया गया है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Tidyverse में Categorical डेटा
अभ्यास निर्देश
CurrentJobTitleSelectके levels को मिलाकर एक नया वैरिएबलgrouped_titlesबनाएँ.- फिर
grouped_titlesमें जो भी इन तीन grouped titles में नहीं आता, उसे "Other Title" में डालें. - अंत में, सभी grouped titles की गिनती निकालें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
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
___(___)