Questions tagged [rcpp]
Rcpp provides seamless integration of C++ code in R.
2,864
questions
3
votes
1
answer
56
views
Efficiency of Rcpp sample v. C++ shuffle
I'm trying to optimize an algorithm for R. Initially, I wrote the algorithm using Rcpp (and Rcpp vectors, etc.) but subsequently rewrote it using standard C++ vectors and only translating it to Rcpp ...
0
votes
0
answers
22
views
Older RcppEigen Package does not install
I need an older RcppEigen package for a school project but it does not install on R. Can anyone help me?
This is the beginning of the error
devtools::install_version("RcppEigen", "0.3.3....
1
vote
1
answer
34
views
Detecting R Version in Rcpp/arrayfire in makevars
I am new to building R packages so I need some help :) I am using Rcpp/arrayfire and want a line in my makevars file to detect the users R version. Currently I have it set in 4.0, but I anticipate ...
0
votes
1
answer
39
views
How to return objects of different types from RcppArmadillo function
l would like to return objects of different types from the function RcppArmadillo.
For example, below is a code where I've tried returning both a vector and function using std::tuple.
#include <...
0
votes
0
answers
25
views
RcppEigen install failure on Ubuntu 18 LTS: warning: ignoring attributes on template argument ‘__m128’
I think this question is a duplicate: RcppEigen install failure on Ubuntu 20.04: warning: ignoring attributes on template argument ‘__m128’
However I don't think the solution proposed will work for me ...
0
votes
0
answers
41
views
How to prevent Rcpp to change some value in R?
I have this C++ function:
std::vector<std::vector<size_t>> list_to_faces(const Rcpp::List L) {
const size_t nfaces = L.size();
std::vector<std::vector<size_t>> faces;
...
0
votes
0
answers
17
views
How can I find readxl and Rcpp files that I downloaded in the Drive C? [duplicate]
I downloaded readxl and Rcpp from cran.rstudio.com.
They've been downloaded to drive C - C:\Users\PC\AppData\Local\Temp\RtmpCwI2AP\downloaded_packages
It was after downloading that I saw that my ...
-1
votes
0
answers
62
views
Install R package: library not found for -lgfortran
I am a Windows user. I build my own R package based on Rcpp and RcppArmadillo. I put it on my GitHub, and I install it using the codes:
devtools::install_github("RunzhiZ/asmbPLS")
I and all ...
0
votes
0
answers
25
views
In Rcpp function ```rdunif`` never choses a particular matrix entry
I wrote the following code in c++ to use it in R through Rcpp
#include <RcppArmadilloExtensions/sample.h>
#include <math.h>
#include<Rmath.h>
using namespace Rcpp;
// [[...
0
votes
0
answers
24
views
Error while installing the library from source due to RcppExports
I have created my own R package for my company but for some of the users, when they install the package, they are facing the following issue:
make: stat: equipped.dll: Too many levels of symbolic ...
0
votes
1
answer
44
views
RCPP and R discrepancy
I'm new to C++ programming and apologize if my solution is in plain sight. I am attempting to use RCPP to speed up a slow R function. I think I've narrowed down the issue to a nested for loop. I've ...
0
votes
0
answers
65
views
To build Rcpp package, how to call my R function (not from R package) in my Rcpp function
I am trying to build a Rcpp package. In my Rcpp function, I am trying to call the R function written by myself (not from any package, for here sum_matrix_row for example) in my Rcpp function. For that ...
1
vote
2
answers
143
views
Subtract extremely small number from one in C++
I need to subtract extremely small double number x from 1 i.e. to calculate 1-x in C++ for 0<x<1e-16. Because of machine precision restrictions for small enoughf x I will always get 1-x=1. ...
0
votes
1
answer
40
views
check boolean expression in dataframe Rcpp (C++)
I have a dataframe dat with data and a vector rule with logical rules
set.seed(124)
ro <- round(runif(n = 30,1,10),2)
dat <- as.data.frame(matrix(data =ro,ncol = 3)) ; colnames(dat) <- paste0(...
0
votes
1
answer
60
views
Rcpp and parallel
I have an Rcpp routine that is given an R function and then does various computations. When run as such it works just fine. Now I want to run it in parallel, and then I get the error
Error in ...
0
votes
0
answers
16
views
Rcpp package doesn't include Rcpp_precious_remove | can't fix the error [duplicate]
I'm trying to use the gtrendsR package and when I want to execute it, I get the error message:
Error in connection_connect(dbname, loadable.extensions, flags, vfs, extended_types) : function '...
0
votes
0
answers
38
views
Error in dyn.load(dll_copy_file) when building Rcpp package on Mac
I'm building my own Rcpp Package (name: RUtilities) on Mac. However, I encountered the following error when executing devtools::document()
** checking absolute paths in shared objects and dynamic ...
1
vote
0
answers
36
views
Scale the columns of an RcppArmadillo matrix using lambda function [duplicate]
I want to min-max the columns of a matrix using RcppArmadillo and a lambda function, without using a for loop. I have tried this in the code below but this just returns the original matrix. How to ...
0
votes
0
answers
24
views
Why armadillo changed after including RcppArmadillo?
I'm working on a RcppArmadillo package. Most part of my algorithm myfun() is implemented in a C++ source file, called myfun.cpp with a header file myfun.h providing some declarations. My algorithm is ...
0
votes
1
answer
98
views
'Rcpp_precious_remove' when trying to run regression [duplicate]
I am trying to run a multilevel regression model when I get this error message in R
Error in initializePtr() :
function 'Rcpp_precious_remove' not provided by package 'Rcpp'
This has only started ...
1
vote
1
answer
32
views
Invoke the element in `Rcpp::List` for futher use directly
In an application, I use List to contain some variables (double, arma::mat and other types), and then take the arma::mat component in this list for futher use directly, such as matrix addition. ...
0
votes
1
answer
31
views
Rcpp Unexpected NaN results
I have a complicated equation with lots of pow's and was getting a NaN result. So I broke it into pieces, called temp1 to temp4. temp4 which is pow(temp3, 0.25) is where I get a nan which then results ...
0
votes
1
answer
41
views
AnnotationHub installation ‘Rcpp’ 1.0.6 is already loaded, but >= 1.0.7 is required [duplicate]
I am currently trying to install AnnotationHub but I am running into problems. I use R 4.0.4, renv (version 0.15.4) and BiocVersion 3.12.
When I run BiocManager::install("AnnotationHub"), I ...
1
vote
3
answers
284
views
sourceCpp error: not mach-o or a static library file '/usr/local/lib/libgfortran.dylib'
I've long been a user of RcppArmadillo, but have been unable to compile any programs via sourceCpp since upgrading my OS to Monterey Version 12.3.
Getting the following error:
ld: malformed universal ...
0
votes
1
answer
37
views
Why cpp diagnostics and code completion stopped working in RStudio?
I have been using Rcpp and RcppArmadillo for quite some time now and I love it! The feasibility of my research projects was boosted thanks to much faster computation performed using cpp code in R!
A ...
0
votes
2
answers
59
views
How can I get R to modify this matrix in place after a call to fastLmPure?
I'm trying to run fastLmPure in a loop, avoiding copying a large matrix.
I've pre-allocated the matrix to the size I need, and it's only the last column I need to change values in. i.e. it doesn't ...
1
vote
0
answers
64
views
Rcpp with OpenMP Check fail due to registration problems
I am building a R package using Rcpp and OpenMP. When doing the CRAN check, I get Notes leading to errors when building. Suggestions from RcppGallery, Stackoverflow, Writing R Extensions and exemplary ...
0
votes
0
answers
25
views
Keeping C++ source code for profiling when installing R package
I've been struggling to profile C++ code within an R package I'm writing on Windows 10, despite the existence of many excellent resources.
I'm building the package with G++ 8.3.0 using -Og -g -fpic -...
0
votes
1
answer
96
views
R fail to find GSL library while installing package
I am installing a package from the Supplementary materials of an academic journal (https://www.degruyter.com/document/doi/10.1515/snde-2012-0064/html?lang=en).
I've set the Windows system environment ...
0
votes
0
answers
72
views
r rcp how to debug segfault on a mac with apple silicon
Background. I have some R code that uses terra and Rcpp code on a Mac with Apple Silicon and runs over large climate data sets. The code runs through these data year by year. It fails randomly with a ...
0
votes
0
answers
41
views
Using Rcpp to create boxplots from a data frame
I have a data set that contains 11 variables and 4177 observations. I am trying to create rcpp functions to determine the five number summary (min, max, median, first quantile, third quantile) in r. I ...
0
votes
0
answers
22
views
Floor_data function only runs with the argument "days" [duplicate]
This is my first post so my apologies if I'm doing it wrong.
When trying to run the floor_date function on a line of code like this
group_by(week=floor_date(date, "week")) %>%
This ...
1
vote
1
answer
40
views
How to retain symbol tables in DLL built from C++ in R
I am trying to profile C++ code that is part of an R package, using 64-bit Windows 10 and R4.1.2.
I've used PKG_CXXFLAGS = -g to retain debugging information, but I also need to retain the symbol ...
0
votes
0
answers
40
views
Unable to compile custom library with SourceCPP/ Rcpp
Trying to compile a custom function using SourceCPP but not having any luck.
Always the same error message, which isnt very insightful. if anyone has any ideas of what i can try i'd be very grateful!
...
0
votes
0
answers
56
views
R package: Error appears not in Windows but in Linux
guys.
I am currently trying to build an R package (using rcpp). By this suggestion, I encountered an error, which was fixed by putting the following line in src/Makevar and/or src/Makevar.win.
...
0
votes
1
answer
53
views
An error with a three dimensional field (of vectors) in rcpp armadillo
I am trying to create a field in rcpp arma due to more than three iterations, but got an error. As an example, see the following simple code:
//[[Rcpp::export]]
field<vec> testgg(int k, int h, ...
0
votes
1
answer
43
views
Rcpp wrapper for algorithm to generate r x c contingency tables
I'm trying to use this C++ implementation of an algorithm for efficiently generating r x c contingency tables with fixed margins: https://people.sc.fsu.edu/%7Ejburkardt/cpp_src/asa159/asa159.html
I'm ...
2
votes
1
answer
465
views
how to update R Rcpp to versions > 1.7
I am trying to update Rcpp from 1.0.6 to 1.0.7 or 1.0.8. The Rcpp update is essential for a primary R library that I intend to use.
I looked at the documentation and tried to install Rcpp using:
...
0
votes
0
answers
77
views
C++ toolchain on macOS Monterey m1 chip [duplicate]
I am trying to get R and Rstudio up and running on my m1 MacBook with monterey 12.2. I have had a lot of problems with different ways of trying to install the c++ toolchain but this great answer ...
2
votes
2
answers
56
views
Poisson draw in Rcpp and R different results
I face the following contradiction when I use the same code in R and in Rcpp
In R I run the following code
t = 0
for(i in 1:50){
t = t + rpois(1, 0.5)
}
t
[1] 28
and I take back a value t which is ...
0
votes
0
answers
38
views
Segfault when running R callback function from C++ after completing a task on a background thread
The following code (seems to) work as expected, but I receive a segfault if I remove the PROTECT call or if I remove the second member expr of struct func_data.
This seems like it could be related to ...
0
votes
0
answers
44
views
GDB crashed in VSCode on Ubuntu
I'm trying to debug Rcpp on Ubuntu 18.04. I followed the https://github.com/renkun-ken/vscode-rcpp-demo.
I installed R and VSCode and required packages all. When I run without debug, it works well. ...
0
votes
0
answers
41
views
Trouble compiling via Rcpp - headers not recognized?
I just finished re-installing both Xcode and CLT on my Mac running Big Sur 11.4. I'm working in RStudio Version 1.4.1717 with R 4.1.1
I then ran devtools::has_devel() to ensure things were installed ...
1
vote
1
answer
78
views
Rcpp: Calculation in loop stops with error "Not a matrix"
in an R script I source a cpp file to make some calculations. In that R script, a function defined in the cpp file is called and a matrix and an integer is provided. After a few rounds through the ...
-1
votes
1
answer
93
views
Missing import(Rcpp) in NAMESPACE leads to C++ library error during R CMD check of tests
Summary
I am working on an R package that uses Rcpp. I took over the project with many issues and I am trying to fix them. The problem with this is that I don't know how to create a minimal example ...
1
vote
1
answer
208
views
Rcpp compile issue in Rstudio
I face an error when compiling an simple rcpp code.
Rcpp::sourceCpp(code = '
#include <RcppArmadillo.h>
#ifdef _OPENMP
# include <omp.h>
#endif
// [[...
-2
votes
1
answer
45
views
Rcpp Armadillo package compilation "error: incorrect or unsupported type" when trying to convert a
I have the latest version of R, RCppArmadillo and RStudio installed. I started a brand new R project using Rcpp with Armadillo, and created a single new cpp file called rcpparma_basic.cpp.
This is the ...
0
votes
0
answers
54
views
How to create variables automatically in for-loop in Rcpp?
I try to create variables automatically in for loop in Rcpp.
I can do it in R with the following codes (example):
for (i in 1:4) {
eval(parse(text = paste0("E_", i, "<- matrix(&...
0
votes
1
answer
286
views
Rcpp does not compile on Mac OS Monterey, R 4.1.2., clang error
Trying to get Rcpp to work on R 4.1.2 on Mac OS Monterey using an Intel computer.
> library(Rcpp)
> evalCpp("2 + 2")
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/...