library(shiny)
ui <- shinyUI(fluidPage( titlePanel("test data clipping"), sidebarLayout( sidebarPanel( actionButton('inDataGen', 'Generate dataset'), br(), br(), uiOutput('resetable_input_clip'), actionButton('inDataClipReset', 'Reset data clipping') ), mainPanel(plotOutput("plotHist", width = "100%")) )))
server <- shinyServer(function(input, output, session) { rValues <- reactiveValues(dataIn = NULL, dataClip = NULL, dataMin = -10e10, dataMax = -10e10) # generate random dataset observeEvent(input$inDataGen, { cat(file = stderr(), '\nuserDataGen\n') # assign result to shared 'dataIn' variable x <- rnorm(1000) rValues$dataIn = x rValues$dataMin = min(x) rValues$dataMax = max(x) }) # clip data from below observeEvent(input$inDataClipMin, { cat(file = stderr(), 'dataMod:min\n') dm = rValues$dataClip thresh = input$inDataClipMin
if (!is.null(dm)) { cat(file = stderr(), 'dataMod:min:clip\n') dm[dm < thresh] <- thresh rValues$dataClip <- dm } })
# clip data from above observeEvent(input$inDataClipMax, { cat(file = stderr(), 'dataMod:max\n') dm = rValues$dataClip thresh = input$inDataClipMax if (!is.null(dm)) { cat(file = stderr(), 'dataMod:max:clip\n') dm[dm > thresh] <- thresh rValues$dataClip <- dm } }) output$resetable_input_clip <- renderUI({ cat(file = stderr(), 'output$resetable_input_clip\n') times <- input$inDataClipReset rValues$dataClip = rValues$dataIn div( id = letters[(times %% length(letters)) + 1], numericInput( 'inDataClipMin', 'Clip data below threshold:', value = rValues$dataMin, width = 200, step = .1 ), numericInput( 'inDataClipMax', 'Clip data above threshold:', value = rValues$dataMax, width = 200, step = .1 ) ) }) output$plotHist <- renderPlot({ cat(file = stderr(), 'plotHist \n') dm = rValues$dataClip if (is.null(dm)) return(NULL) else { plot(hist(dm)) Sys.sleep(2) } })})
shinyApp(ui = ui, server = server)
# App started
output$resetable_input_clipplotHist dataMod:mindataMod:max
userDataGen # generate data button pressedoutput$resetable_input_clipplotHist # 1st drawing of the plotdataMod:mindataMod:min:clipdataMod:maxdataMod:max:clipplotHist # 2nd drawing
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/3c435a73-89a7-4a1e-b77b-e151f23f1fbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/b8030687-455e-4958-bbdb-47658eb794f0%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/e24eb9ed-fc7e-453a-b183-5111332b89ab%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/e24eb9ed-fc7e-453a-b183-5111332b89ab%40googlegroups.com.
locInGen1 = input$inDataGen1 locInGen2 = input$inDataGen2
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/D0AE0CD0-385B-4BDF-9E06-7F780E300B2D%40gmail.com.