Dear all,
I have an array of strings
a <- c("2008q3","2005q1","2004q3")
I would like to add to each a[i], with i = 1,2,3
the following string "IMT",
such that in the end I could get
b <- c("IMT2008q3","IMT2005q1","IMT2004q3")
Is it possible to accomplish this without a loop command?
Thank you.
Best,
Borissssssssssssssss
--
Hi Boris,
Yes. Try this:
paste('IMT',a,sep="")
See ?paste.
HTH,
Jorge
On Wed, Dec 17, 2008 at 10:25 AM, Boriss <Boriss@gmx.net> wrote:
> Dear all,
>
> I have an array of strings
>
> a <- c("2008q3","2005q1","2004q3")
>
> I would like to add to each a[i], with i = 1,2,3
>
> the following string "IMT",
>
> such that in the end I could get
>
> b <-
c("IMT2008q3","IMT2005q1","IMT2004q3")
>
> Is it possible to accomplish this without a loop command?
>
> Thank you.
>
> Best,
>
> Borissssssssssssssss
> --
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
Your question has already been answered but as an aside note that the zoo package has a yearqtr class that can be helpful when dealing with quarterly dates. On Wed, Dec 17, 2008 at 10:25 AM, Boriss <Boriss at gmx.net> wrote:> Dear all, > > I have an array of strings > > a <- c("2008q3","2005q1","2004q3") > > I would like to add to each a[i], with i = 1,2,3 > > the following string "IMT", > > such that in the end I could get > > b <- c("IMT2008q3","IMT2005q1","IMT2004q3") > > Is it possible to accomplish this without a loop command? > > Thank you. > > Best, > > Borissssssssssssssss > -- > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >