Re: [Rd] colnames slow (PR#10470)

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Mon, 26 Nov 2007 22:14:07 +0100

tomas.larsson_at_gm.com wrote:
> Full_Name: Tomas Larsson
> Version: 2.6.0
> OS: Windows XP
> Submission from: (NULL) (198.208.251.24)
>
>
> This is not a bug, it is a performance issue but I think it should have an easy
> fix.
>
> I have a large matrix (about 2,000,000 by 20), when I type colnames(x) it takes
> a long time to get the result. However, if I select just the first couple of
> rows of the matrix I don't have to wait for the result. See below for example.
>

>> system.time(colnames(x))

> user system elapsed
> 9.98 0.00 10.00
>> system.time(colnames(x[1:2,]))

> user system elapsed
> 0.01 0.00 0.02

Documentation in the released version of R (2.6.1) tells us:

For a data frame, 'rownames'

      and 'colnames' are calls to 'row.names' and 'names' respectively,
      but the latter are preferred.

and on my machine I get:

system.time(names(x))

    user system elapsed

       0 0 0

Uwe Ligges

> Sincerely,
>
> Tomas
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 26 Nov 2007 - 21:24:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 26 Nov 2007 - 23:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.