R/run_shiny.R

Defines functions run_shiny

Documented in run_shiny

#' Run the LeXOPS `shiny` App
#'
#' Runs the LexOPS `shiny` App, with optional additional arguments.
#'
#' The LexOPS `shiny` app requires additional packages. If any dependencies are missing, the user will be prompted to install them. The additional packages required are:
#' * `shiny`
#' * `shinydashboard`
#' * `plotly`
#' * `ggwordcloud`
#' * `colourpicker`
#' * `shinycssloaders`
#' * `shinyjs`
#' * `viridis`
#' * `DT`
#' * `readr`
#' * `forcats`
#' * `stringdist`
#' * `lexopsdata` (http://github.com/JackEdTaylor/lexopsdata)
#'
#' @param ... optional arguments to \code{shiny::\link[shiny]{runApp}}
#'
#' @returns No return value, called to initialise the LexOPS `shiny` app.
#'
#' @examples
#' if (interactive()) { run_shiny() }
#'
#' @export

run_shiny <- function(...) {
  app_dir <- system.file("shiny-app", package = "LexOPS")
  # check app is installed
  if (app_dir == "") {
    stop("Could not find the directory for the LexOPS Shiny App. Try re-installing `LexOPS`.")
  }
  # check dependencies
  rlang::check_installed(
    c("lexopsdata", "shiny", "shinydashboard", "plotly", "ggwordcloud", "colourpicker", "shinycssloaders", "shinyjs", "viridis", "DT", "readr", "forcats", "stringdist", "dplyr", "tidyr", "tibble", "purrr"),
    reason = "to run the LexOPS shiny app",
    action = function(pkg, ...) {
      # use github repository for lexopsdata
      pkg[pkg=="lexopsdata"] <- "JackEdTaylor/lexopsdata@*release"
      pak::pkg_install(pkg)
    }
  )
  # run app
  shiny::runApp(app_dir, ...)
}

Try the LexOPS package in your browser

Any scripts or data that you put into this service are public.

LexOPS documentation built on Dec. 1, 2026, 5:06 p.m.