Re: [R] decimal number format as quarter

2012-02-08 Thread Petr Savicky
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 t

Re: [R] decimal number format as quarter

2012-02-08 Thread Arnaud Gaboury
] 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)

Re: [R] decimal number format as quarter

2012-02-08 Thread Gabor Grothendieck
On Wed, 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

Re: [R] decimal number format as quarter

2012-02-08 Thread peter dalgaard
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 an

Re: [R] decimal number format as quarter

2012-02-08 Thread Arnaud Gaboury
- 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

Re: [R] decimal number format as quarter

2012-02-08 Thread jim holtman
Message- > From: jim holtman [mailto:jholt...@gmail.com] > Sent: mercredi 8 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

Re: [R] decimal number format as quarter

2012-02-08 Thread David Reiner
-Original 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 tryin

Re: [R] decimal number format as quarter

2012-02-08 Thread David Winsemius
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 a

Re: [R] decimal number format as quarter

2012-02-08 Thread Arnaud Gaboury
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

Re: [R] decimal number format as quarter

2012-02-08 Thread jim holtman
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 +

[R] decimal number format as quarter

2012-02-08 Thread Arnaud Gaboury
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. A