rcpp

Fatal error: Unable to open the base package [closed]

不想你离开。 提交于 2020-06-17 08:14:34
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . So, now I have managed to compile the hello program of RInside on WindowsXP (VirtualBox). But, when I click on its executable, I get a dialogbox showing

How to scale a NumericMatrix in-place with Rcpp?

为君一笑 提交于 2020-06-16 05:13:38
问题 This is what I'm doing now library(Rcpp) A <- diag(c(1.0, 2.0, 3.0)) rownames(A) <- c('X', 'Y', 'Z') colnames(A) <- c('A', 'B', 'C') cppFunction(' void scaleMatrix(NumericMatrix& A, double x) { A = A * x; }') Unfortunately It doesn't work :( > A A B C X 1 0 0 Y 0 2 0 Z 0 0 3 > scaleMatrix(A, 2) > A A B C X 1 0 0 Y 0 2 0 Z 0 0 3 I learned from Rcpp FAQ, Question 5.1 that Rcpp should be able to change the object I passed by value. Stealing an example from Dirk's answer to my previous question:

How to scale a NumericMatrix in-place with Rcpp?

蓝咒 提交于 2020-06-16 05:13:33
问题 This is what I'm doing now library(Rcpp) A <- diag(c(1.0, 2.0, 3.0)) rownames(A) <- c('X', 'Y', 'Z') colnames(A) <- c('A', 'B', 'C') cppFunction(' void scaleMatrix(NumericMatrix& A, double x) { A = A * x; }') Unfortunately It doesn't work :( > A A B C X 1 0 0 Y 0 2 0 Z 0 0 3 > scaleMatrix(A, 2) > A A B C X 1 0 0 Y 0 2 0 Z 0 0 3 I learned from Rcpp FAQ, Question 5.1 that Rcpp should be able to change the object I passed by value. Stealing an example from Dirk's answer to my previous question:

How to package R shiny app in electron with included Rcpp code

最后都变了- 提交于 2020-06-13 05:40:14
问题 I am trying to package a shiny app as a standalone application using electron as per: https://github.com/ColumbusCollaboratory/electron-quick-start A portable R instance is used and electron calls it to create the shiny app. I need to do this as the app I am building is for someone who doesn't have R installed and doesn't want it installed. This works great until I try to 'sourceCpp' files written in Rcpp. I get the error: Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir

Rcpp subsetting rows of DataFrame

我与影子孤独终老i 提交于 2020-05-29 05:58:30
问题 I wished to create a following subset of the iris dataset using the Rcpp package: head(subset(iris, Species == "versicolor")) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 51 7.0 3.2 4.7 1.4 versicolor 52 6.4 3.2 4.5 1.5 versicolor 53 6.9 3.1 4.9 1.5 versicolor 54 5.5 2.3 4.0 1.3 versicolor 55 6.5 2.8 4.6 1.5 versicolor 56 5.7 2.8 4.5 1.3 versicolor I know how to subset columns of Rcpp::DataFrame - there is an overloaded operator [ which works as in R: x["var"] . However, I cannot

Large Matrices in RcppArmadillo via the ARMA_64BIT_WORD define

谁都会走 提交于 2020-04-11 09:58:10
问题 From a previous post, Large SpMat object with RcppArmadillo, I decided to use Rcpp to compute a large matrix (~600,000 rows x 11 cols) I've installed Rcpp and RcppArmadillo > sessionInfo() R version 3.3.1 (2016-06-21) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X 10.11.6 (El Capitan) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1]

R语言的cpp扩展支持Rcpp模块介绍

女生的网名这么多〃 提交于 2020-04-07 05:51:51
概述 Rcpp包提供C++类方便C or C++代码与R软件包进行交互,使用R中提供的 .Call() 调用界面。 Rcpp提供R中的基础数据类型的C++类供访问。包作者可以保持R的数据结构而无需与C++进行不断的转换。同时,这些数据结构提供C++级别的存取。数据类型可以双向映射。可以从 R中把数据赋给C++, 返回数据从C++到R也完全一样。下面列出支持的数据类型。 Transfer from R to C++, and from C++ to R R 数据类型 (SEXP) 与C++对象是一致的,按照类的衍生关系。所有的R类型都支持 (vectors, functions, environment, etc ...) 并且每一种对对应到C++的类对象。例如, numeric vectors代表类Rcpp::NumericVector的实例, environments代表Rcpp::Environment, functions代表Rcpp::Function,等等... 相应的 C++库都提供Rcpp::wrap函数,该函数是一个模版函数负责把数据转换为SEXP。 这个机制让使用标准C++类型实现C++的逻辑变得非常直接,比如使用STL编程然后包装为SEXP返回到R中。内部的封装操作使用高级元编程技术,目前支持的数据类型包括:bool, int, double, size_t,

How to build Rcpp packages within Rstudio using RcppArmadillo?

社会主义新天地 提交于 2020-03-26 05:46:29
问题 I'm trying to compile a Rcpp package that uses RcppArmadillo within RStudio. I am only trying to compile: #include <RcppArmadillo.h> // [[Rcpp::depends(RcppArmadillo)]] using namespace Rcpp; // Implementation of MASS' rmvrnorm() // [[Rcpp::export]] arma::mat rmvrnorm_arma2(int n, arma::vec mu, arma::mat sigma) { int ncols = sigma.n_cols; arma::mat Y = arma::randn(n, ncols); return arma::repmat(mu, 1, n).t() + Y * arma::chol(sigma); } which is found here: http://gallery.rcpp.org/articles

How to build Rcpp packages within Rstudio using RcppArmadillo?

泄露秘密 提交于 2020-03-26 05:46:10
问题 I'm trying to compile a Rcpp package that uses RcppArmadillo within RStudio. I am only trying to compile: #include <RcppArmadillo.h> // [[Rcpp::depends(RcppArmadillo)]] using namespace Rcpp; // Implementation of MASS' rmvrnorm() // [[Rcpp::export]] arma::mat rmvrnorm_arma2(int n, arma::vec mu, arma::mat sigma) { int ncols = sigma.n_cols; arma::mat Y = arma::randn(n, ncols); return arma::repmat(mu, 1, n).t() + Y * arma::chol(sigma); } which is found here: http://gallery.rcpp.org/articles

How to make Rcpp code efficient with multiple for loops?

偶尔善良 提交于 2020-03-02 07:43:13
问题 I am trying to implement following Rcpp code by calling from R. The computing time is extremely slow. There are lots of for loops involved. #include <RcppArmadillo.h> using namespace Rcpp; // [[Rcpp::depends(RcppArmadillo)]] // [[Rcpp::export]] arma::mat qpart( const int& n, const int& p, const int& m, arma::vec& G, arma::vec& ftime, arma::vec& cause, arma::mat& covs, arma::mat& S1byS0hat, arma::vec& S0hat, arma::vec& expz){ arma::mat q(n,p); q.zeros(); for(int u=0;u<n;++u){ arma::mat q1(1,p)