Hi all,
I want to round my values to the nearest 5.
For example, if I have a value of 11, I want R to round it to 10.
I have been searching for this command on the web and in the help file, but
I couldn't find anything useful.
Any help would be greatly appreciated.
Many thanks,
Chris
--
x5 - 5*round(x/5)
From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of
Chris Li [chri...@austwaterenv.com.au]
Sent: 16 September 2009 09:15
To: r-help@r-project.org
Subject: [R] Rounding to the nearest 5
Hi all,
I want
hope this will help
for (i in 1:10) {
if (i%%52) {
print((i%/%5+1)*5)
}
else {
print((i%/%5)*5)
}
}
Jimmy
Chris Li wrote:
Hi all,
I want to round my values to the nearest 5.
For example, if I have a value of 11, I want R to round it to 10.
I have been
you can also use:
round(x / 5) * 5
for (i in 1:20) cat(round(i / 5) * 5, ' ')
0 0 5 5 5 5 5 10 10 10 10 10 15 15 15 15 15 20 20 20
On Tue, Sep 15, 2009 at 8:08 PM, J Chen jiaxuan.c...@mdc-berlin.de wrote:
hope this will help
for (i in 1:10) {
if (i%%52) {
Dear all,
A hopefully simple question: how do I round a series of values (held in an
object) to the nearest 5? I've checked out trunc, round, floor and ceiling, but
these appear to be more tailored towards rounding decimal places.
Thanks,
Steve
Steve Murray ha scritto:
Dear all,
A hopefully simple question: how do I round a series of values (held in an
object) to the nearest 5? I've checked out trunc, round, floor and ceiling, but
these appear to be more tailored towards rounding decimal places.
Thanks,
Steve
I had a similar
mround - function(x,base){
base*round(x/base)
}
mround(14,5)
[1] 15
Steve Murray wrote:
Dear all,
A hopefully simple question: how do I round a series of values (held in an
object) to the nearest 5? I've checked out trunc, round, floor and ceiling,
but these appear to be more
7 matches
Mail list logo