Last active
August 29, 2015 14:15
-
-
Save cdeterman/fd6bf3955ef56fe9f38d to your computer and use it in GitHub Desktop.
SO 28491576
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(shiny) | |
library(ggvis) | |
library(dplyr) | |
shinyServer( | |
function(input, output, session) { | |
# A reactive subset of mtcars | |
mtc <- reactive({ | |
mtcs <- mtcars %>% | |
mutate(name = row.names(.)) | |
if (nchar(input$filter) > 0) | |
{ | |
mtcs <- mtcs %>% filter(grepl(input$filter, name)) | |
} | |
mtcs | |
}) | |
myvis <- reactive({ | |
myData <- mtc() | |
my_lb <- linked_brush(keys = 1:nrow(myData), "red") | |
out <- myData %>% | |
ggvis(~wt, ~mpg) %>% | |
scale_numeric("y", | |
domain = c(0, max(myData$mpg)), | |
nice=FALSE) %>% | |
layer_points(fill := my_lb$fill, fill.brush := 'red') %>% | |
my_lb$input() | |
return(out) | |
}) | |
myvis %>% bind_shiny("plot", "plot_ui") | |
}) |
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(shiny) | |
library(ggvis) | |
shinyUI( | |
pageWithSidebar( | |
div(), | |
sidebarPanel( | |
textInput('filter', 'Filters', ''), | |
uiOutput("plot_ui") | |
), | |
mainPanel( | |
ggvisOutput("plot") | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment