Try this gallery item. It uses ggvis to accomplish this goal in shiny.
In case the gallery disappears, here is some minimal code that will produce a tooltip, similar to identify()
, using ggvis.
require(ggvis)
mtcars$model<-rownames(mtcars)
mtcars %>% ggvis(~wt, ~mpg,key:=~model) %>%
layer_points() %>%
add_tooltip(function(df) df$model)
And, a more complete, but still minimal example:
require(shiny)
require(ggvis)
mtcars$model<-rownames(mtcars)
shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel(h2("GGVis to Identify Points")),
mainPanel(ggvisOutput("carsplot"))
)
),
server = function(input, output) {
vis <- reactive({
mtcars %>% ggvis(~wt, ~mpg,key:=~model) %>%
layer_points() %>%
add_tooltip(function(df) df$model)
})
vis %>% bind_shiny("carsplot")
}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With