[Rcpp-devel] Template and non-template arguments in RCPP_RETURN_VECTOR

2014-08-20 Thread Sven E. Templer
To create a templated function one can use the macro RCPP_RETURN_VECTOR, e.g: sourceCpp(code=' #include template T index_template ( T X ) { Rcpp::IntegerVector I(1, 0); return X[I]; } // [[Rcpp::export]] SEXP index ( SEXP X ) { RCPP_RETURN_VECTOR(index_template, X); } ') index(letters) ind

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread Sven E. Templer
ii), e.g.: http://www.mail-archive.com/search?q=call+R+function&l=rcpp-devel%40lists.r-forge.r-project.org or try yourself: http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/ Nevertheless I liked the question and learned something today (thank you Romain). So the trend is at le

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

[Rcpp-devel] sort() not sorting names

2014-06-27 Thread Sven E. Templer
Hi, sorting an Rcpp Vector leaves it's name attribute unsorted. See this code: require(Rcpp) require(inline) f <- cxxfunction(sig=c(xx="integer"), plugin="Rcpp", body=' IntegerVector x(xx); x.sort(); return x;') x <- c(a=1, b=2, c=0) f(x) sort(x) I would love to have this available, but I am no

[Rcpp-devel] table, rev and missing names

2014-06-06 Thread Sven E. Templer
Hi, consider this code: require(Rcpp) require(inline) t <- cxxfunction(sig=c(xx="character"), plugin="Rcpp", body=' CharacterVector x(xx); IntegerVector t = table(x); return t;') r <- cxxfunction(sig=c(xx="character"), plugin="Rcpp", body=' CharacterVector x(xx); IntegerVector t = table(x); Inte

[Rcpp-devel] vector < RawVector > to RawMatrix [like do.call(rbind, mylist)]

2014-01-10 Thread Sven E. Templer
Hello, reading a matrix from a file and transforming it to raw format, I get a "std::vector< Rcpp::RawVector >", how can I wrap it to "Rcpp::RawMatrix". Right now I use "Rcpp::List::create(vector< RawVector >)" and use do.call(rbind, mylist) in R (does this do a copy to the memory?). Is there a wa