"dump" Splus -> R

Gregory R. Warnes warnes@biostat.washington.edu
Wed, 31 Mar 1999 14:17:40 -0800 (PST)


A couple of comments for core...

In my examples, it looks like the only calls that need to be evaluated
inside the structure are "c()" and "list()".  A heuristic approach for
loading the dump files, is to assume that any other call ought to be
returned as a call, rather than evaluated.  Providing an undump() command
with this behavour might make it easier for people to move data between
Splus and R.

-Greg 


On Wed, 31 Mar 1999, Gregory R. Warnes wrote:

  GRW>> 
  GRW>> Hi All,
  GRW>> 
  GRW>> I just used "dump" on Splus to transfer a pile of survival objects from
  GRW>> Splus 3.4 on Solaris 7 to R 0.63.3 on Intel. 
  GRW>> 
  GRW>> The only trick is that survival objects contain an element holding the
  GRW>> original call that generated the object.  When Splus writes these out, it
  GRW>> doesn't mark them in any way, so when R tries to read them in, it ends up
  GRW>> trying to reevaluate the call.  Not nice.  
  GRW>> 
  GRW>> Anyway, as all but one** of the offending calls occur in statements
  GRW>> that look like
  GRW>>    "blah" <- structure( [...], call = func( param1, param2, [...], )
  GRW>>                  class = "myclass" [...] )
  GRW>> 
  GRW>> so I wrote the following perl script to encapsulate each call in 
  GRW>> as.call(expression(...)) :
  GRW>> 
  GRW>> -------begin translate.dump.pl--------
  GRW>> $RS="<-";
  GRW>> $OS="<-";
  GRW>> 
  GRW>> while(<>)
  GRW>>   {
  GRW>>         s/call\s*=(.*?),(\s+?)class/call=as.call(expression($1)),$2
  GRW>> class/s;
  GRW>>         print $_;
  GRW>>    }
  GRW>> ---------end translate.dump.pl----------
  GRW>> 
  GRW>> Now the data can be transfered by :
  GRW>> 
  GRW>>    Splus on Unix:
  GRW>>    > dump(ls())
  GRW>> 
  GRW>> Downloading the resulting "dumpdata" file.
  GRW>> 
  GRW>>    Linux shell:
  GRW>>    $  translate.dump.pl < dumpdata > dumpdata.fixed
  GRW>> 
  GRW>>    R on Linux:
  GRW>> 
  GRW>>    > source("dumpdata.fixed")
  GRW>> 
  GRW>> Just thought this might help someone out...
  GRW>> 
  GRW>> 
  GRW>> -Greg 
  GRW>> 
  GRW>> 
  GRW>> **The only exception was the ".Last.warning" object, which contained
  GRW>> something like 
  GRW>>   structure( "Warning Message" = offending(call) )
  GRW>> 
  GRW>> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._