Thank you, Bert and Peter, for helpful responses. I'm having a little trouble
with Bert's approach because writing the lapply function is challenging when
I'm drawing from two dataframes. Peter's approach works perfectly, although it
has less "R" personality. Wrapping the model statement in
... or let R do all the setup:
lmModels <- lapply(seq_len(nrow(dat2)) , FUN = etc. ## the last result
is returned as the list component
I never declare lists and use for() loops to fill them any more.
-- Bert
On Thu, Nov 1, 2012 at 2:51 PM, Peter Alspach
wrote:
> Tena koe Toby
>
> Try creating
Tena koe Toby
Try creating a list and storing each model as an element of the list. For
example,
lmModels <- vector('list', nrow(dat2))
for (i in 1:nrow(dat2))
{
lmModels[[i]] <- etc
}
Generally, I add a line after creating the list to name the elements and then
address the list using these
On Nov 1, 2012, at 2:16 PM, nrm2010 wrote:
>
>
> Dear helpeRs-
>
> I'm using a for loop to create a series of models.
> I'm trying to assign a name to each model created,
> using the loop index. The loop gets stuck at the name
> of the model, giving the error "target of assignment
> expan
4 matches
Mail list logo