[R] duplicate row.names

John Smith JSmith at telicmanagement.com
Thu Jul 17 14:27:08 CEST 2003

row.names=NULL seems to have fixed my problem.  strange that NULL uses row
numbers and not specifying uses row numbers, but NULL poses no problems and
the latter does.

Thanks to you and everyone else who responded.


-----Original Message-----
From: Simon Blomberg [mailto:Simon.Blomberg at anu.edu.au]
Sent: Wednesday, July 16, 2003 9:50 PM
To: John Smith; r-help at stat.math.ethz.ch
Subject: RE: [R] duplicate row.names 

I think you need to be a bit more specific for us to be able to help you. At
least provide a toy problem which replicates the error. Does this do what
you want?

dat1 <- data.frame (x=rnorm(100), y=rnorm(100)) #make up some data
dat2 <- data.frame (x=rnorm(100), y=rnorm(100))
write.table(dat1, file="test1.txt") #write data to files
write.table(dat2, file="test2.txt")
F<- NULL # Initialise
for (i in 1:2) F <- rbind(F, read.table(paste("test", i, ".txt", sep="")))
F <- data.frame(F, row.names=NULL) # clean up row names.

Hope this helps,


Simon Blomberg, PhD
Depression & Anxiety Consumer Research Unit
Centre for Mental Health Research
Australian National University
Simon.Blomberg at anu.edu.au  +61 (2) 6125 3379

> -----Original Message-----
> From: John Smith [mailto:JSmith at telicmanagement.com]
> Sent: Thursday, 17 July 2003 10:06 AM
> To: 'r-help at stat.math.ethz.ch'
> Subject: [R] duplicate row.names 
> I am looping over many data files and reading in the data 
> with	 F <-
> read.table(filename)	to read in a 22000 by 15 matrix.  Works 
> fine on the
> first matrix F, but I get the following error when the second 
> file is read
> into F:
> Error in "row.names<-.data.frame"(*tmp*, value = row.names) : 
>         duplicate row.names are not allowed
> I have tried picking a column of the matrix and making that 
> my rownames by
> doing		rownames <- as.vector(F[,4])
> -but that does not work.
> Each row in my matrix is not unique.
> Any suggestions greatly appreciated.
> John
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help

More information about the R-help mailing list