[R] Returning the name of an object passed directly or from a list by lapply
ahoerner at rprogress.org
Fri Sep 16 02:36:22 CEST 2011
You are correct. I did not understand what was inmy list.
I posted a simplified example in the hope of focusing on the essentials, but
I see I have edited out the motivation. When my programs go awry, and
sometimes when they don't, I find I need to understand what is in some
variable or variables. To help with debugging, I have built a little
testing function that takes the names of one or more variables and returns a
variety of information about each one: summary(), str(), class(), type(),
etc., starting with the name. (The name is unimportant when I hand it one
variable, but for a longer list, I want to print it to help keep track of
what outcome goes with what variable). It also gives me some extra
information about certain data types that I seem to have more trouble with,
notably factors. These days I’m devoting myself nearly full-time to trying
to learn R, and I probably run this function between 50 and 200 times a day.
Now I am trying to figure out some way of running my testing function on
more than one variable at a time. Should be easy on a computer, right? I
don't care if I cluster my variables is a list, vector, or what -- I just
want to be able to evaluate a bunch of them at one time. And I'd rather not
have to type quotation marks around each variable name. I've timed myself,
and it increases the time it takes me to type a list by 250%. Shortly I'll
be posting a different question with regards to my failure to get this
function to work in a loop. But I also very much want to be able to use one
of the apply-family functions to run on multiple variables.
If, as you have persuaded me, I can not use a list of variable names, this
larger problem still has to have a straightforward solution, I think. But I
sure don't know what it is.
Any suggestions from any quarter would be deeply appreciated.
View this message in context: http://r.789695.n4.nabble.com/Returning-the-name-of-an-object-passed-directly-or-from-a-list-by-lapply-tp3816798p3817116.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help