And yet another way:
x <- as.character(101:199)
substr(x,1,1) <- "A"
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Marc Schwartz
> Sent: Friday, August 20, 2004 4:38 PM
> To: Peter Dalgaard
> Cc: R Help; sundar.dorai-raj at pdf.com
> Subject: Re: [R] How generate "A01", "A02", ...,
"A99"?
>
>
> On Fri, 2004-08-20 at 15:15, Peter Dalgaard wrote:
> > 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")
>
>
> or yet another variation:
>
> paste("A", formatC(1:99, width = 2, format = "d", flag
= "0"),
> sep = "")
>
>
> HTH,
>
> Marc Schwartz
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>