<div dir="ltr"><div>What about using "TYPEOF"? Please see R Internals (<a href="https://cran.r-project.org/doc/manuals/r-release/R-ints.html#SEXPTYPEs">https://cran.r-project.org/doc/manuals/r-release/R-ints.html#SEXPTYPEs</a>) for more details.<br></div><div><br></div><div>#include <Rcpp.h><br><br>using namespace Rcpp;<br><br>// [[Rcpp::export]]<br>DataFrame rcpp_df(){<br>  NumericVector   numeric = {1,3};<br>  IntegerVector   integer = {1,3};<br>  CharacterVector character = {"B","D"};<br>  LogicalVector   logical = {false, true};<br><br>  DataFrame df = DataFrame::create(Named("numeric") = numeric,<br>                                    Named("integer") = integer,<br>                                         Named("character") = character,<br>                                     Named("logical") = logical);<br><br>  Rcpp::Rcout << "numeric:" << TYPEOF(df["numeric"]) << std::endl;<br>  Rcpp::Rcout << "integer:" << TYPEOF(df["integer"]) << std::endl;<br>  Rcpp::Rcout << "character:" << TYPEOF(df["character"]) << std::endl;<br>  Rcpp::Rcout << "logical:" << TYPEOF(df["logical"]) << std::endl;<br><br>  return df;<br>}</div><div><br></div><div>/*</div><div>> Rcpp::sourceCpp("test.cc")<br>> df <- rcpp_df()<br>numeric:14<br>integer:13<br>character:13<br>logical:10<br></div><div></div><div>*/<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 6, 2019 at 2:59 PM Brook Milligan <<a href="mailto:brook@nmsu.edu">brook@nmsu.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Is there a way to discover the value type for the result of calling DataFrame::operator[]?  For example, is there a metafiction that will deduce the type?<br>
<br>
A similar question could be asked about the result of calling Vector::operator[].<br>
<br>
I understand that these functions actually return a proxy, but it would be very helpful to find out the underlying value type.<br>
<br>
Thanks for your help.<br>
<br>
Cheers,<br>
Brook<br>
<br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></blockquote></div>