R inferno (rant) [Software]

posted by ElMaestro  – Denmark, 2015-10-28 09:44 (3074 d 02:22 ago) – Posting: # 15585
Views: 6,483

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,957 posts in 4,819 threads, 1,639 registered users;
89 visitors (1 registered, 88 guests [including 3 identified bots]).
Forum time: 12:06 CET (Europe/Vienna)

Nothing shows a lack of mathematical education more
than an overly precise calculation.    Carl Friedrich Gauß

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