It is my understanding Shiny's selectInput widget returns a character vector. I am unclear as to why the user input cannot be passed to ggplot as a column name. Naturally this fails to plot as desired.
This is my yaml.
[![enter image description here][1]][1]
Blockquote --- title: "Untitled" output: flexdashboard::flex_dashboard: orientation: rows runtime: shiny
library(tidyverse)
library(flexdashboard)
library(shiny)
spy <- tibble(Date = as.Date(c("2020-12-28", "2021-12-30", "2022-03-15")),
Happy = c(8.25, 12.48, 11.52 ),
Glad = c(4, 5, 7 ) )
shiny::selectInput(
inputId = "select_data",
label = "Select Data",
choices = c("Happy", "Glad"),
selected = "Happy"
)
renderPlot({
ggplot(spy, aes( 1:3, input$select_data) ) +
geom_line()
})
[1]: https://i.stack.imgur.com/sHEWu.png
[2]: https://i.stack.imgur.com/rIWrY.png