ClickEvent on Leaflet Map to show a graph or table on the side

Hi All,

I wanted to implement clickevent the Leaflet Map. It should work in such a way that once I click on a state, then it should provide me a graph or a table on the side. It should be reactive to clicks that I make on the states in the map.

Below is the code.

library(sp)
library(leaflet)
library(albersusa)

spdf <- rmapshaper::ms_simplify(usa_sf(), keep = 0.1)
pal <- colorQuantile("Blues", domain = spdf$pop_2014, n=5)
epsg2163 <- leafletCRS(
crsClass = "L.Proj.CRS",
code = "EPSG:2163",
proj4def = "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs",
resolutions = 2^(16:7))

leaflet(spdf, options = leafletOptions(crs = epsg2163)) %>%
addPolygons(weight = 1, color = "#444444", opacity = 1,
fillColor = ~pal(pop_2014),
highlightOptions = highlightOptions(color = "black", weight = 2.5, bringToFront = TRUE),fillOpacity = 0.7, smoothFactor = 0.5,
label = ~paste(name, pop_2014),
labelOptions = labelOptions(direction = "auto"))%>%
addLegend(pal = pal, values = spdf$pop_2014, opacity = 0.7, title = "Coverage Rates (%)",
position = "bottomleft")

Let me know if you need anymore information.

Thanks in advance.