title: Gini coefficient, ineq package in R and integer overflow
body: <p>I want to calculate the Gini coefficient for each column in a <code>2090 x 25</code> dataframe. I am using the Gini function in the ineq package and the following code:</p>
  
  <pre><code>gini &lt;- sapply(mydata, function(x) ineq(x,type="Gini")).
  </code></pre>
  
  <p>This produces results that look valid but also the following warning message: </p>
  
  <p>Warning messages:</p>
  
  <pre><code>1: In n * sum(x) : NAs produced by integer overflow
  2: In sum(x * 1:n) : Integer overflow - use sum(as.numeric(.))
  3: In n * sum(x) : NAs produced by integer overflow
  </code></pre>
  
  <p>To overcome the integer overflow I converted the dataframe to a matrix <code>(mymatrix &lt;- as.matrix(mydf))</code> but then the results were all zeros or NAs. I think this is because ineq package requires a vector and matrix is not a vector.</p>
  
  <p>My questions are:</p>
  
  <ul>
  <li>how can I convert integer columns to numeric and retain a vector class?</li>
  <li>are there any other options to work around the integer overflow problem?</li>
  </ul>
  
  <p>Thanks</p>
  
  <p>Nerida</p>