On Dec 3, 2012, at 9:47 AM, Audrey wrote:
Ok, it seems that the function to get generic field names is get()
Er, not really.
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"]]. Read:
?"["
If you had a numeric object, 'ind' then
dat[ind] would retrieve a sub-list, with as many columns as there were
items in 'ind' and would have class data.frame.
If `ind` is numeric with one element only, then
dat[[ind]] <- tolower( as.character (dat[[ind]] ) ) # should succeed
at least to the extent of returning a vector of a different class ...
if what were what you wanted as to change .
It would have been faster to change just the levels attributes for
factor columns if you were willing to retain the class of that column
as a factor.
levels(dat[[1]])<- toupper( levels(dat[[1]] )
--
David Winsemius, MD
Alameda, CA, USA
______________________________________________
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.