Error in read.table(file = file, header = header, sep = sep, quote = quote, : duplicate 'row.names' are not allowed
2
0
Entering edit mode
7.9 years ago
IOM • 0

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 • 67k views
ADD COMMENT
0
Entering edit mode

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

IOM

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

That's the March1 gene converted by excel.

ADD REPLY
1
Entering edit mode
7.9 years ago

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.

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
7.9 years ago
apa@stowers ▴ 610

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.

ADD COMMENT

Login before adding your answer.

Traffic: 1696 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6