Learn R Programming

btw (version 1.0.0)

btw_tool_search_packages: Tool: Search for an R package on CRAN

Description

Uses pkgsearch::pkg_search() to search for R packages on CRAN.

Usage

btw_tool_search_packages(
  query,
  format = c("short", "long"),
  n_results = NULL,
  `_intent` = ""
)

Value

A listing of packages matching the search term.

Arguments

query

Search query string. If this argument is missing or NULL, then the results of the last query are printed, in short and long formats, in turns for successive pkg_search() calls. If this argument is missing, then all other arguments are ignored.

format

Default formatting of the results. short only outputs the name and title of the packages, long also prints the author, last version, full description and URLs. Note that this only affects the default printing, and you can still inspect the full results, even if you specify short here.

n_results

Number of search results to include. Defaults to 10 for 'short' format and 5 for 'long' format.

_intent

An optional string describing the intent of the tool use. When the tool is used by an LLM, the model will use this argument to explain why it called the tool.

See Also

btw_tools()

Other Tools: btw_tool_docs_package_news(), btw_tool_env_describe_data_frame(), btw_tool_env_describe_environment(), btw_tool_files_code_search(), btw_tool_files_list_files(), btw_tool_files_read_text_file(), btw_tool_files_write_text_file(), btw_tool_ide_read_current_editor(), btw_tool_package_docs, btw_tool_session_package_info(), btw_tool_session_platform_info(), btw_tool_web_read_url(), btw_tools()

Examples

Run this code
if (FALSE) { # identical(Sys.getenv("IN_PKGDOWN"), "true")
# Copy pkgsearch results to the clipboard for use in any LLM app
btw(
  pkgsearch::pkg_search("network visualization", size = 1),
  clipboard = FALSE
)
btw(
  pkgsearch::pkg_search("network visualization", format = "long", size = 1),
  clipboard = FALSE
)
}

Run the code above in your browser using DataLab