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

Joseph Voelkel jgvcq@ @end|ng |rom r|t@edu
Tue Jan 17 16:42:43 CET 2023


Thank you for the response, and the reasoning behind. I will try to do as you suggested.

Joe
________________________________
From: Uwe Ligges <ligges using statistik.tu-dortmund.de>
Sent: Tuesday, January 17, 2023 10:04 AM
To: Viechtbauer, Wolfgang (NP) <wolfgang.viechtbauer using maastrichtuniversity.nl>; Kevin Thorpe <kevin.thorpe using utoronto.ca>; Joseph Voelkel <jgvcqa using rit.edu>
Cc: R Help Mailing List <R-help using r-project.org>
Subject: Re: [R] foreign package: unable to read S-Plus objects

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:
> @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 using 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 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=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
> ______________________________________________
> 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.

	[[alternative HTML version deleted]]



More information about the R-help mailing list