[6392] in s-news-athena
Re: signif()
daemon@ATHENA.MIT.EDU (John Wallace)
Fri Feb 3 19:54:50 1995
Date: Fri, 3 Feb 1995 16:35:11 -0800 (PST)
From: John Wallace <jrw@fish.washington.edu>
To: Greg Unrau <gregu@ocgy.ubc.ca>
Cc: spluslist <S-news@stat.wisc.edu>
In-Reply-To: <9502032100.AA27755@penguin.ocgy.ubc.ca>
Use format();
text(x,y,labels=format(signif(round(fish,1),3)))
This also works for changing to character;
as.character(signif(round(fish,1),3))
[1] "11" "32.3" "46.8" "45.4"
format(signif(round(fish,1),3))
[1] "11.0" "32.3" "46.8" "45.4"
-jrw
On Fri, 3 Feb 1995, Greg Unrau wrote:
> I wish to figure out how to include zeros when using signif() and round().
> Here's what I mean. Let's say I have vector fish_c(11.02,32.34,46.78,45.44) and
> I want to plot these values on a figure using text(). So this is what I
> supply to the function:
>
> text(x,y,labels=signif(round(fish,1),3))
>
> This *should* result in the following values plotted:
>
> "11.0","32.3","46.8","45.4"
>
> However Splus thinks I don't care about the .0 on the 11.0 and cuts it off
> so that I get:
>
> "11","32.3","46.8","45.4"
>
> Isn't signif() supposed to retain the number of sigfigs you give it regardless
> of zeros. Help!
> --
> |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
> | Greg Unrau | |\ (__) |
> | Atmospheric Science Programme, | | \ (oo) "What sea-cows |
> | University of British Columbia | /-------\/ really look like" |
> | CANADA | / | || |
> | e-mail INTERNET: gregu@ocgy.ubc.ca |* ||W---|| |
> | | ^^ ^^ |
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>