Session Ready
Exercise

mutate, filter and select

Now we will reset murders to the original table by using data(murders).

Instructions
100 XP

Use one line of code to create a new data frame, called my_states, that has murder rate and rank columns (with the rank ordered from highest to lowest), considers only states in the Northeast or West which have a murder rate lower than 1, and contain only the state, rate, and rank columns. The line should have four components separated by three %>% operators:

  • The original dataset murders
  • A call to mutate to add the murder rate and the rank.
  • A call to filter to keep only the states from the Northeast or West and that have a murder rate below 1.
  • A call to select that keeps only the columns with the state name, the murder rate, and the rank.

The line should look something like this my_states <- murders %>% mutate something %>% filter something %>% select something. Columns in the final data frame MUST be in the order: state, rate, rank.