r - How could I deploy a shiny app created using shinyApp() via shinyapps::deployApp( )? -
i want deploy (to web) application made in r/shiny call shinyapp()
function.
it possible make app call shinyapp()
follows:
test_app = shinyapp( ui = fluidpage( numericinput("n", "n", 1), plotoutput("plot") ), server = function(input, output) { output$plot <- renderplot( plot(head(cars, input$n)) ) } )
this retuns object represents app , app can run printing object. wish deploy app made usingshinyapps::deployapp( test_app)
gives me following error:
error in shinyapps::deployapp(test_app) : appdir must single element character vector
this because deployapp
function expecting directory not shinyapp object. presumably information build , therefore deploy app contained in test_app
object, inspecting object not reveal much, , seems same app create:
> str(test_app) list of 4 $ httphandler :function (req) $ serverfuncsource:function () $ onstart : null $ options : list() - attr(*, "class")= chr "shiny.appobj" >
the code produce app not contained in obvious way in object. suspect answer may have r6 reference classes, not understand.
does know how might extract information contained in app test_app
object in order deploy via deployapp()
function? (or alternative approach)
i have posted on shinyapps users google group got no response, i'm trying again here.
the shinyapp
command not meant used app construction, its' help:
you shouldn't need use these functions create/run applications; intended interoperability purposes, such embedding shiny apps inside knitr document.
deployapp
doesn't support shinyapp
apps, found ?deployapp
. said, it's easy fix (and most) apps, more or less pasting commands files called ui.r
, server.r
, wrapped in shinyui()
, shinyserver()
:
ui.r:
library(shiny) shinyui(fluidpage( numericinput("n", "n", 1), plotoutput("plot") ) )
server.r:
library(shiny) shinyserver(function(input, output) { output$plot <- renderplot( plot(head(cars, input$n)) ) } )
put 2 files in directory , run deployapp("dir")
after testing runapp("dir")
if have parts of shiny app not part of server or ui (ie data preprocessing), need paste them above shiny call in relevant file. if calling shiny app arguments, can either hard code them above shiny call, or integrate them reactive values in shiny itself.
Comments
Post a Comment