> res=names(dat);
> get(res[ind],pos=dat) will retrieve dat$name

There are far less baroque was of doing that (including dat$name and  
dat[["name"]].

Both dat$name and dat[["name"]] require you to know what "name" is. I was
looking for a way to retrieve a data frame column by name without actually
knowing what the data frame column name was. get() seems to do that, but I
am open to other options. 

Thank you for your advice regarding [ vs. [[. Indeed, lower(dat[[ind]]) does
return the desired result. However, it seems that ind can only be a single
integer (or evaluate to TRUE for only 1 column), I guess because "[[" is
returning a vector. 

By "text" I mean anything that was non-numerical: character and factor
classes, in my case. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Change-case-of-factor-in-data-frame-tp4651696p4651971.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to