rcpp

Apply function to multiple groups using Rcpp and R function

倖福魔咒の 提交于 2019-12-25 03:22:56
问题 I'm trying to apply a function to multiple groups/id's in r using the foreach package. It's taking forever to run using parallel processing via %dopar% , so I was wondering if it's possible to run the apply or for loop portion in c++ via rcpp or other packages to make it faster. I'm not familiar with c++ or other packages that can do this so I'm hoping to learn if this is possible. The sample code is below. My actual function is longer with over 20 inputs and takes even longer to run than

Calling QuantLib from R through Rcpp

北战南征 提交于 2019-12-25 03:06:53
问题 Preliminary steps QuantLib was installed along with Boost and built following these instructions in Microsoft Visual C++ 2010; test code went on with no issues. Using R with the following sample code gave the expected results: install.packages("Rcpp") library(Rcpp) cppFunction(' int add(int x, int y, int z) { int sum = x + y + z; return sum; }' ) add(1, 2, 3) # > add(1, 2, 3) # [1] 6 As of the use of separate C++ files, the example below #include <Rcpp.h> using namespace Rcpp; // Below is a

Rcpp could not be loaded

喜夏-厌秋 提交于 2019-12-25 00:36:01
问题 Any idea why I keep getting the message below in R? Error : .onLoad failed in loadNamespace() for 'Rcpp', details: call: .External("class__dummyInstance", ...) error: C symbol name "class_dummyInstance" not in load table Error: package 'Rcpp' could not be loaded I have tried everything and it seems that nothing can fix this problem. The machine used is not mine but a client's. There are a lot of restrictions from IT and they have roaming profiles. I installed the 32-bit and 64-bit, just the

Using boost multiprecision with Rcpp on Windows

谁都会走 提交于 2019-12-24 21:20:56
问题 I'm trying to compile and use the following code (which I have seen on SO): // [[Rcpp::depends(BH)]] #include <Rcpp.h> #include <boost/multiprecision/float128.hpp> namespace mp = boost::multiprecision; // [[Rcpp::export]] std::string mexp(double mx) { mp::float128 x(mx); mp::float128 res = mp::exp(x); return res.convert_to<std::string>(); } Before compiling, I have to do Sys.setenv("PKG_LIBS" = "-lquadmath") otherwise the compilation does not work. Then the compilation runs fine, but when I

Threadsafe function pointer with Rcpp and RcppParallel via std::shared_ptr

给你一囗甜甜゛ 提交于 2019-12-24 20:06:36
问题 I would like to use a threadsafe function pointer to be applied in an RcppPrallel worker. But I have already problems with this tiny example. No matter if I use it in a package and add SystemRequirements: C++11 in the DESCRIPTION file, or use it in a standard cpp file and add // [[Rcpp::plugins(cpp11)]] I get the same Errors: 'shared_ptr' is not a member of 'std' . Can anyone please help me? Thank you! #include <Rcpp.h> using namespace Rcpp; using namespace std; double f1 (double x, double y)

Rcpp wrapper for the .C interface

徘徊边缘 提交于 2019-12-24 12:21:53
问题 I help to maintain the R package iRF. As you can see, it have been using Rcpp to call some C functions via the .C interface since its last release in 2017. When I clone that repo and try to install it on my computer (running macOS Mojave) with the latest version of R and Rcpp, it installs successfully. However, any modification to the src/ directory would change some MD5 hash and trigger an Rcpp::compileAttributes . Unfortunately, the recompiled attributes don't work with the legacy .C

Preparing for CRAN: '-fopenmp' clang error?

早过忘川 提交于 2019-12-24 09:58:32
问题 I am preparing a package (which makes use of Rcpp and RcppArmadillo) for submission to CRAN. I am using Travis CI and I have included the following to test my package more thoroughly: os: - linux - osx compiler: - clang - gcc This, however, yields the (familiar, it seems) error when using clang on OS X * installing *source* package ‘my_pkg’ ... ** libs clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Users/travis/R/Library/Rcpp/include" -I"/Users/travis/R/Library

Unable to use Rcpp after conda install

北城以北 提交于 2019-12-24 08:58:30
问题 I installed R with conda conda install -c r r-essentials Now I cannot use the Rcpp library, even so it is installed with r-essentials . I get the following error: # using library inline to compile a C++ code on the fly library(inline) library(Rcpp) src <- ' std::vector<std::string> s; s.push_back("hello"); s.push_back("world"); return Rcpp::wrap(s); ' hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE) cat(hellofun(), '\n') Error in dyn.load(libLFile): unable

windows r inside rcpp eclipse

流过昼夜 提交于 2019-12-24 08:48:20
问题 I'm trying to use Rinside in an IDE, Eclipse. Follow step by step manual http://blog.fellstat.com/?p=170 However, when you Build All I mark the following errors C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:55:17: error: 'internal' does not name a type C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:68:21: error: expected ')' before 'charsxp' C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:73:23: error: 'StringProxy' does not name a type C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h

How do I convert R data types into an Eigen::Matrix<double,dim,1> in this situation?

狂风中的少年 提交于 2019-12-24 07:38:18
问题 Why is this reporting error: no matching function for call to ‘as<Eigen::Matrix<double, 400, 1, 0, 400, 1> >(int)’ and cannot convert ‘3’ (type ‘int’) to type ‘SEXP {aka SEXPREC*}’ ? There appears to be a similar problem here. In a previous question, I asked about registering plugins so that I could use a c++ template library from within R . Continuing on with that example, I still cannot get this small example to work. The plugin issue has been figured out, but now Rcpp::as won't allow me to