use_*() functions act on the active project. If it is
unset, usethis uses rprojroot to
find the project root of the current working directory. It establishes the
project root by looking for a
.here file, an RStudio Project, a package
DESCRIPTION, Git infrastructure, a
remake.yml file, or a
file. It then stores the active project for use for the remainder of the
1 2 3 4 5 6 7 8 9 10 11 12
Path to set. This
character vectors, if any values are NA, the result will also be NA.
An optional extension to append to the generated path.
Code to run with temporary active project.
Whether to suppress user-facing messages, while operating in the temporary active project.
The environment to use for scoping. Defaults to current execution environment.
In general, end user scripts should not contain direct calls to
usethis::proj_*() utility functions. They are internal functions that are
exported for occasional interactive use or use in packages that extend
usethis. End user code should call functions in
rprojroot or its simpler companion,
here, to programmatically detect a project and
build paths within it.
proj_get: Retrieves the active project and, if necessary,
attempts to set it in the first place.
proj_set: Sets the active project.
proj_path: Builds a path within the active project returned by
proj_get(). Thin wrapper around
with_project: Runs code with a temporary active project. It is an
example of the
with_*() functions in withr.
local_project: Sets an active project until the current execution
environment goes out of scope, e.g. the end of the current function or
test. It is an example of the
local_*() functions in
Other project functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## Not run: ## see the active project proj_get() ## manually set the active project proj_set("path/to/target/project") ## build a path within the active project (both produce same result) proj_path("R/foo.R") proj_path("R", "foo", ext = "R") ## build a path within SOME OTHER project with_project("path/to/some/other/project", proj_path("blah.R")) ## convince yourself that with_project() temporarily changes the project with_project("path/to/some/other/project", print(proj_sitrep())) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.