Package Setup & Maintenace

#> Package: RtmpWqdRaE
#> Title: What the Package Does (One Line, Title Case)
#> Version: 0.0.0.9000
#> Authors@R (parsed):
#>     * First Last <[email protected]> [aut, cre]
#> Description: What the package does (one paragraph).
#> License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
#>     license
#> Config/roxygen2/version: 8.1.1
#> Encoding: UTF-8
#> Roxygen: list(markdown = TRUE)

Create package infrastructure

A startup message

use_zzz() creates a package documentation file with .onLoad, .onAttach, and %||%. It is similar to usethis::use_package_doc() while also providing a useful starting template.

use_zzz(path = dir, open = FALSE)
#> ✔ Setting active project to "/tmp/RtmpWqdRaE".
#> ✔ Created '/tmp/RtmpWqdRaE/R/RtmpWqdRaE-package.R' from template.
#> ✔ Adding cli to 'Imports' field in DESCRIPTION.
#> 
#> ☐ Refer to functions with `cli::fun()`.

Check missing function in _pkgdown reference

check_pkgdown_reference() identifies exported functions that are absent from the reference section of _pkgdown.yml.

check_pkgdown_reference(pkg = dir)

Configure the clangd language server

use_clangd() writes a .clangd configuration file that lets the clangd language server find the system R headers and the include/ directory of the packages you pass in include (Rcpp, RcppEigen and RcppArmadillo by default). Packages that are not installed are skipped with a warning.

use_clangd(path = dir, overwrite = TRUE)
#> Warning: Package RcppEigen is not installed; skipping its include path.
#> Warning: Package RcppArmadillo is not installed; skipping its include path.
#> ✔ Created '/tmp/RtmpWqdRaE/.clangd'.

When path is a package root, the file also disables background indexing for the R/ directory (which holds no C++ code) and adds .clangd to .Rbuildignore.

use_clangd(path = dir, include = c("Rcpp", "BH"), overwrite = TRUE)

Vendor permissively licensed code

use_vendor() records attribution and licensing information when incorporating selected source files from a permissively licensed GitHub R package. It creates an inst/vendor/ directory, a R/vendor-*.R file, and updates relevant DESCRIPTION fields.

try(use_vendor(
  pkg = "WangLabCSU/rpkgkit",
  "43_use_vendor.R",
  branch = "main",
  path = dir
))
#> ℹ Fetching repository information for WangLabCSU/rpkgkit...
#> ✔ Vendor package uses MIT license.
#> ✔ Created directory '/tmp/RtmpWqdRaE/inst/vendor/rpkgkit'.
#> ✔ Copied 'LICENSE'.
#> ✔ Copied 'LICENSE.md'.
#> ✔ Created 'inst/vendor/rpkgkit/README.md'.
#> ✔ Created '/tmp/RtmpWqdRaE/R/vendor-rpkgkit.R'.
#> ✔ Added rpkgkit authors to Authors@R.
#> ✔ Updated DESCRIPTION.
#> ☐ Consider pasting the following statement into README.md
#> 
#> 
#> ## Acknowledgements
#> 
#> We would like to thank the following people and projects:
#> 
#> - The authors of the [rpkgkit](https://github.com/WangLabCSU/rpkgkit) package &mdash; **Yuxi Yang** &mdash; whose code is included (under MIT license) in `R/vendor-rpkgkit.R`.

Only packages with a supported permissive license can be vendored. Review the acknowledgement text printed by the function and add it to your README when appropriate.

rpkgkit::PERMISSIVE_LICENSE
#> [1] "MIT"          "Apache-2.0"   "Apache 2.0"   "BSD-2-Clause" "BSD-3-Clause"
#> [6] "Unlicense"    "CC0-1.0"      "CC0"

usethis extensions

Use the following helpers from the package root:

Use R 4.1.0 version

R 4.1.0 introduced the pipe (|>) and anonymous function \(). If these syntaxes need to be used in a package, the R package must require at least R version 4.1.0.

use_r_v4.1.0(path = dir)
#> ✔ Adding R to 'Depends' field in DESCRIPTION.

Add URL in DESCRIPTION

use_url(dir)

Add bug reports URL in DESCRIPTION

use_bugreports(dir)

Open CFF

CITATION.cff files are plain text files with human- and machine-readable citation information for software and datasets.

Code developers can include such files in their source code repositories to let others know how to correctly cite their software.

open_cffinit()

This cannot replace usethis::use_citation(), it just complements project.

Global ignore-file templates

Use add_global_rbuildignore() and add_global_gitgnore() to add the corresponding global ignore-file templates to a package.

add_global_rbuildignore(path = dir)
#> ✔ Added 39 pattern(s) to '.Rbuildignore'.
add_global_gitgnore(pkg = dir)