Last active
December 6, 2015 00:28
-
-
Save cpsievert/a565a5595f6175ec5cbc to your computer and use it in GitHub Desktop.
Pass plotly selections to shiny
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(plotly) | |
library(shiny) | |
m <- round(cor(mtcars), 3) | |
nms <- names(mtcars) | |
ui <- fluidPage( | |
plotlyOutput("heat"), | |
textOutput("p") | |
) | |
server <- function(input, output, session) { | |
output$heat <- renderPlotly({ | |
plot_ly(x = nms, y = nms, z = m, key = m, type = "heatmap") | |
}) | |
rv <- reactive({ | |
cv <- crosstalk::ClientValue$new("plotly_click", group = "A") | |
cv$get() | |
}) | |
output$p <- renderPrint({ | |
rv() | |
}) | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment