R/launch_explorer.R

Defines functions launch_pagerank_explorer

Documented in launch_pagerank_explorer

#' @title Launch PageRank Explorer
#' @description Opens an interactive Shiny application for exploring PageRank
#'   results. Upload CSV files for edge lists, redirects, and PageRank scores,
#'   then visualize the graph interactively, inspect distributions, audit
#'   redirects, and export in multiple formats.
#'
#' @param ... Additional arguments passed to \code{shiny::runApp} (e.g.,
#'   \code{port}, \code{host}, \code{launch.browser}).
#'
#' @details
#' The app requires the \code{shiny} and \code{DT} packages. For interactive
#' network visualization, \code{visNetwork} is recommended (the app falls back
#' to a static igraph plot if visNetwork is not installed).
#'
#' Install optional dependencies with:
#' \preformatted{install.packages(c("shiny", "DT", "visNetwork"))}
#'
#' @return Called for its side effect (launches the app). Returns invisibly.
#' @export
#' @examples
#' if (interactive()) {
#'   launch_pagerank_explorer()
#' }
launch_pagerank_explorer <- function(...) {
  if (!requireNamespace("shiny", quietly = TRUE)) {
    stop("The 'shiny' package is required. Install with: ",
      "install.packages('shiny')",
      call. = FALSE
    )
  }
  if (!requireNamespace("DT", quietly = TRUE)) {
    stop("The 'DT' package is required. Install with: ",
      "install.packages('DT')",
      call. = FALSE
    )
  }

  app_dir <- system.file("shiny", "pagerank_explorer", package = "pagerankr")
  if (app_dir == "") {
    stop("Could not find the Shiny app. Try reinstalling pagerankr.",
      call. = FALSE
    )
  }

  if (!requireNamespace("visNetwork", quietly = TRUE)) {
    message(
      "Tip: Install 'visNetwork' for interactive graph visualization: ",
      "install.packages('visNetwork')"
    )
  }

  shiny::runApp(app_dir, ...)
}

Try the pagerankr package in your browser

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

pagerankr documentation built on Oct. 1, 2026, 5:09 p.m.