p_down: Download the Package Documentation in One Directory or in...

View source: R/p_down.R

p_downR Documentation

Download the Package Documentation in One Directory or in Several Subdirectories

Description

If pkgs is a vector of packages obtained from s_crandb, p_down downloads from CRAN and saves in the dir directory (by default the current directory) the index page, the manual, the vignettes, the README, NEWS, ChangeLog, CRAN checks files, the source code in pkg_ver.tar.gz format, the binary code in pkg_ver.tgz (Mac OSX) or pkg_ver.zip (Windows) format and a minimal R-script of each package. The files that do not exist are ignored, with no warning.

If pkgs is a list of packages obtained from s_crandb_list, p_down saves the downloaded files in subdirectories named after the names of the list, e.g. the keywords used at the search step. The names are eventually modified with gsub(".", "_", make.names(pkg), fixed = TRUE) to cope with Unix and Windows directory names.

p_down0 calls p_down with different values for each argument. With the default configuration, this function downloads nothing. It is mostly used to download one specific item which has not been previously downloaded.

p_downarch downloads from CRAN archive the tar.gz file of one or several packages, either the last version(s) with Sys.Date() or the version(s) before a given date. It combines 3 functions: p_archive_lst lists the packages stored in CRAN archive and their version numbers, l_targz extracts the appropriate version numbers available before a given date, targz_down downloads the tar.gz files in the selected directory (default is the current directory) and eventually decompresses it.

targz_down downloads the tar.gz files from CRAN archive to the selected directory (default is the current directory) and eventually decompresses it. If url = "https://cran.r-project.org/src/contrib", targz_down will take the latest version of the package.

Usage

p_down(..., char = NULL, index = TRUE, manual = TRUE, vignettes = TRUE,
  README = TRUE, NEWS = FALSE, ChangeLog = FALSE, checks = FALSE,
  targz = FALSE, untar = FALSE, binary = FALSE, type = "binary",
  script = FALSE, dir = ".", crandb = get("crandb", envir = .GlobalEnv),
  repos = getOption("repos")[1])

p_down0(..., char = NULL, index = FALSE, manual = FALSE,
  vignettes = FALSE, README = FALSE, NEWS = FALSE, ChangeLog = FALSE,
  checks = FALSE, targz = FALSE, untar = FALSE, binary = FALSE,
  type = "binary", script = FALSE, dir = ".", crandb = get("crandb",
  envir = .GlobalEnv), repos = getOption("repos")[1])

p_downarch(..., char = NULL, before = Sys.Date(), dir = ".",
  untar = FALSE, url = "https://cran.r-project.org/src/contrib/Archive")

targz_down(ptargz, dir = ".", untar = FALSE,
  url = "https://cran.r-project.org/src/contrib/Archive")

Arguments

...

any format recognized by cnsc, including list. A vector or packages or a named list of packages (with names being the keywords).

char

(name to) a character vector or a list. Use this argument if ... fails or if you call the function from another function. If used, argument ... is ignored.

index

logical. Download the html index page of each package.

manual

logical. Download the pdf manual.

vignettes

logical. Download the html and pdf vignettes, if they exist.

README

logical. Download the README file, if it exists.

NEWS

logical. Download the NEWS file, if it exists.

ChangeLog

logical. Download the ChangeLog file, if it exists.

checks

logical. Download the CRAN checks file.

targz

logical. Download the *.tar.gz source file.

untar

logical. Decompress the downloaded tar.gz file.

binary

logical. Download the *.tgz (Mac OSX) or *.zip (Windows) binary file, depending the type value.

type

character. Either "mac.binary", "mac.binary.el-capitan", or "win.binary". The default, "binary", automatically detects the local OS and the variants between R-3.6.3, R-4.0.0 or (for Windows) gcc8. See the type section of utils::install.packages.

script

logical. Create a mini-script and save it in a *.R file.

dir

character. The directory in which the files are saved. Default value "." is the current directory.

crandb

data.frame crandb. The data.frame of CRAN packages.

repos

character. The address of your local CRAN.

before

character which can be converted to a Date, for instance "2017-05-14". Extract from CRAN archive the package(s) available before this date. Can be synchronized with the release dates of base-R versions listed at: https://CRAN.R-project.org/src/contrib/ and https://CRAN.R-project.org/package=rversions/readme/README.html

url

character. The url address of CRAN archive html file.

ptargz

character. A vector of package(s) with their version number and tar.gz extension stored in CRAN archive. These packages can be identified with l_targz.

Examples

## In real life, download crandb from CRAN or load it from your directory
## with functions crandb_down() or crandb_load().
## In this example, we use a small file.
crandb_load(system.file("data", "zcrandb.rda", package = "RWsearch"))

## Download the documentation in the "dirpkgs" directory. Flat representation.
dir <- file.path(tempdir(), "dirpkgs")
p_down(RWsearch, pdfsearch, sos, dir = dir, repos = "https://cloud.r-project.org")
list.files(dir, recursive = TRUE, full.names = TRUE)

## Download the documentation in subdirectories named after the keywords.
dir   <- file.path(tempdir(), "dirpkgslist")
(lst  <- s_crandb_list(thermodynamic, "chemical reaction"))
(lst2 <- lapply(lst, function(x) x[1:2]))
system.time(
  p_down(lst2, dir = dir, repos = "https://cloud.r-project.org")
)
list.files(dir, recursive = TRUE, full.names = TRUE)

## Download tar.gz files stored in CRAN archive.
dir <- file.path(tempdir(), "targzip")
p_downarch(fitur, zmatrix, NotAPkg, before = "2017-05-14", dir = dir)
targz_down("SVN_1.0.tar.gz", dir = dir, untar = TRUE)
list.files(dir, recursive = TRUE, full.names = TRUE)


RWsearch documentation built on March 18, 2022, 5:17 p.m.