included shiny app with package, bslib, documentation, fixing NA bug

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-11-15 20:42:25 +01:00
commit 3cfdb66a32
21 changed files with 767 additions and 270 deletions

View file

@ -1,40 +1,39 @@
utils::globalVariables(c("server"))
#' Shiny server factory
#'
#' @return shiny server
#' @export
server_factory <- function() {
source(here::here("app/server.R"))
server
}
#' UI factory for shiny app
#'
#' @return shiny ui
#' @export
ui_factory <- function() {
# require(ggplot2)
source(here::here("app/ui.R"))
}
#' Launch the included Shiny-app for database casting and upload
#'
#' @description
#' Wraps shiny::runApp()
#'
#' @param ... Arguments passed to shiny::runApp()
#'
#' @return shiny app
#' @export
#'
#' @examples
#' # shiny_cast()
#'
shiny_cast <- function() {
# shiny::runApp(appDir = here::here("app/"), launch.browser = TRUE)
shiny_cast <- function(...) {
appDir <- system.file("shiny-examples", "casting", package = "REDCapCAST")
if (appDir == "") {
stop("Could not find example directory. Try re-installing `REDCapCAST`.", call. = FALSE)
}
shiny::shinyApp(
ui_factory(),
server_factory()
)
shiny::runApp(appDir = appDir, ...)
# This is from the VarSelLCM
# shiny_cast2 <- function(X){
# check.results(X)
# G <- .GlobalEnv
# assign("resVSLC", X, envir=G)
# a=shiny::runApp(system.file(package="REDCapCAST"),launch.browser = TRUE)
# return(invisible(a))
# }
# shiny::runApp(appDir = here::here("app/"),...)
# ## Need adjustments to run anywhere
}
#' Helper to import files correctly
#'
#' @param filenames file names