This exercise is another extension of the previous exercises so you dont
have to import any libraries or datasets. We have made an object murders_expanded
which contains the murders dataset with the extra rate- and rank-columns
from previous exercise.
7. Suppose you want to live in the Northeast or West and want the
murder rate to be less than 1. We want to see the data for the states
satisfying these options. Note that you can use logical operators with
filter
. Here is an example in which we filter to keep only small
states in the Northeast region.
filter(murders_expanded, population < 5000000 & region == "Northeast")
Create a table called that contains rows for
states satisfying both the conditions: it is in the Northeast or West
and the murder rate is less than 1. Use select
to show only the state
name, the rate, and the rank. Store the result in my_states
.