[R] modifying colnames of tables in a loop

Werner Wernersen pensterfuzzer at yahoo.de
Thu Nov 16 16:06:19 CET 2006


That's almost perfect! Only the operation
 colnames(get(x)) <- 
seems not to be defined. 

Now I can't figure out how to assign the colnames of
the object in the original environment. 

Thanks, Benilton!

--- Benilton Carvalho <bcarvalh at jhsph.edu> schrieb:

> how about:
> 
> for (x in l) colnames(get(x)) <-
> lower.case(colnames(get(x)))
> 
> b
> 
> On Nov 16, 2006, at 9:01 AM, Werner Wernersen wrote:
> 
> > Hi,
> >
> > I have a list with the names of tables, e.g.
> > l <- c("t1","t2","t3")
> > and I want to change the colnames of each of the
> > tables in a for loop like this:
> > for (x in l) {
> >     colnames(eval(x)) <-
> lower.case(colnames(eval(x)))
> > }
> >
> > This does not work but could someone give me some
> help
> > to get on the right track?
> >
> > Thanks a million,
> >   Werner
> >
> > ______________________________________________
> > 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
> > and provide commented, minimal, self-contained,
> reproducible code.
>



More information about the R-help mailing list