[R] looking at C code from the stats package

Marc Schwartz marc_schwartz at me.com
Fri May 30 02:52:42 CEST 2014


On May 29, 2014, at 7:12 PM, Erin Hodgess <erinm.hodgess at gmail.com> wrote:

> Dear R People:
> 
> How are you?
> 
> I would like to look at the underlying C code from the program C_ARIMA_Like
> in the stats package.
> 
> However, since that is a base package, I'm not entirely sure how to access
> this.
> 
> When I used the .C(C_ARIMA_Like....)
> 
> it says that the C_ARIMA_Like cannot be found.
> 
> This is on Windows 7, R version 3.0.2.
> 
> Thank you for any help!
> Sincerely,
> Erin


Hi Erin,

If you are working from a binary install of R, you won't able to see the sources for C or FORTRAN based functions.

If it is a base package in the '../library' tree like 'stats', in the source tarball from CRAN or in the R SVN repo, there will be a 'src' directory for the package where relevant C and/or FORTRAN code will be contained.

As an example for arima.c, in the SVN repo for the 3.0 branch tree:

  https://svn.r-project.org/R/branches/R-3-0-branch/src/library/stats/src/arima.c

For R-Devel, it will be in 'trunk':

  https://svn.r-project.org/R/trunk/src/library/stats/src/arima.c

Scroll down or search in the arima.c source for the function name "ARIMA_Like".

If you know something about SVN repo trees, the path will make sense.

Other common C and/or FORTRAN code that is not part of the base packages may be in the ../src/main directory:

  https://svn.r-project.org/R/branches/R-3-0-branch/src/main/

and there is a file 'names.c' that can be helpful in locating specific C functions and their associated declared C names.

For Recommended packages, there is also a separate SVN repo at:

  https://svn.r-project.org/R-packages/

but it may be easier to download the tarball for each package from CRAN.

Regards,

Marc Schwartz



More information about the R-help mailing list