Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments on "Common errors in R" #19

Open
noamross opened this issue Mar 24, 2015 · 6 comments
Open

Comments on "Common errors in R" #19

noamross opened this issue Mar 24, 2015 · 6 comments

Comments

@noamross
Copy link
Owner

Comments on https://github.com/noamross/zero-dependency-problems/blob/master/misc/stack-overflow-common-r-errors.md

@dpastoor
Copy link

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.

@revodavid
Copy link

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.

@mxxdxxx
Copy link

mxxdxxx commented Mar 31, 2015

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.

@hdarabi
Copy link

hdarabi commented Aug 4, 2015

Great and funny analysis. Thanks!

@benmarwick
Copy link

What's your preference for citing this? Has it been published somewhere?

@noamross
Copy link
Owner Author

@benmarwick It hasn't been published elsewhere. I guess it makes sense to just cite it as one would a blog post somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants