Hi!
I'm trying to plot a graph using GGPLOT2, but it appears that my DF can't be found. So:
observeEvent(c(input$plotDF),ignoreInit = TRUE,{
dfPlot2<- dbGetQuery(
connection_reportUser,
query <- glue(
"select * from my_table")
)
output$table2 <- DT::renderDataTable({
datatable(dfPlot2,
options = list(scrollX = TRUE)
)
})
output$plot1 <- renderPlot({
hist(dfPlot2$PE_OD_MIN_MIN,
main = "Histograma",
xlab = "OD Pe MIN/MIN")
})
}) #end observEvent
observeEvent(c(input$plot2),ignoreInit = TRUE,{
p1<- ggplot(dfPlot2, aes(x=PE_OD_MIN_MIN)) +
geom_histogram(aes(y = ..density..), colour = "#1F3552", fill = "#4271AE") +
geom_density(fill="red", alpha = 0.2) +
scale_x_continuous(name = "Tubes") +
scale_y_continuous(name = 'Frequency') +
theme_bw()
p1<- ggplotly(p1)
})
My "output$table2" is creating the table and the "output$plot1" is working too.
When I try to to run the GGPLOT in "observeEvent(c(input$plot2)", an error appear saying that my "dfPlot2 not found". If the output$table2 is working, my DF exist.
What can it be?