简体   繁体   中英

Deploying packaged shiny-app on shinyapps.io

as described here and here , there are several possibilities to develop a shiny-application as a package and host it online. A common way is to include a ui.R and a server.R file in the inst-Directory in the package, and as part of the package to write a function which calls runApp() using this files.

However, to launch this packaged app online, the file structure on the server must be modified or the function to launch the app must be called by creating another skript. As far as I know, this is not possible on shinyapps.io .

Since I want/must use shinyapps.io, my question is: How can I best deploy a packaged app on shinyapps.io? One possibility would be to upload the package to CRAN, to manually copy the ui.R and server.R files into a new app, include the package (to have access to all the other functions included in the package, beside UI and server-logic), and then deploy this app on shinyapps.io. But: Are there other/better possibilities?

You could try to upload your package on CRAN and call it inside your shinyApp. This would give you all the functionality of your package and everyone else who might be interested in your package aswell. The downside of this is, that you will have to go through a lot of formating, documenting, error checking, rebuilding, etc.. CRAN has quite some strict rules on how the package must "look" like to accept and host it. At least you have to have 0 errors and 0 warnings when checking it.


If you dont want to host it on CRAN you can just include all the functions from the package in a directory and source those files in your Shinyapp. You can do that inside a global.R file or even inside the server.R file, but outside the server function.

----- ./App_Directory/
---------- global.R
---------- server.R
---------- ui.R
---------- www/
--------------- function1.R
--------------- function2.R
--------------- function_etc.R

Then you would source them by including those commands in your global.R / server.R file:

source("www/function1.R")
source("www/function2.R")
source("www/function_etc.R")

You could also just put all the functions directly in your global/server file, but sourcing them is probably more organized and easier to maintain.

----- ./App_Directory/
---------- global.R
---------- server.R
---------- ui.R

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM