Re: [Rd] C-Side: Applying a function (given as param) to data (given as param)

From: Douglas Bates <bates_at_stat.wisc.edu>
Date: Fri, 03 Jun 2011 11:14:39 -0500

On Fri, Jun 3, 2011 at 5:17 AM, oliver <oliver_at_first.in-berlin.de> wrote:
> Hello,
>
> I'm implementing a package (C-extension),
> where one function gets data and a function
> that needs to be applied to the data.
>
> I want to apply the function to (parts of)
> the data on the C-side.
>
> 1) how do I apply a function (given via SEXP) to data
> 2) how do I select parts of the data (also provided via SEXP)?

Not to be facetious but you begin by reading the "Writing R Extensions" manual.

An alternative is to read the vignette Rcpp-Introduction available as http://dirk.eddelbuettel.com/code/rcpp/Rcpp-introduction.pdf and soon to be in The R Journal. They show an explicit example of apply in compiled code (C++ using the Rcpp structures, in their case).

> Comment on 2: I want to implement a moving/rolling/running
> apply on the data, so I want to select a data window.
> How can this be done, and how can it be done efficiently?
>
> For example on page 101 of "Writing R extensions" there was a trick
> on how to use REAL on the result, before using it in a loop.
> Can this be used for efficiency reasons in general?
>
>
>  Ciao,
>    Oliver
>
>
> P.S.: What do these macros (like REAL()) do? Do they convert data
>      or rather cast datatypes?
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 03 Jun 2011 - 16:16:47 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 Sat 04 Jun 2011 - 11:20:15 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