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 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 advance,
> > 
> > Dimitri
> >     [[alternative HTML version deleted]]
> 
> Try:
> 
> X <- c(11999, 122000, 81997)
> Y <- X %/% 10000
> Z <- X - Y * 10000
> 

Or even

> X %% 10000
[1] 1999 2000 1997

Regards,
 John

> See ?Arithmetic for more details.
> 
> HTH,
> 
> --sundar
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to