Last active
May 21, 2019 13:10
-
-
Save reinholdsson/b465bf2c9246082011c1561b9162ed9d to your computer and use it in GitHub Desktop.
R ggvis shiny app transition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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