title: How to fix 'duplicate row.names' in plm package?
body: <p>I'm a beginner with R, so bear with me. I've spent a while trying to fix this issue based on earlier answers, but I can't work it out.</p>
  
  <p>I want to run a panel regression using the plm package. However, when I try code of the form <code>reg&lt;-plm(y ~ x1, x2, x3, data=mydataframe, index=c('region', 'year'), model='within')</code> it gives the error </p>
  
  <pre><code>Error in .rowNamesDF&lt;-(x, value = value) : 
    duplicate 'row.names' are not allowed
  In addition: Warning message:
  non-unique values when setting 'row.names': ‘10’, ‘11’, ‘14’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’ 
  </code></pre>
  
  <p>I can't figure out why it says I have duplicate row names. I've tried some of the suggestions made by other people, such as checking <code>anyDuplicated(row.names(mydataframe))</code> - which tells me there are no duplicated row names - or <code>make.names(mydataframe, unique=TRUE</code> - which doesn't fix the problem.</p>
  
  <p>The data looks like this</p>
  
  <pre><code>   ï..region id year  grpmlnr    grppc   cpi
  
  1   RegionA   1 1998  18245.5  12242.8 167.7      
  2   RegionA   1 1999  32060.6  21398.0 140.8      
  3   RegionA   1 2000  42074.5  27969.5 120.9    
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Thank you very much in advance, I'm aware it's a dumb question but I really need help. </p>
  
  <p>Maurits</p>