| dscore | R Documentation |
This function computes the mean number of unique values minus one for each specified variable within each group specified by the group_var. It is designed to provide insights into the variability of each variable while adjusting for the minimum possible unique count.
dscore(data, group_var, variables)
data |
A dataframe containing the data to be analyzed. |
group_var |
A character string specifying the column name used for grouping the data. |
variables |
A character vector of column names in 'data' for which the mean number of unique values minus one is calculated. |
A tibble with each specified variable showing the mean of (unique values - 1) for each group. The data is grouped by the 'group_var' and returns the results in a wide format, where each variable is prefixed with "dscore_" to indicate the calculation.
df <- data.frame(
group = c("A", "A", "B", "B", "B"),
age = c(25, 25, 30, 35, 30),
gender = c("Male", "Male", "Female", "Female", "Female"),
income = c(50000, 50000, 60000, 65000, 60000)
)
result <- dscore(df, "group", c("age", "gender", "income"))
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.