Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(shiny)
- ui <- basicPage(
- plotOutput("plot1", click = "plot_click"),
- verbatimTextOutput("info"),
- plotOutput("plot2", click = "plot_click"),
- verbatimTextOutput("moreinfo")
- )
- server <- function(input, output) {
- output$plot1 <- renderPlot({
- plot(mtcars$wt, mtcars$mpg)
- })
- output$info <- renderPrint({
- # With base graphics, need to tell it what the x and y variables are.
- nearPoints(mtcars, input$plot_click, xvar = "wt", yvar = "mpg")
- # nearPoints() also works with hover and dblclick events
- })
- output$plot2 <- renderPlot({
- plot(ecdf(mtcars$mpg), col="blue", main=NA)
- })
- output$moreinfo <- renderPrint({
- # With base graphics, need to tell it what the x and y variables are.
- nearPoints(mtcars, input$plot_click, xvar = "mpg")
- # nearPoints() also works with hover and dblclick events
- })
- }
- shinyApp(ui, server)
Add Comment
Please, Sign In to add comment