[R] spliting an integer

2005-10-20 Thread Dimitri Szerman
Hi there, From the vector X of integers, X = c(11999, 122000, 81997) I would like to make these two vectors: Z= c(1999, 2000, 1997) Y =c(1 , 12 , 8) That is, each entry of vector Z receives the four last digits of each entry of X, and Y receives the rest. Any suggestions? Thanks in

Re: [R] spliting an integer

2005-10-20 Thread Anne Hertel
Hi Dimitri, You could write z - trunc(x/1) z [1] 1 12 8 y - x-trunc(x/1)*1 y [1] 1999 2000 1997 And there you have it. Cheers, Anne Hertel On Thu, 20 Oct 2005 17:40:10 -0200 Dimitri Szerman [EMAIL PROTECTED] wrote: Hi there, From the vector X of integers, X = c(11999,

Re: [R] spliting an integer

2005-10-20 Thread Sundar Dorai-Raj
Dimitri Szerman wrote: Hi there, From the vector X of integers, X = c(11999, 122000, 81997) I would like to make these two vectors: Z= c(1999, 2000, 1997) Y =c(1 , 12 , 8) That is, each entry of vector Z receives the four last digits of each entry of X, and Y receives the rest.

Re: [R] spliting an integer

2005-10-20 Thread Gabor Grothendieck
On 10/20/05, Dimitri Szerman [EMAIL PROTECTED] wrote: Hi there, From the vector X of integers, X = c(11999, 122000, 81997) I would like to make these two vectors: Z= c(1999, 2000, 1997) Y =c(1 , 12 , 8) That is, each entry of vector Z receives the four last digits of each entry of X,

Re: [R] spliting an integer

2005-10-20 Thread Berton Gunter
PROTECTED] On Behalf Of Dimitri Szerman Sent: Thursday, October 20, 2005 12:40 PM To: R-Help Subject: [R] spliting an integer Hi there, From the vector X of integers, X = c(11999, 122000, 81997) I would like to make these two vectors: Z= c(1999, 2000, 1997) Y =c(1 , 12 , 8

Re: [R] spliting an integer

2005-10-20 Thread Peter Dalgaard
Anne Hertel [EMAIL PROTECTED] writes: Hi Dimitri, You could write z - trunc(x/1) z [1] 1 12 8 y - x-trunc(x/1)*1 y [1] 1999 2000 1997 And there you have it. Er, we do have integer divide and remainder operators: X = c(11999, 122000, 81997) X %% 1e4 [1] 1999

Re: [R] spliting an integer

2005-10-20 Thread John Fox
Dear Sundar and Dimitri, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sundar Dorai-Raj Sent: Thursday, October 20, 2005 3:50 PM To: Dimitri Szerman Cc: R-Help Subject: Re: [R] spliting an integer Dimitri Szerman wrote: Hi