powered by
This function stratifies data based on a specified grouping column and assigns custom labels according to a given percentage.
stratified_custom_labels(df, group_col, label_percentage, label1, label2)
A data frame with an additional column "Custom_Labels" containing the stratified custom labels.
A data frame to be stratified.
A character string specifying the column name to group by.
A numeric value between 0 and 100 indicating the percentage of the first label to assign within each group.
A character string representing the first label.
A character string representing the second label.
result <- stratified_custom_labels(iris, group_col = "Species", label_percentage = 50, label1 = "High", label2 = "Low")
Run the code above in your browser using DataLab