[R] Printing 2 digits after decimal point
Linlin Yan
yanlinlin82 at gmail.com
Mon Feb 15 12:09:20 CET 2010
format(x, nsmall = 2)
On Mon, Feb 15, 2010 at 5:41 PM, <T.Wunder at stud.uni-heidelberg.de> wrote:
>
> Hi there,
>
> i'm not getting along with the following problem.
> I'd like to print a real number, e.g.
> x <- 12.3
> with exactly two digits after the decimal point, e.g.
> 12.30
> I've tried the whole format(), formatC() and prettyNum() functions but
> did not have any success with it.
> This should work with all real numbers, in case even with 0.0 (-> 0.00).
> For cracks this thing is pretty sure obvious, but I've spent the whole morning with it.
>
> Please help me!
>
> Thanks a lot,
> Tom
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list