'Is there a way ( in shiny) to have the brushed points that show up in a table averaged out? I have the graph and table data,just need the avg of them

How and where do I go about splitting the type.of.data up into their own respective column (split function?) and getting the avg's of those to export within shiny?

ui <- basicPage(
  plotOutput("plot1", brush = "plot_brush"),
  verbatimTextOutput("info"),
  actionButton("save", "Save")
)


server <- function(input, output) {
    output$plot1 <- renderPlot({
      plot(depths$time2, depths$value)
    })
    
    data <- reactive({
      brushedPoints(depths, input$plot_brush, xvar = "time2", yvar = "value")
    })
    
    output$info <- renderPrint({data()})
    
    observeEvent(input$save, {
      write.csv(data(), 'brushed_data.csv', row.names = FALSE)
    })
  }
  
shinyApp(ui, server)

An example of the table the brushed points produce:

Type.of.Data Value date.time time2
Depth 43.01050 2021-10-12 10:44:03 2021-10-12 10:44:03
Temperature 4.82535 2021-10-12 10:44:03 2021-10-12 10:44:03
Depth 43.43850 2021-10-12 10:44:05 2021-10-12 10:44:05
Depth 43.01050 2021-10-12 10:44:06 2021-10-12 10:44:06
Depth 43.22450 2021-10-12 10:44:08 2021-10-12 10:44:08
Temperature 4.78734 2021-10-12 10:44:08 2021-10-12 10:44:08
Height 160.00000 2021-10-12 10:44:09 2021-10-12 10:44:09
Depth 43.11750 2021-10-12 10:44:09 2021-10-12 10:44:09
Spread 11.04210 2021-10-12 10:44:10 2021-10-12 10:44:10
Depth 43.54560 2021-10-12 10:44:11 2021-10-12 10:44:11
Temperature 4.66667 2021-10-12 10:44:12 2021-10-12 10:44:12


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source