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

Dirk Eddelbuettel edd at debian.org
Sat Oct 30 16:34:13 CEST 2010


On 30 October 2010 at 13:02, Johannes Egner wrote:
| > 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).
| >
| 
| I was imprecise here: it does work using the Rterm connector in
| Eclipse/StatET, but not with the RJ-connector. (For those who use this IDE.)
| 
| It seems to boild down to contingent (and annoying) implementation details
| that are far beyond Rcpp's control -- I suspect my question really doesn't
| belong here.

I would agree :)  Rcpp does not special here --- we not define or redefine
anything related to input/output.  

And the "Writing R Extensions" manual clearly states it:

   5.6 Interfacing C++ code
   ========================
   
   [...]
   
      Using C++ iostreams, as in this example, is best avoided.  There is
   no guarantee that the output will appear in the R console, and indeed it
   will not on the R for Windows console.  Use R code or the C entry points
   (*note Printing::) for all I/O if at all possible.

so the line you were referring to actually came from simple debugging output,
and was authored by Sebastian to whom I replied with a fix.

So in short: if you must print, use Rprintf, or REprintf for stderr, as
detailed in section "6.5 Printing" of Writing R Extensions.

Regards, Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list