Shiny 闪亮:刷新绘图以添加新点

Shiny 闪亮:刷新绘图以添加新点,shiny,Shiny,我有一个波浪图,需要识别曲线中的每个峰值: 我想做以下工作: 反应性地将点添加到绘图中,单击以标记每个峰值的存在 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) }) 分类。根据前一篇文章的帮助: 库(闪亮) 用户界面 could not

我有一个波浪图,需要识别曲线中的每个峰值:

我想做以下工作:

反应性地将点添加到绘图中,单击以标记每个峰值的存在

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)
})

分类。根据前一篇文章的帮助:

库(闪亮)
用户界面
could not find function "func"
library(shiny)
ui <- basicPage(
  actionButton("submit","submit"),
  plotOutput("plot1", click = "plot_click"),
  verbatimTextOutput("info"),
  tableOutput('table')
)

server <- function(input, output) {
  click_saved <- reactiveValues(singleclick = NULL)
  observeEvent(eventExpr = input$plot_click, handlerExpr = { click_saved$singleclick <- input$plot_click })
  rv=reactiveValues(m=data.frame(x=0,y=0))
  output$plot1 <- renderPlot({
    plot(x,y, type='l')
    points(rv$m$x[-1],rv$m$y[-1])
  })

  output$info <- renderText({
    paste0(unlist(click_saved$singleclick))
  })


  observeEvent(input$submit, {
    if (input$submit > 0) {
      rv$m <- rbind(rv$m,unlist(click_saved$singleclick))
    }
  })

  output$table <- renderTable({
    if (is.null(rv$m)) {return()}
    print(rv$m)
  }, 'include.rownames' = FALSE
  , 'include.colnames' = TRUE
  )

}

shinyApp(ui, server)