I have tried to look through these examples https://www.datasciencemadesimple.com/delete-or-drop-rows-in-r-with-conditions-2/ Delete rows based on multiple conditions in r but its now working on my code
I seem to be able to delete all of station 7, or not delete any, but I only want to delete depth 1 and depth 2 of station 7 but keep depth 3. Is this possible?
Station <- c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7,7,8, 8, 8, 9, 9,9)
Depth <- c(1, 2, 3, 1, 2, 3,1, 2, 3,1, 2, 3,1, 2, 3,1, 2, 3,1, 2, 3,1, 2, 3,1, 2, 3)
Value <- c(5, 8, 3, 2, 6, 8, 3, 6, 3, 8, 3, 5, 7, 2, 6, 9, 1, 3, 456, 321, 2, 5, 7, 4, 2, 6, 8)
df <- data.frame(Station, Depth, Value)
df
a <- df[!(df$Station == 7 & df$Depth == 1 ) | !(df$Station == 7 & df$Depth == 2 ),]
a