Re: [Rd] Sending lists using .C

From: Brian G. Peterson <brian_at_braverock.com>
Date: Sun, 22 Apr 2012 05:08:53 -0500

On Sat, 2012-04-21 at 17:49 -0700, chris90nz wrote: <...>
> I have written the following code which will let me pass it through
> using .C
> as two vectors, one containing the numbers contained in the lists all
> concatenated, the other containing the indicies at which each list
> starts.
<...>
> This approach works, but is still slow (10,000 times doing this takes
> ~30seconds).
>
> I know you can pass a list through by having the C function take as a
> parameter SEXP*. However I am not familiar with using Rinternals.h and
> am a little lost as to how I would access elements of my big list if I
> just pass the whole thing through to a SEXP*.
>
> The other thing is I have 2 lists to pass through like this, and
> another with an arbitrary sized matrix instead of a list of integers,
> so I think the only way I can do this efficiently is if I do pass
> these lists through to a SEXP*.

The fact that you admit to being 'a little lost' suggests that you should use a higher level interface. The list archives here have a wealth of information, most recently a very good summary of the more modern .Call interface here:
http://www.mail-archive.com/r-devel@r-project.org/msg26578.html and here:
http://www.mail-archive.com/r-devel@r-project.org/msg26631.html

as an even higher level interface, perhaps you should consider RCpp, which contains even more data structures for handling large R data structures, and more hand holding. Reference slides here: http://dirk.eddelbuettel.com/bio/presentations.html (see especially the full day workshop from 2010)

Regards,

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sun 22 Apr 2012 - 10:30:44 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 23 Apr 2012 - 13:30:47 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive