[R] taking variables from data.frame
MUGGEO VITO
vito.muggeo at giustizia.it
Fri Jan 4 13:22:35 CET 2002
Dear all,
Two of the arguments of my function fn(), say, are a glm-obj and a variable
in the data.frame where there are the variable of the obj too.
Is there a way to build a function that takes the variables form the same
data.frame? For instance, the update() function does so:
>obj<-glm(....,data=mydata)
>update(obj,.~.+x) #works becuse it searches x in mydata
But for my function:
>fn(....,obj, mydata$x) #it works
and
>fn(....,obj, x) #doesn't works: x not found!
Of course I can attach the data.frame in the function by something like:
fn<-function(....,data){
attach(data)
....
detach()
}
but is there anyone that can suggest me anything better?
Thank you very much for your help,
vito
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list