Hello, I'm simply trying to import a .txt file that has a column of about 30,000 pts. I found the file, but I'm getting an error:> m <- read.table(choose.files())Error in "row.names<-.data.frame"(`*tmp*`, value = row.names) : duplicate row.names are not allowed Any help with getting around this? I really appreciate all the help. Thanks dave [[alternative HTML version deleted]]
Try read.table(choose.files(), row.names=NULL). BTW, I think you might be using an older R version because in R-1.9.1, the value for row.names is missing by default in read.table().> args(read.table)function (file, header = FALSE, sep = "", quote = "\"'", dec = ".", row.names, col.names, as.is = FALSE, na.strings = "NA", colClasses = NA, nrows = -1, skip = 0, check.names = TRUE, fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip = TRUE, comment.char = "#") Try read.delim() or read.csv() if the data is tab-delimited or comma separated. Also check to see if you have a header, in which case you would set the option header=TRUE. For more info, help("read.table"). Do dim(m), head(m) to see if the data has been read correctly. On Wed, 2004-07-14 at 16:12, Herman, David (NIH/NIMH) wrote:> Hello, > I'm simply trying to import a .txt file that has a column of > about 30,000 pts. I found the file, but I'm getting an error: > > m <- read.table(choose.files()) > Error in "row.names<-.data.frame"(`*tmp*`, value = row.names) : > duplicate row.names are not allowed > > Any help with getting around this? > > I really appreciate all the help. > Thanks > dave > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
Dear David, If there is one fewer variable name in the first row of the data file than fields in the remaining rows, then read.table() will treat the first entry in each row as the row name. Simply add a new first variable (such as "name") to the first row, and specify header=TRUE in the call to read.table(). (Of course, this assumes that I've correctly guessed the source of the problem.) I hope that this helps, John> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of > Herman, David (NIH/NIMH) > Sent: Wednesday, July 14, 2004 10:13 AM > To: 'r-help at stat.math.ethz.ch' > Subject: [R] duplicate row importing issue > > Hello, > I'm simply trying to import a .txt file that has > a column of about 30,000 pts. I found the file, but I'm > getting an error: > > m <- read.table(choose.files()) > Error in "row.names<-.data.frame"(`*tmp*`, value = row.names) : > duplicate row.names are not allowed > > Any help with getting around this? > > I really appreciate all the help. > Thanks > dave >
How about you delete the first row (column names) and then use "header=FALSE" in read.table()? Frank -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Herman, David (NIH/NIMH) Sent: Wednesday, July 14, 2004 11:13 To: 'r-help at stat.math.ethz.ch' Subject: [R] duplicate row importing issue Hello, I'm simply trying to import a .txt file that has a column of about 30,000 pts. I found the file, but I'm getting an error:> m <- read.table(choose.files())Error in "row.names<-.data.frame"(`*tmp*`, value = row.names) : duplicate row.names are not allowed Any help with getting around this? I really appreciate all the help. Thanks dave [[alternative HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Or just read.table(..., header=FALSE, skip=1) Andy> From: F Duan > > How about you delete the first row (column names) and then use > "header=FALSE" in read.table()? > > Frank > > -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Herman, David > (NIH/NIMH) > Sent: Wednesday, July 14, 2004 11:13 > To: 'r-help at stat.math.ethz.ch' > Subject: [R] duplicate row importing issue > > Hello, > I'm simply trying to import a .txt file that has > a column of > about 30,000 pts. I found the file, but I'm getting an error: > > m <- read.table(choose.files()) > Error in "row.names<-.data.frame"(`*tmp*`, value = row.names) : > duplicate row.names are not allowed > > Any help with getting around this? > > I really appreciate all the help. > Thanks > dave > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >