This function checks if a variable is complete within another variable. If all levels of the first variable appear in all levels of the second variable, it returns TRUE; otherwise, it returns FALSE. The function can also handle NA values based on the na.rm parameter.
Examples
df <- data.frame(
site = c("A", "A", "B", "B"),
plot1 = c("A1", "A2", "B1", "B2"),
plot2 = c("A1", "A2", "A1", "A2")
)
is_complete(df$plot1, df$site) # FALSE
#> [1] FALSE
is_complete(df$plot2, df$site) # TRUE
#> [1] TRUE