When I was re-reading Hadley's Advanced R recently, I noticed that he said in Chapter 6 that `if`
can be used as a function like `if`(i == 1, print("yes"), print("no"))
(If you have the physical book in hand, it's on Page 80)
We know that ifelse
is slow (Does ifelse really calculate both of its vectors every time? Is it slow?) as it evaluates all arguments. Will `if`
be a good alternative to that as if
seems to only evaluate TRUE
arguments (this is just my assumption)?
I'm sorry if there was a duplicated question on SO. I did a quick search but I didn't see any.
Aucun commentaire:
Enregistrer un commentaire