[R] Rounding fractional numbers to nearest fraction
bogdan romocea
br44114 at gmail.com
Wed May 25 19:34:30 CEST 2005
Multiply by 4, round and divide by 4.
a <- c(1.15,5.82)
round(a*4,digits=0)/4
-----Original Message-----
From: Ken Termiso [mailto:jerk_alert at hotmail.com]
Sent: Wednesday, May 25, 2005 1:27 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Rounding fractional numbers to nearest fraction
Hi all,
I've got a matrix of fractional data that is all positive and greater than
zero that I would like to "loosely" classify, for lack of a better word. It
looks something like this :
1.07 1.11 1.27 1.59 0.97 0.76
2.23 0.98 0.71 0.88 1.19 1.02
What I'm looking for is a way to round these numbers to the nearest 0.25,
i.e. the above matrix would be transformed to :
1.00 1.00 1.25 1.50 1.00 0.75
2.25 1.00 0.75 1.00 1.25 1.00
Anyone have a clever way to do this??
Thanks in advance,
Ken
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list