Rcpp function cannot be found by R

I built an R package (called myUtils), which uses a cpp file, in RStudio following Hadley's manual. My cpp file resides in the src directory, created after running: devtools::use_rcpp(), and under my R directory I have a file called myUtils.R, with t...
more »

2017-12-02 22:12 (1) Answers

Rcpp isn't finding Boost headers

I have a file called src/windows.cpp (windowing functions for vectors, nothing to do with MS Windows!) in an R package project. The top of the file looks like this: // [[Rcpp::depends(BH)]] // [[Rcpp::plugins(cpp11)]] #include <Rcpp.h> #incl...
more »

2017-11-01 22:11 (1) Answers

Group vector on conditional sum

I want to group a vector based on the sum of the elements being less than or equal to n. Assume the following, set.seed(1) x <- sample(10, 20, replace = TRUE) #[1] 3 4 6 10 3 9 10 7 7 1 3 2 7 4 8 5 8 10 4 8 #Where, n = 15 The ...
more »

2017-08-07 16:08 (2) Answers

Mac: Removing compilers and starting from scratch

I have been coding with Rcpp and RcppArmadillo for the last 3 years. At some point I had installed additional compilers (gcc / gfortran) over the Xcode Command Line tools. Since then I haven't been able to install RcppArmadillo without compiling R fr...
more »

2017-07-01 12:07 (1) Answers

Rcpp function inside data.table join

Question Why does my Rcpp function inside a data.table join produce a different (& incorrect) result compared to when used outside of a join? Example I have two data.tables, and I want to find the Euclidean distance between each pair of coordi...
more »

2017-06-09 01:06 (1) Answers

Compiling multiple source files in Rcpp

I have the following directory structure my_func - my_func_r.cpp - my_func.c - my_func.h - my_func_test.c - matrix/ - matrix.h - matrix.c The matrix directory contains some matrix structures in matrix.h and some ini...
more »

2017-05-06 13:05 (1) Answers

How to compute rowSums in rcpp

I'm converting an R function into Rcpp, where I have used the R function rowSums, which appears to not be a valid sugar expression in Rcpp. I found code for an Rcpp version of rowSums here. But I'm getting error: use of undeclared identifier w...
more »

2017-01-31 01:01 (1) Answers

S4 object with a pointer to a C struct

I have a third-party C library I am using to write an R extension. I am required to create a few structs defined in the library (and initialize them) I need to maintain them as part of an S4 object (think of these structs as defining to state of a co...
more »

2016-12-18 17:12 (1) Answers

Can't use Rcpp engine in R Markdown

I tried to Knit HTML the following Rmd file: --- title: "Untitled" author: "Florian Privé" date: "12 septembre 2016" output: html_document --- ```{r fibCpp, engine='Rcpp'} #include <Rcpp.h> // [[Rcpp::export]] int fibonacci(const int x) { ...
more »

2016-09-12 20:09 (2) Answers