s-news
[Top] [All Lists]

Re: rounding

To: Zheng_Jenny <Zheng_Jenny@Allergan.com>
Subject: Re: rounding
From: Andreas Krause <stats@elmo.ch>
Date: Sun, 12 Apr 2009 11:08:15 +0200
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <37A0A965AB353B4D93AE86C2F16FF382EB0271@IRMAIL134.irvine.allergan.com>
References: <37A0A965AB353B4D93AE86C2F16FF382EB0271@IRMAIL134.irvine.allergan.com>
Reply-to: stats@elmo.ch
User-agent: Thunderbird 2.0.0.12 (Windows/20080213)

To avoid any machine-dependent arithmetic and keep trailing zeros, converting to characters helps at times.

The example here would be
format(c(2.5, 3.5), nsmall=2)

  Andreas


Zheng_Jenny wrote:
Hi, everyone,

I use function signif to report number since it requires 3 significant numbers in my report. I have two questions: A) according to Splus help manual, when rounding off a 5, the two common conventions are to: 1) go to the higher number, or 2) go to the even digit. The |round| function obeys convention 2, so |round(2.5)| is |2| and |round(3.5)| is |4|. The rounding mechanism for |signif| is machine dependent, but most machines will use the "round to even" rule. I am wondering if I can select convention 1 rather than depending on machine. B) when last digit is zero, e.g. 3.50, the output will be 3.5, which is not appropriate for my report. I am wondering if there is a command I can use so that 3.50 will be reported as 3.50 rather than 3.5.

Thanks for your help.

Jenny

This e-mail, including any attachments, is meant only for the intended recipient and may be a confidential communication or a communication privileged by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of this e-mail is strictly prohibited. Please notify the sender immediately of the error by return e-mail and please delete this message from your system. Thank you in advance for your cooperation.



<Prev in Thread] Current Thread [Next in Thread>