Depending on what you want to do, use 'sprintf':

> x <- 1.23456789
> x
[1] 1.234568
> as.character(x)
[1] "1.23456789"
> sprintf("%.1f  %.3f  %.5f", x,x,x)
[1] "1.2  1.235  1.23457"
>


On Thu, May 14, 2009 at 7:40 AM, lehe <timlee...@yahoo.com> wrote:

>
> Hi,
> I was wondering how to specify the number of decimal numbers in my
> computation using R? I have too many decimal numbers for my result, when I
> convert them to string with as.character, the string will be too long.
> Thanks and regards!
> --
> View this message in context:
> http://www.nabble.com/specify-the-number-of-decimal-numbers-tp23538852p23538852.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[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.

Reply via email to