I have a very long dataset and a relatively short list of ID values for which my data is wrong. The following works, but my wrong_IDs vector is actually much larger:
wrong_IDs <- c('A1', 'B3', 'B7', 'Z31')
df$var1[df$var2 == 'A1' | df$var2 == 'B3' | df$var2 == 'B7' | df$var2 == 'Z31'] <- 0L
This looks very basic but I haven't found a compact way of writing this. Thanks for any help