s-news
[Top] [All Lists]

Re: List of Frames

To: "Myers, Brent" <MyersDB@missouri.edu>, s-news@lists.biostat.wustl.edu
Subject: Re: List of Frames
From: Pete Meyer <pmeyer160@comcast.net>
Date: Mon, 28 Apr 2003 20:57:04 -0400
References: <7CC4280A9B5470499092940B3DDB5AD20823B9@COL-EMAIL3.col.missouri.edu>
Although you can make lists of lists, since frames are
large it probably makes more sense to have a list of
frame names from which to select.  When repeating
an analysis for each of a large number of data frames
with the same content, I list the names of the frames
and abstract the characteristic of interest each time
the analysis is repeated.  In the
following example, assume I am interested in the
coefficient vector when fitting the same model to a
number of datasets.
 
I am using an example from the "lm" documentation
page.
 
#Setup the model with an existing dataframe
mod.1 <- lm(Fuel ~ . , data = "">
 
#Check to see that the function you want
#works with the original data
coef(update(mod.1,data="">
 
#Setup some sample frames (random samples
#of 50 out of 60 rows in the original frame.
frm1 <- fuel.frame[sample(1:60,50),]
frm2 <- fuel.frame[sample(1:60,50),]
frm3 <- fuel.frame[sample(1:60,50),]
 
#Setup up the list of names
list.frameNames <- c('frm1','frm2','frm3')
 
#Use sapply to repeat the model for each dataframe.
betas <- sapply(list.frameNames, function(x,mod.1)
    coef(update(mod.1, data="" mod.1=mod.1)
 
#Assign names to the rows and columns
dimnames(betas) <- list(names(coef(update(mod.1,data="">
    list.frameNames)
 
The point is to use "data="" as a
means of accessing the appropriate data frame when you
need it.
 
Hope this helps.
 
Pete
 
----- Original Message -----
From: "Myers, Brent" <MyersDB@missouri.edu>
Sent: Monday, April 28, 2003 1:01 PM
Subject: [S] List of Frames

Good day to you,

Is it possible to put frames in a list?

D. Brent Myers
Research Specialist - Agronomy
University of Missouri
158 Ag Engineering Building
Columbia, MO 65211



--------------------------------------------------------------------
This message was distributed by
s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to
s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news
<Prev in Thread] Current Thread [Next in Thread>