[R] extracting the names of the dataframe and variables in aov or lm

John Miyamoto jmiyamot at u.washington.edu
Sun Mar 23 00:27:17 CET 2003


Dear R Users,
   I want to write a function that applies to the dataframe and variables
that were used in a previous call to lm or aov.  In order to do this, I
need to write a function that applies to the output of lm or aov, and
yields the names of the dataframe and variables that were used in the lm
or aov analysis.
   For example, suppose that I give the command:

aov.out <- aov( Rt ~ Vis*Cmplx*Isi, data = Rt.data)

I want to write a function E that applies to aov.out such that

E(aov.out) = c("Rd.data", "Rt", "Vis", "Cmplx", "Isi").

In other words, I want to write an extractor function that yields the
dataframe and variables that were used in a previous call to lm or aov.  I
realize that aov.out$call shows this information, but I don't know how to
automatically extract the names of the dataframe and variables from
aov.out$call.  The reason I am trying to extract these names is that I
want to write a general purpose function that displays descriptive
statistics and plots that are relevant to an aov or lm analysis.  If I
could extract these names from previous aov or lm output, I wouldn't have
to mention them individually as inputs to my function.

John Miyamoto

--------------------------------------------------------------------
John Miyamoto, Dept. of Psychology, Box 351525
University of Washington, Seattle, WA 98195-1525
Phone 206-543-0805, Fax 206-685-3157, Email jmiyamot at u.washington.edu
Homepage http://faculty.washington.edu/jmiyamot/
--------------------------------------------------------------------



More information about the R-help mailing list