Aan de slagGa gratis aan de slag

Summarizing data

Right now, our data is still in the format of one row per person per question. But for us to graph it, we'll want to change that so each row is a question with the summary information about the response to that question.

Deze oefening maakt deel uit van de cursus

Categorical Data in the Tidyverse

Cursus bekijken

Oefeninstructies

  • Summarize the data set into two columns, the question (i.e., response_var), and a new column, perc_rude, the mean of the rude column for each question.
  • Save it as rude_behaviors and then view your new dataset.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

rude_behaviors <- gathered_data %>%
    mutate(response_var = str_replace(response_var, '.*rude to ', '')) %>%
    mutate(response_var = str_replace(response_var, 'on a plane', '')) %>%
	# Remove rows that are NA in the value column
	filter(!is.na(value)) %>%
    mutate(rude = if_else(value %in% c("No, not rude at all", "No, not at all rude"), 0, 1)) %>%
    # Group by response_var
    ___ %>%
    # Create perc_rude, the percent considering each behavior rude
    ___

rude_behaviors
Code bewerken en uitvoeren