[R] How to create a mixed col.names?

Jonas Malmros jonas.malmros at gmail.com
Mon Dec 17 19:48:40 CET 2007


Thanks Gabor!

On Dec 17, 2007 3:22 PM, Gabor Csardi <csardi at rmki.kfki.hu> wrote:
> paste(rep(c("Factor", "Sign Factor"), 5), rep(1:5, each=2))
>
> Replace '5' with the desired number,
> Gabor
>
>
> On Mon, Dec 17, 2007 at 03:08:09PM +0100, Jonas Malmros wrote:
> > Hello,
> >
> > I have a vector of names, say :
> >
> > names <- c("Factor 1", "Factor 2", Factor 3")
> >
> > I am creating a dataframe and I want the column names to be mixed like this:
> > "Factor 1" " Sign Factor 1" "Factor 2" "Sign Factor 2" "Factor 3"
> > "Sign Factor 3"
> > How can I automate the creation of such a mixed vector? I tried with
> > rep but did not succeed.
> >
> > Could someone please suggest a solution to this problem?
> > Thanks in advance!
> >
> > Regards,
> > JM
> > --
> > Jonas Malmros
> > Stockholm University
> > Stockholm, Sweden
> >
> > ______________________________________________
> > 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.
>
> --
> Csardi Gabor <csardi at rmki.kfki.hu>    MTA RMKI, ELTE TTK
>



-- 
Jonas Malmros
Stockholm University
Stockholm, Sweden



More information about the R-help mailing list