Created
November 23, 2022 08:21
-
-
Save ismirsehregal/1ca6c17879e5bb91610d3fd31a7ffe24 to your computer and use it in GitHub Desktop.
Update reactiveVal based on upstream reactive expressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/questions/74525623/follow-up-delete-rows-from-data-frames-in-shiny-using-datatable-server-side | |
library(shiny) | |
library(DT) | |
ui <- fluidPage( | |
sliderInput( | |
inputId = "sl1", | |
label = "sl1", | |
min = 1, | |
max = 10, | |
value = c(1,10) | |
), | |
sliderInput( | |
inputId = "sl2", | |
label = "sl2", | |
min = 1, | |
max = 10, | |
value = c(1,10) | |
), | |
sliderInput( | |
inputId = "sl3", | |
label = "sl3", | |
min = 1, | |
max = 10, | |
value = c(1,10) | |
), | |
DTOutput("table") | |
) | |
server <- function(input, output, session) { | |
r1 <- reactive({input$sl1*2}) | |
r2 <- reactive({input$sl2*3}) | |
r3 <- reactive({input$sl3*4}) | |
expanded_table <- reactiveVal() | |
observe({ | |
expanded_table(expand.grid(r1(), r2(), r3())) | |
}) | |
result_table <- reactive({ | |
expanded_table()*10 | |
}) | |
output$table <- renderDT({ | |
result_table() | |
}, server = FALSE) | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment