[R] dump() an object of type raw ?

David Winsemius dwinsemius at comcast.net
Wed Jul 22 04:14:17 CEST 2009


On Jul 21, 2009, at 7:19 PM, Benjamin Tyner wrote:

> Is there a way to do this? I tried
>
>  x <- writeBin(pi, raw())
>  dump("x","x.R")
>  source("x.R")
>
> but is seems x.R is not source()-able, as it contains an unexpected  
> symbol.
>

Yes, "2d".I get:
 > source("/Users/davidwinsemius/x.R")
Error in source("/Users/davidwinsemius/x.R") :
   /Users/davidwinsemius/x.R:2:8: unexpected symbol
1: x <-
2: c(18, 2d
           ^

So there was an good faith effort to source the file but the  
interpreter was not put on notice that it would be getting  
hexadecimal. The file contains:

x <-
c(18, 2d, 44, 54, fb, 21, 09, 40)

and when you try to execute that from the command line you get:

 > x <-
+ c(18, 2d, 44, 54, fb, 21, 09, 40)
Error: syntax error

(R variable names cannot start with 2 and R wouldn't assume these are  
hexadecimal numbers.)


David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list