[R] Fwd: Re: calling R's library using C
Globe Trotter
itsme_410 at yahoo.com
Fri Mar 3 06:04:58 CET 2006
> 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.
Of course! Thanks! I did look at this some years ago: there were no examples
then (that I could decipher, at least) and so it is time to look again!
> No problem here -- see below for you altered program and output.
Thanks; I did figure it out, before I sent the e-mail. (I was just relating my
Thursday experiences.) But thanks! It validates exactly, what I did (except
that I used runif, which actually calls unif_rand(). Fabulous!!
Thanks a lot again, Dirk! This has, really really helped!!
Best wishes!
>
> | > (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