Skip to content

99 Creating the maar package

Shamindra Shrotriya edited this page Nov 15, 2020 · 5 revisions

Setting up the maar package

Note: This post is meant as a reference for @ricfog and @shamindras on how the maar package was setup. If you intend to contribute to this package, you can safely skip this page.

R commands using the usethis package

To setup this maar R package for the first time, we used the fantastic usethis R package.

We used the following R commands locally, once we cloned a blank maar github repo. We then pushed the changes after running these commands. Note that these commands only needed to be run once, to setup the maar R package github repo for the first time.

# Create the package in the active directory
usethis::create_package(path = here::here())

# Check if package name is available
available::available("maar")

# MIT License
usethis::use_mit_license()

# Use Rmd for README
usethis::use_readme_rmd()
# Update Readme.Rmd with package details, and also credits

# Testing with testthat
usethis::use_testthat()

# Spell Checking
usethis::use_spell_check()

# Use makefile
usethis::use_make()

# Use NEWS.md
usethis::use_news_md()

# Use version
usethis::use_version()

# Run once to configure your package to use pkgdown
usethis::use_pkgdown()

# Run to build the website
pkgdown::build_site()
# 1. Then need to go to Github settings for the maar package i.e.
#    https://github.com/shamindras/maar/settings
# 2. Scroll to Github Pages section and select dropdown and set branch to
#    be "main/(root)". Then click "Save"

# Setup tidy github labels
# Note: First a GITHUB token needs to be added to your account
#       see here: https://kbroman.org/AdvData/18_rpack_demo.html
usethis::use_github_labels(delete_default = TRUE)

# Now create tidy labels
usethis::use_tidy_labels()

# Use tidy style preferences
# First convenience wrapper that calls use_tidy_contributing(), use_tidy_issue_template(), use_tidy_support(), use_tidy_coc().
usethis::use_tidy_github()

# Clean up package using tidy style
# Puts fields in standard order and alphabetises dependencies.
usethis::use_tidy_description()

# Imports a standard set of helpers to facilitate programming with the tidy
# eval toolkit.
usethis::use_tidy_eval()
devtools::document()

# styles source code according to the tidyverse style guide. This function will overwrite files! See below for usage advice.
usethis::use_tidy_style()

# Sets up the following workflows using GitHub Actions:
# Run R CMD check on the current release, devel, and four previous versions of R.
# Report test coverage.
# Build and deploy a pkgdown site.
# Provide two commands to be used in pull requests:
#   /document to run roxygen2::roxygenise() and update the PR, and
#   /style to run styler::style_pkg() and update the PR.
usethis::use_tidy_github_actions()

# Implements the pkgdown setup used for most tidyverse and r-lib packages:
# configures a GitHub Action to automatically build the pkgdown site and deploy
# it via GitHub Pages
usethis::use_github_action("pkgdown")
usethis::use_tidy_pkgdown()
Clone this wiki locally