\HeaderA{demo}{Demonstrations of R Functionality}{demo}
\keyword{documentation}{demo}
\keyword{utilities}{demo}
\begin{Description}\relax
\code{demo} is a user-friendly interface to running some demonstration
\R{} scripts.  \code{demo()} gives the list of available topics.
\end{Description}
\begin{Usage}
\begin{verbatim}
demo(topic, package = NULL, lib.loc = NULL,
     character.only = FALSE, verbose = getOption("verbose"),
     echo = TRUE, ask = getOption("demo.ask"))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{topic}] the topic which should be demonstrated, given as a
\LinkA{name}{name} or literal character string, or a character string,
depending on whether \code{character.only} is \code{FALSE} (default)
or \code{TRUE}.  If omitted, the list of available topics is
displayed.
\item[\code{package}] a character vector giving the packages to look into for
demos, or \code{NULL}.  By default, all packages in the search path
are used.
\item[\code{lib.loc}] a character vector of directory names of \R{} libraries,
or \code{NULL}.  The default value of \code{NULL} corresponds to all
libraries currently known.  If the default is used, the loaded
packages are searched before the libraries.
\item[\code{character.only}] logical; if \code{TRUE}, use \code{topic} as
character string.
\item[\code{verbose}] a logical.  If \code{TRUE}, additional diagnostics are
printed.
\item[\code{echo}] a logical.  If \code{TRUE}, show the \R{} input when sourcing.
\item[\code{ask}] a logical (or \code{"default"}) indicating if
\code{\LinkA{devAskNewPage}{devAskNewPage}(ask=TRUE)} should be called before
graphical output happens from the demo code.  The value
\code{"default"} (the factory-fresh default) means to ask if
\code{echo == TRUE} and the graphics device appears to be
interactive.  This parameter applies both to any currently opened
device and to any devices opened by the demo code.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If no topics are given, \code{demo} lists the available demos.  The
corresponding information is returned in an object of class
\code{"packageIQR"}.  The structure of this class is experimental.  In
earlier versions of R, an empty character vector was returned along
with listing available demos.
\end{Details}
\begin{SeeAlso}\relax
\code{\LinkA{source}{source}} and \code{\LinkA{devAskNewPage}{devAskNewPage}} which 
are called by \code{demo}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
demo() # for attached packages

## All available demos:
demo(package = .packages(all.available = TRUE))

## Display a demo, pausing between pages
demo(lm.glm, package="stats", ask=TRUE)

## Display it without pausing
demo(lm.glm, package="stats", ask=FALSE)

## Not run: 
 ch <- "scoping"
 demo(ch, character = TRUE)
## End(Not run)

## Find the location of a demo
system.file("demo", "lm.glm.R", package="stats")
\end{ExampleCode}
\end{Examples}

