I'm trying to delete all rows in a dataframe when the average of a vector > an individual number in the vector. For some reason it seems to pick and choose which ones it deletes. All help is appreciated thank you, here is my code.
k<-c(HW2$AGE)
j<-mean(k)
for (i in HW2$AGE)
if (j>i){
HW2 <- HW2[-i, ]
}