[R] duplicate row.names

Adaikalavan Ramasamy gisar at nus.edu.sg
Thu Jul 17 05:31:29 CEST 2003

The row.names argument (if present) defines which column is to be used
as the row names. The default in read.table() is missing row.names and
hence row.names is not detected. The row names (if present) need to be

Giving us your code would have been helpful, but I am guessing you have
set the row.names to some number and hence it would be complain if it
not unique. Try :

1. Setting row.names=FALSE 
2. Assigning a unique identifier to each row
2. Manually rename the redundant rows

Your problem is with reading the data itself, and ` rownames <-
as.vector(F[,4]) ` just creates another unrelated variable.

Regards, Adai.

-----Original Message-----
From: John Smith [mailto:JSmith at telicmanagement.com] 
Sent: Thursday, July 17, 2003 8: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
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
doing		rownames <- as.vector(F[,4])
-but that does not work.

Each row in my matrix is not unique.

Any suggestions greatly appreciated.


R-help at stat.math.ethz.ch mailing list

More information about the R-help mailing list