问题
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