0

I am a newbie to R, it's definitely been a learning curve and I am still bad at it. I can't really solve this issue myself as I don't really know what I am doing wrong.

library(shiny)
library(dplyr)
library(readxl)

#UI
ui <- fluidPage(

  #Title
  titlePanel("Testing Shiny"),

  #Sidebar Layout
  sidebarLayout(

    # Sidebar panel
    sidebarPanel(

      #Input

      selectInput("typedata",
                  label = "What do you want to see?",
                  list("Count of Job Reqs",
                       "Candidates")),


      selectInput("Work Location", label = "Location", choices = unique(exceldata$"Work Location")),
    ),

    #Main Panel
    mainPanel(

      #Output
      textOutput("selected_typedata"),
      textOutput("totalreq"),
      plotOutput("plot")

    )
  )
)

#Server
server <- function(input, output) {

 output$selected_typedata <- renderText({
    paste("You wanted to see", input$typedata)

 })

  output$plot <- renderPlot({
    ggplot(data=exceldata, aes(x=exceldata$`Application Date`,
                                      y=exceldata$`Candidate ID`, fill=c('steelblue'))) +
      geom_bar(stat='Identity', width=0.8)
  })

}
#Shiny app
shinyApp(ui = ui, server = server)

What it's doing is not actually graphing anything. I don't know why, it draws the x and y, but not the actual bars. What I am trying to accomplish here is a basic bar graph showing the count of candidate IDs that applied during their application dates.

enter image description here

If someone could point out what I could possibly be doing wrong, I would greatly appreciate it. I tried using (count(exceldata$"Application Date')), but it gives me an error "no applicable method for 'tbl_vars' applied to an object of class "c('double', 'numeric')".

I tried reading documentation, and it just works fine for others. My data comes from a table loaded as a function using read_excel.

  • 2
    Where do you actually create the `exceldata` variable? Please make sure your example code is [minimal and reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so we can copy/paste the code in R and run it ourselves to see what's going on. – MrFlick Jul 26 '22 at 15:07
  • Right. This is not reproducible. When I assign fake data to `exceldata` I get a plot. Your problem is most likely the data. – Jan Jul 30 '22 at 10:47

0 Answers0