[R] How to find the significant digits of a number?

Duncan Murdoch murdoch at stats.uwo.ca
Wed Dec 16 14:56:25 CET 2009


On 16/12/2009 8:48 AM, Xiang Wu wrote:
> Yes, that's true. But what I need is the original precision of a 
> numeric. So to me, 1.00 and 1.0000 are different. 

In that case, they are not numbers, but strings:  and you can probably 
use nchar() to count characters, after stripping off any leading or 
trailing whitespace, commas, and decimal points.

Duncan Murdoch

> 
> 
> On Wed, Dec 16, 2009 at 6:31 AM, Duncan Murdoch <murdoch at stats.uwo.ca 
> <mailto:murdoch at stats.uwo.ca>> wrote:
> 
>     On 16/12/2009 12:39 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'?
> 
> 
>     The question may not have an unambiguous answer: I would say 1.00
>     and 1.00000 have a different number of significant digits, but once
>     converted to numbers they are identical in R.
> 
>     Duncan Murdoch
> 
>




More information about the R-help mailing list