rcpp

How to create instances of S4 classes from R packages in Rcpp code

主宰稳场 提交于 2019-12-14 00:42:52
问题 I'm getting my feet wet with Rcpp trying to create an instance of a sparseMatrix from within Rcpp code. I understand that in order to create S4 objects we call the S4 constructor with the name of the desired class as a string, e.g.: S4 foo() { S4 s("dgCMatrix"); return s; } But in my case this fails with Error in getClass("dgCMatrix") : “dgCMatrix” is not a defined class I assume this is because the Matrix package has not been loaded? I have tried adding // [[Rcpp::depends(Matrix)]] as well

Rcpp: Is there an implementation fisher.test() in Rcpp [closed]

て烟熏妆下的殇ゞ 提交于 2019-12-13 23:24:17
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Is there an implementation of fisher.test for Rcpp? 回答1: There is no current implementation of the fisher.test function within Rcpp. A specific component of the test in the R function is written in C due to the computational intensity of it. You are more than welcome to reimplement the test in Rcpp. A few notes

Using `c++` class templates into `R`

僤鯓⒐⒋嵵緔 提交于 2019-12-13 22:32:42
问题 It's my first time taking a look at how to write wrap functions that allow me to interface with a class template I have created in c++, and I have a few questions. How do I use an Rcpp::depends attribute to declare dependencies on static libraries that I've created? I assume I'll need to specify a path somewhere, but all the examples here just refer to libraries that are well known. What are my options for R types I can use when I try to use this stuff in an R session? I have c++ classes that

Specifying Google perftools to g++ for using C++ in R

帅比萌擦擦* 提交于 2019-12-13 19:26:57
问题 I installed Google perftools (google-perftools 1.7-1ubuntu1), and add -lprofiler to PKG_LIBS in R, when compiling the C++ code. library(RcppArmadillo) library(Rcpp) Sys.setenv("PKG_CXXFLAGS"="-fopenmp") Sys.setenv("PKG_LIBS"="-fopenmp -lprofiler") sourceCpp('my.cpp') The output is: /usr/bin/ld: cannot find -lprofiler collect2: ld returned 1 exit status make: *** [sourceCpp_17496.so] Error 1 g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R

Compiling the Rcpp package

时光怂恿深爱的人放手 提交于 2019-12-13 19:24:44
问题 Background My company is thinking about bringing R into our work environment in conjunction with RStudio. As part of the security checks, we have to compile each of the different C/C++ files in a package to scan for possible security flaws. I know that the binaries are available, and I really wish that I could use them, but we have to compile ourselves. I have no R experience and a little experience with c++ from about 5 years ago. I'm trying to compile just the Rcpp C++ code and I don't know

Linking error of R package with Rcpp: “undefined symbol: LAPACKE_dgels”

大憨熊 提交于 2019-12-13 14:52:42
问题 I am creating an R package 'lapacker' to provide the C interface for internal LAPACK library provided and used by R (with double precision and double complex only) using the R API header file "R_ext/Lapack.h". The source code: https://github.com/ypan1988/lapacker/ And the project structure: /lapacker /inst /include /lapacke.h /someother header files /R /zzz.R /src /lapacke_dgetrf.c /lapacke_dgetrf_work.c /loads of other utility functions provided by LAPACKE /rcpp_hello.cpp DESCRIPTION

correctly registering a plugin to use Eigen via Rcpp

偶尔善良 提交于 2019-12-13 14:35:11
问题 I'm trying to be able to use a c++ class template in R . This was my first try at a small reproducible example. library(inline) library(Rcpp) inc <- "#include <Eigen/Dense> template <size_t dim> class SillyWrapper { public: Eigen::Matrix<double,dim,1> m_vec; SillyWrapper(const Eigen::Matrix<int,dim,1>& vec) : m_vec(vec); };" src <- 'SillyWrapper mything(Rcpp::as<Eigen::Map<Eigen::Matrix<double,dim,1>>>(x));' library(inline) fun <- cxxfunction(signature(x="numeric"), body=src, includes=inc,

Rcpp R sample equivalent from a NumericVector

拥有回忆 提交于 2019-12-13 08:53:47
问题 I have created a NumericVector and I need to sample one random Integer from it. I tried to use various RcppArmarillo functions but it failed to works for me. The function is below: //#include <algorithm> #include <RcppArmadilloExtensions/sample.h> using namespace Rcpp; using namespace arma; using namespace std; int simulateNextStepC(double currentAmount, double lastPaid, int currentStatus, int currentMaturity, NumericMatrix amountLinkMatrix, NumericMatrix statusMatrix, double

Function not available for .Call using Rcpp.package.skeleton() and compileAttributes [closed]

陌路散爱 提交于 2019-12-13 08:17:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am trying to follow closely the directions in the Rcpp package documentation, but I am getting the error Error in .Call("MicroCreditLRVBR_TestJacobian", PACKAGE = "MicroCreditLRVBR") : "MicroCreditLRVBR_TestJacobian" not available for .Call() for package "MicroCreditLRVBR" The package framework was built with

C++ / R: RInside in Windows 7 machine

你说的曾经没有我的故事 提交于 2019-12-13 06:55:13
问题 This question is related to: C++ and R: Create a .so or .dll plus i have read the questions and replies of these posts: Compiling RInside programs on Windows Problem with compiling RInside examples under Windows I try to run the code provided as an example in the answer provided #include <RInside.h> // for the embedded R via RInside #include <iomanip> int main(int argc, char *argv[]) { RInside R(argc, argv); // create an embedded R instance std::string txt = // load library, run regression,