[R-pkg-devel] stdout in R package

Pieter Eendebak pieter.eendebak at gmail.com
Tue May 26 15:55:10 CEST 2015


Dear developers,

For an R package I am including some code I have written previously which
uses stdout, stderr and printf. The command R CMD check [packagename] gives
me warnings about these items. What is the proper way to print output in an
R package?

The documentation mentions that output is shpuld be written to the console.
Does this mean printing using printf only?

In my code I have several constructions like:

void print_structure(FILE *fid, object_t object);
void print_structure(object_t object) {
   print_structure(stdout, object);
}
void print_structure(const char *filename, object_t object) {
   FILE *fid = fopen(filename, 'wt');
   print_structure(fid, object);
   fclose(fid);
}

How can I keep using this code in R without duplicating the print_structure
function (once for output to console, and once for output to file)?

With kind regards,
Pieter Eendebak

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list