I have a DT table and a Plotly function in which there are some conditions and based on each condition a specific figure will be plotted (based on the table's data). In one of those conditions, I get the selected rows of a table(users select some desired rows). I would like to add an action button there that users can press it then see the plots of selected rows.
This is a part of my code (It's an example and It isn't complete), It works but it shows an error middle of the output page.
I need to mention here I wrote the code for the action button in the GG function.
The error is:
no applicable method for 'plotly_build' applied to an object of class "c('Observer.event', 'Observer', 'R6')"
# a part of UI section
actionButton("add_graph", "Plots of selected rows")
),
mainPanel(
actionButton("download1", "Download table"),
DT::dataTableOutput("fancyTable"),
tags$hr(),
plotlyOutput("fancyPlot"
,width = "auto"
, height = "auto"
),
#server section
GG = observeEvent(input$add_graph,{
output$fancyPlot <- renderPlotly({
#I got E which is my data set, I removed those lines
plot1 = ggplot(E, aes(x = b , y = E, text = paste("Cell type:", b,
"\n", "shap value:", E))) +
geom_jitter(alpha = 0.3, color = "tomato")+
geom_boxplot(alpha = 0)
plot1 <- plot1%>%
ggplotly(tooltip="text")
return(plot1)
})
})
#main plot
output$fancyPlot <- renderPlotly({
if(a){
#a specific action and plot, I removed it here
}
else (b){
#a specific action and plot, I removed it here
}
else{
GG #I think error is related to this part
}
})