ticks <- ticks(length(var), nmin=30)
sliderInput(inputId = "size",
label = "Sample size (n)",
min = 1,
max = length(ticks),
value = 1,
ticks = ticks,
step = 1)
ticks <- c(90, 95, 99, 99.9)
values <- paste0(' data-values="', paste0(ticks, collapse=','), '"/>')
html <- sliderInput("foo", min=1, max=length(ticks), ticks=T)
html <- sub('/>', values, html, fixed=T)
html
ui <- pageWithSidebar( headerPanel("Slider labels"), sidebarPanel(# sliderInput("foo2", label = "slider 1 :", min = 1, max = 4, value = 1), uiOutput("slider") ), mainPanel())
server <- function(input, output) { output$slider <- renderUI ({ ticks <- c(90, 95, 99, 99.9) values <- paste0(' data-values="', paste0(ticks, collapse=','), '"/>') html <- sliderInput("foo", label = "slider 2:", min=1, max=length(ticks), ticks=T, value = 1) html <- sub('/>', values, html, fixed=T) html })}runApp(list(ui = ui, server = server))To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/99d0b375-3951-4e80-83a0-11001a825e95%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
output$sizeUI <- renderUI({
args <- mmstat$UI$size # fixed parameters for sliderInput stored in a list
args$min <- 1
args$max <- length(args$ticks)
if (sessionInfo()$otherPkgs$shiny$Version=="0.11") {
ticks <- paste0(args$ticks, collapse=',')
args$ticks <- T
html <- do.call('sliderInput', args)
html$children[[2]]$attribs[['data-values']] <- ticks;
} else {
html <- do.call('sliderInput', args)
}
html
})
mmstat.sliderInput <- function (...) {
iapply <- function (l) {
ret <- l
if (is.list(l)) {
if (!is.null(ret$name) && (ret$name=='input')) {
ret$attribs[['data-values']] <- ticks
} else {
for (i in seq(ret)) ret[[i]] <- iapply(ret[[i]])
}
}
ret
}
args <- list(...)
if ((compareVersion(mmstat$shiny, "0.11")>=0) && !is.null(args$ticks) && length(args$ticks)) {
ticks <- paste0(args$ticks, collapse=',')
args$ticks <- T
html <- do.call('sliderInput', args)
html <- iapply(html)
} else {
html <- do.call('sliderInput', args)
}
html
}
output$sizeUI <- renderUI({
mmstat.log('sizeUI')
args <- mmstat$UI$size
args$min <- 1
args$max <- length(args$ticks)
do.call('mmstat.sliderInput', args)
})
ui <- pageWithSidebar(
headerPanel("Slider labels"),
sidebarPanel(
uiOutput("slider")
),
mainPanel()
)
server <- function(input, output) {
output$slider <- renderUI({
args <- list(inputId="foo", label="slider :", ticks=c(90,95,99,99.9), value=c(2,3))
args$min <- 1
args$max <- length(args$ticks)
if (sessionInfo()$otherPkgs$shiny$Version>="0.11") {
ticks <- paste0(args$ticks, collapse=',')
args$ticks <- T
html <- do.call('sliderInput', args)
html$children[[2]]$attribs[['data-values']] <- ticks;
} else {
html <- do.call('sliderInput', args)
}
html
})
}
runApp(list(ui = ui, server = server))