decimal number format as quarter
Thanks so much Peter. You are the man. Easy way and working for me. Arnaud Gaboury ? A2CT2 Ltd. -----Original Message----- From: peter dalgaard [mailto:pdalgd at gmail.com] Sent: mercredi 8 f?vrier 2012 16:15 To: David Reiner Cc: Arnaud Gaboury; jim holtman; r-help at r-project.org Subject: Re: [R] decimal number format as quarter
On Feb 8, 2012, at 15:48 , David Reiner wrote:
Looks like something priced in eighths; we deal with similar notation for bonds and similar instruments.
x <- c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6) as.integer(x)+10*(x-as.integer(x))/8
[1] 2.25 2.50 2.75 3.25 3.50 3.75 Adjust the 10 and 8 if you have other denominators.
For the case at hand, I expect that you can even get away with
ceiling(x*4)/4
[1] 2.25 2.50 2.75 3.25 3.50 3.75 -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com