Use a standalone file from another repoSource:
A "standalone" file implements a minimum set of functionality in such a way
that it can be copied into another package.
use_standalone() makes it easy
to get such a file into your own repo.
It always overwrites an existing standalone file of the same name, making it easy to update previously imported code.
A string identifying the GitHub repo in one of these forms:
Browser URL, such as
HTTPS Git URL, such as
SSH Git URL, such as
Name of standalone file. The
standalone-prefix and file extension are optional. If omitted, will allow you to choose from the standalone files offered by that repo.
The name of a branch, tag, or commit. By default, the file at
pathwill be copied from its current state in the repo's default branch. This is extracted from
repo_specwhen user provides a URL.
GitHub host to target, passed to the
repo_specis a URL,
hostis extracted from that.
If unspecified, gh defaults to "https://api.github.com", although gh's default can be customised by setting the GITHUB_API_URL environment variable.
For a hypothetical GitHub Enterprise instance, either "https://github.acme.com/api/v3" or "https://github.acme.com" is acceptable.
A standalone file has YAML frontmatter that provides additional information, such as where the file originates from and when it was last updated. Here is an example:
--- : r-lib/rlang repo: standalone-types-check.R file-updated: 2023-03-07 last: https://unlicense.org license: standalone-obj-type.R dependencies: rlang (>= 1.1.0) imports--- `use_standalone()`: Two of these fields are consulted by - `dependencies`: A file or a list of files in the same repo that the standalone file depends on. These files are retrieved`use_standalone()`. automatically by - `imports`: A package or list of packages that the standalone file in parentheses, depends on. A minimal version may be specified `rlang (>= 1.0.0)`. These dependencies are passed to e.g. use_package()] to ensure they are included in the `Imports:` [`DESCRIPTION` file. field of the Note that lists are specified with standard YAML syntax, usingfor example: `imports: [rlang (>= 1.0.0), purrr]`. square brackets, use_package()]: R:use_package() [rlang (>= 1.0.0), purrr]: R:rlang%20(%3E=%201.0.0),%20purrr[