The only comprehensive way to do this would be to change R's internaal
print mechanisms. (Note that changing 0. to . breaks the layout:
changing '0.' to ' .' would be better.)
But you haven't told use why you would want to do this. Leaving off
leading zeroes makes output harder to read for most people, and indded
leading periods are easy to miss (much easier than failing to see that
you were asked not to send HTML mail).
It would be easy for the cognescenti to add an option to R, but I
suspect they all would need a lot of convincing to do so.
On Sat, 24 Jan 2009, Ista Zahn wrote:
Dear all,
Is there a simple way to strip the leading "0"'s from R output? For example,
I want
Data <- data.frame(x=rnorm(10), y=x*rnorm(10), z = x+y+rnorm(10))
cor(Data)
to give me
x y z
x 1.0000000 -.1038904 -.3737842
y -.1038904 1.0000000 .4414706
z -.3737842 .4414706 1.0000000
Several of you were kind enough to alert me to the existence of gsub a few
weeks ago, so I can do
gsub("0\\.","\\.",cor(Data))
but I'm hoping someone has a better way (e.g, one that returns an object of
the same class as the original, preserving dimnames, etc.)
Thanks,
Ista
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Brian D. Ripley, rip...@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
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.