shiny-reactivity

How to listen for more than one event expression within a Shiny observeEvent

我只是一个虾纸丫 提交于 2019-12-04 10:51:36
问题 I want two different events to trigger an observer. It was suggested here that this should work. But it seems that it depends only on the second event. observeEvent({ input$spec_button mainplot.click$click }, { ... } ) Have a look at the example. ui <- shinyUI(bootstrapPage( actionButton("test1", "test1"), actionButton("test2", "test2")) ) server <- shinyServer(function(input, output) { observeEvent({ input$test1 input$test2 }, { print('Hello World') }) }) shinyApp(ui, server) Once you click

Can I save the old value of a reactive object when it changes?

点点圈 提交于 2019-12-03 12:26:12
Note: After coming up with the answer I reworded the question to make if clearer. Sometimes in a shiny app. I want to make use of a value selected by the user for a widget, as well as the previous value selected for that same widget. This could apply to reactive values derived from user input, where I want the old and the new value. The problem is that if I try to save the value of a widget, then the variable containing that value has to be reactive or it will not update every time the widget changes. But, if I save the the value in a reactive context it will always give me the current value,

How to listen for more than one event expression within a Shiny observeEvent

只谈情不闲聊 提交于 2019-12-03 08:04:22
I want two different events to trigger an observer. It was suggested here that this should work. But it seems that it depends only on the second event. observeEvent({ input$spec_button mainplot.click$click }, { ... } ) Have a look at the example. ui <- shinyUI(bootstrapPage( actionButton("test1", "test1"), actionButton("test2", "test2")) ) server <- shinyServer(function(input, output) { observeEvent({ input$test1 input$test2 }, { print('Hello World') }) }) shinyApp(ui, server) Once you click button test1 nothing happens. If you click button test2 it prints to your console. Once test2 button

Loading shiny module only when menu items is clicked

早过忘川 提交于 2019-12-02 04:25:33
问题 Background Within a modular 1 Shiny application, I would like to load module only when menu item on shinydashboard is clicked. If the menu item is not accessed I wouldn't like to load the module. Basic application app.R # Libs library(shiny) library(shinydashboard) # Source module source("sample_module.R") ui <- dashboardPage( dashboardHeader(title = "Dynamic sidebar"), dashboardSidebar(sidebarMenuOutput("menu")), dashboardBody(tabItems( tabItem(tabName = "tab_one", h1("Tab One")), tabItem

R Shiny: Editing DT with locked columns

与世无争的帅哥 提交于 2019-11-29 11:36:51
I am trying to have a DT that is editable by the user but I only want certain columns to be editable. Since this isn't a feature yet in DT , I am trying to hack it together by having the table refresh back to the original value when edited a column that I want "locked". Below is my code: library (shiny) library (shinydashboard) library (DT) library (dplyr) library (data.table) rm(list=ls()) ###########################/ui.R/################################## #Header---- header <- dashboardHeaderPlus() #Left Sidebar---- sidebar <- dashboardSidebar() #Body---- body <- dashboardBody( useShinyjs(),

R Shiny: Editing DT with locked columns

人走茶凉 提交于 2019-11-28 05:03:13
问题 I am trying to have a DT that is editable by the user but I only want certain columns to be editable. Since this isn't a feature yet in DT , I am trying to hack it together by having the table refresh back to the original value when edited a column that I want "locked". Below is my code: library (shiny) library (shinydashboard) library (DT) library (dplyr) library (data.table) rm(list=ls()) ###########################/ui.R/################################## #Header---- header <-

R shiny passing reactive to selectInput choices

人盡茶涼 提交于 2019-11-26 04:36:48
问题 In a shiny app (by RStudio), on the server side, I have a reactive that returns a list of variables by parsing the content of a textInput . The list of variables is then used in selectInput and/or updateSelectInput . I can\'t make it work. Any suggestions? I have made two attempts. The first approach is to use the reactive outVar directly into selectInput . The second approach is to use the reactive outVar in updateSelectInput . Neither works. server.R shinyServer( function(input, output,