Alternatively,
signif(c(pi,exp(1)), 3)
?signif # and others in that page
HTH,
baptiste
On 14 May 2009, at 13:47, jim holtman wrote:
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.
_____________________________
Baptiste AuguiƩ
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________________________
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.