implicit return? [R for BE/BA]

posted by ElMaestro  – Belgium?, 2019-04-29 09:40 (465 d 11:07 ago) – Posting: # 20260
Views: 3,880

Hi Hötzi,

Interestingly (at least to moi!), I tried out of curiosity to do this:

 ifelse ((x==0), "foo", "bar")

The benchmark for this version is much, much slower than any of the other proposals (at least on my system). Another example that shows that condensing code towards fewer keystrokes is not always fastest. I wonder what goes on internally since this is much slower? Perhaps space is allocated for both "foo" and "bar" in memory and then there is a decision as to which one to throw away and which one to keep on the CPU stack? I don't have a very good at understanding of these things.

This one is appearing even worse:
 ifelse (x, "bar", "foo")

I have no idea why QWERTY2 would not outperform QWERTY or at least be the same if R has a kind of optimiser in the interpreter. Would you happen know????

I could be wrong, but...

Best regards,

"Pass or fail" (D. Potvin et al., 2008)

Complete thread:

 Admin contact
20,969 posts in 4,374 threads, 1,460 registered users;
online 10 (0 registered, 10 guests [including 8 identified bots]).
Forum time: Thursday 20:47 CEST (Europe/Vienna)

It is a good morning exercise for a research scientist
to discard a pet hypothesis every day before breakfast.
It keeps him young.    Konrad Lorenz

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz