[R] R function implementation

jim holtman jholtman at gmail.com
Thu Dec 8 02:10:24 CET 2011


Before rewriting in C, especially if you are new at it, have you
profiled (Rprof) your function to see the time is being spent?  Are
you using dataframe or matrices; there is a big speed different
between them when accessing data.  So profile your code, see where the
time is spent and then decide what to do about it.  Depending on your
choice of data structures and algorithms, R can be very fast.  So take
some time, profile your code and provide a sample of the function so
that we can see what you are trying to do and then maybe we would
suggest other approaches.  I have been using R/SPlus for a number of
years, know C reasonably well, and have yet to write any function in C
to improve the speed of R.

On Wed, Dec 7, 2011 at 7:02 PM, Diviya Smith <diviya.smith at gmail.com> wrote:
> Hello there,
>
> I recently wrote some code to perform pairwise correlations between all
> samples in a large dataset. So we are talking about performing pairwise
> correlations between 400K vectors. Since R has a very rich library of
> functions, it was very easy to code this in R. However, R was probably not
> the best choice as it is super slow for this large job. So my plan is to
> recode it in C. I was wondering if it is possible to see the code between
> some of the functions.
>
> I am looking for the raw code for simple data handling functions such as
> split, cut, etc so that I can directly use those in C. I am fairly new to
> programming in C and so this will be a big help.
>
> Thanks for you help in advance.
>
> Diviya
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.



More information about the R-help mailing list