utils (version 3.6.2)

vignette: View, List or Get R Source of Package Vignettes

Description

View a specified package vignette, or list the available ones; display it rendered in a viewer, and get or edit its R source file.

Usage

vignette(topic, package = NULL, lib.loc = NULL, all = TRUE)

# S3 method for vignette print(x, …) # S3 method for vignette edit(name, …)

Arguments

topic

a character string giving the (base) name of the vignette to view. If omitted, all vignettes from all installed packages are listed.

package

a character vector with the names of packages to search through, or NULL in which ‘all’ packages (as defined by argument all) are searched.

lib.loc

a character vector of directory names of R libraries, or NULL. The default value of NULL corresponds to all libraries currently known.

all

logical; if TRUE search all available packages in the library trees specified by lib.loc, and if FALSE, search only attached packages.

x, name

object of class vignette.

ignored by the print method, passed on to file.edit by the edit method.

Details

Function vignette returns an object of the same class, the print method opens a viewer for it.

On Unix-alikes, The program specified by the pdfviewer option is used for viewing PDF versions of vignettes.

If several vignettes have PDF/HTML versions with base name identical to topic, the first one found is used.

If no topics are given, all available vignettes are listed. The corresponding information is returned in an object of class "packageIQR".

See Also

browseVignettes for an HTML-based vignette browser; RShowDoc(<basename>, package = "<pkg>") displays a “rendered” vignette (pdf or html).

Examples

Run this code
# NOT RUN {
## List vignettes from all *attached* packages
vignette(all = FALSE)

## List vignettes from all *installed* packages (can take a long time!):
vignette(all = TRUE)

## The grid intro vignette -- open it
# }
# NOT RUN {
vignette("grid") # calling print()
# }
# NOT RUN {
## The same (conditional on existence of the vignettte).
## Note that 'package = *' is much faster in the case of many installed packages:
if(!is.null(v1 <- vignette("grid", package="grid"))) {
# }
# NOT RUN {
v1 # calling print(.)
# }
# NOT RUN {
  str(v1)
  ## Now let us have a closer look at the code
  
# }
# NOT RUN {
<!-- %% print(utils:::getRcode(v1)) # the R file name -->
# }
# NOT RUN {
  
# }
# NOT RUN {
<!-- %% if(interactive()) # "display" it -->
# }
# NOT RUN {
  
# }
# NOT RUN {
<!-- %%   file.show(utils:::getRcode(v1)) -->
# }
# NOT RUN {
  
# }
# NOT RUN {
<!-- %% ## or even more interactively: -->
# }
# NOT RUN {
edit(v1) # e.g., to send lines ...
# }
# NOT RUN {
}# if( has vignette "installed")
## A package can have more than one vignette (package grid has several):
vignette(package = "grid")
if(interactive()) {
   ## vignette("rotated")
   ## The same, but without searching for it:
   vignette("rotated", package = "grid")
}
# }

Run the code above in your browser using DataCamp Workspace