If values in a range of columns aren't present in another column, replace with NA
问题 I have a dataset that includes some non-referenced data that I would like to replace with NA. In the following example, if the data in columns rep1 to rep4 does not match one of the values in the ID column, I would like to replace the value with NA. In this case, the values of x, y, and z aren't listed in the ID column, so they should be replaced. This is a somewhat similar question that I asked earlier here : If data present, replace with data from another column based on row ID I think the