[R] subsetting from C code, do_subset
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Apr 22 20:33:56 CEST 2006
On Sat, 22 Apr 2006, Gabor Csardi wrote:
> Dear List,
>
> do you know a way for subsetting an R object from C code? I would need the
> equivalent of x[s]. I've found that the do_subset internal function does
> this, but don't really know how to call it properly. I've two SEXP's, one
> for the object and one for the index.
>
> I'm thinking of creating an enviroment, place the two SEXP's in it and then
> just parse and run the corresponding R code, but there might be simpler
> way...
That's overkill. You know where your objects are so you can set up a call
with e.g. lang2 and eval it in the right place. The code for e.g. optim
might give you some ideas.
do_subset is not a public entry point, and may well not be visible to
you in R >= 2.3.0.
[I'd say this was an R-devel question, BTW.]
--
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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list