title: areaPolygon() on list of data frames R
body: <p>packages:</p>
  
  <pre><code>library(geosphere)
  library(dplyr)
  </code></pre>
  
  <p>I have a list of data frames like this:</p>
  
  <p><code>df_list</code>:</p>
  
  <pre><code>[[1]]
    name X1 X2
  1    A  1  1
  2    A  1  2
  3    A  2  2
  4    A  2  1
  
  [[2]]
    name X1 X2
  1    B  1  1
  2    B  1  2
  3    B  2  2
  4    B  2  1
  
  [[3]]
    name X1 X2
  1    C  1  1
  2    C  1  2
  3    C  2  2
  4    C  2  1
  </code></pre>
  
  <p>I want to loop through each data frame in the list and calculate the area of the polygon the dataframe represents using <code>areaPolygon()</code> from the <code>geosphere</code> package. I can do this for one data frame like this:</p>
  
  <pre><code>name &lt;- c("A","A","A","A")
  X1 &lt;- c(1,1,2,2)
  X2 &lt;- c(1,2,2,1)
  df &lt;- data.frame(name, X1, X2)
  
  areaPolygon(df[,2:3])
  </code></pre>
  
  <p>I tried doing this with pipes by concatenating the list of data frames into one dataframe and grouping by name:</p>
  
  <pre><code>df_list_con &lt;- do.call(rbind, df_list)
  area &lt;- df_list_concat %&gt;% group_by(name) %&gt;% areaPolygon(.[,2:3])
  </code></pre>
  
  <p>but it didn't work, giving the error message:</p>
  
  <pre><code>Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘areaPolygon’ for signature ‘"grouped_df"’
  </code></pre>
  
  <p>Can I do this using <code>mapply</code> or <code>lapply</code>? I wouldn't know how to do it.</p>