title: How to show every second R ggplot2 x-axis label value?
body: <p>I want to show every second of x-axis label list in the presentation.
  Simplified code example in the following and its output in Fig. 1 where four Dates shown but #2 and #4 should be skipped. </p>
  
  <pre><code># https://stackoverflow.com/a/6638722/54964
  require(ggplot2)
  my.dates = as.Date(c("2011-07-22","2011-07-23",
                       "2011-07-24","2011-07-28","2011-07-29"))
  my.vals  = c(5,6,8,7,3)
  my.data &lt;- data.frame(date =my.dates, vals = my.vals)
  plot(my.dates, my.vals)
  p &lt;- ggplot(data = my.data, aes(date,vals))+ geom_line(size = 1.5)
  </code></pre>
  
  <p>Expected output: skip dates second and fourth.   </p>
  
  <h2>Actual code</h2>
  
  <p>Actual code where due to <code>rev(Vars)</code> logic, I cannot apply <code>as.Date</code> to the values in each category; the variable <code>molten</code> has a column <code>Dates</code></p>
  
  <pre><code>p &lt;- ggplot(molten, aes(x = rev(Vars), y = value)) + 
      geom_bar(aes(fill=variable), stat = "identity", position="dodge") + 
      facet_wrap( ~ variable, scales="free") +
      scale_x_discrete("Column name dates", labels = rev(Dates)) 
  </code></pre>
  
  <p>Expected output: skip #2,#4, ... values in each category. 
  I thought here changing <code>scale_x_discrete</code> to <code>scale_x_continuous</code> and having a break sequence <code>breaks = seq(1,length(Dates),2))</code> in <code>scale_x_continuous</code> but it fails because of the following error.</p>
  
  <pre><code>Error: `breaks` and `labels` must have the same length 
  </code></pre>
  
  <h2>Proposal based Juan's comments</h2>
  
  <p>Code </p>
  
  <pre><code>ggplot(data = my.data, aes(as.numeric(date), vals)) + 
    geom_line(size = 1.5) +
    scale_x_continuous(breaks = pretty(as.numeric(rev(my.data$date)), n = 5)) 
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Error: Discrete value supplied to continuous scale
  </code></pre>
  
  <h2>Testing EricWatt's proposal application into Actual code</h2>
  
  <p>Code proposal</p>
  
  <pre><code>p &lt;- ggplot(molten, aes(x = rev(Vars), y = value)) + 
      geom_bar(aes(fill=variable), stat = "identity", position="dodge") + 
      facet_wrap( ~ variable, scales="free") +
      scale_x_discrete("My dates", breaks = Dates[seq(1, length(Dates), by = 2)], labels = rev(Dates))  
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Error: `breaks` and `labels` must have the same length 
  </code></pre>
  
  <p>If you have <code>scale_x_discrete("My dates", breaks = Dates[seq(1, length(Dates), by = 2)])</code>, you get x-axis without any labels so blank.   </p>
  
  <p>Fig. 1 Output of the simplified code example, 
  Fig. 2 Output of EricWatt's first proposal </p>
  
  <p><a href="https://i.stack.imgur.com/4YqpU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4YqpUs.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/QbWKh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QbWKhs.png" alt="enter image description here"></a></p>
  
  <p>OS: Debian 9<br>
  R: 3.4.0    </p>