Skip to content

Rounding fractional numbers to nearest fraction

1 message · Ken Termiso

#
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