Hi list,

I've searched in R-help and found some related discussions but still could
not understand this type of error. My own function is pretty complex, so I
would not put it here, but the basic algorithm is like this:
myfun<-function(k){
  mydata<-...#by someway I create a data frame
  mymodel<-glm(y~.,family=binomial(),data=mydata)
  ...#some other stuff
}


as I execute this function, it gives error like this
Error in inherits(x, "data.frame") : object "mydata" not found

So I guess glm here tries to find "mydata" in the parent environment. Why
doesn't it take "mydata" inside the function? How to let glm correctly
locate it? Is this (scope/environment) mentioned in R manual? Thanks,

Mike

        [[alternative HTML version deleted]]

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to