knitr::opts_chunk$set(echo = TRUE, eval = FALSE,warning = F, message = F)
The following code outlines the key steps I did, principally using the usethis package.
I use these packages for setting things up
library(devtools) library(usethis) library(here)
I create a shroom git repo then cloned into it by hand by creating an RStudio Project.
I then used create_package() within my project directory to build the basic package infrastructure This overights the initial project (after a handy prompt in the console).
create_package(path = getwd())
Create a vignette infrastructure and dummy vignette
usethis::use_vignette("Results-model-equation")
use_readme_rmd() use_news_md()
Am not sure how to use this properly yet
use_git_ignore(".pdf", directory = ".")
use_package("dplyr", "Imports") use_package("tidyr", "Imports") use_package("ggplot2", "Imports") use_package("nlme", "Imports") use_package("lme4", "Imports") use_package("bbmle", "Imports") #bbmle use_package("RCurl", "Imports") use_package("GGally", "Imports") use_package("broom", "Imports") use_package("arm", "Imports") use_package("psych", "Imports") devtools::use_package("stringi", "Imports") devtools::use_package("stringr", "Imports") devtools::use_package("ggpubr", "Imports") devtools::use_package("plotrix", "Imports") devtools::use_package("here", "Imports") devtools::use_package("cowplot", "Imports") devtools::use_package("data.tree", "Imports") devtools::use_package("treemap", "Imports") #use_package("igraph", "Imports") devtools::use_package("PRISMAstatement", "Imports") devtools::use_package("sjPlot", "Imports") devtools::use_package("sjlabelled", "Imports") devtools::use_package("sjmisc", "Imports") devtools::use_package("visreg", "Imports")
use_blank_slate()
use_roxygen_md()
"Adds a dummy .R file that will prompt roxygen to generate basic package-level documentation. "
use_package_doc()
For making front end website
use_pkgdown()
dir.create(here("/inst")) dir.create(here("/inst/extdata"))
External data is stored in "/inst/extdata"
list.files(here::here("/inst/extdata"))
milk_raw <- read.csv(here::here("/inst/extdata", "skibiel_mammalsmilk_raw.csv")) use_data(milk_raw) use_r("milk_raw")
Just the fat column
milk <- read.csv(here::here("/inst/extdata", "skibiel_mammalsmilk.csv")) use_data(milk) use_r("milk")
Just the primates and relatives rows
milk_primates <- read.csv(here::here("/inst/extdata", "skibiel_primate_fat.csv")) use_data(milk_primates) use_r("milk_primates")
Just the fat column
milk_fat <- read.csv(here::here("/inst/extdata", "skibiel_fat.csv")) use_data(milk_fat) use_r("milk_fat")
http://kbroman.org/pkg_primer/pages/licenses.html
usethis::use_mit_license(name = "Nathan Brouwer")
#use_data_raw()
use_spell_check
use_r() #Create or edit a .R file
use_build_ignore() Add files to .Rbuildignore
use_version() use_dev_version() Increment package version
edit_r_profile() edit_r_environ() edit_r_makevars() edit_rstudio_snippets() edit_git_config() edit_git_ignore()
use_directory() Use a directory
"Builds package vignettes using the same algorithm that R CMD build does"
devtools::build_vignettes()
"This uses a fairly rudimentary algorithm where any files in ‘inst/doc’ with a name that exists in ‘vignettes’ are removed."
clean_vignettes()
pkgdown::build_site()
check_failures
"Clean and rebuild" ==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source mammalsmilk
"Install restart" ==> Rcmd.exe INSTALL --no-multiarch --with-keep.source mammalsmilk
## "Document" devtools::document(roclets=c('rd', 'collate', 'namespace')) ## "Load all" devtools::load_all(".") ## devtools::build_vignettes() ## "Check" devtools::check()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.