jeudi 2 avril 2020

I get this error message when trying to use a for loop with a if statement, missing value where TRUE/FALSE needed

This is a reproducible example:

I want to see if tac2 is less than 80% tac and if it is, then cap the decrease at 80% of tac.

tac = 1000 tac2= c(790,600,678,900,1200,300,800,9000)

 if ((tac2[i]-tac) < tac*.8) {
 tac2[i] <- tac - tac*.2 
} else {
 tac2[i] = tac2[i]
 print(tac2)
} } ```

Aucun commentaire:

Enregistrer un commentaire