Hi,
I'm currently writing an S4/Oracle interface, and as Brian Ripley
points out, the .Call interface is the key. The good news is that
the S part (I presumed the R part as well) is remarkably straight-
forward by using the .Call facilities to create list and other S objects
directly from C. I'm following Brian's suggestion and printing the
R-external documentation --- I need to make my code R-compatible.
I'd be embarrassed to release the code in its current state, but
I'd be happy to share it with people if they are in desperate need:-)
> Date: Wed, 24 Nov 1999 07:17:43 +0000 (GMT)
> From: Prof Brian D Ripley <ripley at stats.ox.ac.uk>
> To: "John D. Barnett" <jbarnett at wi.mit.edu>
> cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] Internal data types
> MIME-Version: 1.0
>
> On Tue, 23 Nov 1999, John D. Barnett wrote:
>
> > Hi-
> >
> > I'm very interested in using R, though I am still new to it.
However,
> > all of the data I'm working with is currently stored in Oracle.
So,
> > either I get data from Oracle, save it to a text file, and then import
> > it to R, or I write an R <-> Oracle bridge. I've taken the
second
> > approach, but I'm sure that I haven't done it entirely
correctly.
> >
> > For starters, is there any unified documentation for the R/C
interface?
>
> Not yet, but
>
> (a) It is pretty similar to the S one, and
> (b) I think you should be using the .Call interface. This is now
> documented in `R-external' manual which is in the 0.90.0 documentation
> (cd doc/manual, make dvi or make pdf).
>
> > I can currently get back the results of a SQL query in a list of
> > vectors; however, the process is quite slow and CPU intensive. This
is
> > probably because I fill in the data structure in R, and call C to get
> > every single value. It makes more sense to me to loop in C and create
> > the entire data structure there, but I'm not quite sure how to
approach
> > this.
>
> Use .Call is the key.
>
> > I think that what I want to do is actually create the appropriate
SEXPR
> > for a list, with each element being a vector (numeric or string).
This
> > would presumably be through allocList() and allocVector(), but how
then
> > do I access individual elements of an SEXPR (list or vector) from C?
> > (i.e., are there access functions that I'm missing, or do I have
to wade
> > through the structure definition of SEXPR?)
>
> See the `R-external' manual. There are two sets of access definitions,
> in Rdefines.h and Rinternals.h
>
> I hope that helps you enough. If not, your only recourse is to study
> examples in the R source code (which is how that manual got written),
> or ask for help. (It might be good to ask really technical points
> on R-devel, as I suspect everyone who knows about this is on that list.)
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272860 (secr)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
-------------------------------------------------------------------------------
-
David A. James
Statistics Research, Room 2C-253 Phone: (908) 582-3082
Bell Labs, Lucent Technologies Fax: (908) 582-3340
Murray Hill, NJ 09794-0636
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._