Skip to content

Rounding fractional numbers to nearest fraction

1 message · Liaw, Andy

#
You don't need the apply():
[,1]      [,2]      [,3]
[1,] 0.6885473 0.4598892 0.2738169
[2,] 0.2393461 0.8863284 0.7891100
[,1] [,2] [,3]
[1,] 0.75  0.5 0.25
[2,] 0.25  1.0 0.75
Be careful: as.integer() trucate the fractional part (so as.integer(1.999)
is 1 intead of 2), which may not be what you want.

Andy