University of Minnesota, Twin Cities School of Statistics Charlie's Home Page
This page still under construction. Don't look yet. Or you can look, but be warned it's unfinished.
Almost all of the R API can be used standalone, that is, from a C main program with no help from the R main program. This just uses R as a C math library.
Get the files
Then do
make export LD_LIBRARY_PATH=/APPS/32/lib foo
in the directory where you put the files.
The example uses the qbeta
function (the same C function
that the R qbeta
function calls) to calculate the median
of a beta distribution.
Get the files
Then do
make export LD_LIBRARY_PATH=/APPS/64/lib64 foo
in the directory where you put the files.
There's lots more stuff in this R standalone library. For example,
To use the random number generators, you have to set the seeds as described in the section on this library in Writing R Extensions.
To find out what's included, look at the header file
To actually find out how a function is called, one must RTFS. To find the source, you must look in the directory where the source is. On our machines it is
/APPS/src/R-2.2.1/src
right now. The directory name changes as the version number changes.
For example, to find out what the calling sequence was for the
qbeta
function is, I did
find /APPS/src/R-2.2.1/src -name qbeta.c
It shows two copies of the same file (look at either), one of which is
A perusal of the source code shows the function signature
double qbeta(double alpha, double p, double q, int lower_tail, int log_p)
so the function takes 5 arguments (but we already knew that from looking
at Rmath.h
) and the argument names are a bit informative.
Looking at the on-line help for the
R function qbeta tells us the arguments are
TRUE
or FALSE
) that says whether
the lower tail or upper tail is wanted.
So that's how the example works.