title: How do I represent the X-axis as the range of factor-type variables with the year name?
body: <p>I want to make panel that can set the range of the x-axis like <code>DataRangeInput</code>.</p>
  <p>However the x-values are factors so i have no idea how to set the range of factors.</p>
  <pre><code>cTempData &lt;- read.csv(&quot;tidy_league.csv&quot;, header = TRUE, sep = &quot;,&quot;)
  
  ui &lt;- fluidPage(
      
      theme = &quot;bootstrap.css&quot;,
  
      titlePanel(&quot;EPL Teams Performance 2009-2019&quot;),
  
      sidebarLayout(
          sidebarPanel(
              shinyjs::useShinyjs(),
              div(
                  id = &quot;form&quot;,
                  selectizeInput(&quot;teams&quot;, &quot;Teams&quot;, levels(cTempData$teams), multiple = T),
                  selectInput(&quot;value&quot;, &quot;Select the Value&quot;, choices = c(&quot;sum_goals&quot;, &quot;sum_points&quot;),
                              selected = &quot;sum_goals&quot;),
                  actionButton(&quot;refresh&quot;, &quot;Clear&quot;, class = &quot;btn-primary&quot;),
              )
          ),
  
          mainPanel(
             plotOutput(&quot;linePlot&quot;),
             tableOutput(&quot;table&quot;)
          )
      )
  )
  
  server &lt;- function(input, output) {
      
      observeEvent(input$refresh, {
          shinyjs::reset(&quot;form&quot;)
      })
  
      output$linePlot &lt;- renderPlot({
          
          if (is.null(cTempData)) return()
          cTempData %&gt;% filter(teams %in% input$teams) %&gt;% 
              ggplot(aes(x = Year,
                         y = .data[[input$value]],
                         color = teams, group = teams)) +
              geom_line(size = 1) + geom_point(size = 2) + theme_bw() + 
              scale_x_continuous(breaks = seq(2009, 2019, 1)) + 
              scale_color_manual(values = c(&quot;Arsenal&quot;=&quot;#FF3300&quot;, &quot;Aston Villa&quot;=&quot;#CC3366&quot;, &quot;Brighton&quot;=&quot;#3399FF&quot;, 
                                            &quot;Burnley&quot;=&quot;#CC0066&quot;, &quot;Chelsea&quot;=&quot;#0000FF&quot;, &quot;Crystal Palace&quot;=&quot;#990066&quot;,
                                            &quot;Everton&quot;=&quot;#0033CC&quot;, &quot;Fulham&quot;=&quot;#CCCCCC&quot;, &quot;Leicester&quot;=&quot;#0066CC&quot;, 
                                            &quot;Liverpool&quot;=&quot;#FF0000&quot;, &quot;Man City&quot;=&quot;#99CCFF&quot;, &quot;Man United&quot;=&quot;#CC0000&quot;,
                                            &quot;Newcastle&quot;=&quot;#666666&quot;, &quot;Southampton&quot;=&quot;#FF3300&quot;, &quot;Tottenham&quot;=&quot;#000066&quot;, 
                                            &quot;Watford&quot;=&quot;#FFFF00&quot;, &quot;West Brom&quot;=&quot;#000099&quot;, &quot;West Ham&quot;=&quot;#993333&quot;,
                                            &quot;Wolves&quot;=&quot;#FFCC00&quot;))
  
      })
      
      output$table = renderTable(cTempData)
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p><img src="https://i.stack.imgur.com/dsurD.png" alt="enter image description here" /></p>