I am having issues displaying my ggplots for each respective program (1:7). I have an inputs sidebar defined below. However, I end up with a blank plot aside from horizontal lines, which don't depend on a DF. Any help is a greatly appreciated.
selectInput("survey", label = h3("Program"), choices = c("1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5, "6" = 6, "7" = 7), selected = 1)
and:
ggplot(cumulative_data[cumulative_data$survey == input$survey,], aes(x=month, y=cum_mean)) +
geom_ribbon(aes(ymin=lower_ci, ymax=upper_ci)) +
geom_point(aes(size= count), color="#440154FF") +
geom_line(aes(x = month, y = cum_mean), linetype=1, color="#440154FF", size = 1.25) +
})
Edit w/ reproduceable data
Here is the structure of my data frame:
Trying to plot the cumulative mean month-by-month for each survey #.
df <- as.data.frame(expand.grid(survey = 1:7, month = factor(month.name[1:12], levels = month.name)))
df$cum_mean <- round(runif(84, 8, 10), 1)
df <- df[order(df$survey),]
Inputs {.sidebar}
-----------------------------------------------------------------------
selectInput("survey", label = h3("Program"), choices = c("1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5, "6" = 6, "7" = 7), selected = 1)
Row
-----------------------------------------------------------------------
### By Program
renderPlot({
ggplot(df[df$survey == input$survey,], aes(x=month, y=cum_mean, group =1)) +
geom_line(aes(x = month, y = cum_mean), linetype=1, color="#440154FF", size = 1.25) +
geom_hline(yintercept = 8.9, col = '#B8DE29FF', lty = 2, lwd = 1.25) +
geom_hline(yintercept = 9.46, col = '#2D708EFF', lty = 2, lwd = 1.25, alpha = .7) + theme_minimal() +
labs(x = 'Month', y = 'Score')
})
output with group =1
output with no group = 1