[R] Fwd: Re: calling R's library using C
Dirk Eddelbuettel
edd at debian.org
Fri Mar 3 05:02:39 CET 2006
On 2 March 2006 at 19:37, Globe Trotter wrote:
| > Thanks for all the help. I thought I would clarify certain things. First, I
| > did
| > not read that section of the manual (no one provided the pertinent link),
I'd do it now. Really. Not later. *Now*. Like the Posting Guide recommends.
You may have heard of the sites www.r-project.org and cran.r-project.org. If
you look closely, you will discover a link 'Manuals' on the left. You'd be
surprised. All that you are griping about here is in Section 5.15 of the
'Writing R Extension' manual.
| > library (and define that MATH_STANDALONE), I get errors: in particular, it
| > would not recognize set_seed (which is a function which should work only if
No problem here -- see below for you altered program and output.
| > (English is not my strong suit, but I can follow there, I am sure): btw, I do
| > not have the /usr/share/doc/r-mathlib/ directory, nor is it anywhere on
| > my
Because you're on Red Hat, and I am on Debian.
| > system (as per the output to locate), I really thank you for all your help! I
| > am sure Professor Ripley would also appreciate your support.
He really doesn't need my help, but I am flattered by the suggestion.
Hope this helps, Dirk
edd at basebud:/tmp> cat globetrotter.c
#include<stdio.h>
#include<stdlib.h>
#define MATHLIB_STANDALONE 1
#include <Rmath.h>
int main(void) {
set_seed(42, 43);
printf("Random with fixed seed: %f\n", unif_rand());
printf("%f \n",pchisq(2.,7., 1, 0));
printf("%f \n",pnchisq(2.,7.,0., 1, 0));
return EXIT_SUCCESS;
}
edd at basebud:/tmp> gcc -o globetrotter globetrotter.c -lm -lRmath
edd at basebud:/tmp> ./globetrotter
Random with fixed seed: 0.692304
0.040160
0.040160
edd at basebud:/tmp> ./globetrotter
Random with fixed seed: 0.692304
0.040160
0.040160
edd at basebud:/tmp>
--
Hell, there are no rules here - we're trying to accomplish something.
-- Thomas A. Edison
More information about the R-help
mailing list