Learn R Programming

lsmeans (version 0.9)

empty.cells: Identify empty factor combinations

Description

This function exists primarily for use by lsmeans with check.cells=TRUE; however, it may be useful for assessing potential problems before fitting a model.

Usage

empty.cells(form, data)

Arguments

form
A model formula. Only the right-hand side is used.
data
A data.frame. Unlike in lm and related functions, it is not optional.

Value

  • A list. Each element is associated with a factor or combination of factors where empty cells were found, and contains a data.frame of the factor levels where they occur. If no empty cells are found, an empty list is returned.

Details

Empty cells are defined in the context of the model formula. For example, suppose that we have a factorial design if factors A and B, but there are no data on certain combinations of A and B. If we call empty.cells with the model ~ A*B or A + B + A:B, the empty cells will be identified. However, if we specify the additive model ~ A + B, no empty cells will be identified because this model can make valid predictions for all combinations of A and B.

See Also

lsmeans

Examples

Run this code
adesign = data.frame(
    A = LETTERS[c(1,1,1, 2,2, 3,3)],
    B = letters[c(1,2,3, 2,2, 2,3)])
empty.cells(~ A * B, adesign)   # missing combinations
empty.cells(~ A + B, adesign)   # empty list

Run the code above in your browser using DataLab