A small logical change with big impact
This article is originally published at https://blog.revolutionanalytics.com/In R, the logical || (OR) and && (AND) operators are unique in that they are designed only to work with scalar arguments. Typically used in statements like while(iter < 1000 && eps < 0.0001) continue_optimization() the assumption is that the objects on either side (in the example above, iter and eps) are single values (that is, vectors of length 1) — nothing else makes sense for control flow branching like this. If either iter or eps above happened to be vectors with more than one value, R would silently consider only the first elements when making the AND comparison....
Thanks for visiting r-craft.org
This article is originally published at https://blog.revolutionanalytics.com/
Please visit source website for post related comments.