neozback
neozback

Reputation: 1

Filtering rows in dataframe with dplyr

I have a harmonized dataset about surveys conducted in different countries from 1960 to 2014. I want to drop the rows where two different surveys have been conducted in the same country in the same year. I am not sure how to use the filter verb in dplyr to drop the rows from the harmonized dataset.

Harm_data1 %>% 
group_by(country, survey, year, protest demo , protest fact) %>% 
filter(country >= 2 | year >=2) 

Upvotes: 0

Views: 561

Answers (1)

ike
ike

Reputation: 312

Are you saying you'd like that output to be piped into a new table? I believe what you have above would give the exact opposite of what you're requesting with is to say, it's only going to return those that are greater. I'd do:

Harm_data1 %>% 
group_by(country, survey, year, protest demo , protest fact) %>% 
filter(country < 2 | year < 2) 

Upvotes: 1

Related Questions