Displaying 1 result from an estimated 1 matches for "model_it".
Did you mean:
model_id
2008 Dec 01
1
Coercing a list of variables in a function call
...l work through the variables in
the data frame and coerce them into being factors.
This is what I tried ...
# Fictitious data for illustration
y<-c(1,2.1,3.3,4.3,5,6.5)
x1<-c(1,1,1,2,2,2)
x2<-c(1,2,3,1,2,3)
x3<-c(1,3,2,4,2,4)
d<-as.data.frame(cbind(y,x1,x2,x3))
#Function definition
model_it=function(data=" ", model=" ", factors=list()){
attach(d) #Attach the data
formula<-as.formula(model) #Set up the model
#Identify the factors
if (length(factors)>0) for(i in 1:length(factors)){
factors[i]<-as....