I have a large base and I want to classify the different case we have in fonction of a defined decision tree. For example where resultatD1 = I and diffcd1<3 then data$classification <-"KI". I try to do it with a if :
if (data$final.resultatD1=="I" && diffcd1<3)data$class<-"KI"
and I also though to use a sql procedure but I don't know how to write in an sql procedure :
sqldf("SELECT idR, resultatD1, diffcd1
FROM data
WHERE resultatD1='I' and diffcd1<3")
So I don't know how to deal with this problem. Also, I have variable resultatD1 to resultatD7, do you know how can I do to repeat the code for this 7 variable?
I found something like this, i think it works, do you know how I can integrate an iteration of my variable from resultatD1 to resultatD7 and diff d1 to diffcd7?
also, you are mixing base syntax and tidyverse syntax, and while there is a time and place for the careful doing of that, your example is not one of those.
Note that you are mutating data so mutate knows the variables in data, and does not require data$ to pick them, therefore, eliminate data$ from your mutate code.