gpt4 book ai didi

R Shiny 动态 slider 动画

转载 作者:行者123 更新时间:2023-12-04 11:07:55 24 4
gpt4 key购买 nike

这个问题已经问过了 here但由于没有答案,我想我会发布另一个简单的例子,希望能找到答案。

问题是当使用 renderUI() 动态构建 slider 时,sliderInput() 的动画选项不起作用。

所以虽然这很好用:

# works 
library(shiny)

shinyApp(

ui = fluidPage(

sliderInput("animationSlider", "non-dynamic animation slider",
min = 1, max = 100, value = 1, step = 1,
animate = animationOptions(200)),

textOutput("sliderValue")

),

server = function(input, output) {

output$sliderValue <- renderText(paste("value:", input$animationSlider))

}
)

这不起作用:
#doesn't work
library(shiny)

shinyApp(

ui = fluidPage(

numericInput("max", "Set max value for dynamic animation slider",
value = 10),
uiOutput("animationSlider"),
textOutput("sliderValue")

),

server = function(input, output) {

output$animationSlider <- renderUI({
sliderInput("animationSlider", "Dynamic animation slider",
min = 1, max = input$max, value = 1, step = 1,
animate = animationOptions(200))
})

output$sliderValue <- renderText(paste("value:", input$animationSlider))

}
)

最佳答案

一切正常,你不能有 2 个同名的 div:

library(shiny)

shinyApp(

ui = fluidPage(

numericInput("max", "Set max value for dynamic animation slider",
value = 10),
uiOutput("animationSlider"),
textOutput("sliderValue")

),

server = function(input, output) {

output$animationSlider <- renderUI({
sliderInput("animationSlider2", "Dynamic animation slider",
min = 1, max = input$max, value = 1, step = 1,
animate = animationOptions(200))
})

output$sliderValue <- renderText(paste("value:", input$animationSlider2))

}
)

关于R Shiny 动态 slider 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38185008/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com