From suharto_anggono at yahoo.com  Sun Nov 27 03:27:14 2016
From: suharto_anggono at yahoo.com (Suharto Anggono Suharto Anggono)
Date: Sun, 27 Nov 2016 02:27:14 +0000 (UTC)
Subject: [Rd] ifelse() woes ... can we agree on a ifelse2() ?
References: <879999629.947686.1480213634160.ref@mail.yahoo.com>
Message-ID: <879999629.947686.1480213634160@mail.yahoo.com>

Related to the length of 'ifelse' result, I want to say that "example of different return modes" in ?ifelse led me to perceive a wrong thing in the past.

     ## example of different return modes:
     yes <- 1:3
     no <- pi^(0:3)
     typeof(ifelse(NA,    yes, no)) # logical
     typeof(ifelse(TRUE,  yes, no)) # integer
     typeof(ifelse(FALSE, yes, no)) # double

As the result of each 'ifelse' call is not printed, I thought that the length of the result is 3. In fact, the length of the result is 1.
I realize just now that the length of 'no' is different from 'yes'. The length of 'yes' is 3, the length of 'no' is 4.



--------------------------------------------


 Subject: Re: ifelse() woes ... can we agree on a ifelse2() ?
 To: R-devel at lists.R-project.org
 Date: Sunday, 27 November, 2016, 8:50 AM
 
In all of the proposed 'ifelse'-like functions so far, including from me (that I labeled as 'ifelse2', following Martin Maechler) and from Martin Maechler, the length of the result equals the length of 'test', like in 'ifelse'. There is no recycling of 'test'.



[Rd] ifelse() woes ... can we agree on a ifelse2() ?
Suharto Anggono Suharto Anggono