Learn R Programming

RWsearch (version 4.8.0)

crandb: 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, rename (with make.names) the column names that are syntactically invalid, removes the duplicated lines located at the end of the file, cleans some bad characters in the Description column, loads the resulting data.frame in .GlobalEnv under the name crandb and saves it in the current directory with the name crandb.rda. If oldfile is defined, the vector of packages between the two files is compared.

crandb_load loads the file filename in .GlobalEnv under the name crandb. Equivalent to load("crandb.rda"). Use this function if you are not connected to internet or do not want to refresh your file.

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

Run this code
# NOT RUN {
### In this example, we use a small file.
## List the 110 packages of this file, the ones uploaded since 2020-01-01
## and those uploaded in the last 15 days before the last date (2020-04-17)

crandb_load(system.file("data", "zcrandb.rda", package = "RWsearch"))
crandb_pkgs()
dim(crandb)   
colnames(crandb) 
crandb$Published
crandb_fromto(from = "2020-01-01", to = Sys.Date())
pkgs <- crandb_fromto(from = -15, to = max(crandb$Published)) ; pkgs
p_table2(pkgs)   # Print in the console (better if full width)
# }
# NOT RUN {
p_display7(pkgs, dir = tempdir())   # Display in the browser

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

Run the code above in your browser using DataLab