How to modify data in shiny app


#1

I need run my shiny app with data parameter. So I’ve encapsulated the shiny app as a function, such as:

start_group_ui<-function(data){
  ui <-(...)
  server <- function(input, output, session) {...}
  shinyApp(ui, server)
}

In RStudio, I ran the app such as: start_group_ui(sample1)
However, in the shiny app, I’d like to modify the variable “sample1”. If I ran the app such as: sample1 <- start_group_ui(sample1), then the app would stop immediately, and didn’t start web interface.
How to get the modified sample1?


#2

Hi @tanhuobin, hopefully this helps:


start_group_ui<-function(data){
  app <- shinyApp(
    ui = fluidPage(
      tableOutput("table")
    ),
    server = function(input, output) {
      output$table = renderTable(data)
    },
    onStart = function()data
  )
  runApp(app)
}
start_group_ui(iris)

#3

I think you may find some useful info/discussion in this github issue of shiny: https://github.com/rstudio/shiny/issues/440


#4

Thanks for your relpy.
I think you misunderstand my question. I can pass paremeters to shinyapp, however, my question is how to return values what were modified in the shinyapp? In other words, I need to save the modifed values in the shinyapp to current workspace.


#5

Thanks for your reply. I’ll try it.