[R] Renaming variables

John Kane jrkrideau at inbox.com
Sat Sep 21 01:59:11 CEST 2013


Depending on what your doing perhaps with()  could help?
Or assuming a data.frame or matrix, score[ , 25] will give you Score$X25

If you would supply a bit more information (and code) about what you are doing we probably can help more.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: lordpreetam at gmail.com
> Sent: Fri, 20 Sep 2013 19:40:23 +0530
> To: r-help at r-project.org
> Subject: [R] Renaming variables
> 
> Hi,
> 
> I guess this is pretty basic.
> 
> I have 25 variables in the data file (name: score), i.e. X1,X2,.....,X25.
> 
> I dont want to use score$X1, score$X2 everytime I use these variables.
> 
> Is there a way I can rename all these variables as simply X1,X2,.....X25
>  without writing 25 lines of code, one line for renaming each variable
> (eg:
>  > X1=score.X1  >X2=score.X2  and so on) ?
> 
> Thanks for your help.
> 
> Regards,
> Preetam
> 
> --
> Preetam Pal
> (+91)-9432212774
> M-Stat 2nd Year,                                             Room No.
> N-114
> Statistics Division,                                           C.V.Raman
> Hall
> Indian Statistical Institute,                                 B.H.O.S.
> Kolkata.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.

____________________________________________________________
Receive Notifications of Incoming Messages
Easily monitor multiple email accounts & access them with a click.
Visit http://www.inbox.com/notifier and check it out!



More information about the R-help mailing list