Category : r

When loading a file from a synced sharepoint folder – i am getting an error advising zip path is too long. >test = read_excel(file_list[1]) Error: Evaluation error: cannot open the connection. In addition: Warning message: In unz(zip_path, file_path, open = "rb") : zip path is too long I thought this may of been due to ..

Read more

I create the following algorithm in Rcpp and compile it in R. #include <RcppArmadilloExtensions/sample.h> // [[Rcpp::export]] arma::colvec Demo(arma::mat n, int K){ arma::colvec N(K); for(int j=0; j<K; ++j){ for(int i=0; i<(K-j); ++i){ N[j] += accu(n.submat(i,0,i,j)); } } return N; } However, something really weird happens when I run it inside a loop. For example, if I ..

Read more

I’m working on an Rcpp sparse matrix class that uses both Rcpp::IntegerVector (row/column pointers) and a templated std::vector<T>. The rationale is that overhead in deep-copying the integer pointer vectors (@i, @p) in extremely large sparse-matrices can be avoided by simply leaving them as pointers to R objects, and consistently, microbenchmarks show that this approach takes ..

Read more

I tried to use sourcecpp to load a cpp file in R, the first three line in the cpp file is #include <Rcpp.h> using namespace Rcpp; #include "gurobi_c++.h" I include gurobi_c++.h and gurobi_c.h under the same directory, and run sourcecpp, I received error: Building shared library DIR: /tmp/RtmpSbU73A/sourceCpp-x86_64-pc-linux-gnu-1.0.6/sourcecpp_72d02d601a1b /usr/lib/R/bin/R CMD SHLIB –preclean -o ‘sourceCpp_9.so’ ‘optlinear.cpp’ ..

Read more

I am a novice Rcpp user. I want to fasten my for loop which uses several entities from r environment, and updates two vectors through iterations. The problem is that this is my first time facing c or c++ so I do not understand how to write rcpp with inline packages. Here is the reproducible ..

Read more

I wrote an R code to calculate the tail sum of a vector: tailsum <- function(x){ sum(x) + x – cumsum(x) } I hope to improve the efficiency of this function through RcppArmadillo, so I wrote #include <RcppArmadillo.h> // [[Rcpp::depends(RcppArmadillo)]] #include <Rcpp.h> using namespace Rcpp; using namespace arma; // [[Rcpp::export]] colvec tailsum_arma(const colvec &x){ return ..

Read more

I apologize if this question is basic, as I have limited knowledge of templates. I have been trying to use a custom type in Rcpp, as shown in the following code: #include <Rcpp.h> #include "tinyutf8.h" using namespace Rcpp; template <> tiny_utf8::string Rcpp::as<tiny_utf8::string>(SEXP x){ tiny_utf8::string xx(Rcpp::as<const char*>(x)); return xx; } // [[Rcpp::export]] IntegerVector returnStr(std::string str2){ tiny_utf8::string ..

Read more