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