R inferno (rant) [Software]

posted by ElMaestro  – Denmark, 2015-10-28 09:44 (3096 d 00:04 ago) – Posting: # 15585
Views: 6,514

Haha Hötzi,

ifelse (x1 < x2,

❝   cat(x1, "less than", x2, "\n"),
❝   cat(x1, "at least", x2, "\n"))


12 less than 13

Error in ifelse(x1 < x2, cat(x1, "less than", x2, "\n"), cat(x1, "at least",  :

❝   replacement has length zero

❝ In addition: Warning message:

❝ In rep(yes, length.out = length(ans)) :

❝   'x' is NULL so the result will be NULL

❝    What the f…k?


I agree ifelse(a,b,c) is a borderline silly function. It is in no way clear from the error message but b and c should be lean and mean variables rather than expressions. Therefore ifelse (a, do.this(blah), do.that(blah)) will only cause headache, at least as long as do.this/that(blah) doesn't return a value.
Like you I'd much prefer the classical if else construct.

I think this also goes to show that error messages should be user-friendly. If I am not mistaking only the guy who wrote the function understands that mumbo-jumbo. Preventive keelhauling would indeed seem to be a proper action to take.

Pass or fail!
ElMaestro

Complete thread:

UA Flag
Activity
 Admin contact
22,987 posts in 4,824 threads, 1,663 registered users;
92 visitors (0 registered, 92 guests [including 3 identified bots]).
Forum time: 10:48 CEST (Europe/Vienna)

The only way to comprehend what mathematicians mean by Infinity
is to contemplate the extent of human stupidity.    Voltaire

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