[R-pkg-devel] "Progress reports" for examples in packages --- SOLVED.

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Sun Jul 7 05:19:27 CEST 2019



Just thought it might be of interest were I to give a progress report
( :-) ) on this problem.

I managed to track down and fix what was going wrong.  It turns out that 
the issue was "stringsAsFactors".  I *hate* stringsAsFactors being TRUE 
so I have a call to options() setting it to FALSE in my .Rprofile.

But of course R CMD check sets it to TRUE.  In my code, I create at one 
point a one-row data frame.  I use a data frame so that the object is 
consistent with appears in other contexts in the code.  I extracting the 
entries of the data frame in question from other objects.  Some of these 
entries are strings ... uh-oh!  When they get changed to factors and 
then passed on to a function which passes them on to (e.g.) binomial() 
they wind up taking values like, e.g., 1, where "logit" was what was 
intended.

I had the function that calls binomial() wrapped up in a try() with 
silent=TRUE, since there are occasional circumstances in which there 
would be a "legitimate" fail (and I wanted to create a missing value if
there was such a fail).  However there was *always* a fail due to the
stringsAsFactors contretemps, so the overall result was useless and the 
repeat{ } loop repeated.  Endlessly.  When R CMD check was run.
(But everything was of course just ducky when I ran the example "as 
myself".)

The fix, once I found the problem, was simple; just stick in a
stringsAsFactors=FALSE in the relevant call to data.frame().

Finding the problem, obvious as it is in retrospect, was a nightmare. 
It required many many many attempts with cat() statements inserted at 
various places (in accordance with the advice given by Ben Bolker).  I 
had the devil's own time figuring out what to cat()!

I found, once I'd tracked down which example was the culprit (by doing
tail -f pkge-Ex.Rout), that I could use \dontrun{} on all of the *other* 
examples and get the same puzzling behaviour.  This speeded up the 
process considerably.

Don't know if there is any message to take away from all of the 
foregoing (other than that Rolf Turner is pretty stupid) but I thought 
that some list members might find the story to be of interest.

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-package-devel mailing list