R-beta: Accessing S-plus objects from R -- no. Must use ASCII files.

Martin Maechler (maechler@stat.math.ethz.ch)
Mon, 20 Oct 1997 15:49:43 +0200


Date: Mon, 20 Oct 1997 15:49:43 +0200
Message-Id: <199710201349.PAA03425@sophie.ethz.ch>
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: gibrat@proline.jouy.inra.fr
Subject: R-beta: Accessing S-plus objects from R -- no.   Must use ASCII files.

Salut Jean-Fran=E7ois,

(( you should really use a "Subject:..." in your postings... ))
>>>>> "JFG" =3D=3D Jean-Francois Gibrat <gibrat@proline.jouy.inra.fr> write=
s:

    JFG> I am currently trying to switch from Splus to R and I would like
    JFG> to know whether there is a way of transfering Splus objects stored
    JFG> on disk into the R environment. 
No, there's no direct way.  However, see below for a solution.

    JFG> In Splus I would do this using the
    JFG> function get, e.g., foo <- get(foo,where=3D"dirname") where dirnam=
e
    JFG> is the name of a directory containing the Splus objects. In R,
    JFG> argument 'where' of function get appears to be replaced by
    JFG> argument 'envir', whose meaning is rather nebulous for me at the
    JFG> moment.....  Thanks for answering me. Sorry if this question has
    JFG> been already asked zillion of times, as it is likely to have been.
not quite a zillion....

I think the new (not-yet-released) version of the FAQ will help you quite a
bit more here [[I assume you looked at the current released FAQ ...]]

Big difference  S <-> R:

In S / Splus, objects are stored as single files in Data directories.
  (at least conceptually, in S-plus Windows, this is not quite true..).

In R,they are only stored in memory, or as part of the ``image'',
when you use  save(..)  or q("yes")
{{and they are reloaded automatically if the image is called
".RData" and is in your current directory,
  or by  load(...) explicitly.}}

  Most of ``us'' however use source files and source(..) 
(and Emacs S-mode / R-mode ...) for our own functions and things.
  If you use HUGE data sets, R is not really there yet with
   ``memory-mapped'' objects.
  
Solution of your problem:
Get your data and function into R, using

source(.)
scan(.)
and/or  read.table(.).

To this end, you must save your S-plus objects in the proper format
from WITHIN S-plus, 
using  dump(..) [then you'll use source(..)]
or     write(..) / write.table(..), then use scan(.) or read.table(.). 

I hope this helps.

Martin Maechler <maechler@stat.math.ethz.ch> <><
Seminar fuer Statistik, SOL G1
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408fax: ...-1086
http://www.stat.math.ethz.ch/~maechler/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=