Get min max of sliderInput in shiny

浪尽此生 提交于 2021-02-11 07:32:35

问题


I have a sliderInput element in my ui.R for which I determine the min and the max value dynamically (actually I use a module, where the values are determined from a data set).

What I would like to do now is to read the min/max values in my server.R. Of course I could use the same code and determine min/max again, but I was wondering whether it is not possible to get the min/max values from the element directly?


回答1:


As a workaround, you could set up reactives to calculate min and max, and then use a renderUI function to make the sliderInput.

I think you should already be using renderUI within your module, so this isn't a big workaround.




回答2:


How can you determine dynamic/reactive min and max values in UI?

The most reasonable solution is to move slider to server.R

UI.R

uiOutput("slider")

Server.R

output$slider <- renderUI({
     maxkaw <- max(...)
     minkaw <- min(...)

     sliderInput("slider","", min   = minkaw, 
                 max   = maxkaw,
                 value = c(minkaw,maxkaw))
   })



回答3:


After reading the two answers, I feel that the solution would be to pass an extra argument to my module containing the min/max values. Overall, the ui.R renders finally to html and I am not sure whether conceptually you should even try to access the html from the server.R



来源:https://stackoverflow.com/questions/40846677/get-min-max-of-sliderinput-in-shiny

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!