遵循Stphane Laurent的建议使用
sliders
stripchart
.
library(shiny)
ui <- fluidPage(
titlePanel("Sliders"),
sidebarLayout(
sidebarPanel(
sliderInput("animation", "Looping Animation:",
min = 0, max = 100,
value = 1, step = 10,
animate = animationOptions(interval = 300, loop = FALSE))
),
mainPanel(plotOutput("plot"))
))
server <- function(input, output) {
x = sample(1:10, 100, TRUE)
sliderValues <- reactive({ (input$animation)})
output$plot <- renderPlot({
stripchart(x[1:sliderValues()], method="stack", at=0.05, frame.plot=FALSE,
pch=16, cex=2, xaxt="n", xlim=range(x))
axis(1, pretty(x))
})
}
# Create Shiny app ----
shinyApp(ui, server)