Created
January 6, 2016 09:47
-
-
Save Nicolabo/2d9e38ae592dfd4f604b to your computer and use it in GitHub Desktop.
This file contains 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
prod <- c('P1','P2','P3') | |
level <- c('L1','L2','L3') | |
part <- c('p1','p2','p3','p4','p5') | |
axis_x <- list(L1 = list('Ordering' = 'id'), | |
L2 = list('Ordering' = 'id', 'Part name' = 'part'), | |
L3 = list('Ordering' = 'id', 'Part name' = 'part')) | |
set.seed(123) | |
test_data <- data.frame(prod = sample(prod,300, replace = T), | |
level = sample(level, 300, replace = T), | |
part = sample(part, 300, replace = T), | |
value = rnorm(300)) | |
test_data <- test_data %>% | |
group_by(prod) %>% | |
mutate(id = 1:n()) %>% | |
arrange(prod, id) |
This file contains 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(shiny) | |
library(ggvis) | |
library(dplyr) | |
shinyServer(function(input, output) { | |
data0 <- reactive({ | |
df <- test_data | |
df <- df %>% | |
filter(prod == input$prod) | |
}) | |
data <- reactive({ | |
df <- data0() | |
df <- df %>% | |
filter(level == input$level) | |
}) | |
output$in_xvar <- renderUI({ | |
choosen_list <- axis_x[input$product] | |
selectInput('xvar','', choosen_list) | |
}) | |
ggvis_plot <- reactive({ | |
x <- prop('x', as.name(input$xvar)) | |
plot <- data() %>% | |
ggvis(x, ~value) %>% | |
layer_points(fill = ~part) | |
}) | |
ggvis_plot %>% bind_shiny('ggvis_plot') | |
}) |
This file contains 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(shiny) | |
shinyUI( | |
fluidPage( | |
fluidRow( | |
column(3, | |
selectInput('prod','', prod), | |
radioButtons('level','',level, level[1]), | |
uiOutput('in_xvar') | |
), | |
column(9, | |
ggvisOutput('ggvis_plot') | |
) | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment