I have to create a new column called SalaryX
, and the values for the column is calculated as follows:
If the original salary is between 20,000 and 30,000, its SalaryX
should be 20,000; If the original salary is between 30,000 and 40,000, its SalaryX
should be 30,000 and so on.
I tried using the cut
function as follows:
cut(employee$salary, 5, include.lowest = T, labels = c("20000", "30000", "40000", "50000", "60000"))
But what that does is if the salary value is 25600
, the SalaryX will be calculated as 30000.
Is there another way to do this?