1. Learn
  2. /
  3. Courses
  4. /
  5. Data Science R Basics

Exercise

filtering by two conditions

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:

filter(murders, population < 5000000 & region == "Northeast")

Instructions

100 XP
  • Add a murder rate column and a rank column as done before
  • Create a table, call it my_states, that satisfies 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