[Rcpp-devel] Value type of DataFrame::operator[]
What about using "TYPEOF"? Please see R Internals ( https://cran.r-project.org/doc/manuals/r-release/R-ints.html#SEXPTYPEs) for more details. #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] DataFrame rcpp_df(){ NumericVector numeric = {1,3}; IntegerVector integer = {1,3}; CharacterVector character = {"B","D"}; LogicalVector logical = {false, true}; DataFrame df = DataFrame::create(Named("numeric") = numeric, Named("integer") = integer, Named("character") = character, Named("logical") = logical); Rcpp::Rcout << "numeric:" << TYPEOF(df["numeric"]) << std::endl; Rcpp::Rcout << "integer:" << TYPEOF(df["integer"]) << std::endl; Rcpp::Rcout << "character:" << TYPEOF(df["character"]) << std::endl; Rcpp::Rcout << "logical:" << TYPEOF(df["logical"]) << std::endl; return df; } /*
Rcpp::sourceCpp("test.cc")
df <- rcpp_df()
numeric:14 integer:13 character:13 logical:10 */
On Fri, Dec 6, 2019 at 2:59 PM Brook Milligan <brook at nmsu.edu> wrote:
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? A similar question could be asked about the result of calling Vector::operator[]. I understand that these functions actually return a proxy, but it would be very helpful to find out the underlying value type. Thanks for your help. Cheers, Brook
_______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20191206/eb615b4b/attachment.html>