Demonstrations of R Functionality

demo is a user-friendly interface to running some demonstration R scripts. demo() gives the list of available topics.

utilities, documentation
demo(topic, package = NULL, lib.loc = NULL,
     character.only = FALSE, verbose = getOption("verbose"),
     echo = TRUE, ask = getOption("demo.ask"),
     encoding = getOption("encoding"))

the topic which should be demonstrated, given as a name or literal character string, or a character string, depending on whether character.only is FALSE (default) or TRUE. If omitted, the list of available topics is displayed.


a character vector giving the packages to look into for demos, or NULL. By default, all packages in the search path are used.


a character vector of directory names of R libraries, or NULL. The default value of NULL corresponds to all libraries currently known. If the default is used, the loaded packages are searched before the libraries.


logical; if TRUE, use topic as character string.


a logical. If TRUE, additional diagnostics are printed.


a logical. If TRUE, show the R input when sourcing.


a logical (or "default") indicating if devAskNewPage(ask = TRUE) should be called before graphical output happens from the demo code. The value "default" (the factory-fresh default) means to ask if 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. If this is evaluated to TRUE and the session is interactive, the user is asked to press RETURN to start.


See source. If the package has a declared encoding, that takes preference.


If no topics are given, demo lists the available demos. The corresponding information is returned in an object of class "packageIQR".

See Also

source and devAskNewPage which are called by demo.

  • demo
library(utils) # NOT RUN { demo() # for attached packages ## All available demos: demo(package = .packages(all.available = TRUE)) # } # NOT RUN { ## 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 { # } # NOT RUN { ch <- "scoping" demo(ch, character = TRUE) # } # NOT RUN { ## Find the location of a demo system.file("demo", "lm.glm.R", package = "stats") # }
Documentation reproduced from package utils, version 3.5.1, License: Part of R 3.5.1

Community examples

Looks like there are no examples yet.