title: R ggplot2: How can I use the aesthetics argument as part of a function?
body: <p>I want to define a function that has several histograms as an output. My inputs are: A dataframe, a variable for binwidth and the name of the "x-variable" in Aesthetics. Unfortunately, the code does not work, so I may need to specify the input differently. Can anybody help here? the code is given below:</p>
  
  <pre><code>```
  histograms &lt;- function(InputData, my_binwidth, my_xvariable) {
    hist_template &lt;- ggplot(aes(x = my_xvariable, y=..density..), 
                            data = InputData) +
      geom_histogram(binwidth=my_binwidth)
  
  
    hist_unscaled &lt;- hist_template +
      scale_x_continuous() +
      labs(title = "No Scaling") 
  
    result &lt;-  list(hist_template=hist_template,hist_unscaled=hist_unscaled)
    return(result)
  }
  
  testhist &lt;- histograms(WineData,0.1,residual.sugar)  ```
  </code></pre>