crandb: CRAN Packages (crandb.rda)

crandbR Documentation

CRAN Packages (crandb.rda)

Description

crandb_down downloads from CRAN the file packages.rds, a file refreshed everyday that describes the packages available in CRAN for this day, opens it as a data.frame and cleans this data.frame with the following oprations: rename (with make.names) the column names that are syntactically invalid, remove the duplicated lines located at the end of the file, clean some bad characters in the Description column. The resulting clean data.frame is then loaded in .GlobalEnv under the name crandb and saved in the current directory with the filename crandb.rda. If oldfile is defined, the vector of packages between the two files is compared and a short message is printed about the differences (removed packages, new packages, updated packages).

crandb_load loads the file filename in .GlobalEnv under the name crandb. It embeds the function load("crandb.rda") and add a short message about the data.frame properties.

crandb_pkgs displays all packages listed in crandb. The number of packages is larger than the number obtained with nrow(available.packages()) since packages for all OSes are counted.

crandb_fromto displays the packages published in CRAN between two dates.

Usage

crandb_down(dir = ".", oldfile = "crandb.rda", verbose = TRUE,
  repos = getOption("repos")[1])

crandb_load(filename = "crandb.rda")

crandb_comp(filename = "crandb.rda", oldfile = "crandb-old.rda", addtxt = "")

crandb_pkgs(bydate = FALSE, rev = FALSE, crandb = get("crandb", envir =
  .GlobalEnv))

crandb_fromto(from = -10, to = Sys.Date(), crandb = get("crandb", envir =
  .GlobalEnv))

Arguments

dir

character. The directory where "crandb.rda" is saved and the old "crandb.rda" is read. Default value "." is the current directory.

oldfile

character or NULL. The (path to an) old file that will be compared to a freshly downloaded version of "crandb.rda" or to filename. Set to NULL if no comparison is required.

verbose

logical. TRUE prints the result. FALSE keeps it invisible.

repos

character. The address of your local CRAN.

filename

character. The (path to a) file "crandb.rda" or an equivalent.

addtxt

character. Internal use.

bydate

logical. List the package by date of publication rather than by alphabetical order.

rev

logical. Print in reverse order.

crandb

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

from

Negative integer or character representing a date. The number of days preceeding to or a date before to.

to

date. The upper date in the search.

Examples

### In this example, we use the small file zcrandb.rda.
## List the 110 packages of this file, the ones uploaded since 2021-03-01
## and those uploaded in the last 15 days before the last date (2021-06-01).

crandb_load(system.file("data", "zcrandb.rda", package = "RWsearch"))
crandb_pkgs()
dim(crandb)
colnames(crandb)
crandb$Published
crandb_fromto(from = "2021-03-01", to = Sys.Date())
pkgs <- crandb_fromto(from = -15, to = max(crandb$Published)) ; pkgs

## Print the table in the console (better if full width)
p_table2(pkgs)

## Display in the browser
if (interactive()) {
p_display7(pkgs, dir = file.path(tempdir(), "crandbdown"))
}


### In the real life, we use a fresh file downloaded from CRAN (6 MB / 20").
## Here, we retrieve the packages uploaded during the last 2 days.
# crandb_down(dir = tempdir(), repos = "https://cloud.r-project.org")
# crandb_fromto(-2)


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