In R I have the following dataset and I would want remove rows if Per<98, unless no rows with the same value in A meet this condition (then add 0):
df <- cbind(c("D1", "D1", "D1", "D1", "D2", "D2", "D2", "D2", "D3", "D3", "D3", "D3"), c(99.8, 99.5, 98.7, 98, 97.8, 97.3, 96, 95.9, 95, 94.9, 94.5, 94), c("sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp")) colnames(df) <- cbind("A", "Per", "B")
The expected result would be
df <- cbind(c("D1", "D1", "D1", "D1", "D2", "D3"), c(99.8, 99.5, 98.7, 98, 0, 0), c("sp", "sp", "sp", "sp", "sp", "sp")) colnames(df) <- cbind("A", "Per", "B")