Hi,
How do I use a function inside a regression formula? When I tried to use
min() function inside a regression formula, I ran into errors. Here are
the commands to reproduce the error:
mydata <- read.csv(url("http://www.ats.ucla.edu/stat/r/dae/binary.csv"))
attach(mydata)
names(mydata)
mylm2 = lm(admit~gre+I(max(gpa,rank)))
*Error in model.frame.default(formula = admit ~ gre + I(max(gpa, rank)), :
variable lengths differ (found for 'I(min(gpa, rank))')*
*
*
*
*
Regards,
David
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.