vendredi 30 avril 2021

How to make the if return the expected result (R)?

Any ideas on how to resolve this error?

Warning messages:
1: In if (A <0) {:
   the condition has length> 1 and only the first element will be used
2: In if (A> 0) {:
   the condition has length> 1 and only the first element will be used
A <- c (0, -2, -4,1,5)
B <- if (A <0) {A/-2} else if (A> 0) {A/2} else {A = 0}

Erro: The result of B must be (0,1,2,0,5,2.5).

Aucun commentaire:

Enregistrer un commentaire