Re: [Rcpp-devel] Manipulation of IntegerVector

2014-07-11 Thread Sven E. Templer
hi, you should change the line matched[j+1] = tmp; to matched[j-1] = tmp; to get rid of your error. require(Rcpp) require(inline) sourceCpp(code=' #include using namespace Rcpp; // [[Rcpp::export]] List createVectorList_Numeric_cpp(NumericMatrix df) { CharacterVector rownames = VECTOR

Re: [Rcpp-devel] Manipulation of IntegerVector

2014-07-11 Thread Sameer D'Costa
On Fri, Jul 11, 2014 at 3:19 AM, Mario Deng wrote: > But when I do "matched[j+1] = matched[j]+1;" everything crashes, I don't > get any error informations etc. Also, is there a way to avoid that the R > instance/RStudio crashes? > I was able to compile and run part of your code on linux outside

[Rcpp-devel] Manipulation of IntegerVector

2014-07-11 Thread Mario Deng
Hello everyone, I still struggle with Rcpp, I hope you guys are patient. The problem occurs here: IntegerVector matched = match(sorted_vec, one_col); for(int j = 0; j < (matched.size() - 1); j++){ if( matched[j] >= matched[j+1] ){ matched[j+1] = matched[j]+1; } } I can access