rcpp

efficiently locf by groups in a single R data.table

我只是一个虾纸丫 提交于 2019-12-17 18:55:28
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 3 years ago . I have a large, wide data.table (20m rows) keyed by a person ID but with lots of columns (~150) that have lots of null values. Each column is a recorded state / attribute that I wish to carry forward for each person. Each person may have anywhere from 10 to 10,000 observations and there are about 500,000 people in the set. Values from one person can not 'bleed' into the

how many vectors can be added in DataFrame::create( vec1, vec2 … )?

时间秒杀一切 提交于 2019-12-17 17:05:41
问题 I am creating a DataFrame to hold a parsed haproxy http log files which has quite a few fields (25+). If I add more than 20 vectors (one for each field), I get the compilation error: no matching function call to 'create' The create method: return DataFrame::create( _["clientIp"] = clientIp, _["clientPort"] = clientPort, _["acceptDate"] = acceptDate, _["frontendName"] = frontendName, _["backendName"] = backendName, _["serverName"] = serverName, _["tq"] = tq, _["tw"] = tw, _["tc"] = tc, _["tr"]

R CRAN, install library Rcpp fails after R3.2 upgrade

荒凉一梦 提交于 2019-12-17 16:44:36
问题 I upgraded from R-3.1 to R-3.2. OK ( Standard upgrade) But this upgrade seems to have lost all the installed packages ( ggplot2, quantmod, Rcpp among dozens and dozens of others). So installed many from the RStudio tools menu option. Most were successful. But problem with Rcpp (when installing as dependency from ggplot2). The same issue occurs when installing package data.table : Warning in install.packages : unable to move temporary installation ‘C:\Users\euclid\Documents\R\win-library\3.2

Error when with Xcode 5.0 and Rcpp (Command Line Tools ARE installed)

烈酒焚心 提交于 2019-12-17 08:59:20
问题 I have a new iMac and I'm trying to run code using the Rcpp library that has been working on both my old iMac and Macbook Pro without issue. I have tried everything I can't seem to figure out what the issue is. Xcode 5.0 downloaded. Command line Tools then installed. R3.0.2 is installed. I downloaded a gcc compiler. When I type gcc in terminal - I get "clang:" - which is good, I think. The error I get is copied below. Thanks in advance for any ideas and advice. Error (in R console): llvm-g++

Calling an R function using inline and Rcpp is still just as slow as original R code

吃可爱长大的小学妹 提交于 2019-12-17 07:53:15
问题 I need to evaluate a function (posterior distribution) which requires long loops. Clearly I don't want to do this within R itself, and so I'm using "inline" and "Rcpp" to implement C++. However, I'm finding that in the case where each loop uses an R function, the cxxfunction is running just as slow as running the R code (see code and output below). In particular, I'm needing to use a multivariate normal cumulative distribution function within each loop, and so I'm using pmvnorm() from the

Multithreaded & SIMD vectorized Mandelbrot in R using Rcpp & OpenMP

▼魔方 西西 提交于 2019-12-17 06:16:24
问题 As an OpenMP & Rcpp performance test I wanted to check how fast I could calculate the Mandelbrot set in R using the most straightforward and simple Rcpp + OpenMP implementation. Currently what I did was: #include <Rcpp.h> #include <omp.h> // [[Rcpp::plugins(openmp)]] using namespace Rcpp; // [[Rcpp::export]] Rcpp::NumericMatrix mandelRcpp(const double x_min, const double x_max, const double y_min, const double y_max, const int res_x, const int res_y, const int nb_iter) { Rcpp::NumericMatrix

Rcpp pass by reference vs. by value

巧了我就是萌 提交于 2019-12-17 02:51:23
问题 I made a first stab at an Rcpp function via inline and it solved my speed problem (thanks Dirk!): R: Replacing negative values by zero The initial version looked like this: library(inline) cpp_if_src <- ' Rcpp::NumericVector xa(a); int n_xa = xa.size(); for(int i=0; i < n_xa; i++) { if(xa[i]<0) xa[i] = 0; } return xa; ' cpp_if <- cxxfunction(signature(a="numeric"), cpp_if_src, plugin="Rcpp") But when called cpp_if(p) , it overwrote p with the output, which was not as intended. So I assumed it

Using Rcpp within parallel code via snow to make a cluster

南楼画角 提交于 2019-12-17 02:26:33
问题 I've written a function in Rcpp and compiled it with inline . Now, I want to run it in parallel on different cores, but I'm getting a strange error. Here's a minimal example, where the function funCPP1 can be compiled and runs well by itself, but cannot be called by snow 's clusterCall function. The function runs well as a single process, but gives the following error when ran in parallel: Error in checkForRemoteErrors(lapply(cl, recvResult)) : 2 nodes produced errors; first error: NULL value

Combine R, C++ and Fortran

廉价感情. 提交于 2019-12-14 03:25:22
问题 I am trying to reimplement an R function using C++ and RCpp to speed up the computation. And in the C++ implementation, I need to use a Fortran function mvtdst found in link. #include <Rcpp.h> #include "mvtnorm.h" using namespace Rcpp; // [[Rcpp::export]] NumericVector pmvnorm_rcpp(NumericVector upper, NumericMatrix corr) { double error; double mvnP = pmvnorm_P(2, upper, corr, &error) ; return mvnP ; } /*** R pmvnorm_rcpp(c(1.5,1.5),c(0.0)) */ Here, pmvnorm_P is defined in the mvtnorm.cpp

unordered_map use in rcpp [closed]

做~自己de王妃 提交于 2019-12-14 02:23:14
问题 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 2 years ago . I am a newbie trying to learn data structure and algorithm implementation using Standard Template Library (STL) in Rcpp. I am trying to implement a very basic hash table using unordered_map in Rcpp, taking a hint from Hadley's Advanced R Here is the C++ code I want to implement in Rcpp (taken from element14 blog