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 [[alternative HTML version deleted]]
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 > [[alternative HTML version deleted]] > >______________________________________________ >R-help@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[[alternative HTML version deleted]]
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? >Have you read section 3.1 in "R Data Import/Export"? http://cran.r-project.org/doc/manuals/R-data.pdf --sundar
Hi,> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [SMTP:r-help-bounces at stat.math.ethz.ch] On Behalf Of Zachary Skrivanek > Sent: Wednesday, August 25, 2004 6:29 PM > To: R-help at stat.math.ethz.ch > Subject: [R] S <-> R > > 'source'). Is there any way that I can save a list object in S that can > be read into R? >With S you probably mean S-PLUS, right? Given that is the case, it depends on the version of S-PLUS you are using. I had no problems to "dump" a list and then load it into R as long as I was using S-PLUS 2000. When I switched to S-PLUS 6, I suddenly could not do that anymore. It was possible again to do it when I used the same specification of dump by setting the argument oldStyle=T This indicates that (excerpt from ?dump) " oldStyle logical flag; should the file be written in a form that can be read by earlier versions of S-PLUS? If F, then the file will not be readable by versions of S-PLUS earlier than 5.0 (Unix) or 6.0 (Windows). " Hope this gets you going. By the way, this has been discussed before on this list. Please check (could be googled by using the keywords: R-project S-PLUS dump; it is actually the first hit): http://tolstoy.newcastle.edu.au/R/help/04/01/0650.html (for the beginning of the thread) http://tolstoy.newcastle.edu.au/R/help/04/01/0665.html (for the same suggestion as given in my message here) Roland +++++ This mail has been sent through the MPI for Demographic Rese...{{dropped}}
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
Thanks Tony. But the Mr. Skrivanek initially said he couldn't get dput() and dget() to work with ***lists***. It seems to turn out that lists, as such, are not the issue. The problem stems from having relatively weird components in the lists. Also, in your example, the issue is not an R <--> S incompatibility problem. The example causes an error even if one stays entirely within Splus (or within R): ===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+==> junk <- list(f=as.name("g"))> dput(junk,"junk.dat") > crap <- dget("junk.dat")Problem in dget("junk.dat"): Object "g" not found Use traceback() to see the call stack ===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+== And the same happens in R (except that the error message is phrased differently: ===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+==Error in structure(list(f = g), .Names = "f") : Object "g" not found ===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+== cheers, Rolf Turner rolf at math.unb.ca