shiny + ggplot interactive plot fails with facet

811 views
Skip to first unread message

Yasutaka Hirasawa

unread,
Feb 15, 2016, 10:24:45 PM2/15/16
to Shiny - Web Framework for R
I am learning shiny's interactive plots, using plotOutput(click=xxx, brush=yyy) with ggplot.
Below is a simple script, taken from http://shiny.rstudio.com/articles/selecting-rows-of-data.html  This works fine but if I uncomment the line:
  # facet_grid(. ~ cyl) +

interactive chart stops working as it fails to detect mouse clicks or brush actions.

I am using ggplot2 v2.0.0 and shiny v0.12.2

Appreciate your help!


library(ggplot2)
library(shiny)

ui <- basicPage(
  plotOutput("plot1", brush = "plot_brush", click = "plot_click", height = 250),
  verbatimTextOutput("info"),
  verbatimTextOutput("info2")
)

server <- function(input, output) {
  output$plot1 <- renderPlot({
    ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() +
      #facet_grid(. ~ cyl) +
      theme_bw()
  })
  
  output$info <- renderPrint({
    brushedPoints(mtcars, input$plot_brush)
  })
  
  output$info2 <- renderPrint({
     nearPoints(mtcars, input$plot_click)
  })
}

shinyApp(ui, server)

Yasutaka Hirasawa

unread,
Feb 15, 2016, 10:41:45 PM2/15/16
to Shiny - Web Framework for R
OK I found the solution....installing the latest shiny from github resolved this.

if (!require("devtools"))
  install.packages("devtools")
devtools::install_github("rstudio/shiny")

Yasutaka Hirasawa

unread,
Feb 15, 2016, 10:44:57 PM2/15/16
to Shiny - Web Framework for R
I also noted that shinyapps.io appeared not to have been updated with the latest and it still has the facet issue.


On Monday, February 15, 2016 at 10:24:45 PM UTC-5, Yasutaka Hirasawa wrote:

Joe Cheng

unread,
Feb 16, 2016, 2:10:13 PM2/16/16
to Yasutaka Hirasawa, Shiny - Web Framework for R
shinyapps.io uses whatever local versions of shiny and ggplot you have installed at the time that you deploy. You should find that if you deploy again, it will work--if not, please let us know! Thanks!

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/13af941f-d9da-42e7-a795-d5883aad0e90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages