15 Create an R
package
Creating an R
package can be done in a few easy steps.
usethis::create_package("~/Documents/GitHub/MyExamplePackage")
usethis::use_mit_license("J Kyle Armstrong")
usethis::use_readme_md()
usethis::use_pkgdown()
usethis::use_testthat()
usethis::use_package("ggplot2", "Imports", min_version = TRUE)
Imports is used for packages that are needed by your package but that don’t need to be loaded with
library()
. Packages referred to in@import
or@importFrom
statements in your Roxygen2 comments, or whose functions are accessed via the::
operator, should be here.Suggests is for packages that aren’t really necessary, but that you’re using in your examples, vignettes, or tests. Any package listed in Imports will need to be installed with your package, while packages listed in Suggests do not need to be installed with your package.
tidyverse_packages <- c('tibble','readr','dplyr','tidyr','stringr','purrr','ggplot2','forcats')
tidyverse_friends <- c('broom','lubridate','readxl','knitr','shiny','furrr','flexdashboard','yardstick')
other_packages <- c('devtools','rsq','arsenal','skimr',
'RSQLite','dbplyr','plotly','DT','GGally','corrr',
'AMR','caret','shiny','DataExplorer','randomForest','usethis','testthat','pkgdown')
purrr::walk(c(tidyverse_packages, tidyverse_friends, other_packages),
function(package){
usethis::use_package(package, "Imports", min_version = TRUE)
}
)
devtools::load_all()
devtools::document()
devtools::install()
detach(package:MyExamplePackage)