I have the start of a brilliant ggplot world map application. I would like to get the coordinates of the click on the plot so that users can do something with the map, but the coordinates are very strange (either NULL, or something very small). Repeated pressing changes only one coordinate:

ui.R:
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("My App"),
sidebarPanel(
textOutput("clickcoord")
),
mainPanel(
plotOutput("myworld", height="600px", clickId="plotclick")
)
))
server.R:
library(shiny)
library(maps)
library(mapdata)
library(ggplot2)
library(rworldmap)
shinyServer(function(input, output) {
output$myworld <- renderPlot({
world <- map_data("world")
worldmap <- ggplot(aes(x = long, y = lat, group = group), data = world) +
geom_path()
print(worldmap)
})
output$clickcoord <- renderPrint({
print(input$plotclick)
})
})
If I just use the command map()to create a non-ggplot world map, I get what looks like good lat / long values for click codes:

server.R (changed):
library(shiny)
library(maps)
library(mapdata)
shinyServer(function(input, output) {
output$myworld <- renderPlot({
map("world2Hires")
})
output$clickcoord <- renderPrint({
print(input$plotclick)
})
})
source
share