knitr::opts_chunk$set(
  collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", eval = TRUE,
  message = FALSE, warning = FALSE, error = FALSE, tidy = TRUE
)

The intent of pkgpeanuts is to automate building out robust R package scaffolding for a newly created package. Create a new R package project in RStudio. Then let pkgpeanuts take care of the rest. It is important to note that the primary function pkgpeanuts::pour is not intended for existing packages.

Package setup

After creating a new local package project with git in RStudio, call pkgpeanuts::pour from the package root directory with your desired arguments. I suggest not doing this, however. Instead, use the convenient RStudio addin.

pkgpeanuts has many arguments. See the help documentation for details. And again, this is not intended for existing packages.

Special notes

This is relevant particularly for Windows users. I have not tested on other systems.

cred <- git2r::cred_ssh_key(publickey = "~/../.ssh/id_rsa.pub", privatekey = "~/../.ssh/id_rsa")
usethis::use_github(credentials = cred)

This is the only way I currently have things functioning without errors.

In the addin, the code linting option is currently disabled. Note that if you provide lintr = "test" to pour and receive a warning like the following:

In file.symlink("inst/.lintr", ".lintr") :
  cannot symlink 'inst\.lintr' to '.lintr', reason 'A required privilege is not held by the client'

this means that pour was unable to create a symlink due to restricted permissions. You need to run RStudio as administrator to avoid this warning. The symbolic link is necessary for the current approach to combining lintr with testthat unit testing and not failing a Travis-CI build. I think there is now another way to do this, but I have not looked into it yet. Stay tuned.

Shiny apps in a package

Add an existing, external Shiny app to a source package with use_app. This will copy the app into the inst directory. For example:

use_app("../app")

By default this will also add a template DESCRIPTION file and template Readme.md file. These files can also be added separately using use_app_description and use_app_readme. This gives more control over the content output by use_app_description. These files are useful for Shiny showcase mode.

use_app_description("path/to/app", title = "My app", author = "Me", url = "example.com", tags = c("data analysis", "graphing"))
use_app_readme()


leonawicz/pkgpeanuts documentation built on June 7, 2019, 2:56 a.m.