I'm currently making a Shiny app and I tried to use this graph (this is used in the server):
output$COTY_out1 <- renderPlot({
data %>%
group_by(year) %>%
summarize(mean_ls = mean(life_satisfaction, na.rm = TRUE)) %>%
ggplot(mapping = aes(x = year, y = mean_ls)) +
geom_line() +
geom_smooth() +
labs(y = "Mean Life Satisfaction", x = "Year", title = "World")
})
This shows up well in the app!
Now, I tried to integrate plotly in this and basically copied this code from working apps. I also consulted stack and found similar answers.
output$COTY_out1 <- renderPlotly({
p <- data %>%
group_by(year) %>%
summarize(mean_ls = mean(life_satisfaction, na.rm = TRUE)) %>%
ggplot(mapping = aes(x = year, y = mean_ls)) +
geom_line() +
geom_smooth() +
labs(y = "Mean Life Satisfaction", x = "Year", title = "World")
p <- ggplotly(p)
p
})
However, after doing this, the graph does not show up. Is there something wrong in the way I've integrated the ggplotly? Like I said before, I looked at similar answers on this forum and basically tried to copy paste a lot of them to no avail.