Hello S+ Users,
Thanks to all who responded to my posting. All recommended the format()
function. I knew there had to be an easy way to pad with 0's.
Here is an example from Sam Buttrey:
> format (c(5, 0.62))
[1] "5.00" "0.62"
If you want to force everything to have three digits after the decimal,
use the nsmall= option:
> format (c(5, 0.62), nsmall = 3)
[1] "5.000" "0.620"
______________________________________________________________________________
Nicole Demers
Statistics Department
The Ohio State University
1958 Neil Ave., #404
Columbus, OH 43210, USA
ntd@stat.ohio-state.edu
On Thu, 25 Feb 1999, Nicole DePriest Demers wrote:
>
> Dear S+ Users,
>
> I would like to be able to specify the number of digits to appear after
> the decimal so that all my numerical output uses up the same number of
> columns. In particular, I have problems of making 5 appear as 5.000 or
> 0.62 to appear as 0.620 if I want all my values to have 3 digits after the
> decimal. Essentially, I want to pad my values with zeros where necessary.
>
> I looked at round(), signif() and options(digits=) but the latter 2 only
> control the number of significant digits and round() won't pad with zeros
> either.
>
> I was just curious if padding with zeros can be done easily. Any help is
> appreciated. I'll summarize any replies to the group.
>
> Thanks,
>
> Nicole Demers
> ______________________________________________________________________________
> Nicole Demers
> Statistics Department
> The Ohio State University
> 1958 Neil Ave., #404
> Columbus, OH 43210, USA
> ntd@stat.ohio-state.edu
>
> -----------------------------------------------------------------------
> This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
> send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
> message: unsubscribe s-news
>
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|