title: Error: Frequency and weighting differ in length - Regional Economic Analysis
body: <p>I have been using codes to gauge Gini, Theil, and other inequality measurements with R. However, I have been receiving an error since last January. I did everything to solve the problem, but I could not. I am sure someone here can solve it in a second.
  And also, I am sure codes can help one who deals with income or wage inequality.</p>
  <pre><code>library(REAT)
  library(ggplot2)
  library(readxl)
  
  theil &lt;- read_excel(file.choose())
  data &lt;- theil
  View(data)
  
  #weighted 
  theil_w2 &lt;- apply (data[2:4], MARGIN = 2, weighting = data[18:20], FUN= theil)
  years &lt;- seq.Date(from = as.Date('2000-01-01'), to = as.Date('2015-01-01'), by = 'years')
  theil_yw &lt;- data.frame(&quot;theil&quot; = theil_w2, &quot;YEARS&quot; = years)
  
  ggplot(data = theil_yw, aes(x = years, y = theil_w2, colour = variable)) +
    geom_line(color = &quot;#00AFBB&quot;, size = 2) + 
    theme_bw() + 
    labs(x = &quot;years&quot;,
         y=&quot;Theil&quot;,
         title = &quot;xxxx&quot;,
         subtitle = &quot;xxxxxxxxxxxxxx&quot;)
  
  #Note: The code can be used for population unweighted. To do that, just delete the &quot;weighted&quot; part.
  
  </code></pre>
  <p>So when I run this code, I always get the following error: Error: Frequency and weighting differ in length.</p>
  <p>I don't know what the problem is. Could you help me, please?</p>
  <p>The data can be found at this address: http://localhost:16785/session/file1b1cc6956e0.html</p>
  <p>Thank you in advance</p>