Lasitha Yapa Lasitha Yapa - 5 months ago 17
SQL Question

Similar function to SQL where clause in R

I have a data set assigned to a variable named 'temps', which have columns 'date', 'temperature', 'country'.

I want to do something like this, which I can do in SQL

SELECT * FROM temps WHERE country != 'mycountry'


How can I do similar selection in R?

Answer

We can use similar syntax in base R

temps[temps$country != "mycountry",]