[R] foreign package: unable to read S-Plus objects

Kevin Thorpe kev|n@thorpe @end|ng |rom utoronto@c@
Tue Jan 17 13:06:44 CET 2023


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 using rit.edu> wrote:
> 
> [You don't often get email from jgvcqa using 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 using 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 using utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016



More information about the R-help mailing list