-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]
1
  • Please also show the input and output, and explain how the output differs from the expected output. Commented Apr 13, 2018 at 19:14

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

You're awesome!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.