I am attempting to run a Shiny app as part of an R package. I followed the instructions listed on Dean Attali's website (https://deanattali.com/2015/04/21/r-package-shiny-app/).
As shown on that website, I created directories as follows in my R package:
- mypackage
|- inst
|- shiny-examples
|- myapp
|- ui.R
|- server.R
|- R
|- runExample.R
|- ...
|- DESCRIPTION
|- ...
Then, in my runExample.R file, I used:
#' @export
runExample <- function() {
appDir <- system.file("shiny-examples", "myapp", package = "mypackage")
if (appDir == "") {
stop("Could not find example directory. Try re-installing `mypackage`.", call. = FALSE)
}
shiny::runApp(appDir, display.mode = "normal")
}
The only difference is that I am attempting to input one parameter into function() above. It is called data, so I am using function(data=data).
However, if I run runExample(data=myData), this causes an Error related to data ("object of type 'closure' is not subsettable"). I believe this is because data=myData is not successfully transferred to the Shiny app. Any ideas on how to approach this issue would be much appreciated!