Hello, I'm stuck with this code.
I want that if My_Data $ Tax> 10 million a new variable is created that multiplies My_Data$Tax by 7%.
If My_Data $ Tax is between 9.9M and 4M, the variable that is created is the value of My_Data$Tax multiplied by 4.5%.
If My_Data$Tax is between 3.9M and 2M, the variable that is created is the value of My_Data$Tax multiplied by 2.5%
Thus until reaching the case in which My_Data$Tax is less than 0.5M when the new variable would register the value of My_Data$Tax multiplied by 0.5%
The message I get says: the condition has length> 1 and only the first element will be used
This is my code
if(My_Data$Tax >= 10000000){
My_Data$New_VAR<- My_Data$VAR1 * 0.07
}else if(My_Data$Tax <= 9999999 & My_Data$Tax >= 4000000){
My_Data$New_VAR <- My_Data$Tax * 0.45
}else if(My_Data$Tax <= 3999999 & My_Data$Tax >= 2000000){
My_Data$New_VAR <- My_Data$Tax * 0.25
}else if(My_Data$Tax <=1999999 & My_Data$Tax >=1000000){
My_Data$New_VAR <- My_Data$Tax * 0.15
}else if(My_Data$Tax <=999999 & My_Data$Tax >=500000){
My_Data$New_VAR <- My_Data$Tax * 0.1
}else{
My_Data$New_VAR <- My_Data$Tax * 0.05
}