Grab a matrix of fixed effects from a model object
grab_design_matrix(data, rhs_formula, ...)
the data from which to extract the matrix
the right hand side of a model formula
Can be used to pass xlev
to model.frame
# Create a "desigm" matrix for the first ten rows of iris data
fit <- lm(Sepal.Width ~ Petal.Width, data = iris)
grab_design_matrix(
data = iris[1:10, ],
grab_fixed_formula(fit))
#> (Intercept) Petal.Width
#> 1 1 0.2
#> 2 1 0.2
#> 3 1 0.2
#> 4 1 0.2
#> 5 1 0.2
#> 6 1 0.4
#> 7 1 0.3
#> 8 1 0.2
#> 9 1 0.2
#> 10 1 0.1
#> attr(,"assign")
#> [1] 0 1