EmpezarEmpieza gratis

Agrupar niveles manualmente

En la encuesta hay 16 puestos de trabajo (incluido "Other") entre los que la gente podía elegir. Vamos a agruparlos en unas pocas categorías amplias: "Computer Scientist", "Data analyst/scientist/engineer", "Researcher" y "Other". El conjunto de datos multiple_choice_responses ya está cargado para ti.

Este ejercicio forma parte del curso

Datos categóricos en el Tidyverse

Ver curso

Instrucciones del ejercicio

  • Agrupa los niveles de CurrentJobTitleSelect en una nueva variable, grouped_titles.
  • Luego, toma grouped_titles y convierte en "Other Title" todo lo que no sea uno de esos tres títulos agrupados.
  • Por último, obtén el recuento de todos los títulos agrupados.

ejercicio interactivo práctico

Prueba este ejercicio completando este código de ejemplo.

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
    ___(___)
Editar y ejecutar código