title: find value closest to x by group in dplyr
body: <pre><code>library(dplyr)
  a &lt;- data_frame(id = c("A","A","A","B","B","B"),
                  b = c(1.2, 1.5, 1.8, 1.1, 1.6, 1.4))
  </code></pre>
  
  <p>Now, I´d like to retrieve the values closest to 1.43 for each of the catergories in id. 
  I thought I could use:</p>
  
  <pre><code>a %&gt;% group_by(id) %&gt;% nth(which.min(abs(.$b-1.43)))
  </code></pre>
  
  <p>but dplyr states</p>
  
  <pre><code>Error: Don't know how to generate default for object of class grouped_df/tbl_df/tbl/data.frame
  </code></pre>