Skip to content

Instantly share code, notes, and snippets.

@reinholdsson
Last active May 21, 2019 13:10
Show Gist options
  • Save reinholdsson/b465bf2c9246082011c1561b9162ed9d to your computer and use it in GitHub Desktop.
Save reinholdsson/b465bf2c9246082011c1561b9162ed9d to your computer and use it in GitHub Desktop.
R ggvis shiny app transition
library(ggvis)
library(shiny)
library(dplyr)
shinyApp(
shinyUI(fluidPage(
titlePanel("Example"),
sidebarLayout(
sidebarPanel(
sliderInput("maximum_supply",
"Maximum Supply",
min = 60,
max = 120,
value = 90),
uiOutput("ggvis_ui")
),
mainPanel(
ggvisOutput("ggvis")
)
)
)),
shinyServer(function(input, output) {
supply.function <- function(supply) {
60 - 60/input$maximum_supply* supply
}
dat <- reactive({ input$maximum_supply;data.frame(price = 1:100, quantity = runif(100) ) })
dat %>%
ggvis(~price, ~quantity) %>%
layer_lines() %>%
scale_numeric("y", domain = c(0, 1)) %>%
set_options(width = "auto", height = "auto", resizable=FALSE) %>%
bind_shiny("ggvis", "ggvis_ui")
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment