Вам необходимо использовать реактивный элемент пользовательского интерфейса.
library(shiny)
ui <- fluidPage(
# Application title
titlePanel("Hello Shiny!"),
# Sidebar with a slider input for number of observations
sidebarLayout(
sidebarPanel(
uiOutput("slider")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
server <- function(input, output) {
# Expression that generates a plot of the distribution. The expression
# is wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should be automatically
# re-executed when inputs change
# 2) Its output type is a plot
#
output$slider <- renderUI({
sliderInput("obs",
"Number of observations:",
min = 1,
max = 1000,
value =runif(1,1,1000))
})
output$distPlot <- renderPlot({
req(input$obs)
# generate an rnorm distribution and plot it
dist <- rnorm(input$obs)
hist(dist)
})
}
shinyApp(ui = ui, server = server)
Это случайным образом выберет новое значение в ползунке. Это то, что вы были после?