Guest User

Untitled

a guest
Feb 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. library(shiny)
  2.  
  3. ui <- basicPage(
  4. plotOutput("plot1", click = "plot_click"),
  5. verbatimTextOutput("info"),
  6. plotOutput("plot2", click = "plot_click"),
  7. verbatimTextOutput("moreinfo")
  8. )
  9.  
  10. server <- function(input, output) {
  11. output$plot1 <- renderPlot({
  12. plot(mtcars$wt, mtcars$mpg)
  13. })
  14.  
  15. output$info <- renderPrint({
  16. # With base graphics, need to tell it what the x and y variables are.
  17. nearPoints(mtcars, input$plot_click, xvar = "wt", yvar = "mpg")
  18. # nearPoints() also works with hover and dblclick events
  19. })
  20.  
  21. output$plot2 <- renderPlot({
  22. plot(ecdf(mtcars$mpg), col="blue", main=NA)
  23. })
  24. output$moreinfo <- renderPrint({
  25. # With base graphics, need to tell it what the x and y variables are.
  26. nearPoints(mtcars, input$plot_click, xvar = "mpg")
  27. # nearPoints() also works with hover and dblclick events
  28. })
  29. }
  30.  
  31.  
  32. shinyApp(ui, server)
Add Comment
Please, Sign In to add comment