Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
Introduction to data frames
Data frame structure
Accessing columns in a data frame
Accessing rows of a data frame
Accessing rows and columns combined in a data frame
Data frame analysis


Nicely done! Let's see how we can perform row filtering by specifying certain conditions. If you would like to analyze only those cities that are in Germany, you could write the following line of code:

cities[cities$country == "Germany", ]

Inside the brackets, [...], before the comma, we defined a condition using a conditional operator (in this case, the equality operator): cities$country == "Germany". This condition will evaluate to TRUE for rows where the country is Germany and FALSE otherwise. R will retrieve only those rows for which this condition is TRUE.


From the countries data frame, extract only those countries (rows) whose region is WESTERN EUROPE. Remember to use only uppercase letters when writing WESTERN EUROPE.

Stuck? Here's a hint!

Use countries$region == "WESTERN EUROPE" inside [...] brackets. Remember about the comma after the condition!