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.
will this do it for you:
x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6)
# get integer part
x.i - as.integer(x)
# get fractional part
x.f - (x * 10) %% 10
# new result
result - x.i + ifelse(x.f == 2
+ , .25
+ , ifelse(x.f == 4
+ , .5
+
Subject: Re: [R] decimal number format as quarter
will this do it for you:
x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6)
# get integer part
x.i - as.integer(x)
# get fractional part
x.f - (x * 10) %% 10
# new result
result - x.i + ifelse(x.f == 2
+ , .25
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
Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Arnaud Gaboury
Sent: Wednesday, February 08, 2012 8:45 AM
To: jim holtman
Cc: r-help@r-project.org
Subject: Re: [R] decimal number format as quarter
TY Jim,
It do the trick.
I was trying to play without
février 2012 15:36
To: Arnaud Gaboury
Cc: r-help@r-project.org
Subject: Re: [R] decimal number format as quarter
will this do it for you:
x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6)
# get integer part
x.i - as.integer(x)
# get fractional part
x.f - (x * 10) %% 10
# new result
result - x.i
-
From: David Reiner [mailto:david.rei...@xrtrading.com]
Sent: mercredi 8 février 2012 15:48
To: Arnaud Gaboury; jim holtman
Cc: r-help@r-project.org
Subject: RE: [R] decimal number format as quarter
Looks like something priced in eighths; we deal with similar notation for bonds
and similar
On Feb 8, 2012, at 15:48 , David Reiner wrote:
Looks like something priced in eighths; we deal with similar notation for
bonds and similar instruments.
x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6)
as.integer(x)+10*(x-as.integer(x))/8
[1] 2.25 2.50 2.75 3.25 3.50 3.75
Adjust the 10 and 8 if you
On Wed, Feb 8, 2012 at 9:12 AM, Arnaud Gaboury arnaud.gabo...@a2ct2.com 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
] decimal number format as quarter
On Feb 8, 2012, at 15:48 , David Reiner wrote:
Looks like something priced in eighths; we deal with similar notation for
bonds and similar instruments.
x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6)
as.integer(x)+10*(x-as.integer(x))/8
[1] 2.25 2.50 2.75 3.25 3.50
On Wed, Feb 08, 2012 at 03:12:56PM +0100, 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
11 matches
Mail list logo