我希望从sliderInput()
. 例如,在 Shiny 应用程序的默认示例 - Old Faithful Geyser Data 中,sliderInput()
可以为直方图选择多个 bin。bin 的数量总是整数。因此,最好隐藏/删除小刻度sliderInput()
并仅显示箱号的主要刻度。
Shiny 应用程序的默认示例:
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 10,
value = 1)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
我试图tick = FALSE
在sliderInput()
这样的:
sliderInput("bins",
label = "Number of bins:",
min = 1,
max = 10,
value = 1,
ticks = FALSE)
Run Code Online (Sandbox Code Playgroud)
但是,这会从sliderInput()
.
在此先感谢所有帮助。
您可以使用 .css 覆盖 CSS tags$style(type = "text/css", ".irs-grid-pol.small {height: 0px;}")
。CSS 可以在这里找到:https : //github.com/IonDen/ion.rangeSlider/issues/171。
结果sliderInput()
只显示整数的刻度:
shinyApp(
ui <- fluidPage(
tags$style(type = "text/css", ".irs-grid-pol.small {height: 0px;}"),
sliderInput("bins", "Number of bins:", 1, 10, 1)
),
server <- function(input, output) {}
)
Run Code Online (Sandbox Code Playgroud)