# Re: [R] Numbers with correct significant digits

From: Andrew Robinson <A.Robinson_at_ms.unimelb.edu.au>
Date: Sat 18 Nov 2006 - 03:33:22 GMT

I meant that it demonstrates that the number is not an integer to the reader, regardless of how it is stored. In the reporting of measurements,

10

is interpreted as an integer, whereas

10.

is interpreted as a real, rounded to two significant digits.

Cheers

Andrew

On Fri, Nov 17, 2006 at 09:55:24PM -0500, Gabor Grothendieck wrote:
> You must be thinking of some other language:
>
> >is.integer(1)
> [1] FALSE
>
>
> On 11/17/06, Andrew Robinson <A.Robinson@ms.unimelb.edu.au> wrote:
> >Nice solution.
> >
> >I believe that showing the decimal point is correct. It demonstrates
> >that the number is not an integer.
> >
> >Cheers
> >
> >Andrew
> >
> >On Fri, Nov 17, 2006 at 02:43:10PM -0800, RMan54 wrote:
> >>
> >> I think that I answered my own question.
> >>
> >> Since formatC is an implementation of the C-style formatting, I thought
> >that
> >> a "#" as flag could work (for g and G conversions, trailing zeros are not
> >> removed from the result as they would otherwise be). Although not in
> >the
> >>
> >> v <- c(9.6996, 99.99)
> >> formatC(v, digits=3, format="g", flag="#")
> >>
> >> result:
> >>
> >> "9.70" "100."
> >>
> >> The only small annoyance is that the decimal point is always shown.
> >>
> >>
> >> RMan54 wrote:
> >> >
> >> > This, for example:
> >> >
> >> > v <- c(9.6996, 99.99)
> >> > formatC(v, digits=3, format="g")
> >> >
> >> > shows:
> >> >
> >> > " 9.7" " 100"
> >> >
> >> > This is scientifically incorrect for the first number in the sense
> >that I
> >> > like to show all 3 significant digits, including trailing zero's.
> >> > Is there a way that the first number would show as " 9.70"?
> >> >
> >> > By the way, can't use format() since it applies the same numbers of
> >digits
> >> > after the decimal point for all numbers in the vector.
> >> >
> >> > Thanks,
> >> > Rene
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >http://www.nabble.com/Numbers-with-correct-significant-digits-tf2657246.html#a7412389
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> ______________________________________________
> >> R-help@stat.math.ethz.ch mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> >--
> >Andrew Robinson
> >Department of Mathematics and Statistics Tel: +61-3-8344-9763
> >University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
> >http://www.ms.unimelb.edu.au/~andrewpr
> >http://blogs.mbs.edu/fishing-in-the-bay/
> >
> >______________________________________________
> >R-help@stat.math.ethz.ch mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
> >

```--
Andrew Robinson
Department of Mathematics and Statistics            Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help