0

In my app user is uploading CSV file/s and graphs are generated by using this/these file/s. The uploaded data is rendered by using rendertable and these tables are used to render the plots using renderplot.

I am able to render a ggplot or plotly from this data. But, I want my graphs to be reactive so that the user can delete some data points interactively on the generated graph.

Now, it is very easy in ggplot, as I can directly use the brush feature and select the data points on the generated graph.

But, I want to do the same thing on the graphs generated by using ggplotly or plotly.

Is there any way?

Ultimately, I want the user to be able to select the data point on the generated graph and be able to delete them and as user delete those points, I want to the app to generate a downloadable excel sheet of the remaining points.

Or, I want the user to be able to select wanted data points only and generate a downloadable excel sheet of those points.

Server side code begins below:

server <- function(input, output, session){
      
      ## Reading the uploaded csv data table 
      output$table <- DT::renderDataTable({
        if(is.null(input$file)){return()}
        else
        data()
          })
      
      ## Rendering ggplotly scatter plot: 
      output$plot <- renderPlot({
        x <- data()[, c(input$xcol, input$ycol)]
        ggplot(data =  x1) + 
          geom_line(aes_string(x = input$xcol, y = input$ycol, color = input$ycol1), size = 1) + 
          stat_smooth(aes_string(x = input$xcol, y = input$ycol, color = input$ycol1))
      })
      
      
      ## Using Brush on the Plotted graph:
      data.new <- reactive({
        User_brush_1 <- input$User_brush_1
        mysel1 <- brushedPoints(data(), User_brush_1)
        return(mysel1)
      })
      
      ## Rendering the filered data:
      output$table_1 <- DT::renderDataTable(DT::datatable(data1.new()))
  }

    
   
  • 2
    Hi, the code in your post is quite long, you should consider simplifying it. Your question is about plots so maybe there is no need to have several tabs and stuff to import data. Just adapt your example with data that everybody have, such as `mtcars` or `iris` – bretauv Apr 12 '20 at 19:16
  • I am quite new to this shiny app development, this is my first app. So, that's why my code is quite long. – Kshitij15571 Apr 14 '20 at 14:54
  • 1
    I understand that, but still you should reduce your app. First, it is always easier for external people to see what the problem is if the code is reduced. Second, you have an interest in making a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) because this will force you to narrow down the problem and doing this can allow you to find the solution without even asking on StackOverflow. Copy and paste your code in a new script so that you can modify it without risking to lose your code, and then try to delete some parts that are not essential – bretauv Apr 14 '20 at 15:01

0 Answers0