Skip to content
Prev 1238 / 10988 Next

[Rcpp-devel] Accessing T of RcppVector<T>

Dirk's code relates to a question I meant to ask the experts for a while:
what's a safe and generic way to print C/C++ objects in an R session?

The background: forwarding the cout-stream in Dirk's example to R as below
doesn't work in the R-GUI on Windows (or in an IDE such as Eclipse); but it
does work if one runs an R session from the command line (that is, within
the console -- no surprise that the stream is correctly forwarded).

Additionally, there's a (confusing) variety of other print-functions that
successfully bridge the gap between C functions and the R-GUI, mostly made
available through prtutil.h. For instance, Rf_PrintValue takes an SEXP and
prints it to R using the "right format" when used in any C/C++-function,
whereas functions such as Rf_printIntegerVector  take C arguments (and
somehow smuggle them into the R session). And then there's the workhorse
Rprintf (which is possibly called by Rf_printIntegerVector).

Apologies for being so vague -- I would say I am eventually looking for a
way to make the below example run in the R-GUI, both to avoid using the
abovementioned functions, and to use existing C++-code that contains
summary/debugging overloads of cout. (This may belong to Rd and not to
Rcpp-devel, but I'm not sure.)

Best, Jo



2010/10/28 Dirk Eddelbuettel <edd at debian.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101030/c26ab56d/attachment.htm>