Models, Next: Others, Previous: Lexical scoping, Up: What are the differences between R and S?
3.3.2 Models There are some differences in the modeling code, such as • Whereas in S, you would use lm(y ~ x^3) to regress y on x^3, in R, you have to insulate powers of numeric vectors (using I()), i.e., you have to use lm(y ~ I(x^3)). • The glm family objects are implemented differently in R and S. The same functionality is available but the components have different names. • Option na.action is set to “na.omit” by default in R, but not set in S. • Terms objects are stored differently. In S a terms object is an expression with attributes, in R it is a formula with attributes. The attributes have the same names but are mostly stored differently. The major difference in functionality is that a terms object is subscriptable in S but not in R. If you can’t imagine why this would matter then you don’t need to know. • Finally, in R y~x+0 is an alternative to y~x-1 for specifying a model with no intercept. Models with no parameters at all can be specified by y~0.