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

change if condition to length of one #114

Open
kbenoit opened this issue Jan 25, 2018 · 0 comments
Open

change if condition to length of one #114

kbenoit opened this issue Jan 25, 2018 · 0 comments
Assignees
Labels

Comments

@kbenoit
Copy link
Collaborator

kbenoit commented Jan 25, 2018

R currently only emits a warning when if/while statement is used with a condition of length greater than one, e.g.

 if (c(1,2)>0) TRUE
[1] TRUE
Warning message:
In if (c(1, 2) > 0) TRUE :
  the condition has length > 1 and only the first element will be used

However, such cases are almost always programming errors, and hence this warning will soon be turned into a runtime error. This can already be done in current R-devel by setting environment variable _R_CHECK_LENGTH_1_CONDITION_=true to make it easier to spot these cases. And this is already done in certain CRAN checks.

A condition of length greater than one has been detected while running tests of your package (and the if/while statement involved was in the code of your package, so it is unlikely that this would have been caused by a dependent package). Detailed reports can be found at

https://github.com/kalibera/rifcond

I've modified R slightly to give more detailed debugging information in case of this error, so hopefully the outputs will be useful in finding the cause of the problem. In either case, one can reproduce the problem in normal R-devel via R_CHECK_LENGTH_1_CONDITION=true or in a released version of R by looking at warnings.

Please check out the reports and fix this in your package(s) as soon as possible. In the unlikely case this is caused by a dependent package, please report to the maintainer of that package.

Thank you,
Tomas (Kalibera)

@kbenoit kbenoit self-assigned this Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant