[R] decimal number format as quarter
David Winsemius
dwinsemius at comcast.net
Wed Feb 8 15:45:22 CET 2012
On Feb 8, 2012, at 9:12 AM, Arnaud Gaboury wrote:
> Hello,
>
> I have to deal with numbers with a decimal part as quarter, coming
> from two systems with different way to show decimals. I need to tell
> R these are in fact the same number.
>
> On one side my number are formatted this way : 2.2 , 2.4 and 2.6. On
> the other side, I have 2.25, 2.50 and 2.75.
> All numbers are in fact 2.1/4, 2.1/2, 2.3/4.
>
> How can I tell R 2.2 is 2.25, 2.4 is 2.50 and 2.6 is 2.75 ?
vec <- c( 2.2 , 2.4 , 2.6)
trunc(vec) + (vec-trunc(vec))*(2.5/2)
[1] 2.25 2.50 2.75
>
> TY for any help.
>
> Arnaud Gaboury
>
> A2CT2 Ltd.
>
> ______________________________________________
> R-help at r-project.org 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list