Displaying 20 results from an estimated 9000 matches similar to: "Writing own simulation function in C"
2020 Sep 06
8
some questions about R internal SEXP types
Hello,
I am writing an R/Go interoperability tool[1] that work similarly to
Rcpp; the tool takes packages written in Go and performs the necessary
Go type analysis to wrap the Go code with C and R shims that allow the
Go code to then be called from R. The system is largely complete (with
the exception of having a clean approach to handling generalised
attributes in the easy case[2] - the less
2009 Jan 08
1
Callbacks seems to get GCed.
Dear list,
I am trying to implement a publish-subscribe mechanism in for an embedded
R interpreter. But somehow my registered closures seem to get collected by
the GC, even though I have protected them. I have reducted my code to the
following sample. Sorry if it is a little verbose.
The first couple of call of calls still work, but at some point one of the
callbacks (callback1 in my
2009 Mar 03
1
profiler and loops
Hello,
(This is follow up from this thread:
http://www.nabble.com/execution-time-of-.packages-td22304833.html but
with a different focus)
I am often confused by the result of the profiler, when a loop is
involved. Consider these two scripts:
script1:
Rprof( )
x <- numeric( )
for( i in 1:10000){
x <- c( x, rnorm(10) )
}
Rprof( NULL )
print( summaryRprof( ) )
script2:
2011 May 04
2
Is this confict of different versions of R or something else?
Hello!
I have had some problems lately with use of R at home and school. At my home
laptop (Ubuntu linux 64bit & R-2.12.0) R works just fine. But when I take my
codes to school(Windows XP 32bit & R-2.10.1 I think) and run those there
those codes probably won't work. Functions as combinations() didn't work and
expand.grid() worked a bit differently. About expand.grid I just
2011 Mar 23
2
Standalone C++ application for processing R parser output(SEXP)
Hi All,
I am trying to write a source-to-source compiler for R. I am trying to
leverage the R parser code for the purpose. I am trying to transform the
SEXP returned from the parser into an AST for our own Ruby embedded Domain
specific language.
I tried using R CMD SHBIN to compile a C function that parses arbitrary R
expressions. But I think, the generated .so file can be used from within R
and
2009 Dec 16
2
What is the fastest way to see what are in an RData file?
Currently, I load the RData file then ls() and str(). But loading the file
takes too long if the file is big. Most of the time, I only interested what
the variables are in the the file and the attributes of the variables (like
if it is a data.frame, matrix, what are the colnames/rownames, etc.)
I'm wondering if there is any facility in R to help me avoid loading the
whole file.
2013 Aug 27
1
Error in simulation. NAN
Hi all,
im triyng to implement a bayesian model with R and c++.
I have a strange problem. I can't reproduce the error with a small
script and then i post the original one.
The problem is after the line
for(MCMC_iter2=0;MCMC_iter2<thin;MCMC_iter2++)
For the first 34 iterations all work fine, after, all the simulations
of mu_acc_P return an "nan". If i delete the line
2009 Sep 29
3
How do I access class slots from C?
Hi
I'm trying to implement something similar to the following R snippet using
C. I seem to have hit the wall on accessing class slots using C.
library(fPortfolio)
lppData <- 100 * LPP2005.RET[, 1:6]
ewSpec <- portfolioSpec()
nAssets <- ncol(lppData)
setWeights(ewSpec) <- rep(1/nAssets, times = nAssets)
ewPortfolio <- feasiblePortfolio(
data = lppData,
spec = ewSpec,
2005 Oct 31
1
R-functions in C-Code
Dear R users,
I would like to use several R functions from a C-code and I have read the "Introduction to the .C Interface to R". Unfortunately, my shared library with the C-code works only in cases where I use R-routines that are defined Rmath.h, eg.
*************************************
less test.c:
#include <R.h>
#include <Rinternals.h>
#include <Rmath.h>
void
2008 Apr 05
2
Adding a Matrix Exponentiation Operator
Hi all
I recently started to write a matrix exponentiation operator for R (by
adding a new operator definition to names.c, and adding the following code
to arrays.c). It is not finished yet, but I would like to solicit some
comments, as there are a few areas of R's internals that I am still feeling
my way around.
Firstly:
1) Would there be interest in adding a new operator %^% that performs
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 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
2020 Feb 26
1
Profiling: attributing costs to place of invocation (instead of place of evaluation)?
Hi
Consider the following example:
f <- function(expr) g(expr)
g <- function(expr) {
? h(expr)
}
h <- function(expr) {
? expr # evaluation happens here
? i(expr)
}
i <- function(expr) {
? expr # already evaluated, no costs here
? invisible()
}
rprof <- tempfile()
Rprof(rprof)
f(replicate(1e2, sample.int(1e4)))
Rprof(NULL)
cat(readLines(rprof), sep = "\n")
#>
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
2006 Jun 03
3
More on bug 7924
Hi,
Again, sorry for the length of this post. Once I get my new office I
will get a website set up on my work machine and will simply post a
link to the log since I doubt many people are truly interested in
these logs.
To further analyze what is happening, I added my own routine in
main.c called DEBUG_SET_NAMED and then redefined the SET_NAMED macro
to use it and then rebuilt R.
I
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;
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
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
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