As an image that I attached, I want to delete rows (ID) that only contains number 9, but not rows that contain other numbers.
Does anyone know how to write r codes to do this?
We can use
rowSums on the logical matrix (
df1[-1]==9 - subset of dataset as the first column in 'ID') and check whether it is 0, then keep that row
If the condition is to keep rows that have numbers other than 9, then as @Rui Barradas, mentioned
df1[rowSums(df1[-1] != 9) > 0,]