[R] step error

From: vasilis pappas <vasileios_p_at_yahoo.gr>
Date: Sat 02 Apr 2005 - 05:29:29 EST


Could anyone tell me what am I doing wrong?

> pro<-function(indep,dep){

+  d<-data.frame(indep)
+  form<-formula(lm(dep~.,data=d))
+ 

forward<-step(lm(dep~X1,data=d),scope=form,trace=0,direction='f') + return(forward)
+ }
> pro(m,q)
Error in inherits(x, "data.frame") : Object "d" not found

Where q is a vector with the dependent variable's values
and m is a matrix containing the values of the independent variables.

While writing the above without a function form has no problem, that is :

> d<-data.frame(m)
> form<-formula(lm(q~.,data=d))
>
forward<-step(lm(q~X1,data=d),scope=form,trace=0,direction='f')
> forward

Call:
lm(formula = q ~ X1 + X2 + X5, data = d)

Coefficients:

(Intercept)           X1           X2           X5  
    -15.798        8.765        6.774       -4.245  


Thank you in advance!
Vasilis



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Apr 02 07:04:45 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:00 EST