is_balanced | R Documentation |
Check if the data frame is balanced by group of columns, i.e., if it contains every combination of the elements in the specified variables
is_balanced(df, by, return = c("logic", "table"))
df |
data frame |
by |
character: variables used to check if |
return |
character: either "logic" or "table". If "logic", returns |
logical, if return == "logic", else returns data frame of unbalanced observations
x1 = data.frame(id = c(1L, 1L, 2L, 3L, NA_integer_),
t = c(1L, 2L, 1L, 2L, NA_integer_),
x = 11:15)
is_balanced(df = x1,
by = c("id", "t"),
return = "table") # returns combination of elements in "id" and "t" not present in df
is_balanced(df = x1,
by = c("id", "t"),
return = "logic") # FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.