Title: | Tools to Make Developing R Packages Easier |
---|---|
Description: | Collection of package development tools. |
Authors: | Hadley Wickham [aut], Jim Hester [aut], Winston Chang [aut], Jennifer Bryan [aut, cre] , Posit Software, PBC [cph, fnd] |
Maintainer: | Jennifer Bryan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.4.5.9000 |
Built: | 2024-11-01 11:16:19 UTC |
Source: | https://github.com/r-lib/devtools |
Open bash shell in package directory.
bash(pkg = ".")
bash(pkg = ".")
pkg |
The package to use, can be a file path to the package or a
package object. See |
Building converts a package source directory into a single bundled file.
If binary = FALSE
this creates a tar.gz
package that can
be installed on any platform, provided they have a full development
environment (although packages without source code can typically be
installed out of the box). If binary = TRUE
, the package will have
a platform specific extension (e.g. .zip
for windows), and will
only be installable on the current platform, but no development
environment is needed.
build( pkg = ".", path = NULL, binary = FALSE, vignettes = TRUE, manual = FALSE, args = NULL, quiet = FALSE, ... )
build( pkg = ".", path = NULL, binary = FALSE, vignettes = TRUE, manual = FALSE, args = NULL, quiet = FALSE, ... )
pkg |
The package to use, can be a file path to the package or a
package object. See |
path |
Path in which to produce package. If |
binary |
Produce a binary ( |
vignettes , manual
|
For source packages: if |
args |
An optional character vector of additional command
line arguments to be passed to |
quiet |
if |
... |
Additional arguments passed to pkgbuild::build. |
DESCRIPTION
entriesConfig/build/clean-inst-doc
can be set to FALSE
to avoid cleaning up
inst/doc
when building a source package. Set it to TRUE
to force a
cleanup. See the clean_doc
argument.
Config/build/copy-method
can be used to avoid copying large
directories in R CMD build
. It works by copying (or linking) the
files of the package to a temporary directory, leaving out the
(possibly large) files that are not part of the package. Possible
values:
none
: pkgbuild does not copy the package tree. This is the default.
copy
: the package files are copied to a temporary directory before
R CMD build
.
link
: the package files are symbolic linked to a temporary
directory before R CMD build
. Windows does not have symbolic
links, so on Windows this is equivalent to copy
.
You can also use the pkg.build_copy_method
option or the
PKG_BUILD_COPY_METHOD
environment variable to set the copy method.
The option is consulted first, then the DESCRIPTION
entry, then the
environment variable.
Config/build/extra-sources
can be used to define extra source files
for pkgbuild to decide whether a package DLL needs to be recompiled in
needs_compile()
. The syntax is a comma separated list of file names,
or globs. (See utils::glob2rx()
.) E.g. src/rust/src/*.rs
or
configure*
.
Config/build/bootstrap
can be set to TRUE
to run
Rscript bootstrap.R
in the source directory prior to running subsequent
build steps.
pkg.build_copy_method
: use this option to avoid copying large
directories when building a package. See possible values above, at the
Config/build/copy-method
DESCRIPTION
entry.
pkg.build_stop_for_warnings
: if it is set to TRUE
, then pkgbuild
will stop for R CMD build
errors. It takes precedence over the
PKG_BUILD_STOP_FOR_WARNINGS
environment variable.
PKG_BUILD_COLOR_DIAGNOSTICS
: set it to false
to opt out of colored
compiler diagnostics. Set it to true
to force colored compiler
diagnostics.
PKG_BUILD_COPY_METHOD
: use this environment variable to avoid copying
large directories when building a package. See possible values above,
at the Config/build/copy-method
DESCRIPTION
entry.
will stop for R CMD build
errors. The pkg.build_stop_for_warnings
option takes precedence over this environment variable.
a string giving the location (including file name) of the built package
The default manual = FALSE
is not suitable for a CRAN
submission, which may require manual = TRUE
. Even better, use
submit_cran()
or release()
.
Create package pdf manual
build_manual(pkg = ".", path = NULL)
build_manual(pkg = ".", path = NULL)
pkg |
The package to use, can be a file path to the package or a
package object. See |
path |
path in which to produce package manual.
If |
build_rmd()
is a wrapper around rmarkdown::render()
that first installs
a temporary copy of the package, and then renders each .Rmd
in a clean R
session. build_readme()
locates your README.Rmd
and builds it into a
README.md
build_rmd(files, path = ".", output_options = list(), ..., quiet = TRUE) build_readme(path = ".", quiet = TRUE, ...)
build_rmd(files, path = ".", output_options = list(), ..., quiet = TRUE) build_readme(path = ".", quiet = TRUE, ...)
files |
The Rmarkdown files to be rendered. |
path |
path to the package to build the readme. |
output_options |
List of output options that can override the options
specified in metadata (e.g. could be used to force |
... |
additional arguments passed to |
quiet |
If |
build_site()
is a shortcut for pkgdown::build_site()
, it generates the
static HTML documentation.
build_site(path = ".", quiet = TRUE, ...)
build_site(path = ".", quiet = TRUE, ...)
path |
path to the package to build the static HTML. |
quiet |
If |
... |
additional arguments passed to |
Builds package vignettes using the same algorithm that R CMD build
does. This means including non-Sweave vignettes, using makefiles (if
present), and copying over extra files. The files are copied in the 'doc'
directory and an vignette index is created in 'Meta/vignette.rds', as they
would be in a built package. 'doc' and 'Meta' are added to
.Rbuildignore
, so will not be included in the built package. These
files can be checked into version control, so they can be viewed with
browseVignettes()
and vignette()
if the package has been
loaded with load_all()
without needing to re-build them locally.
build_vignettes( pkg = ".", dependencies = "VignetteBuilder", clean = TRUE, upgrade = "never", quiet = FALSE, install = TRUE, keep_md = TRUE )
build_vignettes( pkg = ".", dependencies = "VignetteBuilder", clean = TRUE, upgrade = "never", quiet = FALSE, install = TRUE, keep_md = TRUE )
pkg |
The package to use, can be a file path to the package or a
package object. See |
dependencies |
Which dependencies do you want to check? Can be a character vector (selecting from "Depends", "Imports", "LinkingTo", "Suggests", or "Enhances"), or a logical vector.
The value "soft" means the same as You can also specify dependencies from one or more additional fields, common ones include:
|
clean |
Remove all files generated by the build, even if there were copies there before. |
upgrade |
Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default"
respects the value of the |
quiet |
If |
install |
If |
keep_md |
If |
clean_vignettes()
to remove the pdfs in
‘doc’ created from vignettes
clean_vignettes()
to remove build tex/pdf files.
check()
automatically builds and checks a source package, using all known
best practices. check_built()
checks an already-built package.
Passing R CMD check
is essential if you want to submit your package to
CRAN: you must not have any ERRORs or WARNINGs, and you want to ensure that
there are as few NOTEs as possible. If you are not submitting to CRAN, at
least ensure that there are no ERRORs or WARNINGs: these typically represent
serious problems.
check()
automatically builds a package before calling check_built()
, as
this is the recommended way to check packages. Note that this process runs
in an independent R session, so nothing in your current workspace will affect
the process. Under-the-hood, check()
and check_built()
rely on
pkgbuild::build()
and rcmdcheck::rcmdcheck()
.
check( pkg = ".", document = NULL, build_args = NULL, ..., manual = FALSE, cran = TRUE, remote = FALSE, incoming = remote, force_suggests = FALSE, run_dont_test = FALSE, args = "--timings", env_vars = c(NOT_CRAN = "true"), quiet = FALSE, check_dir = NULL, cleanup = deprecated(), vignettes = TRUE, error_on = c("never", "error", "warning", "note") ) check_built( path = NULL, cran = TRUE, remote = FALSE, incoming = remote, force_suggests = FALSE, run_dont_test = FALSE, manual = FALSE, args = "--timings", env_vars = NULL, check_dir = tempdir(), quiet = FALSE, error_on = c("never", "error", "warning", "note") )
check( pkg = ".", document = NULL, build_args = NULL, ..., manual = FALSE, cran = TRUE, remote = FALSE, incoming = remote, force_suggests = FALSE, run_dont_test = FALSE, args = "--timings", env_vars = c(NOT_CRAN = "true"), quiet = FALSE, check_dir = NULL, cleanup = deprecated(), vignettes = TRUE, error_on = c("never", "error", "warning", "note") ) check_built( path = NULL, cran = TRUE, remote = FALSE, incoming = remote, force_suggests = FALSE, run_dont_test = FALSE, manual = FALSE, args = "--timings", env_vars = NULL, check_dir = tempdir(), quiet = FALSE, error_on = c("never", "error", "warning", "note") )
pkg |
The package to use, can be a file path to the package or a
package object. See |
document |
By default ( |
build_args |
Additional arguments passed to |
... |
Additional arguments passed on to |
manual |
If |
cran |
if |
remote |
Sets |
incoming |
Sets |
force_suggests |
Sets |
run_dont_test |
Sets |
args |
Character vector of arguments to pass to |
env_vars |
Environment variables set during |
quiet |
if |
check_dir |
Path to a directory where the check is performed.
If this is not |
cleanup |
|
vignettes |
If |
error_on |
Whether to throw an error on
|
path |
Path to built package. |
An object containing errors, warnings, notes, and more.
Devtools does its best to set up an environment that combines best practices with how check works on CRAN. This includes:
The standard environment variables set by devtools:
r_env_vars()
. Of particular note for package tests is the NOT_CRAN
env
var, which lets you know that your tests are running somewhere other than
CRAN, and hence can take a reasonable amount of time.
Debugging flags for the compiler, set by
compiler_flags(FALSE)
.
If aspell
is found, _R_CHECK_CRAN_INCOMING_USE_ASPELL_
is set to TRUE
. If no spell checker is installed, a warning is issued.
Environment variables, controlled by arguments incoming
, remote
and
force_suggests
.
release()
if you want to send the checked package to
CRAN.
This function first bundles a source package, then uploads it to https://mac.r-project.org/macbuilder/submit.html. This function returns a link to the page where the check results will appear.
check_mac_release( pkg = ".", dep_pkgs = character(), args = NULL, manual = TRUE, quiet = FALSE, ... )
check_mac_release( pkg = ".", dep_pkgs = character(), args = NULL, manual = TRUE, quiet = FALSE, ... )
pkg |
The package to use, can be a file path to the package or a
package object. See |
dep_pkgs |
Additional custom dependencies to install prior to checking the package. |
args |
An optional character vector of additional command
line arguments to be passed to |
manual |
Should the manual be built? |
quiet |
If |
... |
Additional arguments passed to |
The url with the check results (invisibly)
Other build functions:
check_rhub()
,
check_win()
R CMD check
does.This function attempts to run the documentation related checks in the
same way that R CMD check
does. Unfortunately it can't run them
all because some tests require the package to be loaded, and the way
they attempt to load the code conflicts with how devtools does it.
check_man(pkg = ".")
check_man(pkg = ".")
pkg |
The package to use, can be a file path to the package or a
package object. See |
Nothing. This function is called purely for it's side effects: if no errors there will be no output.
## Not run: check_man("mypkg") ## End(Not run)
## Not run: check_man("mypkg") ## End(Not run)
It runs build()
on the package, with the arguments specified
in args
, and then submits it to the R-hub builder at
https://builder.r-hub.io. The interactive
option controls
whether the function waits for the check output. Regardless, after the
check is complete, R-hub sends an email with the results to the package
maintainer.
check_rhub( pkg = ".", platforms = NULL, email = NULL, interactive = TRUE, build_args = NULL, ... )
check_rhub( pkg = ".", platforms = NULL, email = NULL, interactive = TRUE, build_args = NULL, ... )
pkg |
The package to use, can be a file path to the package or a
package object. See |
platforms |
R-hub platforms to run the check on. If |
email |
email address to notify, defaults to the maintainer address in the package. |
interactive |
whether to show the status of the build interactively. R-hub will send an email to the package maintainer's email address, regardless of whether the check is interactive or not. |
build_args |
Arguments passed to |
... |
extra arguments, passed to |
a rhub_check
object.
To build and check R packages on R-hub, you need to validate your
email address. This is because R-hub sends out emails about build
results. See more at rhub::validate_email()
.
Other build functions:
check_mac_release()
,
check_win()
This function first bundles a source package, then uploads it to
https://win-builder.r-project.org/. Once the service has built and checked
the package, an email is sent to address of the maintainer listed in
DESCRIPTION
. This usually takes around 30 minutes. The email contains a
link to a directory with the package binary and check logs, which will be
deleted after a couple of days.
check_win_devel( pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ... ) check_win_release( pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ... ) check_win_oldrelease( pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ... )
check_win_devel( pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ... ) check_win_release( pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ... ) check_win_oldrelease( pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ... )
pkg |
The package to use, can be a file path to the package or a
package object. See |
args |
An optional character vector of additional command
line arguments to be passed to |
manual |
Should the manual be built? |
email |
An alternative email address to use. If |
quiet |
If |
... |
Additional arguments passed to |
check_win_devel()
: Check package on the development version of R.
check_win_release()
: Check package on the released version of R.
check_win_oldrelease()
: Check package on the previous major release version of R.
Other build functions:
check_mac_release()
,
check_rhub()
This uses a fairly rudimentary algorithm where any files in ‘doc’ with a name that exists in ‘vignettes’ are removed.
clean_vignettes(pkg = ".")
clean_vignettes(pkg = ".")
pkg |
The package to use, can be a file path to the package or a
package object. See |
Create a package
create(path, ..., open = FALSE)
create(path, ..., open = FALSE)
path |
A path. If it exists, it is used. If it does not exist, it is created, provided that the parent path exists. |
... |
Additional arguments passed to |
open |
If
|
The path to the created package, invisibly.
dev_sitrep()
reports
If R is up to date
If RStudio is up to date
If compiler build tools are installed and available for use
If devtools and its dependencies are up to date
If the package's dependencies are up to date
Call this function if things seem weird and you're not sure what's wrong or how to fix it. If this function returns no output everything should be ready for package development.
dev_sitrep(pkg = ".", debug = FALSE)
dev_sitrep(pkg = ".", debug = FALSE)
pkg |
The package to use, can be a file path to the package or a
package object. See |
debug |
If |
A named list, with S3 class dev_sitrep
(for printing purposes).
## Not run: dev_sitrep() ## End(Not run)
## Not run: dev_sitrep() ## End(Not run)
This function is a wrapper for the roxygen2::roxygenize()
function from the roxygen2 package. See the documentation and vignettes of
that package to learn how to use roxygen.
document(pkg = ".", roclets = NULL, quiet = FALSE)
document(pkg = ".", roclets = NULL, quiet = FALSE)
pkg |
The package to use, can be a file path to the package or a
package object. See |
roclets |
Character vector of roclet names to use with package.
The default, |
quiet |
if |
roxygen2::roxygenize()
,
browseVignettes("roxygen2")
Uses R CMD INSTALL
to install the package. Will also try to install
dependencies of the package from CRAN, if they're not already installed.
install( pkg = ".", reload = TRUE, quick = FALSE, build = !quick, args = getOption("devtools.install.args"), quiet = FALSE, dependencies = NA, upgrade = "default", build_vignettes = FALSE, keep_source = getOption("keep.source.pkgs"), force = FALSE, ... )
install( pkg = ".", reload = TRUE, quick = FALSE, build = !quick, args = getOption("devtools.install.args"), quiet = FALSE, dependencies = NA, upgrade = "default", build_vignettes = FALSE, keep_source = getOption("keep.source.pkgs"), force = FALSE, ... )
pkg |
The package to use, can be a file path to the package or a
package object. See |
reload |
if |
quick |
if |
build |
if |
args |
An optional character vector of additional command line
arguments to be passed to |
quiet |
If |
dependencies |
Which dependencies do you want to check? Can be a character vector (selecting from "Depends", "Imports", "LinkingTo", "Suggests", or "Enhances"), or a logical vector.
The value "soft" means the same as You can also specify dependencies from one or more additional fields, common ones include:
|
upgrade |
Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default"
respects the value of the |
build_vignettes |
if |
keep_source |
If |
force |
Force installation, even if the remote state has not changed since the previous install. |
... |
additional arguments passed to |
If quick = TRUE
, installation takes place using the current package
directory. If you have compiled code, this means that artefacts of
compilation will be created in the src/
directory. If you want to avoid
this, you can use build = TRUE
to first build a package bundle and then
install it from a temporary directory. This is slower, but keeps the source
directory pristine.
If the package is loaded, it will be reloaded after installation. This is
not always completely possible, see reload()
for caveats.
To install a package in a non-default library, use withr::with_libpaths()
.
update_packages()
to update installed packages from the
source location and with_debug()
to install packages with
debugging flags set.
Other package installation:
uninstall()
install_deps()
will install the
user dependencies needed to run the package, install_dev_deps()
will also
install the development dependencies needed to test and build the package.
install_deps( pkg = ".", dependencies = NA, repos = getOption("repos"), type = getOption("pkgType"), upgrade = c("default", "ask", "always", "never"), quiet = FALSE, build = TRUE, build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"), ... ) install_dev_deps( pkg = ".", dependencies = TRUE, repos = getOption("repos"), type = getOption("pkgType"), upgrade = c("default", "ask", "always", "never"), quiet = FALSE, build = TRUE, build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"), ... )
install_deps( pkg = ".", dependencies = NA, repos = getOption("repos"), type = getOption("pkgType"), upgrade = c("default", "ask", "always", "never"), quiet = FALSE, build = TRUE, build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"), ... ) install_dev_deps( pkg = ".", dependencies = TRUE, repos = getOption("repos"), type = getOption("pkgType"), upgrade = c("default", "ask", "always", "never"), quiet = FALSE, build = TRUE, build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"), ... )
pkg |
The package to use, can be a file path to the package or a
package object. See |
dependencies |
Which dependencies do you want to check? Can be a character vector (selecting from "Depends", "Imports", "LinkingTo", "Suggests", or "Enhances"), or a logical vector.
The value "soft" means the same as You can also specify dependencies from one or more additional fields, common ones include:
|
repos |
A character vector giving repositories to use. |
type |
Type of package to |
upgrade |
Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default"
respects the value of the |
quiet |
If |
build |
if |
build_opts |
Options to pass to |
... |
additional arguments passed to |
## Not run: install_deps(".")
## Not run: install_deps(".")
The default linters correspond to the style guide at
https://style.tidyverse.org/, however it is possible to override any or all
of them using the linters
parameter.
lint(pkg = ".", cache = TRUE, ...)
lint(pkg = ".", cache = TRUE, ...)
pkg |
The package to use, can be a file path to the package or a
package object. See |
cache |
Store the lint results so repeated lints of the same content use the previous results. Consult the lintr package to learn more about its caching behaviour. |
... |
Additional arguments passed to |
lintr::lint_package()
, lintr::lint()
load_all()
loads a package. It roughly simulates what happens
when a package is installed and loaded with library()
, without
having to first install the package. It:
Loads all data files in data/
. See load_data()
for more
details.
Sources all R files in the R directory, storing results in
environment that behaves like a regular package namespace. See
load_code()
for more details.
Adds a shim from system.file()
to shim_system.file()
in
the imports environment of the package. This ensures that system.file()
works with both development and installed packages despite their differing
directory structures.
Adds shims from help()
and ?
to shim_help()
and shim_question()
to make it easier to preview development documentation.
Compiles any C, C++, or Fortran code in the src/
directory and
connects the generated DLL into R. See pkgbuild::compile_dll()
for more details.
Loads any compiled translations in inst/po
.
Runs .onAttach()
, .onLoad()
and .onUnload()
functions at
the correct times.
If you use testthat, will load all test helpers so you can
access them interactively. devtools sets the DEVTOOLS_LOAD
environment variable to the package name to let you check whether the
helpers are run during package loading.
is_loading()
returns TRUE
when it is called while load_all()
is running. This may be useful e.g. in .onLoad
hooks.
load_all( path = ".", reset = TRUE, recompile = FALSE, export_all = TRUE, helpers = TRUE, quiet = FALSE, ... )
load_all( path = ".", reset = TRUE, recompile = FALSE, export_all = TRUE, helpers = TRUE, quiet = FALSE, ... )
path |
Path to a package, or within a package. |
reset |
clear package environment and reset file cache before loading
any pieces of the package. This largely equivalent to running
|
recompile |
DEPRECATED. force a recompile of DLL from source code, if
present. This is equivalent to running |
export_all |
If |
helpers |
if |
quiet |
if |
... |
Additional arguments passed to |
load_all()
tries its best to reproduce the behaviour of
loadNamespace()
and library()
. However it deviates from normal
package loading in several ways.
load_all()
doesn't install the package to a library, so system.file()
doesn't work. pkgload fixes this for the package itself installing a shim,
shim_system.file()
. However, this shim is not visible to third party
packages, so they will fail if they attempt to find files within your
package. One potential workaround is to use fs::path_package()
instead of system.file()
, since that understands the mechanisms that
devtools uses to load packages.
load_all()
loads all packages referenced in Imports
at load time,
but loadNamespace()
and library()
only load package dependencies as
they are needed.
load_all()
copies all objects (not just the ones listed as exports)
into the package environment. This is useful during development because
it makes internal objects easy to access. To export only the objects
listed as exports, use export_all = FALSE
. This more closely simulates
behavior when loading an installed package with library()
, and can
be useful for checking for missing exports.
## Not run: # Load the package in the current directory load_all("./") # Running again loads changed files load_all("./") # With reset=TRUE, unload and reload the package for a clean start load_all("./", TRUE) # With export_all=FALSE, only objects listed as exports in NAMESPACE # are exported load_all("./", export_all = FALSE) ## End(Not run)
## Not run: # Load the package in the current directory load_all("./") # Running again loads changed files load_all("./") # With reset=TRUE, unload and reload the package for a clean start load_all("./", TRUE) # With export_all=FALSE, only objects listed as exports in NAMESPACE # are exported load_all("./", export_all = FALSE) ## End(Not run)
The method is heuristic - looking for objs with a period in their name.
missing_s3(pkg = ".")
missing_s3(pkg = ".")
pkg |
The package to use, can be a file path to the package or a
package object. See |
Run automated and manual tests, then post package to CRAN.
release(pkg = ".", check = FALSE, args = NULL)
release(pkg = ".", check = FALSE, args = NULL)
pkg |
The package to use, can be a file path to the package or a
package object. See |
check |
if |
args |
An optional character vector of additional command
line arguments to be passed to |
The package release process will:
Confirm that the package passes R CMD check
on relevant platforms
Confirm that important files are up-to-date
Build the package
Submit the package to CRAN, using comments in "cran-comments.md"
You can add arbitrary extra questions by defining an (un-exported) function
called release_questions()
that returns a character vector
of additional questions to ask.
You also need to read the CRAN repository policy at
'https://cran.r-project.org/web/packages/policies.html' and make
sure you're in line with the policies. release
tries to automate as
many of polices as possible, but it's impossible to be completely
comprehensive, and they do change in between releases of devtools.
usethis::use_release_issue()
to create a checklist of release
tasks that you can use in addition to or in place of release
.
This attempts to unload and reload an installed package. If the package is
not loaded already, it does nothing. It's not always possible to cleanly
unload a package: see the caveats in unload()
for some of the potential
failure points. If in doubt, restart R and reload the package with
library()
.
reload(pkg = ".", quiet = FALSE)
reload(pkg = ".", quiet = FALSE)
pkg |
The package to use, can be a file path to the package or a
package object. See |
quiet |
if |
load_all()
to load a package for interactive development.
## Not run: # Reload package that is in current directory reload(".") # Reload package that is in ./ggplot2/ reload("ggplot2/") # Can use inst() to find the package path # This will reload the installed ggplot2 package reload(pkgload::inst("ggplot2")) ## End(Not run)
## Not run: # Reload package that is in current directory reload(".") # Reload package that is in ./ggplot2/ reload("ggplot2/") # Can use inst() to find the package path # This will reload the installed ggplot2 package reload(pkgload::inst("ggplot2")) ## End(Not run)
One of the most frustrating parts of R CMD check
is getting all of your
examples to pass - whenever one fails you need to fix the problem and then
restart the whole process. This function makes it a little easier by
making it possible to run all examples from an R function.
run_examples( pkg = ".", start = NULL, show = deprecated(), run_donttest = FALSE, run_dontrun = FALSE, fresh = FALSE, document = TRUE, run = deprecated(), test = deprecated() )
run_examples( pkg = ".", start = NULL, show = deprecated(), run_donttest = FALSE, run_dontrun = FALSE, fresh = FALSE, document = TRUE, run = deprecated(), test = deprecated() )
pkg |
The package to use, can be a file path to the package or a
package object. See |
start |
Where to start running the examples: this can either be the
name of |
show |
DEPRECATED. |
run_donttest |
if |
run_dontrun |
if |
fresh |
if |
document |
if |
run , test
|
Deprecated, see |
Helper function wrapping IDE-specific calls to save all documents in the
active session. In this form, callers of save_all()
don't need to
execute any IDE-specific code. This function can be extended to include
other IDE implementations of their equivalent
rstudioapi::documentSaveAll()
methods.
save_all()
save_all()
Show package news
show_news(pkg = ".", latest = TRUE, ...)
show_news(pkg = ".", latest = TRUE, ...)
pkg |
The package to use, can be a file path to the package or a
package object. See |
latest |
if |
... |
other arguments passed on to |
“Gist is a simple way to share snippets and pastes with others. All gists are git repositories, so they are automatically versioned, forkable and usable as a git repository.” https://gist.github.com/
source_gist(id, ..., filename = NULL, sha1 = NULL, quiet = FALSE)
source_gist(id, ..., filename = NULL, sha1 = NULL, quiet = FALSE)
id |
either full url (character), gist ID (numeric or character of numeric). |
... |
other options passed to |
filename |
if there is more than one R file in the gist, which one to
source (filename ending in '.R')? Default |
sha1 |
The SHA-1 hash of the file at the remote URL. This is highly
recommend as it prevents you from accidentally running code that's not
what you expect. See |
quiet |
if |
## Not run: # You can run gists given their id source_gist(6872663) source_gist("6872663") # Or their html url source_gist("https://gist.github.com/hadley/6872663") source_gist("gist.github.com/hadley/6872663") # It's highly recommend that you run source_gist with the optional # sha1 argument - this will throw an error if the file has changed since # you first ran it source_gist(6872663, sha1 = "54f1db27e60") # Wrong hash will result in error source_gist(6872663, sha1 = "54f1db27e61") #' # You can speficy a particular R file in the gist source_gist(6872663, filename = "hi.r") source_gist(6872663, filename = "hi.r", sha1 = "54f1db27e60") ## End(Not run)
## Not run: # You can run gists given their id source_gist(6872663) source_gist("6872663") # Or their html url source_gist("https://gist.github.com/hadley/6872663") source_gist("gist.github.com/hadley/6872663") # It's highly recommend that you run source_gist with the optional # sha1 argument - this will throw an error if the file has changed since # you first ran it source_gist(6872663, sha1 = "54f1db27e60") # Wrong hash will result in error source_gist(6872663, sha1 = "54f1db27e61") #' # You can speficy a particular R file in the gist source_gist(6872663, filename = "hi.r") source_gist(6872663, filename = "hi.r", sha1 = "54f1db27e60") ## End(Not run)
If a SHA-1 hash is specified with the sha1
argument, then this
function will check the SHA-1 hash of the downloaded file to make sure it
matches the expected value, and throw an error if it does not match. If the
SHA-1 hash is not specified, it will print a message displaying the hash of
the downloaded file. The purpose of this is to improve security when running
remotely-hosted code; if you have a hash of the file, you can be sure that
it has not changed. For convenience, it is possible to use a truncated SHA1
hash, down to 6 characters, but keep in mind that a truncated hash won't be
as secure as the full hash.
source_url(url, ..., sha1 = NULL)
source_url(url, ..., sha1 = NULL)
url |
url |
... |
other options passed to |
sha1 |
The (prefix of the) SHA-1 hash of the file at the remote URL. |
## Not run: source_url("https://gist.github.com/hadley/6872663/raw/hi.r") # With a hash, to make sure the remote file hasn't changed source_url("https://gist.github.com/hadley/6872663/raw/hi.r", sha1 = "54f1db27e60bb7e0486d785604909b49e8fef9f9") # With a truncated hash source_url("https://gist.github.com/hadley/6872663/raw/hi.r", sha1 = "54f1db27e60") ## End(Not run)
## Not run: source_url("https://gist.github.com/hadley/6872663/raw/hi.r") # With a hash, to make sure the remote file hasn't changed source_url("https://gist.github.com/hadley/6872663/raw/hi.r", sha1 = "54f1db27e60bb7e0486d785604909b49e8fef9f9") # With a truncated hash source_url("https://gist.github.com/hadley/6872663/raw/hi.r", sha1 = "54f1db27e60") ## End(Not run)
Runs a spell check on text fields in the package description file, manual pages, and optionally vignettes. Wraps the spelling package.
spell_check(pkg = ".", vignettes = TRUE, use_wordlist = TRUE)
spell_check(pkg = ".", vignettes = TRUE, use_wordlist = TRUE)
pkg |
The package to use, can be a file path to the package or a
package object. See |
vignettes |
also check all |
use_wordlist |
ignore words in the package WORDLIST file |
test()
runs all tests in a package. It's a shortcut for
testthat::test_dir()
test_active_file()
runs test()
on the active file.
test_coverage()
computes test coverage for your package. It's a
shortcut for covr::package_coverage()
plus covr::report()
.
test_coverage_active_file()
computes test coverage for the active file. It's a
shortcut for covr::file_coverage()
plus covr::report()
.
test(pkg = ".", filter = NULL, stop_on_failure = FALSE, export_all = TRUE, ...) test_active_file(file = find_active_file(), ...) test_coverage(pkg = ".", show_report = interactive(), ...) test_coverage_active_file( file = find_active_file(), filter = TRUE, show_report = interactive(), export_all = TRUE, ... )
test(pkg = ".", filter = NULL, stop_on_failure = FALSE, export_all = TRUE, ...) test_active_file(file = find_active_file(), ...) test_coverage(pkg = ".", show_report = interactive(), ...) test_coverage_active_file( file = find_active_file(), filter = TRUE, show_report = interactive(), export_all = TRUE, ... )
pkg |
The package to use, can be a file path to the package or a
package object. See |
filter |
If not |
stop_on_failure |
If |
export_all |
If |
... |
additional arguments passed to wrapped functions. |
file |
One or more source or test files. If a source file the corresponding test file will be run. The default is to use the active file in RStudio (if available). |
show_report |
Show the test coverage report. |
Uses remove.packages()
to uninstall the package. To uninstall a package
from a non-default library, use in combination with withr::with_libpaths()
.
uninstall(pkg = ".", unload = TRUE, quiet = FALSE, lib = .libPaths()[[1]])
uninstall(pkg = ".", unload = TRUE, quiet = FALSE, lib = .libPaths()[[1]])
pkg |
The package to use, can be a file path to the package or a
package object. See |
unload |
if |
quiet |
If |
lib |
a character vector giving the library directories to remove the
packages from. If missing, defaults to the first element in
|
with_debug()
to install packages with debugging flags set.
Other package installation:
install()
Set working directory.
wd(pkg = ".", path = "")
wd(pkg = ".", path = "")
pkg |
The package to use, can be a file path to the package or a
package object. See |
path |
path within package. Leave empty to change working directory to package directory. |