I think you may be right about the cause. From the, ?R Data Import/Export? document I find, Function read.S which can read binary objects produced by S-PLUS 3.x, 4.x or 2000 on (32-bit) Unix or Windows (and can read them on a different OS). This is able to read many but not all S objects: in particular it can read vectors, matrices and data frames and lists containing those. This suggests that the binary objects you have cannot be read by this function. The next two paragraphs read, 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 later written with data.dump(oldStyle=T). If you have access to S-PLUS, it is usually more reliable to dump the object(s) in S-PLUS and source the dump file in R. For S-PLUS 5.x and later you may need to use dump(..., oldStyle=T), and to read in very large objects it may be preferable to use the dump file as a batch script rather than use the source function. I think this means that if you had dumped versions of the files you could read them back with data.restore() or source().> On Jan 16, 2023, at 5:22 PM, Joseph Voelkel <jgvcqa at rit.edu> wrote: > > [You don't often get email from jgvcqa at rit.edu. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] > > Dear foreign maintainers and others, > > I am trying to import a number of S-Plus objects into R. The only way I see how to do this is by using the foreign package. > > However, when I try to do this I receive an error message. A snippet of code and the error message follows: > > read.S(file.path(Spath, "nrand")) > Error in read.S(file.path(Spath, "nrand")) : not an S object > > I no longer know the version of S-Plus in which these objects were created. I do know that I have printed documentation, dated July 2001, from S-Plus 6; and that all S-Plus objects were created in the 9/2004 -- 5/2005 range. > > I am afraid that I simply have S-Plus objects that are not the S version 3 files that the foreign package can read, yes? But I am still hoping that it may be possible to read these in. > > I am not attaching some sample S-Plus objects to this email, because I believe they will be stripped away as binary files. However, a sample of these files may be found at > > https://drive.google.com/drive/folders/1wFVa972ciP44Ob2YVWfqk8SGIodzAXPv?usp=sharing (simdat is the largest file, at 469 KB) > > Thank you for any assistance you may provide. > > R 4.2.2 > Microsoft Windows [Version 10.0.22000.1455] > foreign_0.8-83 > > > Joe Voelkel > Professor Emeritus > RIT > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.-- Kevin E. Thorpe Head of Biostatistics, Applied Health Research Centre (AHRC) Li Ka Shing Knowledge Institute of St. Michael?s Hospital Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.thorpe at utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016
Viechtbauer, Wolfgang (NP)
2023-Jan-17 13:21 UTC
[R] foreign package: unable to read S-Plus objects
@Joe: I have S-Plus 6.0 ("Professional Edition Version 6.0.3 Release 2 for Microsoft Windows : 2001") running here and can't load them there either. Tried simdat and S-Plus apparently thinks it is a script and then you just get a garbled up mess. Tried to change it to simdat.sdd and a few other extensions, but this didn't help. Also tried: data.restore("simdat") but this also didn't work: Warning messages: file "simdat": incomplete last line Problem: in reading invalid mode for data: [again a garbled mess] at line 2 Not sure how else these are supposed to be read into S-Plus (and if they are even compatible with this version, although version 6 was the current version between 2001 and 2005). Best, Wolfgang>-----Original Message----- >From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Kevin Thorpe >Sent: Tuesday, 17 January, 2023 13:07 >To: Joseph Voelkel >Cc: R Help Mailing List >Subject: Re: [R] foreign package: unable to read S-Plus objects > >I think you may be right about the cause. From the, ?R Data Import/Export? >document I find, > >Function read.S which can read binary objects produced by S-PLUS 3.x, 4.x or 2000 >on (32-bit) Unix or Windows (and can read them on a different OS). This is able >to read many but not all S objects: in particular it can read vectors, matrices >and data frames and lists containing those. > >This suggests that the binary objects you have cannot be read by this function. >The next two paragraphs read, > >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 later written with >data.dump(oldStyle=T). > >If you have access to S-PLUS, it is usually more reliable to dump the object(s) >in S-PLUS and source the dump file in R. For S-PLUS 5.x and later you may need to >use dump(..., oldStyle=T), and to read in very large objects it may be preferable >to use the dump file as a batch script rather than use the source function. > >I think this means that if you had dumped versions of the files you could read >them back with data.restore() or source(). > >> On Jan 16, 2023, at 5:22 PM, Joseph Voelkel <jgvcqa at rit.edu> wrote: >> >> [You don't often get email from jgvcqa at rit.edu. Learn why this is important at >https://aka.ms/LearnAboutSenderIdentification ] >> >> Dear foreign maintainers and others, >> >> I am trying to import a number of S-Plus objects into R. The only way I see how >to do this is by using the foreign package. >> >> However, when I try to do this I receive an error message. A snippet of code >and the error message follows: >> >> read.S(file.path(Spath, "nrand")) >> Error in read.S(file.path(Spath, "nrand")) : not an S object >> >> I no longer know the version of S-Plus in which these objects were created. I >do know that I have printed documentation, dated July 2001, from S-Plus 6; and >that all S-Plus objects were created in the 9/2004 -- 5/2005 range. >> >> I am afraid that I simply have S-Plus objects that are not the S version 3 >files that the foreign package can read, yes? But I am still hoping that it may >be possible to read these in. >> >> I am not attaching some sample S-Plus objects to this email, because I believe >they will be stripped away as binary files. However, a sample of these files may >be found at >> >> >https://drive.google.com/drive/folders/1wFVa972ciP44Ob2YVWfqk8SGIodzAXPv?usp=shar >ing (simdat is the largest file, at 469 KB) >> >> Thank you for any assistance you may provide. >> >> R 4.2.2 >> Microsoft Windows [Version 10.0.22000.1455] >> foreign_0.8-83 >> >> Joe Voelkel >> Professor Emeritus >> RIT