[R] help with coef

2006-10-20 Thread tom soyer
Hi, I am trying to get R to return just the slope of a linear regression line, but it seems that R has to return both the slope and the name of the slope. For example, a=coef(lm(y~miles)) a (Intercept) miles 360.3778 -7.2875 names(a) [1] (Intercept) miles a[1] (Intercept)

Re: [R] help with coef

2006-10-20 Thread Gabor Grothendieck
Using the builtin BOD data frame: as.vector(coef(lm(demand ~ Time, BOD)))[2] On 10/21/06, tom soyer [EMAIL PROTECTED] wrote: Hi, I am trying to get R to return just the slope of a linear regression line, but it seems that R has to return both the slope and the name of the slope. For

Re: [R] help with coef

2006-10-20 Thread tom soyer
Gabor, Thanks for the code example, but it seems that BOD is not needed. I still don't understand what is going on with the data structure returned by coef(). The strangness is illustrated by the following example: a=coef(lm(y~miles)) is.vector(a) [1] TRUE a[2] miles -7.2875 a=as.vector(a)

Re: [R] help with coef

2006-10-20 Thread Gabor Grothendieck
On 10/21/06, tom soyer [EMAIL PROTECTED] wrote: Gabor, Thanks for the code example, but it seems that BOD is not needed. I still demand and Time are columns of BOD so if you omit it then it won't know where they are. don't understand what is going on with the data structure returned by

Re: [R] help with coef

2006-10-20 Thread Christos Hatzis
without setting its names attribute: as.vector(a) -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tom soyer Sent: Saturday, October 21, 2006 1:00 AM To: Gabor Grothendieck Cc: r-help Subject: Re: [R] help with coef Gabor, Thanks for the code

Re: [R] help with coef

2006-10-20 Thread Gabor Grothendieck
Also try this to look inside the objects: cc - coef(lm(demand ~ Time, BOD)) dput(cc) structure(c(8.52142857142858, 1.72142857142857), .Names = c((Intercept), Time)) cc2 - as.vector(cc) dput(cc2) c(8.52142857142858, 1.72142857142857) from which we see that the only difference in their

Re: [R] help with coef

2006-10-20 Thread tom soyer
PROTECTED] On Behalf Of tom soyer Sent: Saturday, October 21, 2006 1:00 AM To: Gabor Grothendieck Cc: r-help Subject: Re: [R] help with coef Gabor, Thanks for the code example, but it seems that BOD is not needed. I still don't understand what is going on with the data structure returned