Description Usage Arguments Details Value See Also Examples
pack_desc reads the ‘DESCRIPTION’ file of
an R package and makes use of its content in several
possible ways. pkg_files lists files within given
subdirectories of a package. It works on either installed
packages or package source folders. is_pkg_dir
determines whether names refer to such package
directories.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | pack_desc(pkg, ...)
## S3 method for class 'character'
pack_desc(pkg,
action = c("read", "update", "source", "spell"),
version = TRUE, demo = FALSE,
date.format = "%Y-%m-%d", envir = globalenv(), ...)
pkg_files(x, ...)
## S3 method for class 'character'
pkg_files(x, what, installed = TRUE,
ignore = NULL, ...)
is_pkg_dir(x)
## S3 method for class 'character'
is_pkg_dir(x)
|
pkg |
Name(s) of one to several package directories. The package name alone does not suffice unless the package is a subdirectory of the working directory. |
action |
Character scalar determining the output mode. |
version |
Logical scalar. Also update the version?
Only relevant if |
demo |
Logical scalar. Do not update or source files, just return a description of the result? |
date.format |
Character scalar. The format used and expected for the date of the package. |
envir |
Environment used when reading the files with
|
x |
Character vector. For |
what |
Character vector. The subdirectories to list. |
installed |
Logical scalar. If |
ignore |
|
... |
Optional arguments passed to and from other methods, or between the methods. |
pack_desc optionally sets the ‘Date’ entry
to the current date, and if requested increments the
subversion number of the package version, if any, and
writes the data back to each input file. Alternatively,
it calls source on all R code files of a package
as listed in the ‘DESCRIPTION’ file. Spell
checking is another option.
The value returned by pack_desc depends on the
value of action:
Object of
class pack_descs, basically a nested list with
pkg as names. The values are objects of class
pack_desc.
This loads the R code
files of the package(s) using source from the
base package in the correct order, and call
library on all the package names given under
‘Depends’ and ‘Imports’. Thus a list of
source results is obtained, returned invisibly.
... is passed to source if demo is
FALSE.
Check the spelling of using
aspell and an appropriate filter. This yields an
object of class aspell. Package names marked as
misspelled, if any, are automatically discarded.
One- or two-column character matrix with
one row per entry in pkg, showing the updated date
and optionally the version string. ... is passed
to write.dcf if demo is FALSE.
pkg_files yields a character vector of file names
(empty if no such files are found).
is_pkg_dir yields a logical vector with the same
length than x.
base::read.dcf base::write.dcf base::source base::list.files base::find.package base::system.file utils::packageDescription
Other package-functions: check_R_code,
check_Sweave_start,
copy_pkg_files,
delete_o_files,
logfile, run_R_CMD,
swap_code,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | pkg <- find.package(c("tools", "utils"), quiet = TRUE)
# Reading
(x <- pack_desc(pkg, "read")) # should look similar to packageVersion()
stopifnot(is.list(x), names(x) == pkg, inherits(x, "pack_descs"))
stopifnot(sapply(x, is.list), sapply(x, inherits, what = "pack_desc"))
# Updating (in demo mode, of course)
(x <- pack_desc(pkg, "update", demo = TRUE, date.format = "%Y/%m/%d"))
stopifnot(is.character(x), is.matrix(x), rownames(x) == pkg,
colnames(x) == c("Date", "Version"))
(x <- pack_desc(pkg, "update", demo = TRUE, version = FALSE))
stopifnot(is.character(x), is.matrix(x), rownames(x) == pkg,
colnames(x) == "Date")
# Source'ing (in demo mode, of course)
(x <- pack_desc(pkg, "source", demo = TRUE))
stopifnot(is.list(x), names(x) == pkg, sapply(x, is.list))
stopifnot(sapply(x, names) == c("Depends", "Imports", "Collate"))
# See also the 'docu.R' script, options '--format' and '--keep'.
## pkg_files()
pkg <- find.package(c("tools", "utils"), quiet = TRUE)
(x <- pkg_files(pkg, "R"))
stopifnot(is.character(x), length(x) > 0)
## is_pkg_dir()
(x <- is_pkg_dir(c("foo", "bar", "baz")))
stopifnot(!x)
(x <- is_pkg_dir(find.package(c("tools", "utils"), quiet = TRUE)))
stopifnot(x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.