-
Notifications
You must be signed in to change notification settings - Fork 985
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
Allow coercion for NA input to fifelse #4277
Comments
I'm happy to file a PR if you haven't started yet... |
I haven't! please do |
Just my view, but I don't think it is a good idea to i/obscure things like this to users ii/break consistency however small it is iii/introduce exception. User must be fully aware of what is going on when they use a function. |
The thing is, in my opinion, we need to provide an interface that's easy for ordinary R users. Unfortunately, many R users just don't know much about programming, don't use GitHub, don't know there's a difference between NA and NA_real_/integer_. Yes, they should be aware of this differences. However, the base R does this coercion everywhere, if 'data.table' do not, they may just think it's a bug of data.table and stop using it - and this is the least I want. In conclusion, I think we'd better support it as well, especially considering there's no penalty for having this (the performance impact I believe is minimal and the maintenance should be fine). |
So you would rather let them be ignorant instead of educating them via useful, clear and helpful error messages? |
NA is quite different thing, I would rather prefer to warn on using |
I agree on the |
Yes, I agree that base R is lack of consistency so I have to admit my argument doesn't stand. 😢 However, despite the documentation that |
In data.table logical NA is coerced to required type in majority of our features/functions. So having a policy about educating users on NA type sensitive usage would not be consistent. If there is no performance cost of it, then for me it is clearly better to make it easier for users. The way it could be, as for example in julia. |
My 2 cents... We're package devs for a high-level language. The point of a high-level language is for end users to be able to write simpler code & not need to know every last detail of the programs they're writing (if they do, more power to them, of course!). The burden of keeping track of these finer points is firmly in the hands of the package devs who can do a bunch of stuff "under the rug" to keep the user-facing house in order. Not really a scientific poll but a point of reference nevertheless: https://twitter.com/michael_chirico/status/1235175842034020352 Less than half of users following #rstats who responded knew off the bat that The code we could write to say "hey, don't you meal Somewhat oblique case in point: Instagram auto-lints PRs for many common syntax inconsistencies: https://instagram-engineering.com/static-analysis-at-scale-an-instagram-story-8f498ab71a0c They've decided that rather than blocking new code because of style inconsistencies or other such minor things, they'd rather automatically fix them with a bot and allow engineers to focus their head space on less tedious things. |
Looks like tidyverse/dplyr#5106 (comment) TBH, when I was a R newbie I was always surprised by this type of error. SQL just has NULL - why wouldn't |
I think including some tips on the error would be nice for end-users like me. This would be enough to prevent confusion at the least. For example,
|
that
typeof(NA)
islogical
I think is an implementaton detail we can obscure from users. we should coerceNA
toNA_integer_
in this case.The text was updated successfully, but these errors were encountered: