On Thu, 18 Mar 2004, Randy Zelick wrote:
> Is there a way to *not* supress leading zeros when printing (to the
> console window or to a file) a dataframe?
If you mean via print() or autoprinting, no.
I am not sure why you would want to do this, but it seems that using
format() and then gsub should work. For example
library(MASS)
fh <- format(hills)
fh[] <- lapply(fh, function(x) gsub(" ", "0",
as.character(x)))
fh
dist climb time
Greenmantle 02.5 0650 016.083
Carnethy 06.0 2500 048.350
Craig Dunain 06.0 0900 033.650
Ben Rha 07.5 0800 045.600
Ben Lomond 08.0 3070 062.267
...
See also ?sprintf.
--
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