title: How to change ggplot2 x-axis values in barplot?
body: <p>I would like to make a barplot in R, where the last bar in the graph indicates that last is the sum of all values whose the frequency is greater than a certain threshold. I want to represent this information on x-value correspondent to the last bar. For instance:</p>
  
  <pre><code>library(ggplot2)
  
  x &lt;- c(1, 2, 3, 4, 5)
  y &lt;- c(4000, 3000, 2000, 1000, 500)
  
  df &lt;- data.frame(x, y)
  
  names(df) &lt;- c("Var1", "Freq")
  
  theme_set(theme_classic())
  
  g &lt;- ggplot(df, aes(Var1, Freq))
  g + geom_bar(stat = "identity", width = 0.5, fill = 'tomato2') + 
    xlab('Var1') +
    ylab('Freq') +
    theme(axis.text.x = element_text(angle = 0, 
                                     vjust = 0.6, 
                                     colour = "black"),
          axis.text.y = element_text(colour = "black"))
  </code></pre>
  
  <p>The above code produces a chart similar to this:</p>
  
  <p><a href="https://i.stack.imgur.com/z4B3P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z4B3P.png" alt="enter image description here"></a></p>
  
  <p>But on the last bar, I want that last value of x-axis (<code>x = 5</code>) be displayed as <code>&gt;= 5</code>.</p>
  
  <p>So far, I've tried to use <code>scale_x_discrete</code>. So I added to the above code the following lines:</p>
  
  <pre><code>n &lt;- 5
  
  # I'm not very creative with names.
  .foo &lt;- function(x, n) {
    if (x == n) {
      element &lt;- paste('\u2265', toString(x), sep = ' ')
    } else {
      element &lt;- toString(x)
    }
  }
  
  labels &lt;- sapply(seq(n), .foo, n)
  
  g + scale_x_discrete(breaks = sapply(seq(n), function(x) toString(x)),
                       labels = labels)
  </code></pre>
  
  <p>This code formats the x-axis as I wish but it overrides the barplot, leaving an empty chart:</p>
  
  <p><a href="https://i.stack.imgur.com/4sby6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4sby6.png" alt="enter image description here"></a></p>
  
  <p>How can I do this?</p>