Interspersed below.
Subject: Re: ifelse() woes ... can we agree on a ifelse2() ?
To: r-de...@lists.r-project.org
Date: Sunday, 27 November, 2016, 12:14 AM
On current 'ifelse' code in R:
...
* If 'test' is a factor, doing
storage.mode(test) <- "log
Well, that's embarrassing. Sorry for the noise on that front, everyone. I
misunderstood something from the aforementioned unrelated conversation I
was having, but not double checking is on me (I rarely use if else and when
I do I avoid that situation in my own code, which is why I didn't already
kn
> Suharto Anggono Suharto Anggono via R-devel
> on Sat, 26 Nov 2016 17:14:01 + writes:
> Just stating, in 'ifelse', 'test' is not recycled. As I said in "R-intro:
length of 'ifelse' result"
(https://stat.ethz.ch/pipermail/r-devel/2016-September/073136.html),
ifelse(conditio
> 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
>
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
For S Ellison, just clarifying, I am Suharto Anggono, not Martin Maechler.
"Martin et al.," from my previous E-mail was the beginning of message from
Gabriel Becker, that I quoted.
The quoted "still a bit disappointed that nobody has taken a look" is from
Martin Maechler.
In all of the proposed
> Just stating, in 'ifelse', 'test' is not recycled. As I said in "R-intro:
> length of 'ifelse' result"
> (https://stat.ethz.ch/pipermail/r-devel/2016-September/073136.html),
> ifelse(condition, a, b)
> returns a vector of the length of 'condition', even if 'a' or 'b' is longer.
That is indee
Just stating, in 'ifelse', 'test' is not recycled. As I said in "R-intro:
length of 'ifelse' result"
(https://stat.ethz.ch/pipermail/r-devel/2016-September/073136.html),
ifelse(condition, a, b) returns a vector of the length of 'condition', even if
'a' or 'b' is longer.
On current 'ifelse' cod
Martin et al.,
On Tue, Nov 22, 2016 at 2:12 AM, Martin Maechler wrote:
>
> Note that my premise was really to get *away* from inheriting
> too much from 'test'.
> Hence, I have *not* been talking about replacing ifelse() but
> rather of providing a new ifelse2()
>
>[ or if_else() if
> Gabriel Becker
> on Tue, 15 Nov 2016 11:56:04 -0800 writes:
> All,
> Martin: Thanks for this and all the other things you are doing to both
> drive R forward and engage more with the community about things like this.
> Apologies for missing this discussion the first
All,
Martin: Thanks for this and all the other things you are doing to both
drive R forward and engage more with the community about things like this.
Apologies for missing this discussion the first time it came around and if
anything here has already been brought up, but I wonder what exactly yo
Finally getting back to this :
> Hadley Wickham
> on Mon, 15 Aug 2016 07:51:35 -0500 writes:
> On Fri, Aug 12, 2016 at 11:31 AM, Hadley Wickham
> wrote:
>>> >> One possibility would also be to consider a
>>> "numbers-only" or >> rather "same type"-only {e.g.,
>>>
On Fri, Aug 12, 2016 at 11:31 AM, Hadley Wickham wrote:
>> >> One possibility would also be to consider a "numbers-only" or
>> >> rather "same type"-only {e.g., would also work for characters}
>> >> version.
>>
>> > I don't know what you mean by these.
>>
>> In the mean time, Bob
> >> One possibility would also be to consider a "numbers-only" or
> >> rather "same type"-only {e.g., would also work for characters}
> >> version.
>
> > I don't know what you mean by these.
>
> In the mean time, Bob Rudis mentioned dplyr::if_else(),
> which is very relevant, th
Excuse for the delay; I had waited for other / additional
comments and reactions (and been distracted with other urgent issues),
but do want to keep this thread alive [inline] ..
> Duncan Murdoch
> on Sat, 6 Aug 2016 11:30:08 -0400 writes:
> On 06/08/2016 10:18 AM, Martin Maech
> Uwe Ligges
> on Sun, 7 Aug 2016 09:51:58 +0200 writes:
> On 06.08.2016 17:30, Duncan Murdoch wrote:
>> On 06/08/2016 10:18 AM, Martin Maechler wrote:
[.]
>>> Of course, an ifelse2() should also be more efficient than
>>> ifelse() in typical "ato
On 06.08.2016 17:30, Duncan Murdoch wrote:
On 06/08/2016 10:18 AM, Martin Maechler wrote:
Dear R-devel readers,
( = people interested in the improvement and development of R).
This is not the first time that this topic is raised.
and I am in now state to promise that anything will result from
On 06/08/2016 10:18 AM, Martin Maechler wrote:
Dear R-devel readers,
( = people interested in the improvement and development of R).
This is not the first time that this topic is raised.
and I am in now state to promise that anything will result from
this thread ...
Still, I think the majority
have you tried seeing if `dplyr::if_else` behaves more to your liking?
On Sat, Aug 6, 2016 at 10:20 AM Martin Maechler
wrote:
> Dear R-devel readers,
> ( = people interested in the improvement and development of R).
>
> This is not the first time that this topic is raised.
> and I am in now stat
Dear R-devel readers,
( = people interested in the improvement and development of R).
This is not the first time that this topic is raised.
and I am in now state to promise that anything will result from
this thread ...
Still, I think the majority among us has agreed that
1) you should never use
When you what you hope for turns out to
be wrong, then have a look at 'The R Inferno'.
http://www.burns-stat.com/documents/books/the-r-inferno/
It does talk about 'ifelse'.
Pat
On 25/03/2013 02:21, Paul Johnson wrote:
I hope you are doing well.
For me, this was an unexpected problem. I've ho
Hi Paul,
Wonder why this is an R devel thing?
ifelse is vectorizedthere should be logical conditions matching
the length of the output.
ifelse(c(1, 1, 1), list(a=2, b=3, c=4), list(d=1, e=2, f=3))
otherwise it is truncated. Also note that both results have to be
valid, because both are typ
I hope you are doing well.
For me, this was an unexpected problem. I've hoped for quite a few
wrong things today, but I'm only asking you about this one. Why does
ifelse(1, list(a, b, c), list(x, y, z))
return a list with only a, not list(a, b, c) as I hoped. I wish it
would either
cause an err
Others have commented on why this holds.
There is an alternative, 'ifelse1', part of the splus2R package, that
does what you'd like here.
Tim Hesterberg
>I find it slightly surprising, that
> ifelse(TRUE, character(0), "")
>returns NA instead of character(0).
>
>--
>Heikki Kaskelma
Prof Brian Ripley wrote:
Another way of looking at this is that ifelse(TRUE, character(0), "")
asks for a length-one result
Just to rub it in: The length of an ifelse() computation is the length
of the "test" argument, so there is no way you should expect
character(0) as the result. (The clas
Another way of looking at this is that ifelse(TRUE, character(0), "") asks
for a length-one result containing the first element of yes=character(0),
and character(0)[1] is NA_character_
I suspect if(TRUE) character(0) else "" was intended.
On Mon, 18 Aug 2008, Marc Schwartz wrote:
on 08/18/2
on 08/18/2008 06:35 PM Heikki Kaskelma wrote:
> I find it slightly surprising, that
>
> ifelse(TRUE, character(0), "")
>
> returns NA instead of character(0).
>
> [WNT 2.6.2 Patched]
Time to upgrade... :-)
The same behavior is in:
R version 2.7.2 beta (2008-08-16 r46368)
The reason for
I find it slightly surprising, that
ifelse(TRUE, character(0), "")
returns NA instead of character(0).
[WNT 2.6.2 Patched]
--
Heikki Kaskelma
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Hi all,
I guess that this is rather a feature request than a bug report, but I'm
not really sure:
I stumbled over this today (R 2.6.2, WinXP):
> c=c(as.Date("2007-01-01"))
> class(c)
[1] "Date"
> ifelse(is.na(c),as.Date(Sys.time()), c)
[1] 13514
> typeof(ifelse(is.na(c),as.Date(Sys.time()),
Duncan Murdoch wrote:
> On 4/26/2007 9:53 AM, [EMAIL PROTECTED] wrote:
>> Hi!
>>
>> I'm puzzled by the return value of ifelse
>>
>> consider
>>
>> x<-integer(0)
>> ifelse(is(x, "character"), paste(x), x)
>> [1] NA
>
> The test evaluates to a length 1 logical vector containing FALSE. So
> ifelse(
A simpler version of your "puzzling call to ifelse" is
ifelse(FALSE, character(0), integer(0))
The most obvious way to satisfy the requirements stated in the
documentation is to extend integer(0) to length 1 by creating an NA
value, and that's what you get as a return value (here the 'test'
ar
On 4/26/2007 9:53 AM, [EMAIL PROTECTED] wrote:
> Hi!
>
> I'm puzzled by the return value of ifelse
>
> consider
>
> x<-integer(0)
> ifelse(is(x, "character"), paste(x), x)
> [1] NA
The test evaluates to a length 1 logical vector containing FALSE. So
ifelse() tries to return the first entry of
Hi!
I'm puzzled by the return value of ifelse
consider
x<-integer(0)
ifelse(is(x, "character"), paste(x), x)
[1] NA
whereas
if (is(x, "character")) return(paste(x)) else x
[1] integer(0)
or
x<-integer(1)
ifelse(is(x, "character"), paste(x), x)
[1] 0
work as I had anticipated. Is this correct
33 matches
Mail list logo