1

I am creating dataframes in a loop. At the end of each loop, I would like to add all data frames together. Its a pretty long and complicated code for the loop, but what I did is created an empty list called "datalist" before the loop and then added the dataframes to the loop. that worked fine. After the loop, I wrote:

big_data = do.call("rbind",datalist)

this hits me with the error

Error in `row.names<-.data.frame`(`*tmp*`, value = value) : 
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘1’, ‘2’, ‘3’, ‘4’ 

I have no idea how to fix this. Can anyone help me out?

Jaap
  • 81,064
  • 34
  • 182
  • 193
Nechama
  • 39
  • 2
  • 1
    Before `rbind`ing your data.frames, consider "flushing" rownames with `rownames(x) <- NULL`. – Roman Luštrik Jan 20 '16 at 20:27
  • Roman, unfortunately that didnt work- I tried doing that in the loop before adding the data frame to the list, and also after th eloop before calling rbind on the list. Any other suggestions? – Nechama Jan 20 '16 at 21:06
  • I had the same problem; the issue turned out to be that I unintentionally had put a data.frame nested inside my data.frame. Found the problem (and resolved it) thanks to the following answer: https://stackoverflow.com/a/23115910/8436923 – Montgomery Clift Oct 30 '19 at 20:18

0 Answers0