Skip to content

Instantly share code, notes, and snippets.

@cpsievert
Last active December 6, 2015 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpsievert/a565a5595f6175ec5cbc to your computer and use it in GitHub Desktop.
Save cpsievert/a565a5595f6175ec5cbc to your computer and use it in GitHub Desktop.
Pass plotly selections to shiny
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