[Rd] Subsetting and conversion in data frames

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jun 27 12:45:28 MEST 2003


I have now finished a long session of documenting and bug-fixing the way 
subscripting of data frames works -- you can see this in the NEWS file in 
R-devel.

As far as I know we are at the point where the only times that character
columns get converted to factors are in data.frame(), read.table() and
when as.data.frame() is called on a list.  (There are read.table-alikes in
other packages which will also convert.)  So if you have a character
column in a data frame, it should stay that way.

cbind.data.frame calls data.frame and so converts, and I believe it should
not.  There may be others (anyone know of any?).

This raises the possibility that using data.frame(I(foo)) could make foo a 
character column and not give it class "AsIs".   I've heard comments that 
having the additional class slows code down, but not seen any examples.
Any relevant experience or comments?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list