round 2.3 to 2.5 and 2.2 to 2.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Mat
Reply | Threaded
Open this post in threaded view
|

round 2.3 to 2.5 and 2.2 to 2.0

Mat
Hello together,

i want to round some numbers in my data.frame.
How can i round a number to values like 0.5; 1.0; 1.5; 2.0; etc.

It should look like this one

before
2.2 ; 2.3; 2.26; 1.11

after
2.0; 2.5; 2.5; 1.0

thanks.

Mat
Reply | Threaded
Open this post in threaded view
|

Re: round 2.3 to 2.5 and 2.2 to 2.0

Uwe Ligges-3


On 07.01.2013 09:59, Mat wrote:

> Hello together,
>
> i want to round some numbers in my data.frame.
> How can i round a number to values like 0.5; 1.0; 1.5; 2.0; etc.
>
> It should look like this one
>
> before
> 2.2 ; 2.3; 2.26; 1.11
>
> after
> 2.0; 2.5; 2.5; 1.0


round(2*x)/2

Uwe Ligges

> thanks.
>
> Mat
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/round-2-3-to-2-5-and-2-2-to-2-0-tp4654813.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Mat
Reply | Threaded
Open this post in threaded view
|

Re: round 2.3 to 2.5 and 2.2 to 2.0

Mat
thx, works perfektly :-)