Helper code for creating library.

Erik.Leppo@tetratech.com 2017-09-26

Package

Package related code.

Create Package

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

# Remove all files in "Results" folder
# Triggered here so can run different files
path_results <- file.path("inst", "apps", "EGLEtools", "results")
fn_results <- list.files(path_results
                         , full.names = TRUE
                         , include.dirs = TRUE
                         , recursive = TRUE)
unlink(fn_results, recursive = TRUE) # to include dir use unlink instead of file.remove
# Copy file to ensure directory not empty
path_shiny <- file.path("inst", "apps", "EGLEtools")
fn_copy    <- "remove.txt"
path_from  <- file.path(path_shiny, "data", fn_copy)
path_to    <- file.path(path_shiny, "results", fn_copy)
file.copy(path_from, path_to)
# Library Name
# 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")
#
myPkg <- "EGLEtools"
# Load Library
library(devtools)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create Package
# create(myPkg)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Document, Install, and Reload Library
## Generate Documentation
#setwd(paste0("./",myPkg))  # will fail as already in this directory
devtools::document()
## Install New Package (locally)
setwd("..") # return to root directory first
devtools::install(myPkg, quick=FALSE, reload=TRUE, build_vignettes = FALSE)

## Reload library
library(myPkg, character.only = TRUE)
# change wd back to package
setwd(paste0("./",myPkg))
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Blocktt/MIEGLEtools documentation built on June 10, 2025, 12:49 a.m.