[R] How generate "A01", "A02", ..., "A99"?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Aug 20 22:15:47 CEST 2004


Sundar Dorai-Raj <sundar.dorai-raj at pdf.com> writes:

> Yao, Minghua wrote:
> 
> > Hi,
> >  Anyone can tell me how to generate "A01", "A02", ..., "A99"?
> >  paste("A", 1:99, sep="") generates "A1", "A2",..., "A99". This is
> > not  what I want.
> >  Thanks for the help.
> >  -MY
> > 	[[alternative HTML version deleted]]
> >
> 
> How about?
> 
> sapply(1:99, function(i) sprintf("A%02d", i))

or just 

sapply(1:99,sprintf,fmt="A%02d")

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list