Skip to content
Prev 17777 / 63421 Next

Future plans for raw data type?

On Wed, Sep 28, 2005 at 10:59:39AM +0100, Prof Brian Ripley wrote:
That's reasonable.  I should have known to be more specific in saying
what I meant by "first class data type", but drawing the line at
interpreting the contents of a raw seems fine.
Hmmm, that's interesting; I wonder how I missed the fact that this
worked.  Somehow I managed to only try things that didn't, even though
the obvious case does work.  Here are some things that are broken:

  x <- data.frame(a=1:10)
  x$b <- as.raw(1:10)
  x[[2]] <- as.raw(1:10)
  x <- data.frame(as.raw(1:10))
  x[1,]
  x[1,1]
Because of how ifelse() is implemented, for type 'X', it requires both
'X' <- logical and logical <- 'X' coercions.  The 'X' <- logical
coercion is used for handling NA elements in 'test' even if there are
none.  The logical <- 'X' coercion is required due to how ifelse()
constructs the result vector from 'yes' and 'no'.  The logical <- raw
coercion seems unambiguous.  Arguably, ifelse() should not care about
the ability to represent NA if there are no NA values in 'test', and
could do:

    if (any(nas)) ans[nas] <- NA

instead of:

    ans[nas] <- NA

I think this is a little bit more consistent with how ifelse() handles
the 'yes' and 'no' arguments, as well (they are only evaluated if they
are actually used).  But as you say, ifelse() is pretty easily to work
around.
I think this is related to the problems I described above, and I
suspect that your fix is the same as mine (i.e. handle "case 1924" in
subassign.c).

-- Dave