I want to delete some rows based on two conditions. Here is my code
test <-datasetjoin[!(datasetjoin$Occupation == "Clerical" & datasetjoin$AvgMonthSpend > 58.515 ),]
test <- test[!(test$Occupation == "Management" & test$AvgMonthSpend > 59.24 ),]
test <- test[!(test$Occupation == "Manual" & test$AvgMonthSpend > 54.28 ),]
test <- test[!(test$Occupation == "Professional" & test$AvgMonthSpend > 60.08 ),]
test <- test[!(test$Occupation == "Skilled Manual" & test$AvgMonthSpend > 57.06 ),]
test <- test[!(test$NumberCarsOwned == "1" & test$YearlyIncome > (81300-51140) * 1.5 + 81300),]
Is it possible to get the same result in a more elegant way?
Thanks in advance
Occupation MonthlySpend
Clerical 60
Management 59
Clerical 62
Clerical 58
Clerical 63
Management 56
Management 58
If Occupation = clerical and MonthlySpend > 60 then drop these rows If Occupation = management and MonthlySpend > 57 then drop these rows. At the end I should get this:
Occupation MonthlySpend
Clerical 58
Management 56