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....@cbs.dk  Priv: pda...@gmail.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to