[Rd] if does not covert raw to logical (PR#13630)

waku at idi.ntnu.no waku at idi.ntnu.no
Sun Mar 29 22:40:11 CEST 2009


Full_Name: Wacek Kusnierczyk
Version: 2.8.0 and 2.10.0 r48242
OS: Ubuntu 8.04 Linux 32 bit
Submission from: (NULL) (80.202.30.36)


The following raises an error:

   if (as.raw(1)) 1
   # error: unimplemented type 'raw' in 'asLogical'

However, ?'if' says:

" 
Arguments:

    cond: A length-one logical vector that is not 'NA'. Conditions of
          length greater than one are accepted with a warning, but only
          the first element is used.  Other types are coerced to
          logical if possible, ignoring any class. 
"

and the help page does not mention raw type arguments to 'if' at all. 

The error above is in clear contradiction to the documentation.  This might be a
flaw in the documentation, but the following succeeds:

   ifelse(raw(1), 1, 0)
   # 1

which suggests that the error above is a bug (i.e., the implementation fails to
convert raw to logical).

The same problem involves 'while':

   while(as.raw(1)) break
   # error: unimplemented type 'raw' in 'asLogical'

Regards,
vQ



More information about the R-devel mailing list