I have a huge data set with 500 000 entries like the one below.
Country Region Code Product name Year Value
Sweden Stockholm 123 Apple 1991 244
Sweden Kirruna 123 Apple 1987 100
Japan Kyoto 543 Pie 1987 544
Denmark Copenhagen 123 Apple 1998 787
Denmark Copenhagen 123 Apple 1987 100
Denmark Copenhagen 543 Pie 1991 320
Denmark Copenhagen 126 Candy 1999 200
Sweden Gothenburg 126 Candy 2013 300
Sweden Gothenburg 157 Tomato 1987 150
Sweden Stockholm 125 Juice 1987 250
Sweden Kirruna 187 Banana 1998 310
Japan Kyoto 198 Ham 1987 157
Japan Kyoto 125 Juice 1987 550
Japan Tokyo 125 Juice 1991 100
From that I want to conditionally all the rows that have a code
corresponding to the values in a vector with a bunch of code
. Like this one:
A <- c(123, 157, 543)
That is, the rows with Apple
, Tomato
, and Pie
should all be removed based on the code
in the vector.
I found this solution here to remove a row based on a specific column value: Conditionally Remove Dataframe Rows with R But what I want to do now is to remove rows based on not just one single value, but a vector with several values.