Automatically Create Model Formula in R


R Data Science: R Programming A-Z: R For Data Science With Real Exercises!

The following method creates model formula in an automated fashion.
names(mydata) <- make.names(names(mydata))
y <- "Class"
x <- names(mydata)[!names(mydata) %in% y]
mymodel <- as.formula(paste(y, paste(x, collapse="+"), sep="~"))
lm(mymodel, data=mydata)
Coursera Data Science

R Tutorials : 75 Free R Tutorials

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

0 Response to "Automatically Create Model Formula in R"

Post a Comment

Next → ← Prev