ComenzarEmpieza gratis

Changing the order of factor levels

In previous exercises, we've worked with the questions in the Kaggle dataset whose answers had no inherent order, like the question about current job title. But other questions do have answers that are ordered. This could be something like a person rating how much they agree with a statement on a 5-point scale from "strongly disagree" to "strongly agree." We'll look at one question in the survey about the tools people use at work and whether they're internal or external. multiple_choice_responses has been loaded for you.

Este ejercicio forma parte del curso

Categorical Data in the Tidyverse

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Get the levels of WorkInternalVsExternalTools
____(multiple_choice_responses$WorkInternalVsExternalTools)

# Reorder the levels from internal to external 
mc_responses_reordered <- multiple_choice_responses %>%
    mutate(WorkInternalVsExternalTools = ___(WorkInternalVsExternalTools,
                                            "Entirely internal", 
                                             "More internal than external",
                                             "Approximately half internal and half external",
                                             "More external than internal", 
                                             "Entirely external",
                                             ___))
Editar y ejecutar código