This function takes a data frame and a model equation as input, and returns a boolean vector indicating which rows of the data frame have complete cases for the variables specified in the equation.

complete_cases_from_equation(df, equation)

Arguments

df

A data frame containing the variables specified in the equation.

equation

A model equation specifying the variables of interest.

Value

A boolean vector indicating which rows of the data frame have complete cases.

Examples

df <- data.frame(
  x = c(1, 2, NA, 4),
  y = c(NA, 2, 3, 4),
  z = c(1, 2, 3, NA)
)
equation <- y ~ x + z
complete_index <- complete_cases_from_equation(df, equation)
print(complete_index)  # Output: FALSE TRUE FALSE FALSE
#> [1] FALSE  TRUE FALSE FALSE