And the patch itself:
--- a/src/library/base/R/ifelse.R
+++ b/src/library/base/R/ifelse.R
@@ -18,12 +18,14 @@
ifelse <- function (test, yes, no)
{
+ attributes_of_test <- attributes(test)
+
if(is.atomic(test)) { # do not lose attributes
if (typeof(test) != "logical")
storage.mo
I propose a patch to ifelse that leverages anyNA(test) to achieve an
improvement in performance. For a test vector of length 10, the change
nearly halves the time taken and for a test of length 1 million, there
is a tenfold increase in speed. Even for small vectors, the
distributions of timings bet