【发布时间】:2017-06-10 13:54:28
【问题描述】:
我希望从sliderInput() 中删除/隐藏次要刻度(不是主要刻度)。例如,在 Shiny 应用程序的默认示例 - Old Faithful Geyser Data 中,有一个 sliderInput() 可以选择直方图的多个 bin。箱数始终是整数。因此,最好隐藏/删除 sliderInput() 中的次要刻度,只显示 bin 编号的主要刻度。
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)
我在sliderInput() 中尝试过tick = FALSE,如下所示:
sliderInput("bins",
label = "Number of bins:",
min = 1,
max = 10,
value = 1,
ticks = FALSE)
但是,这会删除 sliderInput() 中的所有刻度(包括主要刻度)。
【问题讨论】: