I am trying to do some calcs using if else, but I can get it :
I have data obtained from a model, but this model tend to overestimate or underestimate the results depending of the total result. I am presenting a simple example:
d <- c(2,2,12,10, 24,30,50,55,60)
e <- c("red", "white", "red")
car <- data.frame(d,e)
names(car) <- c("carro","Color") # variable names
if(car$carro < 10){
car$carro <- car$carro * 0.5 ##50%
} else {
if((car$carro> 10) && (car$carro < 30)){
car$carro <- car$carro * 0.9 #90%
} else {
if(car$carro >30) {
car$carro <- car$carro * 1.50 #150%
}
}
}
However, when I run the script it just assume the first condition (50%) for all the data.
Aucun commentaire:
Enregistrer un commentaire