I have a data frame with 4 variables, month, year, code and rainfall. I need to get the data frame according to the code variable that are not equal to the following values.
vector = c(87553, 87568, 87569, 87570, 87571, 87572, 87573, 87574, 87576, 87582, 87593, 87596)
The data frame is
I tried to make
df.mensual <- df.mensual %>% filter(codigo != vector)
But I got the following error
In codigo != vector : longer object length is not a multiple of shorter object length
The == or != operator works only for unique values and in your case you are trying to filter a vector, the solution is to use the %in%
We add the ! (negation) to indicate that it filters the values that are not contained in the vector