On Sat, Apr 22, 2006 at 07:33:56PM +0100, Prof Brian Ripley wrote: > 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.
Thanks, i've checked the optim code. The only difference is that i don't have a function or expression object for '[' itself, and i couldn't manage to find a public entry point which can create one for me. > do_subset is not a public entry point, and may well not be visible to > you in R >= 2.3.0. That is true, it is better to extract the entry from R_FunTab then? Of course i don't need this if i use eval, lang2, etc. But for that i need a function which can create a function object for '[', something like do_call, but do_call is not a public entry point either.... > [I'd say this was an R-devel question, BTW.] Maybe. I've posted it here because i don't want to 'develop' R, only use it as a user. But you're right that most people here might be not interested in R internals.... I there was an R-help-advenced list i would have posted it there. Gabor [...] -- Csardi Gabor <[EMAIL PROTECTED]> MTA RMKI, ELTE TTK ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
