Skip to content
Prev 306521 / 398506 Next

Running different Regressions using for loops

Ok...this solves a part of my problem

When I type   " lm.list2[2] " ...I get the following output

[[1]]

Call:
lm(formula = as.formula(fmla), data = tryout2)

Coefficients:
(Intercept)       Price2       Media1      Distri1        Trend
Seasonality
   13491232     -5759030        -1520        34370        48628
445351




When I enter   " lm.list2[[2]]$coefficient[2] " it gives me the below
output

Price2
-5759030

And when I enter   " lm.list2[[2]]$coefficient[[2]] " ...I get the
number...which is   -5759030


I am looking out for a way to get just the  " Price2 "....is there a
statement for that??



Thanks & Regards,

Krunal Nanavati
9769-919198


-----Original Message-----
From: Rui Barradas [mailto:ruipbarradas at sapo.pt]
Sent: 28 September 2012 15:18
To: Krunal Nanavati
Cc: David Winsemius; r-help at r-project.org
Subject: Re: [R] Running different Regressions using for loops

Hello,

To access list elements you need `[[`, like this:

summ.list[[2]]$coefficients

Or Use the extractor function,

coef(summ.list[[2]])

Rui Barradas
Em 28-09-2012 07:23, Krunal Nanavati escreveu:
"summ.list
all
analysis.
"for"