quanteda / readtext

an R package for reading text files
https://readtext.quanteda.io
120 stars 28 forks source link

change if condition to length of one #114

Open kbenoit opened 6 years ago

kbenoit commented 6 years ago

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_1CONDITION=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)