This gives you a data.frame with rows grouped based on the columns parameter and tell you how many unique values are in each group.

make_k_score(data, columns = NULL, quiet = FALSE, minimum_k_score = 3)

Arguments

data

The data.frame with the data you want to make the k score from.

columns

A string or vector of strings for the names of columns to group the data by.

quiet

A Boolean (default FALSE) for whether you want to output a message that tells you if there are groups with too few observations - you can set how many is 'too few' in the parameter minimum_k_score, default is 3.

minimum_k_score

A single integer which sets the number of observations in each group that will message (if quiet is FALSE) saying how many groups have fewer observations below that group.

Value

A data.frame

Examples

make_k_score(mtcars, columns = c("cyl", "vs", "am", "gear"))
#> Note: There are 9 groups with 3 or fewer observations.
#> cyl vs am gear number_of_observations #> 1 4 0 1 5 1 #> 2 4 1 0 3 1 #> 3 4 1 1 5 1 #> 4 6 0 1 5 1 #> 5 4 1 0 4 2 #> 6 6 0 1 4 2 #> 7 6 1 0 3 2 #> 8 6 1 0 4 2 #> 9 8 0 1 5 2 #> 10 4 1 1 4 6 #> 11 8 0 0 3 12