Compartmentalized Documented Extendible Reproducible Robust

Part 2, Bells and whistles. Checking your package, vignettes, and {pkgdown}.

Checking your package

Just use the RStudio Check in the Build tab. You’ll have many issues (most likely). Plug away at each one until you pass with no errors or warnings. Don’t ignore Notes either. They are sometimes more serious than the errors and warnings.

If R asks you to update packages, and then proceeds to fail at installation because of a warning that a package was built under a later R version than you have on your computer, use

Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS=TRUE)

Writing a vignette

Doing this in RStudio is easy. See rmarkdown vignette chapter and Hadley’s vignette chapter for more info.

Making the vignette

Manually

  • Make a vignettes folder at the base level (same level as the R folder)
  • Create a new vignette file from a template. RStudio > File > New > R Markdown > From Template > Vignette
  • Save in vignettes folder
  • Change the title in the 2 places in the yaml at the top. ‘yaml’ is between the --- fences.
  • Add the following 2 lines to your DESCRIPTION file:
Suggests: knitr, rmarkdown
VignetteBuilder: knitr

Or use a helper function:

usethis::use_vignette("plots", title="Plotting")

Testing your vignette

Open your vignette file and click the Knit button.

Sharing your vignette

Read more here about getting vignettes to show up with browseVignettes().

If you use {pkgdown} (recommended) to share your package documentation, the vignettes will automatically be displayed.

Making a {pkgdown} webpage

pkgdown makes it easy to make nice webpages for your packages.

Once you have a working R package, run this

  • In RStudio Cloud to view only, pkgdown::build_site(override = list(destination = "~/docs"))
  • In RStudio Cloud to create the docs folder for the package, pkgdown::build_site()
  • On your computer in RStudio, pkgdown::build_site()

You’ll need to install {pkgdown} if you are on your own computer.

NMFS branded package

Elements of a NMFS branded package: open this: https://rstudio.cloud/project/3592880

  • LICENSE
  • Disclaimer
  • Logos
  • Footer
  • NMFS pallette

The NMFS Fisheries Integrated Toolbox has a NMFS branded template that you can use: https://github.com/nmfs-fish-tools/pkgdownTemplate

Let’s see an example,

Then type

`pkgdown::build_site(override = list(destination = "~/docs"))`

NWFSC Math Bio Program