This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Execute chunks by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

Package

Package related code.

Vignette

# generate Vignette
library(MBSStools)
library(devtools)
devtools::build_vignettes()

devtools::build() more useful and build_vignettes()

Create Package

Use the code below to create the package. Assumes you are in the development package directory

# NEWS
# Render then Copy NEWS so picked up in help
rmarkdown::render("NEWS.rmd", "all")
file.copy("NEWS.md", "NEWS", overwrite = TRUE)
file.remove("NEWS.html")
#file.remove("NEWS.md")
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Library Name
myPkg <- "MBSStools" # "ContDataQC","MMIcalc","MMIcalcNV","MBSStools","XC95"
# Load Library
library(devtools)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create Package
# create(myLibrary)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# files to library folder
# file.copy("metric.values.R","./Library/MMIcalc/R/metric.values.R",overwrite=TRUE)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Document, Install, and Reload Library
## Generate Documentation
#setwd(file.path(".", myPkg))
devtools::document()
## Install New Package (locally)
setwd("..") # return to root directory first
devtools::install(myPkg, quick=FALSE, reload=TRUE, build_vignettes = TRUE)

# blank row above allows for the code to continue instead of waiting for user 
#   response to pkg updates.
## Reload library
library(myPkg, character.only = TRUE)
# change wd back to package
setwd(paste0("./", myPkg))
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After creating the package reload it after restarting R within RStudio (Control+Shift+F10).

# Restart R within RStudio:  Ctrl + Shift + F10
myPkg <- "MBSStools"
library(myPkg, character.only = TRUE)
help(package=(myPkg))
#?metric.scores 
citation(myPkg)

PkgDown website pkgdown::build_site()

https://www.r-bloggers.com/2020/12/top-10-tips-to-make-your-r-package-even-more-awesome/

use separate branch with GitHub actions.

Including Data

All data should have already been created.

Data Documentation

Use promptData to get data.r listing for columns. Short cuts creating documentation.

promptData(data_benthos_MBSS)

Error Checking

Need to use testthat but not to that stage yet.

# Check for errors (or press Cmd + Shift + E in RStudio)
#http://r-pkgs.had.co.nz/check.html
devtools::check()

Testings

https://testthat.r-lib.org/

https://r-pkgs.org/tests.html

Set up folders with devtools::test(). This is also the command to run tests.

Create test file usethis::use_test("name")

CI, Badges, Code Coverage, etc

badger package creates the text for pkg readme file.

Also https://shields.io/
https://github.com/badges/shields Can make some badges dynamic, static ones below

issues

GitHub issues

release

GitHub release

downloads

Github all releases

pkg_GH <- "leppott/MBSStools"
pkg_lic <- "MIT"

# GitHub Action, CI
usethis::use_github_actions()
usethis::use_github_actions_badge()
# badger::badge_github_actions(pkg_GH)

# Code coverage
usethis::use_github_action("test-coverage")

# GitHub Action, pkgdown
usethis::use_github_action("pkgdown")

# Badges
# lifecycle
badger::badge_lifecycle("stable", "green") # stable/green, maturing/dormant/blue
# maintained
# license
badger::badge_license(pkg_lic)
# code quality
badger::badge_codefactor(pkg_GH)
# code testing coverage
badger::badge_codecov(pkg_GH)
# cmd check
badger::badge_github_actions(pkg_GH)


leppott/MBSStools documentation built on April 8, 2024, 9:57 p.m.