From ggrothendieck at gmail.com  Sat Sep 10 14:48:30 2005
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Sat, 10 Sep 2005 08:48:30 -0400
Subject: [Rd] \dontshow
In-Reply-To: <17186.44811.377236.677233@mithrandir.hornik.net>
References: <971536df05090919025bc98fce@mail.gmail.com>
	<971536df050909191772cf7127@mail.gmail.com>
	<17186.44811.377236.677233@mithrandir.hornik.net>
Message-ID: <971536df050910054851d74efd@mail.gmail.com>

On 9/10/05, Kurt Hornik <Kurt.Hornik at wu-wien.ac.at> wrote:
> >>>>> Gabor Grothendieck writes:
> 
> > On 9/9/05, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> >> In R 2.2.0 I find that even if I use \dontshow in the examples section
> >> of an .Rd file that the code still shows.
> >>
> >> Has anyone else seen this?
> >>
> >> Are there any packages that use this facility that I could
> >> try in order to check this?
> >>
> >> I am using
> >>
> >> > R.version.string # XP
> >> "R version 2.2.0, 2005-09-03"
> >>
> 
> > I realize that this description was not clear enough.  It does not
> > show in the help file but when you run the example it shows
> > and it was that part I was concerned about.  Is that the way its
> > supposed to work?
> 
> According to the docs, yes.  R-exts has
> 
>     For example,
> 
>          x <- runif(10)       # Shown and run.
>          \dontrun{plot(x)}    # Only shown.
>          \dontshow{log(x)}    # Only run.
> 
> -k
> 

A bit of background.   My package depends on external software that 
would not be on CRAN.

In order to pass R CMD check on a system that does not contain the
external software, what I am currently doing is to add an if statement at 
the beginning and end of each example section in each help file and in the 
demo that checks if the external software is present.  This check is done 
within a \dontrun{...} in the case of the help files.  

The if statement at the top simply checks for the availability of the external
software on the system and if not found then replaces f, the function
which would otherwise access that software, with a dummy function.
The if statement at the bottom removes the dummy function.

For example, 

\dontrun{  if (!software.found()) f <- function(...) cat("*** software
not present\n") }
...body of example...
\dontrun{ if (!software.found()) rm(f) }

Now this is quite kludgy but I currently know of no better alternative.
The help file looks ok but when you run it it does show the if statements
at the beginning and end which may be a bit disconcerting.

I had previously placed the entire body of the example section or demo
in an if but that had the disadvantage of not interleaving input and output
but rather showing all input and then all output.



[Rd] \dontshow
Gabor Grothendieck