-1

I need to remove the rows of data in data frame that have been entered incorrectly for example I have a column of countries. I need to delete all the values that are not counties. I know the list of countries that should be there. For example I would want to delete the row containing a numeric value as a country. Here is my attempt:

currency_list <- c("GBP","HKD","AUD","NZD","USD")
KS_2016.update$currency[KS_2016.update$currency =currency_list]
MKR
  • 19,739
  • 4
  • 23
  • 33

1 Answers1

2

We can use subset it with %in% and !

subset(KS_2016.update, !currency %in% currency_list)

Or use filter from dplyr

library(dplyr)
KS_2016.update %>%
        filter(!currency %in% currency_list)
akrun
  • 874,273
  • 37
  • 540
  • 662