Displaying 2 results from an estimated 2 matches for "plotwithlin".
Did you mean:
plotwithline
2018 Dec 17
0
Documentation examples for lm and glm
...tuechler at gmx.at> wrote:
>
> Dear All,
>
> do you think that use of a data argument is best practice in the example below?
No, but it is *normally* or *usually* the best option, in my opinion.
Best,
John
>
> regards,
>
> Heinz
>
> ### trivial example
> plotwithline <- function(x, y) {
> plot(x, y)
> abline(lm(y~x)) ## data argument?
> }
>
> set.seed(25)
> df0 <- data.frame(x=rnorm(20), y=rnorm(20))
>
> plotwithline(df0[['x']], df0[['y']])
>
>
>
> Fox, John wrote/hat geschrieben on/am 17.12....
2018 Dec 14
7
Documentation examples for lm and glm
FWIW, before all the examples are changed to data frame variants, I think there's fairly good reason to have at least _one_ example that does _not_ place variables in a data frame.
The data argument in lm() is optional. And there is more than one way to manage data in a project. I personally don't much like lots of stray variables lurking about, but if those are the only variables out