[R] formula

Luis Torgo ltorgo at liacc.up.pt
Thu Jul 15 18:04:57 CEST 2004


On Thu, 2004-07-15 at 16:28, solares at unsl.edu.ar wrote:
> Hi, i 'dont understand how to take a general formula, view this:
> 
> x<-1:5
> y<-c(0,1,1.7,2,2.1.4)
>  dummy<-data.frame(x=x,y=y)
> formula<-"y~A*log(x)/log(2)"
> formu<-as.formula(formula)
> fm<-lm(formu,data=dummy)

You probably meant something similar to this:
> lm(as.formula("y ~ log(x)"),dummy)
 
Call:
lm(formula = as.formula("y ~log(x)"), data = dummy)
 
Coefficients:
(Intercept)       log(x)
     0.0473       1.3793

And your "A" in this case would be 1.3793

Luis Torgo

-- 
Luis Torgo
  FEP/LIACC, University of Porto   Phone : (+351) 22 607 88 30
  Machine Learning Group           Fax   : (+351) 22 600 36 54
  R. Campo Alegre, 823             email : ltorgo at liacc.up.pt
  4150 PORTO   -  PORTUGAL         WWW   : http://www.liacc.up.pt/~ltorgo




More information about the R-help mailing list