complete_levels: Create a data.frame with all factor or character levels

View source: R/complete_levels.R

complete_levelsR Documentation

Create a data.frame with all factor or character levels

Description

model.matrix and get_predicted break when newdata includes a factor variable, but not all levels are present in the data. This is bad for us because we often want to get predictions with one (or few) rows, where some factor levels are inevitably missing.

Usage

complete_levels(x, character_levels = NULL)

marginaleffects documentation built on Nov. 24, 2022, 1:06 a.m.