Use variables from formula in R function -
i'd write function of type myfunction(y,data)
, y
being column name of data
. have idea on how code in order able use formula myfunction(y~,data=mydata)
when calling it?
also, how can use someything of form data$y
within function?
maybe should take @ model.frame
:
model.frame(formula= z~y,data=data.frame(y=1:3,x=1:3,z=1:3)) z y 1 1 1 2 2 2 3 3 3
the result data.frame containing variables used in formula.
Comments
Post a Comment