For something like this, I would just call back to the R functions for summarizing an object. Rcpp makes this easy.
#include <Rcpp.h>
using namespace Rcpp;
Function structure("str");
// [[Rcpp::export]]
void RcppStr(SEXP x) {
structure(x);
}
/*** R
RcppStr(data.frame(x=1:5, y=letters[1:5]))
*/
If you want more fine-grained control, you're going to have to write your own pretty printers (as Dirk said). But for something like this it would be worth leveraging what already exists in R -- print
, head
, tail
, and so on.