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