On Dec 3, 2012, at 3:34 PM, Audrey wrote:
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.
And I gave you some, but you failed to include context, an annoying
habit of Nabble users. (In my opinion the Nabble interface is more
hassle than it is worth.) For instance, I wrote:
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.
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
That was what I wrote I believe.
(or evaluate to TRUE for only 1 column),
In some instances TRUE is coerced to 1.
I guess because "[[" is returning a vector.
No. You have failed to understand that "[[" can only return a single
referenced object. It might be a vector or a list, but you cannot give
it a vector with more than one element and expect satisfactory results.
By "text" I mean anything that was non-numerical: character and factor
classes, in my case.
Then you should be clear. "text" is not a well defined term when
referring to R objects.
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.
No. This borders on actionable fraud. R-help is not Nabble. Do not
believe what Nabble is saying. Do read the Rhelp Posting Guide.
--
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.