Skip to content

row.names in read.table()

4 messages · Ko-Kang Kevin Wang, Thomas Lumley, Brian Ripley

#
Hi,

I was trying to read in the following data set by using:
  gas <- read.table("gas.tab", header = T)
when I got the error message:
  Error in "row.names<-.data.frame"(*tmp*, value = row.names) : 
          duplicate row.names are not allowed

Any help are appreciated.

Thanks,

Ko-Kang Wang


------------------------------------------------------------------------------
Ko-Kang Kevin Wang
Postgraduate PGDipSci Student (Summer Research Assistant)
Department of Statistics
University of Auckland
New Zealand
-------------- next part --------------
X1 X2 X3 X4 Y
33 53 3.32 3.42 29 30
31 36 3.10 3.26 24 24
33 51 3.18 3.18 26 26
37 51 3.39 3.08 22 22
36 54 3.20 3.41 27 27
35 35 3.03 3.03 21 20
59 56 4.78 4.57 33 32
60 60 4.72 4.72 34 34
59 60 4.60 4.41 32 27
60 60 4.53 4.53 34 34
34 35 2.90 2.95 20 19
60 59 4.40 4.36 36 37
60 62 4.31 4.42 34 34
60 36 4.27 3.94 23 22
62 38 4.41 3.49 24 24
62 61 4.39 4.39 32 32
90 64 7.32 6.70 40 38
90 60 7.32 7.20 46 44
92 92 7.45 7.45 55 57
91 92 7.27 7.26 52 53
61 62 3.91 4.08 29 29
59 42 3.75 3.45 22 21
88 65 6.48 5.80 31 28
91 89 6.70 6.60 45 45
63 62 4.30 4.30 37 39
60 61 4.02 4.10 37 39
60 62 4.02 3.89 33 34
59 62 3.98 4.02 27 26
59 62 4.39 4.53 34 34
37 35 2.75 2.64 19 19
35 35 2.59 2.59 16 15
37 37 2.73 2.59 22 22
#
Whoops.  Problem solved.  I have one extra columns of data at the end
(though I don't know why the error message did not say that, but said
about row.names!).

Thanks,
On Mon, 4 Feb 2002, Ko-Kang Kevin Wang wrote:

            
------------------------------------------------------------------------------
Ko-Kang Kevin Wang
Postgraduate PGDipSci Student (Summer Research Assistant)
Department of Statistics
University of Auckland
New Zealand

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 4 Feb 2002, Ko-Kang Kevin Wang wrote:

            
As help(read.table) says

     If `row.names' is not specified and the header line has one less
     entry than the number of columns, the first column is taken to be
     the row names.

This lets you have the row names as the first column of the data.

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 4 Feb 2002, Ko-Kang Kevin Wang wrote:

            
With header=T, it was interpreting the first columns as row names.
That's standard behaviour: see the help page.  If you don't want that, set
row.names.