Questions tagged [rcpp]

Rcpp provides seamless integration of C++ code in R.

Rcpp is an package allowing integration with code. R data types (SEXP) are matched to C++ objects in a class hierarchy. All R types are supported and each type is mapped to a dedicated class.

Repositories

Vignettes

Books

Other resources

Related tags

3011 questions
1
vote
0 answers

R non-standard evaluation : get promise value while leaving it unevaluated [or: keep external pointer valid...]

This a follow-up to Parallelize function taking external pointers (XPtr) I won't reproduce the Cpp code here to make things shorter. The problem was to that once a parameter of a function is evaluated, it is defined in the function's environment…
Elvis
  • 548
  • 2
  • 14
1
vote
1 answer

dqrng with Rcpp for drawing from a normal and a binomial distribution

I'm trying to learn how to draw random numbers from a normal and a binomial distribution from within a Rcpp OpenMP loop. I wrote the following code using R::rnorm and R::rbinom which I understand to be a be a don't do that. #include…
Ignacio
  • 7,646
  • 16
  • 60
  • 113
1
vote
1 answer

How to set a default value for a SEXP parameter in Rcpp

I have a Rcpp function that has an optional argument which is the maturity of a financial instrument. This can be given as a string (e.g. "2y") or as a integer. If no value is given, the function needs to use a default integer. How can I set the…
JLG
  • 37
  • 6
1
vote
1 answer

r aborted when using rcpp

I am writing some code, and when running, it aborted. The r version is 3.5.1. I think there is something wrong with my rcpp code, but I can't find it. It just shows R session aborted. ################I don't think there is anything wrong in this…
S.Shen
  • 23
  • 3
1
vote
0 answers

Finding C source code for cor() function in R stats package

I am looking to find the C source code for the cor() function in the R Stats package. I've done some digging but I have hit a wall. Looking at the source code on GitHub (https://github.com/SurajGupta/r-source/blob/master/src/library/stats/R/cor.R) I…
user11035327
1
vote
1 answer

Rcpp import list / dataframe from R with a large number of variable

I am new to Rcpp programming and I cannot figure out a very basic thing. I am trying to import an large list from R to c++. I am using Rcpp. The list I have contains about 400,000 rows and 50 columns. I am recreating a smaller version of it here for…
Prometheus
  • 673
  • 3
  • 25
1
vote
0 answers

Best way to access C++ class members from R using Rcpp

I have a simulation model which is written as a C++ class. I have written a simple Rcpp wrapper to allow it to be run from R. I am wondering about the best way to get and set the model properties (doubles, vectors of doubles, and vectors of vectors…
Simon Woodward
  • 1,946
  • 1
  • 16
  • 24
1
vote
0 answers

Exploiting symmetry in Armadillo

Is there any way to exploit the fact that the resulting matrix in Armadillo is symmetric? I often have products of the form A * B * A.t() (where B is symmetric and positive definite) and I wonder if there is some way to do the multiplication faster…
hejseb
  • 2,064
  • 3
  • 18
  • 28
1
vote
1 answer

Rcpp function complaining about unintialized variables

In a very first attempt at creating a C++ function which can be called from R using Rcpp, I have a simple function to compute a minimum spanning tree from a distance matrix using Prim's algorithm. This function has been converted into C++ from a…
maurobio
  • 1,480
  • 4
  • 27
  • 38
1
vote
1 answer

Odd SHLIB behavior while compiling and linking an R package with cpp code

I am compiling an R package containing .cpp source files from a third party. To compile the .cpp files into a static library, I am using the Makevars.win file (link). I stumbled upon an odd behavior of SHLIB on Windows only, while trying to fix…
Satya
  • 1,708
  • 1
  • 15
  • 39
1
vote
1 answer

Iterate over vectors from an imported dataframe row-wise

Im trying to make the switch from R to c++ coding. If you choose to down vote this question, at the very least patronize me with an answer so I can learn something. My question is how am I supposed to approach row-wise calculations in c++ once I…
Phil_T
  • 942
  • 9
  • 27
1
vote
0 answers

Double sum in Rcpp

I have to calculate this double sum in Rcpp: . Here, "t" and "m" are variables. "beta", "c" and "p" are the parameters. For which I wrote the following code. The first code is the functor which I am going to integrate. The second code is used for…
gultu
  • 143
  • 10
1
vote
0 answers

Rcpp: passing native c++ functions as arguments?

I'm writing a function where there is a binary operation running at the deepest level. Writing this function in Rcpp gave me a huge performance improvement for a fixed binary operation (+ for example), but when I try to find ways to generalize it…
VFreguglia
  • 2,129
  • 4
  • 14
  • 35
1
vote
0 answers

RcppNumerical gives completely different integration results than R

I have a Rcpp file where I am trying to integrate the function- f<- function(x){dexp(x-a,beta)} . Where a=2 and beta=1.2. The file looks like- // [[Rcpp::depends(RcppEigen)]] // [[Rcpp::depends(RcppNumerical)]] #include…
Geotas
  • 35
  • 6
1
vote
1 answer

Installing R library: undefined symbol

I have a working C++ library and I'm trying to expose a function to R through Rcpp, I have the following directory setup ├── CMakeLists.txt ├── DESCRIPTION ├── install_log.txt ├── LICENSE ├── mock_data.csv ├── NAMESPACE ├── R │   └──…
mariob6
  • 469
  • 1
  • 6
  • 16
1 2 3
99
100