findPackage: Searching for packages on CRAN

Description Usage Arguments Details Value Author(s) Examples

View source: R/packagefinder.r

Description

Searches for packages on CRAN based on the user's specification of search terms. Considers the package name, description as well as the long description, and prioritizes the results.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
findPackage(
  keywords = NULL,
  query = NULL,
  mode = "or",
  case.sensitive = FALSE,
  always.sensitive = NULL,
  weights = c(2, 2, 1, 2),
  display = "viewer",
  results.longdesc = FALSE,
  limit.results = 15,
  silent = FALSE,
  index = NULL,
  advanced.ranking = TRUE,
  return.df = FALSE,
  clipboard = FALSE
)

Arguments

keywords

A vector of keywords to be searched for. Instead of separate search terms, keywords can also be a query like "meta AND regression". In this case the mode argument is ignored. Only one type of logical operator (either and or and) may be used in a query; operators are not case-sensitive.

query

A vector of regular expressions (regex) to match against package name and descriptions; alternative to keywords, if both are provided the regular expressions search will prevail, and keywords will be ignored.

mode

Indicates whether the search terms in keywords shall be combined with a logical OR or with a logical AND; accordingly, permitted values are "or" (default) and "and". In "or" mode, every package that contains at least one of the keywords from the keywords argument is a search hit, in "and" mode generating a search hit requires all search terms from the keywords argument to be found.

case.sensitive

Indicates if the search shall be case sensitive, or not.

always.sensitive

A vector of search terms for which capitalization is always considered relevant (even if case.sensitive = FALSE). This allows to better reflect abbreviations like 'GLM'.

weights

A numeric vector describing how search hits in different fields of the a package's data shall be weighted. The first three elements of the vector are the weights assigned to hits in the package's title, short description and long description, respectively. The fourth element is a factor applied to the overall score of a search hit if all search terms from the keywords argument are found (obviously only meaningful in "or" mode). All weights must be 1 or larger.

display

Describes where the search results shall be shown. Either "viewer", "console" or "browser". If "viewer", the results are shown in RStudio's Viewer pane if the RStudio IDE is being used. If results = "console" the search results are shown as a text table in the R console. results = "browser" shows the search results in the web browser.

results.longdesc

Indicates whether the packages' long descriptions shall also be included in the search results. Given the length of some long decsriptions this may make the search results harder to read.

limit.results

The maximum number of matches presented in the search results; choose a negative number to display all results

silent

Indicates whether any visible output is produced. Use silent = TRUE if you are only interested in getting the search results as a dataframe (with return.df = TRUE).

index

Either a path (or URL) to a search index, or a search index that is already loaded. If no index is provided, findPackage() creates an ad hoc search index.

advanced.ranking

Indicates if the ranking of search results shall be based on weights taking into account the inverse frequencies of the different search terms across all packages and the length of the matches relative to the texts they were found in. Usually, using advanced ranking (advanced.ranking = TRUE, default) gives more relevant results, especially in "or" mode when the search terms differ strongly in their frequency of occurrence across packages.

return.df

If TRUE, findPackage() returns a dataframe with the results, otherwise there is no return value. Default is FALSE.

clipboard

If TRUE, findPackage() copies the results to the clipboard.

Details

The GO column in the search results is an index number that can be used to address the found package easily with the go() function. The Total Downloads column in the search results gives the overall number of downloads of the respective package since its submission to CRAN. The number is based on the figures for the RStudio CRAN mirror server. This field is only provided if the search index contains download figures. Ad hoc indices (when index = NULL) never include download statistics. Please refer to buildIndex() for more details.

fp() is a shorter alias for findPackage().

Value

The search results as a dataframe, if df.return = TRUE.

Author(s)

Joachim Zuckarelli joachim@zuckarelli.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
search <- c("regression", "meta")
findPackage(search)

findPackage(c("text", "tables"))

searchindex <- buildIndex()
findPackage(keywords=c("regression", "linear"), mode="and",
   always.sensitive="GLM", index=searchindex)

findPackage("meta and regression", display="console")

# Alternatively, show results in browser
# findPackage("meta and regression", display="browser")

my.results <- findPackage("meta AND regression")

packagefinder documentation built on Jan. 13, 2021, 1:02 p.m.