waku at idi.ntnu.no
2009-Mar-29 20:40 UTC
[Rd] if does not covert raw to logical (PR#13630)
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
maechler at stat.math.ethz.ch
2009-Mar-30 16:55 UTC
[Rd] if does not covert raw to logical (PR#13630)
Thank you, Wacek, for>>>>> Wacek Kusnierczyk <waku at idi.ntnu.no> >>>>> on Sun, 29 Mar 2009 22:40:11 +0200 (CEST) writes:> 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' indeed, it was pretty straightforward hard to implement the missing case in asLogical(.) and I will commit my patch to the sources tomorrow {being busy otherwise for the rest of today}. Note that the raw data type has been a newish addition to R a while ago though, and if you find further cases where such raw objects do not "work" as documented, we'd gladly accept further such reports. Regards, Martin Maechler, ETH Zurich
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
2009-Mar-30 20:15 UTC
[Rd] if does not covert raw to logical (PR#13630)
Martin Maechler wrote:> Thank you, Wacek, >happy to serve. (...)> indeed, it was pretty straightforward hard to implement the missing case in > asLogical(.) and I will commit my patch to the sources tomorrow > {being busy otherwise for the rest of today}. >thanks!> Note that the raw data type has been a newish addition to R a > while ago though, and if you find further cases where > such raw objects do not "work" as documented, > we'd gladly accept further such reports. >yes, i'll keep sniffing. best, vQ
Reasonably Related Threads
- duplicated fails to rise correct errors (PR#13632)
- odd behaviour of identical
- actual argument matching does not conform to the definition (PR#13634)
- Variable passed to function not used in function in select=... in subset
- incorrect output and segfaults from sprintf with %*d (PR#13667)