[Rd] Tips for debugging: R CMD check examples

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jun 30 17:19:24 CEST 2010


On Wed, 30 Jun 2010, hadley wickham wrote:

>> R CMD check produces a foo-Ex.R file where foo is the package name. You
>> could start by sourcing that file in R --vanilla and see where it fails
>> and also use standard debugging tools in R from there (i.e. drop into a
>> debugger on error).
>
> I knew about the foo-Ex.R file, but unfortunately running that
> produced no errors.

How did you 'run' it?   I suspect you source()d it, not at all the 
same thing.  I have yet to encounter a problem which

R --vanilla < foo-Ex.R

or perhaps

env LANGUAGE=en R --vanilla --encoding=latin1 < foo-Ex.R

did not reproduce.

> I ended up resorting to inserting print statements
> every few lines to narrow down the exact location of the problem,
> which revealed that my code assumed options(keep.source = TRUE) but
> during R CMD check, options(keep.source = FALSE).

Rather, the default (along with many others) differs in interactive 
use and batch running.   If you had used a command like those a few 
lines about you would have had 'keep.source = FALSE' set.

> Hopefully this type of problem will be easier to sort out with the new
> pure R R CMD check in 2.11.

Maybe (if you meant the one in R-devel, 2.12.0-to-be). But the 
examples are run in a sub-process just as before, so your very rare 
mis-assumption still needs an understanding of how R code is run.

>
> Hadley
>
>
> -- 
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list