On Jul 21, 2009, at 10:21 PM, Benjamin Tyner wrote:
Thank you David for taking the time to respond to my question.
Perhaps I should clarify: the man page says "a 'dump' file can be
'source'd"; have I taken the documentation too literally in this case?
I suppose that objects of type raw may not have been given full
provision in the construction of source(). The help page suggests to
me that attributes are not dumped. Perhaps you could be more expansive
about what you are hoping to accomplish?
Does this get any closer?
> x <- as.numeric( writeBin(pi, raw()) )
> x
[1] 24 45 68 84 251 33 9 64
> dump("x","x.R")
> source("/Users/davidwinsemius/x.R")
> x
[1] 24 45 68 84 251 33 9 64
> as.raw(x)
[1] 18 2d 44 54 fb 21 09 40
Or this: The help page also advises that save() is more appropriate
for R data.
> x <- writeBin(pi, raw())
> save("x",file="x.R")
> load("x.R")
> x
[1] 18 2d 44 54 fb 21 09 40
David Winsemius wrote:
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
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.