Re: [Rd] colnames is slow for data.frames with implicit row.names

2006-09-27 Thread Martin Morgan
Yes, obviously, with hindsight. In lieu of code change, the colnames documentation could indicate the restricted sense of 'equivalent'. For a data frame, 'rownames' and 'colnames' are equivalent to 'row.names' and 'names' respectively. It might help to add 'names' to See Also of ?data.fr

Re: [Rd] colnames is slow for data.frames with implicit row.names

2006-09-27 Thread Prof Brian Ripley
On Wed, 27 Sep 2006, Martin Morgan wrote: > colnames on a data.frame with implicit row.names > >> df <- data.frame(x=1:600) > > is slow > >> system.time(colnames(df)) > [1] 21.655 0.327 21.987 0.000 0.000 >> system.time(names(df)) > [1] 0 0 0 0 0 > > because colnames calls dimnames calls ro

[Rd] colnames is slow for data.frames with implicit row.names

2006-09-27 Thread Martin Morgan
colnames on a data.frame with implicit row.names > df <- data.frame(x=1:600) is slow > system.time(colnames(df)) [1] 21.655 0.327 21.987 0.000 0.000 > system.time(names(df)) [1] 0 0 0 0 0 because colnames calls dimnames calls row.names.data.frame calls as.character on the implicit row.na