Re: [R] How to change ONLY the first character of each variable name

2009-06-19 Thread Wacek Kusnierczyk
Henrique Dallazuanna wrote: Try this: gsub("^M{1}", "MOLE", names(data)) {1} is inessential here. vQ On Thu, Jun 18, 2009 at 8:24 PM, Mark Na wrote: Dear R-helpers, I would like to adapt the following code names(data)<-sub("M","MOLE",names(data)) which changes any o

Re: [R] How to change ONLY the first character of each variable name

2009-06-18 Thread Henrique Dallazuanna
Try this: gsub("^M{1}", "MOLE", names(data)) On Thu, Jun 18, 2009 at 8:24 PM, Mark Na wrote: > Dear R-helpers, > > I would like to adapt the following code > > > names(data)<-sub("M","MOLE",names(data)) > > which changes any occurrence of "M" (in my variable names) to "MOLE" > > such that it ON

[R] How to change ONLY the first character of each variable name

2009-06-18 Thread Mark Na
Dear R-helpers, I would like to adapt the following code > names(data)<-sub("M","MOLE",names(data)) which changes any occurrence of "M" (in my variable names) to "MOLE" such that it ONLY operates on the first character of each variable name, i.e. M will only be changed to MOLE if it's the first