I am trying to build a flexdashbaord with two columns, The first one is a simple plot_ly scatter plot. In the second column I want a DT data table that will show the data of the points selected via box or lasso select in the scatter plot as shown in the screenshot below.
Code below:
```{r global, include=FALSE}
library(flexdashboard)
library(reticulate)
library(tidyr)
library(tidyverse)
library(ggplot2)
library(plotly)
library(purrr) 
library(DT)
library(shinyalert)
library(shinyWidgets)
library(thematic)
library(dashboardthemes)
library(shinyjs)
library(datasets)
library(crosstalk)
data(iris)
summary(iris)
```
```{r runandsavereactive}
#run and generate data
actionButton("run_button", "RUN")
```
### create plot
```{r update_data}
output_data <- eventReactive(input$run_button, {
    showModal(modalDialog(title = "Running!"))
  
  
    ## Start initial plot
  fig2 <- iris %>% 
    plot_ly(
      type = 'scatter',
      mode = 'markers',
      x = ~Sepal.Length,
      y = ~Petal.Length,
      #marker = list(size = ~numbEmployed, sizeref = 4000, sizemode = 'area'),
      color = ~Species,
      marker = list(size = 5),
      hoverinfo = 'text',
      text = ~paste0("Name: ",Species),
      source="A"
    ) 
  ## style the layout
  fig2 <- fig2 %>% 
    layout(
      title = 'iris data test',
      scene = list(
        xaxis = list(title = ' ',
                     range = list(-4,7),
                     showticklabels=FALSE,
                     zeroline = F,
                     showgrid = F
        ),
        yaxis = list(title = ' ',
                     range = list(-1, 5),
                     showticklabels=FALSE,
                     zeroline = F,
                     showgrid = F
        )
     
      ))
   
  list("fig2" = fig2)
})
```
### Scatter Plot
```{r data }
plotlyOutput("iris")
output$iris <- renderPlotly({
req(input$run_button)
req(output_data()$fig2)
output_data()$fig2 
})
```
### Data Table
```{r datatsble }
output$table <- DT::renderDataTable(data)
proxy <- DT::dataTableProxy("table")
observe({
... 
})
```

 
     
    