[R] "dump" Splus -> R

Gregory R. Warnes warnes at biostat.washington.edu
Thu Apr 1 00:08:38 CEST 1999


Hi All,

I just used "dump" on Splus to transfer a pile of survival objects from
Splus 3.4 on Solaris 7 to R 0.63.3 on Intel. 

The only trick is that survival objects contain an element holding the
original call that generated the object.  When Splus writes these out, it
doesn't mark them in any way, so when R tries to read them in, it ends up
trying to reevaluate the call.  Not nice.  

Anyway, as all but one** of the offending calls occur in statements
that look like
   [...], call = func( param1, param2, [..] ), class = "myclass"

so I wrote the following perl script to encapsulate each call in 
as.call(expression(...)) :

-------begin translate.dump.pl--------
$RS="<-";
$OS="<-";

while(<>)
  {
        s/call\s*=(.*?),(\s+?)class/call=as.call(expression($1)),$2
class/s;
        print $_;
   }
---------end translate.dump.pl----------

Now the data can be transfered by :

   Splus on Unix:
   > dump(ls())

Downloading the resulting "dumpdata" file.

   Linux shell:
   $  translate.dump.pl < dumpdata > dumpdata.fixed

   R on Linux:

   > source("dumpdata.fixed")

Just thought this might help someone out...


-Greg 


**The only exception was the ".Last.warning" object, which contained
something like 
  structure( "Warning Message" = offending(call) )

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list