title: How to plot weighted loess smoothing in ggplot2?
body: <p>How do I add a loess-smoothing which respects another column as weights?</p>
  
  <p>Let's say I have the following data.frame:</p>
  
  <pre><code>    library(ggplot2)
  
      df &lt;- data.frame(x=seq(1:21))
      df$y &lt;- df$x*0.3 + 10
      df$weight &lt;- 10
  
      df[6,] &lt;- c(6, 0.1, 1)
      df[7,] &lt;- c(7, 0.1, 1)
  
      df[13,] &lt;- c(13, 0.1, 1)
      df[14,] &lt;- c(14, 0.1, 1)
  
      df[20,] &lt;- c(20, 0.1, 1)
      df[21,] &lt;- c(21, 0.1, 1)
  
      ggplot(data=df, aes(x=x, y=y, size=weight)) + geom_point() + geom_smooth(method=loess, legend=FALSE)
  </code></pre>
  
  <p>Plotting a loess-smoothing brings up the following:</p>
  
  <p><img src="https://i.stack.imgur.com/dzPuR.png" alt="loess-smoothing without weights"></p>
  
  <p>But I want to use the column weight such that loess is the same as if every point with weight 10 is 10-times existent:</p>
  
  <pre><code>    df2 &lt;- subset(df, !(x %in% c(6,7,13,14,20,21)))
      df2$weight &lt;- 1
  
      df3 &lt;- df2
      for(i in seq(1:9)){
        df3 &lt;- rbind(df3, df2)
      }
      df3 &lt;- rbind(df3, c(6, 0.1, 1))
      df3 &lt;- rbind(df3, c(7, 0.1, 1))
  
      df3 &lt;- rbind(df3, c(13, 0.1, 1))
      df3 &lt;- rbind(df3, c(14, 0.1, 1))
  
      df3 &lt;- rbind(df3, c(20, 0.1, 1))
      df3 &lt;- rbind(df3, c(21, 0.1, 1))
  
      ggplot(data=df3, aes(x=x, y=y)) + geom_point() + geom_smooth(method=loess, legend=FALSE) 
      # or to demonstrate
      ggplot(data=df3, aes(x=x, y=y)) + geom_jitter() + geom_smooth(method=loess, legend=FALSE)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/WMUuF.png" alt="smoothing with weights"></p>
  
  <p>I found the parameter weights of the function loess. But I don't know how to invoke it from geom_smooth().</p>