Skip to content
Prev 70416 / 398525 Next

Rounding fractional numbers to nearest fraction

Thx for the help...

mdiv <- function(dec)
{
	dec <- dec * 4
	dec <- round(dec, 0)
	dec <- dec / 4
	dec
}

where m is a matrix --

m1 <- apply(m, 1, mdiv)

...but it looks like as.integer(x.1*4)/4 or (round(x.1*4,0))/4 might be 
easier...

thx again,
ken