Skip to content

foreign package: unable to read S-Plus objects

7 messages · jgvcqa at rit.edu, Kevin E. Thorpe, Wolfgang Viechtbauer +3 more

#
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
#
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().

  
    
#
@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
#
You could try to see what stattransfer can make of it. They have a free 
version that imports only part of the data. You could use that to see if 
stattransfer would help and perhaps discover what format it is in.

HTH
Jsn
On 16-01-2023 23:22, Joseph Voelkel wrote:
#
I just checked the header:

read.S from foreign expects:

  readheader <- function(s) {
         head <- readBin(s, "int", 8L, 1L)
         all(head == c(0L, 83L, 32L, 100L, 97L, 116L, 97L, 1L))
     }

but head is

[1]  0 83 32 86 52 45 77  3

i.e. similar but not identical, so a different format is used (S-PLUS 6 
or later).
Likely, it is not too hard to write some import function based on read.S 
if the file format is documented anywhere. Unfortunately, I do not find 
any web resources for it.


So simplest way would be to install the old S-PLUS version and export 
all data in a readable format.

Best,
Uwe Ligges
On 17.01.2023 14:21, Viechtbauer, Wolfgang (NP) wrote:
#
Thank you for the response, and the reasoning behind. I will try to do as you suggested.

Joe
#
Just an idea if this is a one-time need to copy static data once used in
non-R to R. You are a bit vague about what you mean by "objects."

If you can find someone who uses S or S+ then maybe they can load the data
in and export it in some format usable for you and send you those files. If,
for example, your data is just a data.frame, they can send it as a .CSV file
or any format you want. Once you have it, you can read it into R and save it
any other way you wish.

If the data is something more complex like a dump of all kinds of variables,
this may not be practical but I have to wonder how much it and R have
diverged all these years and whether it would be something you can import
and continue running with.

I downloaded the files and they seem to be in a folder with 8 files that
have no suffixes with sizes ranging from 1KB to 469  KB so nothing gigantic.
The big files is simdata and two smaller files called simmax and simmean may
well be related  but I have to wonder if the way to view them is at the
folder level as a grouped entity or the individual file level.

I wonder if there is a trial version of the software you could get from
whoever sells it, like TIBCO.

Good luck with that. 

-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Jan van der Laan
Sent: Tuesday, January 17, 2023 9:09 AM
To: r-help at r-project.org
Subject: Re: [R] foreign package: unable to read S-Plus objects

You could try to see what stattransfer can make of it. They have a free
version that imports only part of the data. You could use that to see if
stattransfer would help and perhaps discover what format it is in.

HTH
Jsn
On 16-01-2023 23:22, Joseph Voelkel wrote:
see how to do this is by using the foreign package.
code and the error message follows:
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.
files that the foreign package can read, yes? But I am still hoping that it
may be possible to read these in.
______________________________________________
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.