Shiny Dashboard not connecting ggplots to drop down menu

I am trying to connect various ggplots to a shiny dashboard but am unable to. The dashboard works when I ran on its own but not in connection to the shiny dropdown menu. Below I have the code I am using:

{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
if (!require("pacman")) install.packages("pacman", repos = "")

p_load(tidyverse, ggthemes, magrittr, lubridate, tidyquant, gridExtra,flexdashboard, knitr, RColorBrewer, hrbrthemes, anytime, plotly, shiny, dplyr,flexdashboard)
Grammy <- read_csv("Grammy.csv") |> rename("Brandi Carlile" = "Brandi Carilie")

Grammy$Date <- strptime(Grammy$Date, format="%m/%d/%Y %H:%M")

Grammy <- mutate(Grammy, Date = as.Date(Grammy$Date, "%m/%d/%Y"))
Grammy$Date <-anydate(Grammy$Date)
Grammy$Date <- as.Date(Grammy$Date)

Grammy$Date<- as.Date(Grammy$Date) #convert to date
Grammylonger <- Grammy |>
  pivot_longer(cols = `Brandi Carlile`:`Silk Sonic`, names_to = "Artists", values_to = "Streams")

The set up code for the data which I am using for my data the Grammys longer has 3 columns of date, Artists and streams while Grammys has Date and all the artists all the categories

{r eruptions, echo=FALSE}
      selectInput(inputId = "Artists", label = "Artists", choices = c("Brandi Carlile", "Silk Sonic", "Brothers Osborne", "Carrie Underwood", "HER", "Justin Bieber", "Jon Baptise", "Lady Gaga", "John Legand", "Chris Stapleton", "NAS", "Billie Ellish", "Lil Nas X", "BTS", "J balvin", "Olivia Rodrigo"),
    selected = "Brandi Carlile")

shinyServer(function(input, output) {
 test <- reactive({
    Grammylonger |>
      filter(`Artists` == input$Artists)
  output$linePlot <- renderPlot({
    p <- ggplot(data = Grammylonger(), aes(x = Date, y = Artists)) +
      geom_point() +
      geom_line(group = 1) +
      labs(title = "Artist Streams by day",
           x = NULL,
           y = NULL) +
      scale_x_date(date_breaks = "1 day", date_labels =  "%b %Y") +

When I run this code I see the drop-down menu however it has no plot connected to any of the names

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.