Re: [R] regession code

2013-11-05 Thread Rui Barradas
Hello, You are trying to get the coefficients of the function, nt of that function's result. Also, your function returns nothing. Try instead fn <- function(x,y){ lreg <- lm(y ~ x) lreg } fit <- fn(x,y) b <- coef(fit) b Hope this helps, Rui Barradas Em 05-11-2013 10:56, IZ

[R] regession code

2013-11-05 Thread IZHAK shabsogh
> y <- c(5.5199668,  1.5234525,  3.3557000,  6.7211704,  7.4237955,  1.9703127, +    4.3939336, -1.4380091,  3.2650180,  3.5760906,  0.2947972,  1.0569417) > x <- c(1,   0,   0,   4,   3,   5,  12,  10,  12, 100, 100, 100) > > fn<-function(x,y){ + lreg<-lm(y ~ x) + } > fn(x,y) > > b<-coef(fn)