Re: [R] function lm, get back the coefficient

2011-07-26 Thread Gavin Simpson
On Tue, 2011-07-26 at 13:42 -0700, Bert Gunter wrote: > Not quite, Gavin. You have to assign the value of unname back: Yes; thought that would be a given. The point was to give a simple example to show that `unname()` removes names/dimnames. G > > z <- structure(2, names="a") > > unname(z) > [1]

Re: [R] function lm, get back the coefficient

2011-07-26 Thread Bert Gunter
Not quite, Gavin. You have to assign the value of unname back: > z <- structure(2, names="a") > unname(z) [1] 2 > z a 2 > zz <- unname(z) > zz [1] 2 > names(z) <- NULL > z [1] 2 Cheers, Bert On Tue, Jul 26, 2011 at 1:18 PM, Gavin Simpson wrote: > On Tue, 2011-07-26 at 16:43 +0100, Barry Rowlin

Re: [R] function lm, get back the coefficient

2011-07-26 Thread Gavin Simpson
On Tue, 2011-07-26 at 16:43 +0100, Barry Rowlingson wrote: > On Tue, Jul 26, 2011 at 4:21 PM, ascoquel wrote: > > Hi, > > > > I've done a linear fit on my data and I would like to get back the a (time) > > coefficient ... > > > > mod<-lm(res_sql2$Lx0x~0+time) > > result<-data.frame() > > result<-c

Re: [R] function lm, get back the coefficient

2011-07-26 Thread ascoquel
It was result[[1]] I have no intercept Thanks !!! -- View this message in context: http://r.789695.n4.nabble.com/function-lm-get-back-the-coefficient-tp3696109p3696230.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-projec

Re: [R] function lm, get back the coefficient

2011-07-26 Thread Jeremy Miles
Will: result$coef[[2]] Give you want you want? Jeremy On 26 July 2011 08:21, ascoquel wrote: > Hi, > > I've done a linear fit on my data and I would like to get back the a (time) > coefficient ... > > mod<-lm(res_sql2$Lx0x~0+time) > result<-data.frame() > result<-coef(mod) > print("result")

Re: [R] function lm, get back the coefficient

2011-07-26 Thread Barry Rowlingson
On Tue, Jul 26, 2011 at 4:21 PM, ascoquel wrote: > Hi, > > I've done a linear fit on my data and I would like to get back the a (time) > coefficient ... > > mod<-lm(res_sql2$Lx0x~0+time) > result<-data.frame() > result<-coef(mod) > print("result") > print(result) > [1] "result" >      time > 0.025

[R] function lm, get back the coefficient

2011-07-26 Thread ascoquel
Hi, I've done a linear fit on my data and I would like to get back the a (time) coefficient ... mod<-lm(res_sql2$Lx0x~0+time) result<-data.frame() result<-coef(mod) print("result") print(result) [1] "result" time 0.02530191 But I would like just the value 0.02530191 ... I tried result$ti