[Rcpp-devel] "expecting a string" and not finding it in a CharacterVector
Davor Cubranic
cubranic at stat.ubc.ca
Thu Feb 7 19:05:27 CET 2013
I have a CharacterVector from which I try to extract an element and assign it to a std::string:
CharacterVector xs;
...
std::string x = as<std::string>(xs(0));
This throws exception: "expecting a string". Why? Looking with the debugger at "xs", this is what I see:
(gdb) print xs
$6 = (CharacterVector &) @0x7fff5fbfcca0: {
<Rcpp::RObject> = {
_vptr$RObject = 0x1061979d0,
m_sexp = 0x10582b618
},
<Rcpp::VectorBase<16,true,Rcpp::Vector<16> >> = {
<Rcpp::traits::expands_to_logical__impl<16>> = {<No data fields>}, <No data fields>},
<Rcpp::internal::eval_methods<16>> = {<No data fields>},
members of Rcpp::Vector<16>:
cache = {
p = 0x7fff5fbfcca0
}
}
I've no idea how to poke any deeper and see what the actual R object in the first element of the vector is. Can anyone help with this?
This is with R 2.15.2 and Rcpp 0.10.2 on OS X 10.7.5. The code in question worked fine with Rcpp 0.10.0.
Davor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130207/ef265db2/attachment.html>
More information about the Rcpp-devel
mailing list