dimanche 8 avril 2018

Is there anything wrong with using the if{} else{} syntax in R?

For years I have been using this syntax in R:

if {}else{}

But it isn't one of the uses shown in the Full Reference Manual, and neither is the simple if() function that I also use. Is there anything wrong with them?

It seems not to be the same as

ifelse(test, yes, no)

which seems to expect the "yes" and "no" arguments to be objects rather than functions like cat().

If it's not okay to use if(), what should I be using instead?

(I see that there is an example in the fullrefman.pdf of the if{}else{} syntax under the bindev() function.)

Aucun commentaire:

Enregistrer un commentaire