I would like to generate sliders in my server (because the number of sliders I need depend on other inputs). As you will see with the code herebelow and the picture, the sliders that appear do not look good. I presume it has to do with the way I specify them in HTML (maybe something to do with the style/css?).
Here is the code:
ui <- pageWithSidebar(
headerPanel("test"),
sidebarPanel(
helpText('these sliders do not look good:')
),
mainPanel(uiOutput('slider'))
)
server <- function(input,output, session){
output$slider <- renderTable({
inputs <- paste0("<input id='Sl_C", 1:2, "' class='jslider-pointer jslider-pointer-to' type = 'range' value='c(0,20)' min='0' max='100'>")
matrix <- data.frame(inputs)
},sanitize.text.function = function(x) x)
}
runApp(list(ui=ui,server=server))
Any advice/suggestion would be highly appreciated.
All the best
Here is one way to achieve multiple slider inputs.
library(shiny)
multiSliders = function(n, ...){
sliders = lapply(1:n, function(i){
sliderInput(paste0('slider-', i), paste('Slider', i), ...)
})
paste_all = function(...) paste(..., collapse = '\n')
HTML(do.call('paste_all', sliders))
}
runApp(list(
ui = pageWithSidebar(
headerPanel('Multiple Sliders'),
sidebarPanel(
sliderInput('slider-0', 'Slider0', 0, 10, 4),
multiSliders(2, 0, 10, 4)
),
mainPanel()
),
server = function(input, output){
}
))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.