Skip to contents

Character strings in btw_this() are used as shortcuts to many underlying methods. btw_this() detects specific formats in the input string to determine which method to call, or by default it will try to evaluate the character string as R code and return the appropriate object description.

btw_this() knows about the following special character string formats:

  • "./path"
    Any string starting with ./ is treated as a relative path. If the path is a file, we call btw_tool_read_text_file() and if the path is a directory we call btw_tool_list_files() on the path.

    • btw_this("./data") lists the files in data/.

    • btw_this("./R/load_data.R") reads the source of the R/load_data.R file.

  • "{pkgName}"
    A package name wrapped in braces. Returns either the introductory vignette for the package (btw_tool_get_vignette_from_package()) or a list of help topics if no such vignette exists (btw_tool_get_package_help_topics()).

    • btw_this("{dplyr}") includes dplyr's introductory vignette.

    • btw_this("{btw}") returns the package help index (because btw doesn't have an intro vignette, yet).

  • "?help_topic"
    When the string starts with ?, btw searches R's help topics using btw_tool_get_help_page().

    • btw_this("?dplyr::across") includes the reference page for dplyr::across.

  • "@current_file" or "@current_selection"
    When used in RStudio or Positron, or anywhere else that the rstudioapi is supported, btw("@current_file") includes the contents of the file currently open in the editor using rstudioapi::getSourceEditorContext().

Usage

# S3 method for class 'character'
btw_this(x, ..., caller_env = parent.frame())

Arguments

x

A character string

...

Ignored.

caller_env

The caller environment.

Value

A character vector of lines describing the object.