[R] S <-> R

Tony Plate tplate at blackmesacapital.com
Wed Aug 25 20:10:45 CEST 2004


I think the issue is that dput() and dget() don't work for some more 
complex structures (as you point out, they do appear to work for simple 
structures).  The R Data Import/Export manual doesn't mention using dput 
and dget to transfer objects between R and S-PLUS, perhaps because these 
functions have limited coverage?

E.g.:

S-PLUS6.1> junk <- list(f=as.name("g"))
S-PLUS6.1> dput(junk,"junk1.dat")
S-PLUS6.1> data.dump("junk", file="junk2.dat", oldStyle=F)
S-PLUS6.1> data.dump("junk", file="junk3.dat", oldStyle=T)

R> dget("junk1.dat")
Error in eval(expr, envir, enclos) : Object "g" not found
R> # with package "foreign" loaded
R> data.restore("junk2.dat")
Error in ReadSdump(TRUE, " ") : S mode "junk" (near byte offset 45) not 
supported
In addition: Warning message:
NAs introduced by coercion
R> data.restore("junk3.dat")
[1] "junk3.dat"
R> junk
$f
g

 >

-- Tony Plate

At Wednesday 11:45 AM 8/25/2004, Rolf Turner wrote:

>I'm puzzled by the discourse in this thread.  Briefly, dput() and
>dget() seem to work just fine for me.
>
>I tried
>
>         > junk <- list(x=rnorm(20),y=sample(1:100,12,TRUE))
>         > dput(junk,"junk.dat")
>
>in Splus (Version 6.1.2 Release 2 for Sun SPARC, SunOS 5.6 : 2002)
>
>and then in R
>
>         > junk <- dget("junk.dat")
>
>R version:
>
>platform sparc-sun-solaris2.9
>arch     sparc
>os       solaris2.9
>system   sparc, solaris2.9
>status
>major    1
>minor    9.1
>year     2004
>month    06
>day      21
>language R
>
>There were no complaints, and typing ``junk'' in the R window
>and in the Splus window appeared to produce indentical results.
>
>So what's the problem?
>
>                                 cheers,
>
>                                         Rolf Turner
>                                         rolf at math.unb.ca
>
>Tony Plate wrote:
>
> > Have you tried following the advice in the R Data Import/Export 
> manual?  It
> > suggests the following:
> >
> > >Function data.restore reads S-PLUS data dumps (created by data.dump) with
> > >the same restrictions (except that dumps from the Alpha platform can also
> > >be read).
> > >It should be possible to read data dumps from S-PLUS 5.x and 6.x 
> written with
> > >data.dump(oldStyle=T).
> >
> > -- Tony Plate
> >
> > At Wednesday 10:29 AM 8/25/2004, Zachary Skrivanek wrote:
> > >Hello!  I would like to be able to read in list data objects in R/S
> > >created in R/S.  (Ie R->S or S->R.)  I have tried 'dput' and 'dump' in S,
> > >but neither of the created files could be read into R (with 'dget' nor
> > >'source').  Is there any way that I can save a list object in S that can
> > >be read into R?
> > >
> > >Sincerely,
> > >Zachary Skrivanek, PhD
> > >Research Scientist
> > >Program Phase Statistics-Endocrine
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list