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