[R] How to find the significant digits of a number?
Romain Francois
romain.francois at dbmail.com
Wed Dec 16 10:32:18 CET 2009
On 12/16/2009 10:26 AM, Xiang Wu wrote:
>
> Is there a function in R that could find the significant digit of a specific
> number? Such as for 3.1415, return '5'?
>
> Thanks in advance.
Not sure to understand what you mean, but you can have a look at ?signif
Something like this perhaps:
> foo <- function( x, y) abs( round( 10^y * (x - signif(x,y) ) ) )
> foo( 3.1415, 4 )
[1] 5
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/HlX9 : new package : bibtex
|- http://tr.im/Gq7i : ohloh
`- http://tr.im/FtUu : new package : highlight
More information about the R-help
mailing list