This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error in read.table(file = file, header = header, sep = sep, quote = quote, : duplicate 'row.names' are not allowed

Hi,

Thanks for reading. I have searched for the answer to this problem in many places, however I am not able of finding the right one and the error keeps popping up. I am trying to read a table that has samples (86) as columns and genes as rows(>37.000).

enter image description here

I have tried to read it from different formats as tab delimited file (.txt) and comma separated values (.CSV) and with different functions (read.table, read.csv, etc)I always get the same error:

Error in read.table(file = file, header = header, sep = sep, quote = quote, : duplicate 'row.names' are not allowed

Has anybody any idea of how fixing this dumb error? Thanks and merry christmas.

IOM

r

Thanks Devon WouterDeCoster, I will check the CSV for duplicated rows. Merry christmas

IOM

Hi, I used following lines (http://stackoverflow.com/questions/6986657/find-duplicated-rows-based-on-2-columns-in-data-frame-in-r?rq=1)

dup <- data.frame(as.numeric(duplicated(data$X))) #creates df with binary var for duplicated rows colnames(dup) <- c("dup") #renames column for simplicity df2 <- cbind(data, dup) #bind to original df df3 <- subset(df2, dup == 1) #subsets df using binary var for duplicated`

And got the error, a gene name changed to Mar-01 repeated twice. Thanks again for your help.

IOM

That's the March1 gene converted by excel.

2 answers

The error message is telling you all you need to know. There's at least one duplicate entry in the first column. Perhaps you want to use row.names=F or whatever that option is called.

OP can just leave the row.names out, R will assume no rownames and add numbering instead.

It is probably a problem with your header row.

If the first row in the file has fewer fields than the second row, read.delim() (and all other functions built on it) will automatically assign column 1 to be rownames.

Log in to answer this question.