滑块故障中的按钮
我的滑块有问题。它不会显示为13号的划分,并且按下我按下按钮检查不起作用。我该怎么办?请帮忙。
这是我写的代码:
library(shiny)
library(readr)
# GiuseppeData <- read_csv("Classes_with_Giuseppe.csv")
GiuseppeData <- structure(list(number_of_classes = c("1_class", "2_class", "3_class",
"4_class", "5_class", "6_class", "7_class", "8_class", "9_class", "10_class",
"11_class", "12_class", "13_class", "14_class", "15_class", "16_class",
"17_class", "18_class"),
length_of_classes = c(2.24, 2.37, 2.14, 2.18, 2.28,
2.3, 2.32, 2.24, 2.36, 2.38, 2.21, 2.25, 2.17, 2.17, 2, 2.1, 2.05, 2.2)),
row.names = c(NA, -18L),
class = "data.frame")
ui <- fluidPage(
titlePanel("Hello Giuseppe!"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "rows",
label = "Amount of Classes",
min = 1,
max = nrow(GiuseppeData),
value = 7, step = 1,
animate = animationOptions(interval = 600, loop = TRUE)),
actionButton(
inputId = "check",
label = "Check"
)
),
mainPanel(
plotOutput(outputId = "distPie")
)
)
)
server <- function(input, output) {
output$distPie <- renderPlot({
x <- GiuseppeData[1:input$rows,]$length_of_classes
pie(x, col = "76776", border = "pink",
xlab = "Pie of Length of Each Class (in hours)",
main = "Pie of Classes")
})
}
shinyApp(ui = ui, server = server)
I have a problem with my slider. It doesn't show divisions up to number 13 and the button check doesn't work when I press it. What should I do to fix it? Please, help.
Here is the code I wrote:
library(shiny)
library(readr)
# GiuseppeData <- read_csv("Classes_with_Giuseppe.csv")
GiuseppeData <- structure(list(number_of_classes = c("1_class", "2_class", "3_class",
"4_class", "5_class", "6_class", "7_class", "8_class", "9_class", "10_class",
"11_class", "12_class", "13_class", "14_class", "15_class", "16_class",
"17_class", "18_class"),
length_of_classes = c(2.24, 2.37, 2.14, 2.18, 2.28,
2.3, 2.32, 2.24, 2.36, 2.38, 2.21, 2.25, 2.17, 2.17, 2, 2.1, 2.05, 2.2)),
row.names = c(NA, -18L),
class = "data.frame")
ui <- fluidPage(
titlePanel("Hello Giuseppe!"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "rows",
label = "Amount of Classes",
min = 1,
max = nrow(GiuseppeData),
value = 7, step = 1,
animate = animationOptions(interval = 600, loop = TRUE)),
actionButton(
inputId = "check",
label = "Check"
)
),
mainPanel(
plotOutput(outputId = "distPie")
)
)
)
server <- function(input, output) {
output$distPie <- renderPlot({
x <- GiuseppeData[1:input$rows,]$length_of_classes
pie(x, col = "76776", border = "pink",
xlab = "Pie of Length of Each Class (in hours)",
main = "Pie of Classes")
})
}
shinyApp(ui = ui, server = server)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要显示一个自定义按钮,我们可以使用
AnimationOptions
,然后将ActionButton
传递到其Playbutton
参数。可以开箱即用自定义滑块tick-但是,我们可以使用
htmltools :: tagquery
。 在这里可以找到一个相关的线程。ps:我一直在使用 plotly ciptly pifly 而不是基础R图。随意恢复这一步骤。
To show a custom button we can use
animationOptions
and pass anactionButton
to itsplayButton
argument.Customizing the slider ticks is not possible out of the box - however, we can use
htmltools::tagQuery
. Here a related thread can be found.PS: I've been using plotly pie charts instead of the base R plots. Feel free to revert this step.