gpt4 book ai didi

r - Shiny slider 定制值

转载 作者:行者123 更新时间:2023-12-02 02:50:07 30 4
gpt4 key购买 nike

我正在尝试为 Shiny slider 设置自定义值(1、5、10、15、20、25 和 30)。我尝试了 step 但结果要么 (0,5,10,15,20,25,30) 要么 (1,6,11,16,21,26,31)。有什么方法可以定义 slider 的自定义值吗?谢谢!

plotpath <- "/Volumes/share-ites-1-$/Projects/Scientifica/Simulations_Scientifica"

ui <- fluidPage(
titlePanel("LandClim Simulations"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "temp",
label = "Temperature increase:",
value = 1, min = 1, max = 2,
step = 1, animate = TRUE ),
sliderInput(inputId = "prec",
label = "Precipitation change:",
value = 0, min = -2, max = 2,
step = 1, animate = TRUE ),
sliderInput(inputId = "decade",
label = "Time (decade):",
value = 1, min = 0, max = 30,
step = 5, animate = TRUE )
),
mainPanel(imageOutput("image"))
)
)

server <- function(input, output) {
output$image <- renderImage( deleteFile = FALSE, {
return(list(
src = paste(plotpath,"/Temp",input$temp,"Prec",input$prec,"Dec",input$decade,".png",sep = ""),
contentType = "image/png"))
} ) }

shinyApp(ui = ui, server = server)

最佳答案

shinyWidgets 包现在通过允许自定义值的 slider 为您解决了这个问题。第三个 slider 的更新代码如下所示:

shinyWidgets::sliderTextInput(inputId = "decade", 
label = "Time (decade):",
choices = c(1,5,10,15,20,25,30))

关于r - Shiny slider 定制值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45776668/

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