R/create_shiny.R

Defines functions create_shiny

Documented in create_shiny

#' Initialize a shiny
#' 
#' Make the directory structure and code for a lab notebook. 
#' 
#' @param name Name of new shiny folder.
#' @param location Path to a new shiny dashboard (from working directory)
#' @param theme Which Shiny theme you want between : "shiny_theme_1", "shiny_theme_2"
#' @export

create_shiny = function(name, theme = "shiny_theme_1", location = getwd()) {
  # Create valid destination pah
  location = normalizePath(location)
  # Copy template to destination -------------------------------------------------------------------
  destination_path = file.path(location, name)
  template_path = system.file(theme, package = "toolbox")
  if (file.exists(destination_path)) stop("Folder with that name already exists. Delete the existing folder or choose a different name.")
  file.copy(from = template_path, to = location, recursive = TRUE)
  # rename root folder
  file.rename(from = file.path(location, theme),
              to = file.path(location, name))
}
AlexisMayer/toolbox documentation built on Aug. 25, 2020, 3:56 p.m.