What is the difference between lm(offense$R ~ offense$OBP) and lm(R ~ OBP)?

前端 未结 2 1867
青春惊慌失措
青春惊慌失措 2020-12-20 20:23

I am trying to use R to create a linear model and use that to predict some values. The subject matter is baseball stats. If I do this:

obp <- lm(offense         


        
2条回答
  •  自闭症患者
    2020-12-20 21:02

    There is no difference---you get the same coefficients.

    But some programming styles are better than others -- and attach is to be avoided, as is the more verbose first form.

    Most experienced users do

     lm(R ~ OBP, offense)
    

    instead.

提交回复
热议问题