title: Dynamic ylim in ggplot2 using dplyr pipe
body: <p>I want to create dynamic ylim values in a ggplot so that the ylim parameter is referencing to the value that dplyr is providing via a pipe. To illustrate the problem, please see a working (non-generic) code that I want to change into a (currently not working generic) code.</p>
  
  <pre><code>require(dplyr)
  require(scales)
  require(ggplot2)
  
  x &lt;- data.frame(name = c("A","B","C"), 
                  value = c(2,4,6))
  </code></pre>
  
  <p>working non-generic code:</p>
  
  <pre><code>arrange(x[1:2, ], value) %&gt;%
    ggplot(data=., aes(x=factor(name), y=value)) + 
    geom_bar(stat="identity") +
    scale_y_continuous(labels=comma, 
                       limits=c(0,max(arrange(x[1:2, ], value)$value) * 1.1))
  </code></pre>
  
  <p>not working generic code (call does not find value):</p>
  
  <pre><code>arrange(x[1:2, ], value) %&gt;%
    ggplot(data=., aes(x=factor(name), y=value)) + 
    geom_bar(stat="identity") +
    scale_y_continuous(labels=comma, 
                       limits=c(0,max(value) * 1.1))
  </code></pre>
  
  <p>So the question is if there is any way to set the limits generally i.e. the part after the arrange will always be the same (I need to produce a lot of the same graphs with differing x i.e. different limits).
  Thanks!</p>