You have the option to listen to any points clicked on the rendered map - but you will have to build any logic on top of that (storing the previous point clicked and drawing a rectangle / identifying and counting points within) yourself.
For an example of a map listening to points clicked consider this code (it is built by slightly modifying my example of Virginia counties that I had lying around; you can disregard any of that).
library(shiny)
library(leaflet)
library(sf)
# VA counties - downloaded via the awesome tigris package
shape <- tigris::counties(state = "VA", class = "sf")
# Define UI
ui <- fluidPage(
# Application title
titlePanel("The Old Dominion"),
# Top panel with county name
verticalLayout(
wellPanel(textOutput("cnty")),
# the map itself
mainPanel(
leafletOutput("map")
)
)
)
# Define server logic
server <- function(input, output) {
output$map <- renderLeaflet({
leaflet() %>%
addProviderTiles("Stamen.Toner") %>%
addPolygons(data = shape,
fillColor = "aliceblue",
color = "grey",
layerId = ~COUNTYNS)
})
# this is the fun part!
observe({
event <- input$map_click
output$cnty <- renderText(paste("lng:", event$lng, "lat:", event$lat))
})
}
# Run the application
shinyApp(ui = ui, server = server)