[R] duplicate row.names
Simon.Blomberg at anu.edu.au
Thu Jul 17 03:50:16 CEST 2003
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
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.
> R-help at stat.math.ethz.ch mailing list
More information about the R-help