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);
IntegerVector r = rev(t);
return r;')
o <- cxxfunction(sig=c(xx="character"), plugin="Rcpp", body='
CharacterVector x(xx);
IntegerVector t = table(x);
CharacterVector n = t.names();
IntegerVector r = rev(t);
r.names() = rev(n);
return r;')
t(c('a','a','b',NA))
r(c('a','a','b',NA))
o(c('a','a','b',NA))


Reversed vectors loose their name ( t() vs r() ) and have to be copied
and reversed 'manually' ( as in o() ). Is rev() a function declared by
Rcpp, if so can names be reserved while reverting or is there any
other easier solution than in o() ?

Thank you!
Sven
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to