Skip to content
Prev 40425 / 63424 Next

C-Side: Applying a function (given as param) to data (given as param)

On Sat, Jun 04, 2011 at 07:51:08AM -0400, Duncan Murdoch wrote:
[...]

[...]
[...]

The reason why I wanted to do this in C, not in R,
is speed as well as consistency.

I have about 700 MB data that I want to analyse....

And loops might be to slow in R.
Some of the apply functions might help and I already implemented
some stuff in R, but the result values that some of the apply functions give me,
are changing under certain circumstances, for example list or matrix or vector.
Also a lot of conversions and value-extracting is needed.
It looked to me as if doing in C would be the better way.

So I want to have the possibility to do that in C,
then loops are no problem, and I can create a certain
result value type, as well as some other features I have in mind.
Also in R the automatic coercion to some types sometimes
is not necessary, and working on the raw values might be
better, it seems to me.

Also I want to learn the C-interface, so that in later cases
I know how to use it.

For simple values I already know how to use it.
But the problem is there, when functions are given as parameters.
That is a very powerful feature. If that only is manageable easy in
R, it might always be a performance bottleneck.
OK, thanks.
[...]

Aha, good to know.

Do I have to look at S3 and S4 methods and classses, if I wish to
make it in C?

Ciao,
   Oliver