getObjecDataType
C++ Function Reference
1 Signature
std::string BigDataStatMeth::getObjecDataType(Rcpp::RObject obj)2 Description
Determines the data type of an R object.
3 Parameters
obj(Rcpp::RObject): R object to analyze
4 Returns
std::string Type identifier string
5 Details
objR object to analyze std::string Type identifier string Supported types:“numeric”: Numeric vectors/matrices”int”: Integer vectors/matrices”char”: Character vectors/matrices”logic”: Logical vectors/matrices”dataframe”: Data frames”list”: Lists”S4”: S4 objects”NULL”: NULL objects”unknown”: Unrecognized types
6 Caller Graph
7 Source Code
NoteImplementation
File: inst/include/Utilities/Utilities.hpp • Lines 129-160
inline std::string getObjecDataType(Rcpp::RObject obj)
{
std::string strtype = "";
try
{
if( Rcpp::is<Rcpp::NumericVector>(obj) ) {
strtype = "numeric";
} else if( Rcpp::is<Rcpp::IntegerVector>(obj) ) {
strtype = "int";
} else if( Rcpp::is<Rcpp::CharacterVector>(obj) ) {
strtype = "char";
} else if( Rcpp::is<Rcpp::LogicalVector>(obj) ) {
strtype = "logic";
} else if( Rcpp::is<Rcpp::DataFrame>(obj) ) {
strtype = "dataframe";
} else if( Rcpp::is<Rcpp::List>(obj) ) {
strtype = "list";
} else if( obj.isS4() ) {
strtype = "S4";
} else if( obj.isNULL() ) {
strtype = "NULL";
} else {
strtype = "unknown";
}
} catch(std::exception& ex) {
Rcpp::Rcout<< "c++ exception getObjecDataType: "<< ex.what() << "\n";
}
return(strtype);
}8 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = getObjecDataType(...);