【发布时间】:2020-09-13 07:28:51
【问题描述】:
我在绘制直方图时需要使用滑块。问题是,当我使用它时,它并不是很好。这里唯一的工作值(从 1 到 36)是 3、5、9、25、36。所以,我想更改滑块并只提供这些值。 这是我的代码: 客户
h2('Percentuale di cacao'),
# Slider per l'istogramma della percentuale di cacao
sidebarLayout(
sidebarPanel(
sliderInput("bins1", "Number of bins:", min = 1, max = 36, value = 10),
),
# Plot dell'istogramma
mainPanel(
plotOutput("distPlot1")
)
),
服务器
output$distPlot1 <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins1)
hist(chocolate$CocoaPerc, nclass = input$bins1, xlab="Percentuale di cacao", main="Frequenza della percentuale
di cacao", col = c("chocolate", "chocolate3", "chocolate2", "chocolate4"))
})
我看到一些用户回答使用 shinyWidgets 的其他问题,但是在看到文档之后,我仍然不知道如何将它放在这里。你能帮帮我吗?
【问题讨论】:
标签: r plot shiny slider histogram