I have data as below. I want a new column called accuracy_level. How can I get it done? I tried if but it didn't work well.
If the
accuracy_percentageis within +/-10% thenaccuracy_levelwill be "Good"accuracy_percentageis within +/-30% and outside +/- 10% thenaccuracy_levelwill be "Bad"accuracy_percentageis outside +/-30% thenaccuracy_levelwill be "Worst"
Here is my code:
actuals=seq(0,10,0.1)
forecast=seq(10,0,-0.1)
data1=data.frame(actuals,forecast)
data1$diff=data1$actuals-data1$forecast
data1$accuracy_percentage=(data1$diff/data1$actuals)*100
if((data1$accuracy_percentage < 10)&(data1$accuracy_percentage > -10),data1$accuracy_level="good",)
Aucun commentaire:
Enregistrer un commentaire