Open noamross opened 9 years ago
nice analysis!
regarding
"Error in if" generally means the logical statement in "if (XXX) { ..." is not yielding a logical value. Most of these have missing value where TRUE/FALSE needed, meaning that the variable in the if statement can't be found.
There are some good 'lessons' to come out of digging into parameter 'truthiness'. The most common of which is to explain first why if(param ==TRUE) is unnecessary, and second once they understand inherently that if statements need boolean values, to introduce how to handle statments that only sometimes return booleans.
if(param) ...
vs
if(isTRUE(param)) {}
I find using all.equal as an example for when isTRUE is appropriate.
The all equal can also lead to a nice aside about floating point numbers!
0.3_3 == 0.9 [1] FALSE all.equal(0.3_3, 0.9) [1] TRUE
Though frankly I wouldn't consider these examples suitable for a beginners workshop (more important things to cover in limited time imo), but are good reference material that should be easily accessible when they are ready to keep exploring.
Very nice analysis! Thanks for the discussion about all the various types of errors, though you seem to have skipped #10, the "missing value where" error type, which I presume is mainly the result of missing values in data where it wasn't expected.
EDIT: On reading closer you did mention it -- those "missing value where" errors were actually bad calls to if
.
Haha nice and pretty useful, thanks! Personally I would have expected "more columns than column names" to be in the list. But maybe it's just a prominent error which is not asked that often.
Great and funny analysis. Thanks!
What's your preference for citing this? Has it been published somewhere?
@benmarwick It hasn't been published elsewhere. I guess it makes sense to just cite it as one would a blog post somewhere.
Comments on https://github.com/noamross/zero-dependency-problems/blob/master/misc/stack-overflow-common-r-errors.md