knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

remotes::install_cran(c("desc"), repos = "https://cran.rstudio.com/", quiet = TRUE)
desc_obj <- desc::description$new()
package_name <- desc_obj$get_field("Package")

This article describes how to use the template for a new package. The Overview section presents a recipe that leads to a fully configure package. The rest of the sections illustrate some of the steps. For more general information about R package development, refer to [@wickham2015r].

Overview

The following steps set up:

To use the template for a new package, follow the next steps:

  1. Choose a package name:
  2. Do use the following characters: letters (uppercase or uppercase), digits and dot ("."); and
  3. Don’t use spaces, underscores or hyphens. Instead, use camelCase or dots to separate words.
  4. Create a new repo on GitHub; name the repo after the package name;
  5. Copy the content of template.package into the new repo;
  6. Delete the vignettes folder;
  7. Rename template.package.Rproj to {package-name}.Rproj;
  8. Update the following fields within the DESCRIPTION file:
  9. Package; rename the package name.
  10. Title; describe the package in one line:
    • It should be plain text (no markup), capitalised like a title, and NOT end in a period; and
    • Keep it short: listings truncate the title to 65 characters.
  11. URL; Add a link pointing at the GitHub pages address of the package:
    • Use the template: https://{user-name}.github.io/{package-name}/
    • For example https://tidylab.github.io/template.package/
  12. BugReports; edit the URL such that it leads to the package issue page:
    • Use the template: https://github.com/{user-name}/{package-name}/issues
    • For example https://github.com/tidylab/template.package/issues
  13. Date; replace with the creation date of the package:
    • The specified date determines the MRAN snapshot date; alternatively
    • Use the most recent packages on CRAN by removing that filed.
  14. Authors and Maintainer: Update persons information;
  15. Description; Elaborate the package Title:
    • You can use multiple sentences but you are limited to one paragrap; and
    • If your description spans multiple lines (and it should!), each line must be no more than 80 characters wide. Indent subsequent lines with 4 spaces
  16. Render the README.Rmd file. By default, README.Rmd displays package information gathered from the DESCRIPTION file;
  17. Push changes to GitHub;
  18. Connect the GitHub repo to external services:
  19. Go to GitHub user Settings/Developer settings/Personal access tokens and generate a token named GITHUB_PAT; then
  20. Go to Travis website, add the project and enable its integration. Add GITHUB_PAT as an environment variable; then
  21. Go to Codecov website, add the project and enable its integration.

References



tidylab/tidy.preparation documentation built on Jan. 6, 2020, 12:45 a.m.