This function is similar to tidyr::nest(), except that it retains
rows for unobserved combinations (and unobserved factor levels) of by
variables, and unobserved combinations of stratifying variables.
The levels are wrapped in lists so they can be stacked with other types
of different classes.