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 callbtw_tool_read_text_file()
and if the path is a directory we callbtw_tool_list_files()
on the path.btw_this("./data")
lists the files indata/
.btw_this("./R/load_data.R")
reads the source of theR/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 (becausebtw
doesn't have an intro vignette, yet).
"?help_topic"
When the string starts with?
, btw searches R's help topics usingbtw_tool_get_help_page()
.btw_this("?dplyr::across")
includes the reference page fordplyr::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 usingrstudioapi::getSourceEditorContext()
.
Usage
# S3 method for class 'character'
btw_this(x, ..., caller_env = parent.frame())
See also
Other btw_this()
methods:
btw_this()
,
btw_this.data.frame()
,
btw_this.environment()