similar to: R-functions in C-Code

Displaying 20 results from an estimated 7000 matches similar to: "R-functions in C-Code"

2011 Jan 20
1
Calling C++ from R
Hi All, I am new to this area and use Rcpp to call C++ from R and try to build the package under Windows 7. I use Rtools and R 2.10.1 32bit. Everything works fine with me, except using R functions like "rnorm" or "runif" in the C++ code. When I use "R CMD check" the package, it always return error ** libs making DLL ... g++
2012 Jul 14
2
rgamma function
Hi, Has anyone encountered the problem of rgamma function in C? The following simplified program always dies for me, and I wonder if anyone can tell me the reason. #include <Rmath.h> #include <time.h> #include <Rinternals.h> SEXP generateGamma () { srand(time(NULL)); return (rgamma(5000,1)); } Has anyone encountered a similar problem before? Is there another way
2013 Apr 11
1
La_svd compiler error
Dear All, I have been trying to compile a package for windows that we have written. Since R version 3.0.0 the package doesn't compile any more. (On Linux the package compiles without errors). The error specifically says: gcc -m32 -I"C:/PROGRA~1/R/R-30~1.0/include" -DNDEBUG -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O3 -Wall -std=gnu99 -mtune=core2 -c
2012 Nov 09
3
Crash - cause 'memory not mapped'
i'm using the following c++ code using namespace std; #include <iostream> #include <stdio.h> #include <opencv/cv.h> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv/highgui.h> #include <opencv/cv.h> #include <R.h> #include <Rinternals.h> #include <Rmath.h> extern "C" { SEXP
2010 Jun 18
3
C interface
Greetings, I am trying to call simple C-code from R. I am on Windows XP with RTools installed. The C-function is #include <R.h> #include <Rinternals.h> #include <Rmath.h> #include <Rdefines.h> // prevent name mangling extern "C" { SEXP __cdecl test(SEXP s){ SEXP result; PROTECT(result = NEW_NUMERIC(1)); double* ptr=NUMERIC_POINTER(result); double t =
2009 Jan 27
1
uninitialised value in R (PR#13476)
Hi, I get an "Conditional jump or move depends on uninitialised value(s)" from valgrind when using 'solve' in combination with some simple C-code. (I did not use other functions of R besides 'solve'.) In detail: running R --vanilla -d "valgrind --tool=memcheck --memcheck:leak-check=yes --num-callers=20 " and calling .Call("XXX") nd <- 3
2010 Jun 18
4
C Interface
Greetings, I am trying to call simple C-code from R. I am on Windows XP with RTools installed. The C-function is #include <R.h> #include <Rinternals.h> #include <Rmath.h> #include <Rdefines.h> // prevent name mangling extern "C" { SEXP __cdecl test(SEXP s){ SEXP result; PROTECT(result = NEW_NUMERIC(1)); double* ptr=NUMERIC_POINTER(result); double t =
2006 Jun 29
1
using "rbinom" in C code gives me erroneous results... random variable is not random (always zero)...
Dear Listers, I am trying to use "rbinom" in my C code, but i always get zeros as output no matter the probability. Am not sure what I am doing wrong because the function has worked before. Attached in an example. Noticed that "rbinom" expects 'n' to be REAL. Regards, Vumani R 2.3.1 (2006-06-01) Windows XP Gcc /* Called this file binom.c and then ran rcmd shlib on it
2010 Jun 15
1
Error when callin g C-Code
Hi when I call the function below in R, i get the error: Object 'pairlist' can't be converted to 'double'. #include <R.h> #include <Rdefines.h> #include <Rmath.h> SEXP CSimPoisson(SEXP lambda, SEXP tgrid, SEXP T2M, SEXP Ni, SEXP NT) { double sign, EVar; double *xlambda, *xtgrid, *xT2M, *xNi, *xNT, *xtau; SEXP tau; int ltgrid =0; int i = 0; int j = 0;
2007 Apr 03
3
Strange number produced by dnorm
Hi All, I just started to learn compiling C codes for R usage, and got a problem when I was playing with my 'hello world' code. #include <R.h> #include <Rdefines.h> #include <Rmath.h> SEXP test( ) { double x; x=dnorm(1.0,0.0,1.0,1); printf(" x value is: %d \n",x); return(R_NilValue); } I got the result : x value is: -466460838 Could
2009 Sep 07
1
Usage of OCaml/R binding.
Hello. I've been pulling together a Debian package out of Maxence Guesdon's OCaml bindings for R. Will be available from my website as soon as I get my router to obey me. Here's Maxence's bindings: http://pauillac.inria.fr/~guesdon/ocaml-r.en.html The purpose of this software is to access R from OCaml programs. However, my issue is that after having pulled things to a Debian
2009 Sep 07
1
Usage of OCaml/R binding.
Hello. I've been pulling together a Debian package out of Maxence Guesdon's OCaml bindings for R. Will be available from my website as soon as I get my router to obey me. Here's Maxence's bindings: http://pauillac.inria.fr/~guesdon/ocaml-r.en.html The purpose of this software is to access R from OCaml programs. However, my issue is that after having pulled things to a Debian
2008 Jan 02
1
setting the seed in standalone code using Rlib
Hi, Is the below -- setSeed -- an okay way to set the seed in standalone applications making use of Rlib? It seems to work as expected. Is there a better way to do it? (I'm also looking at do_setseed but am unsure what to supply as op. findFun("set.seed", R_GlobalEnv)?) Thanks much. -- David Faden, dfaden at iastate.edu AIM: pitulx -- #include <assert.h> #include
2016 Jul 01
1
Calling C implementations of rnorm and friends
Well, For this particular use case why not just transform the parameters at the R level and then call the existing function? Is there not a closed form mapping? ~G On Jul 1, 2016 2:50 PM, "Joshua Ulrich" <josh.m.ulrich at gmail.com> wrote: > On Fri, Jul 1, 2016 at 6:13 AM, Luis Usier > <luis.henrique.usier at gmail.com> wrote: > > Gabriel, > > > >
2006 Mar 07
2
double pointer matrix
Hello, I'm having some difficulty to understand how I could take the proper result from the following listing: -- cut --- #include <stdlib.h> #include <R.h> #include <Rmath.h> void retMat ( double **y, int *n, int *m, double *a, double *b) { int i, j; y = malloc( (*n) * sizeof( double ) ); for (i=0; i<*n; i++) { y[i] = malloc (
2007 Jul 04
1
Calling C Code from R
Hi R Users, Thanks in advance. I am using R-2.5.1 on Windows XP. I am trying to call C code (testCX1.C) from R. testCX1.c calls another C code (funcC1.c) and returning a value to testCX1.c. I like to have this value in R. My steps are below: 1. R CMD SHLIB testCX1.c funcC1.c (at command propmt) 2. It creates testCX1.dll with warning (but testCX1.dll works):
2008 Oct 11
1
defines in Rmath.h and R_NO_REMAP
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi, I'm programming with R 2.7.2 and had some trouble including Rmath.h for its random variates generation routines: Although I define R_NO_REMAP (which works fine for Rinternals.h stuff), Rmath.h defines "beta" as "Rf_beta" etc., so that my "beta" strings get redefined as well! Is this a feature? I found an old
2007 Jan 04
1
Parameter changes and segfault when calling C code through .Call
I am experiencing some odd behavior with the .Call interface, and I am hoping someone out there can help me with it. Below is a simple example (in that there are R packages that do exactly what I want), but this code illustrates the problem. Thanks in advance for any help you can provide. Suppose I want to compute the log density of a multivariate normal distribution using C code and the gsl
2011 Aug 04
1
How to seed the R random number generator in C (standalone) with an instance of .Random.seed
hello all, I use the R standalone math library in my own C program, and the default R random number generator can be seeded with set_seed(const unsigned int, const unsigned int). How could I seed the RNG with an instance of .Random.seed ? I would need this or a similar workaround for debugging purposes. More precisely, I use the default R random number generator to sample from various
2016 Jul 01
2
Calling C implementations of rnorm and friends
Gabriel, Thanks for that! I guess I really should have figured that one out sooner, huh? I understand why that wouldn't be CRAN-compliant. But then, what *is* the proper way to do it? Is there any way I can call unexported functions from another package and have it accepted by CRAN? Also, if I instead re-write the random variable generating functions, do you have any idea of where the