The R Project SVN R

Rev

Rev 88202 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 88202 Rev 89330
Line 1... Line 1...
1
% File src/library/utils/man/vignette.Rd
1
% File src/library/utils/man/vignette.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2016 R Core Team
3
% Copyright 1995-2026 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{vignette}
6
\name{vignette}
7
\title{View, List or Get R Source of Package Vignettes}
7
\title{View or List Package Vignettes or Edit their R Code Files}
8
\alias{vignette}
8
\alias{vignette}
9
\alias{edit.vignette}
9
\alias{edit.vignette}
10
\alias{print.vignette}
10
\alias{print.vignette}
11
\alias{vignettes} % to link to from e.g. grid-package.Rd
11
\alias{vignettes} % to link to from e.g. grid-package.Rd
12
%% \alias{getRcode}
12
%% \alias{getRcode}
13
%% \alias{getRcode.vignette}%hidden
13
%% \alias{getRcode.vignette}%hidden
14
\description{
14
\description{
15
  View a specified package vignette, or list the available ones;
15
  View a specific package vignette or its \R code file,
16
  display it rendered in a viewer, and get or edit its \R source file.
16
  or list the available ones.
17
}
17
}
18
\usage{
18
\usage{
19
vignette(topic, package = NULL, lib.loc = NULL, all = TRUE)
19
vignette(topic, package = NULL, lib.loc = NULL, all = TRUE)
20
 
20
 
21
\S3method{print}{vignette}(x, \dots)
21
\S3method{print}{vignette}(x, \dots)
22
\S3method{edit}{vignette}(name, \dots)
22
\S3method{edit}{vignette}(name, \dots)
23
%% \S3method{getRcode}{vignette}(x, strict=TRUE, \dots)
23
%% \S3method{getRcode}{vignette}(x, strict=TRUE, \dots)
24
}
24
}
25
\arguments{
25
\arguments{
26
  \item{topic}{a character string giving the (base) name of the vignette
26
  \item{topic}{a character string giving the (base) name of the vignette
-
 
27
    to view, or an (unevaluated) expression of the form \code{package::topic}.
27
    to view.  If omitted, all vignettes from all installed packages are
28
    If omitted, all vignettes from all installed packages are listed.}
28
    listed.}
-
 
29
  \item{package}{a character vector with the names of packages to
29
  \item{package}{a character vector with the names of packages to
30
    search through, or \code{NULL} in which \sQuote{all} packages (as
30
    search through, or \code{NULL} in which case \sQuote{all} packages (as
31
    defined by argument \code{all}) are searched.}
31
    defined by argument \code{all}) are searched.}
32
  \item{lib.loc}{a character vector of directory names of \R libraries,
32
  \item{lib.loc}{a character vector of directory names of \R libraries,
33
    or \code{NULL}.  The default value of \code{NULL} corresponds to all
33
    or \code{NULL}.  The default value of \code{NULL} corresponds to all
34
    libraries currently known.}
34
    libraries currently known.}
35
  \item{all}{logical; if \code{TRUE} search all available packages in
35
  \item{all}{logical; if \code{TRUE} search all available packages in
Line 68... Line 68...
68
}
68
}
69
\examples{
69
\examples{
70
## List vignettes from all *attached* packages
70
## List vignettes from all *attached* packages
71
vignette(all = FALSE)
71
vignette(all = FALSE)
72
 
72
 
73
## List vignettes from all *installed* packages (can take a long time!):
73
## List vignettes from all *installed* packages (can take a long time!)
74
vignette(all = TRUE)
74
vignette(all = TRUE)
75
 
75
 
76
## The grid intro vignette -- open it
-
 
77
\dontrun{vignette("grid") # calling print()}
-
 
78
## The same (conditional on existence of the vignette).
-
 
79
## Note that 'package = *' is much faster in the case of many installed packages:
-
 
80
if(!is.null(v1 <- vignette("grid", package="grid"))) {
-
 
81
\dontrun{v1 # calling print(.)}
-
 
82
  str(v1)
-
 
83
  ## Now let us have a closer look at the code
-
 
84
  %% print(utils:::getRcode(v1)) # the R file name
-
 
85
  %% if(interactive()) # "display" it
-
 
86
  %%   file.show(utils:::getRcode(v1))
-
 
87
  %% ## or even more interactively:
-
 
88
\dontrun{edit(v1) # e.g., to send lines ...}
-
 
89
}# if( has vignette "installed")
-
 
90
## A package can have more than one vignette (package grid has several):
76
## List all vignettes of a specific package (package 'grid' has several)
91
vignette(package = "grid")
77
vignette(package = "grid")
-
 
78
 
-
 
79
## Open one of the 'grid' vignettes
92
if(interactive()) {
80
if(interactive()) {
93
   ## vignette("rotated")
81
  ## vignette("rotated", package = "grid")
-
 
82
  ## Or, the same:
-
 
83
  vignette(grid::rotated) # calling the print() method
-
 
84
}
-
 
85
 
94
   ## The same, but without searching for it:
86
## Now open the 'grid' intro vignette -- without specifying the package
-
 
87
\dontrun{vignette("grid")}
-
 
88
## OK, but warns as this topic is ambiguous: both {grid} and {lattice} have it.
-
 
89
## => Specify the 'package' argument or use the <package>::<topic> syntax
-
 
90
##    (also accelerates vignette retrieval, esp. with many installed packages):
95
   vignette("rotated", package = "grid")
91
v1 <- vignette("grid", package = "grid") # not "printed" (opened) yet
-
 
92
if(inherits(v1, "vignette")) { # it was found installed
-
 
93
  \dontrun{print(v1) # open it}
-
 
94
  str(v1)
-
 
95
  ## To open the associated R code in an editor:
-
 
96
  \dontrun{edit(v1) # e.g., to send lines ...}
-
 
97
%% print(rfilepath <- utils:::getRcode(v1))
-
 
98
%% if(interactive()) file.show(rfilepath)
96
}
99
}
97
}
100
}
98
\keyword{documentation}
101
\keyword{documentation}