Something like this?
x <- c(a=1, b=2)
f <- cppFunction("CharacterVector foo(NumericVector x){return x.names();}")
> f(x)
[1] "a" "b"
Søren
From: [email protected]
[mailto:[email protected]] On Behalf Of David
Edwards
Sent: 25. marts 2014 10:45
To: '[email protected]'
Subject: [Rcpp-devel] Getting names
Another novice question: the function
// [[Rcpp::export]]
IntegerVector maketable(IntegerVector x) {
IntegerVector tab=table(x);
return tab;
}
returns a named vector, and is about twice as fast as the R function 'table'.
Is there a way to extract the names of the vector as a CharacterVector (or even
better here, as an IntegerVector)?
BR David
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel