[R] Ceiling to the nearest ten?
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Mon Jan 14 18:27:53 CET 2008
Lauri Nikkinen wrote:
> R-users,
>
> Is there a function for ceiling to the nearest ten?
>
> a <- 1:10*4
> a
> [1] 4 8 12 16 20 24 28 32 36 40
>
> The resulting vector should look like this ("ceiling to the nearest ten")
> [1] 10 10 20 20 20 30 30 40 40 40
>
Divide and conquer:
> a
[1] 4 8 12 16 20 24 28 32 36 40
> ceiling(a/10)*10
[1] 10 10 20 20 20 30 30 40 40 40
Barry
More information about the R-help
mailing list