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
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
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
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
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
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