i am trying to iterate over all the data, depending on the IF statements a new column is created. I do not get an error but the results are completely off. so it is hard for me to find the error. Any tip or suggestion is appreciated
```{r, echo=TRUE}
for (i in 1:length(Data)){
if (Data$P[i]=="A")
{
Data$NC[i]=Data$C[i]*5
}
else if (Data$P[i]=="B")
{
Data$NC[i]=Data$C[i]*10
}
else if (Data$P[i]=='C')
{
DataNC[i]=Data$C[i]*15
}
else if (Data$P[i]=="D")
{
Data$NC[i]=Data$C[i]*20
}
}
Aucun commentaire:
Enregistrer un commentaire