shiny: refresh plot to add new points

Viewed 1108

I have a plot of waves where I need to identify each peak in the curve: enter image description here

I would like to do the following:

Reactively add points to the plot where I click to mark the presence of each peak.

ui.R
plotOutput("plot1", click = "plot_click")

server.R
output$plot1 <- renderPlot({
  plot(x,y)
  points(x=input$plot_click$x,y=input$plot_click$y)
})

The problem here is that although the 'plot_click' mechanism identifies the x and y position of the points- the 'points()' command only causes points to appear momentarily and then disappear.

I also tried reactivePlot but this returned the error:

could not find function "func"
1 Answers
Related