Skip to content

Instantly share code, notes, and snippets.

@tjmahr
Created April 15, 2024 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjmahr/ab3689d094192077153337fbd2dc95f6 to your computer and use it in GitHub Desktop.
Save tjmahr/ab3689d094192077153337fbd2dc95f6 to your computer and use it in GitHub Desktop.
update() is bad
data <- mtcars
m <- lm(mpg ~ wt, data)

data <- mtcars[-c(1:10), ]
m_update <- update(m, . ~ . + disp)

nobs(m)
#> [1] 32

nobs(m_update)
#> [1] 22

# but i didn't want to change the data. all i updated 
# was the formula

Created on 2024-04-15 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment