Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Filtering by row
4. Subset rows: logical operators
Extracting data by column
Practice using filter() and select()
The pipe operator
Sorting rows
Summary

Instruction

What if we want to use logical operators on filter()? We can do that. Just include logical operators in the filtering statements. If we wanted to see information about Canada and Italy, we'd write:

filter(countries, country_name == "Canada" | country_name == "Italy")

Note: We're using the | operator here (remember, | is the or operator in R), which will return a result if either condition is true.

Exercise

Find information about the United States and Finland from countries.

Stuck? Here's a hint!

Type:

filter(countries, country_name == "United States" | country_name == "Finland")