get_datagrid.emmGrid | R Documentation |
{emmeans}
and {marginaleffects}
Extract a reference grid from objects created by {emmeans}
and {marginaleffects}
## S3 method for class 'emmGrid'
get_datagrid(x, ...)
x |
An object created by a function such as |
... |
Currently not used |
Note that for {emmeans}
inputs the results is a proper grid (all
combinations of values are represented), except when a nesting structure is
detected. Additionally, when the input is an emm_list
object, the function
will rbind()
the data-grids of all the elements in the input.
For {marginaleffects}
inputs, the output may very well be a non-grid
result. See examples.
A data.frame
with key columns that identify the rows in x
.
data("mtcars")
mtcars$cyl <- factor(mtcars$cyl)
mod <- glm(am ~ cyl + hp + wt,
family = binomial("logit"),
data = mtcars
)
em1 <- emmeans::emmeans(mod, ~ cyl + hp, at = list(hp = c(100, 150)))
get_datagrid(em1)
contr1 <- emmeans::contrast(em1, method = "consec", by = "hp")
get_datagrid(contr1)
eml1 <- emmeans::emmeans(mod, pairwise ~ cyl | hp, at = list(hp = c(100, 150)))
get_datagrid(eml1) # not a "true" grid
mfx1 <- marginaleffects::slopes(mod, variables = "hp")
get_datagrid(mfx1) # not a "true" grid
mfx2 <- marginaleffects::slopes(mod, variables = c("hp", "wt"), by = "am")
get_datagrid(mfx2)
contr2 <- marginaleffects::avg_comparisons(mod)
get_datagrid(contr2) # not a "true" grid
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.