A tool to help find R packages by matching packages either to a text description, or to entire packages. Can find matching packages either from rOpenSci’s suite of packages, or from all packages currently on CRAN.
The easiest way to install this package is via the associated
r-universe. As shown
there, simply enable the universe with
options (repos = c (
ropenscireviewtools = "https://ropensci-review-tools.r-universe.dev",
CRAN = "https://cloud.r-project.org"
))
And then install the usual way with,
install.packages ("pkgmatch")
Alternatively, the package can be installed by first installing either the remotes or pak packages and running one of the following lines:
remotes::install_github ("ropensci-review-tools/pkgmatch")
pak::pkg_install ("ropensci-review-tools/pkgmatch")
remotes::install_git ("https://codeberg.org/ropensci-review-tools/pkgmatch")
remotes::install_git ("https://codefloe.com/ropensci-review-tools/pkgmatch")
The package can then loaded for use with
library (pkgmatch)
pkgmatch packageThe ‘pkgmatch’ package takes input either from a text description or local path to an R package, and finds matching packages based on text and code matching algorithms.
The package has two main functions:
pkgmatch_similar_pkgs()
to find similar rOpenSci,
CRAN, or
BioConductor
packages based on input as either a local path to an entire package,
the name of an installed package, or as a single descriptive text
string; andpkgmatch_similar_fns()
to find similar functions from rOpenSci or BioConductor packages based
on descriptive text input. (Not available for functions from CRAN
packages.)The following code demonstrates how these functions work, first matching general text strings packages from rOpenSci:
input <- "
Packages for analysing evolutionary trees, with a particular focus
on visualising inter-relationships among distinct trees.
"
pkgmatch_similar_pkgs (input, corpus = "ropensci")
## [1] "ssarp" "rotl" "phylogram" "canaper" "taxa"
input <- "Visualise evolutionary trees"
pkgmatch_similar_fns (input, corpus = "ropensci")
## [1] "visdat::vis_binary" "visdat::vis_cor"
## [3] "tracerer::count_trees_in_file" "phylotaR::cTrees"
## [5] "tracerer::parse_beast_trees"
The corpus parameter must be specified as one of “ropensci”, “cran”, or
“bioc” (for BioConductor; all
case-insensitive). The CRAN corpus is much larger than the rOpenSci or
BioConductor corpora, and matching for corpus = "cran" will generally
take notably longer.
The input parameter can also specify an entire package, either as a
local path to a package directory, or the name of an installed package.
For any locally-installed packages, you can just use the name of the
package:
pkgmatch_similar_pkgs (input = "httr2", corpus = "cran")
## [1] "httr2" "vcr" "crul" "gargle" "curl"
Alternatively, the input parameter can be a local path to a package
repository. To demonstrate that, the following code downloads a
.tar.gz file of the same httr2 package from CRAN:
pkg <- "httr2"
p <- available.packages () |>
data.frame () |>
dplyr::filter (Package == pkg)
url_base <- "https://cran.r-project.org/src/contrib/"
url <- paste0 (url_base, p$Package, "_", p$Version, ".tar.gz")
path <- fs::path (fs::path_temp (), basename (url))
download.file (url, destfile = path, quiet = TRUE)
The path to that package (in this case as a compressed tarball) can then
be passed to the
pkgmatch_similar_pkgs()
function:
pkgmatch_similar_pkgs (path, corpus = "cran")
## [1] "httr2" "vcr" "crul" "gargle" "curl"
Websites of packages or functions returned by either the
pkgmatch_similar_pkgs()
of pkgmatch_similar_fns()
functions
can be automatically opened, either by calling the function with
browse = TRUE, or by storing the return value of these functions as an
object and passing that to the pkgmatch_browse()
function.
The pkgmatch package includes the following vignettes:
pkgmatch,
and illustrates the ways by which this package provides different kind
of results to search engines and to general language model interfaces.pkgmatch caches and updates the language model
results for the individual corpora.utils::RSiteSearch()
function.sos package that queries
the “RSiteSearch” database.pkgsearch package to
“search R packages on CRAN” using CRAN metadata.packagefinder
package
for matching to DESCRIPTION entries of CRAN packages.All contributions to this project are gratefully acknowledged using the
allcontributors package
following the allcontributors
specification. Contributions of any kind are welcome!
|
mpadge |
MargaretSiple-NOAA |
Bisaloo |
|
maelle |
Selbosh |
nhejazi |
|
agricolamz |