Learn R Programming

stratifiedyh (version 0.1.0)

stratified_custom_labels: Stratify and Assign Custom Labels to Data

Description

This function stratifies data based on a specified grouping column and assigns custom labels according to a given percentage.

Usage

stratified_custom_labels(df, group_col, label_percentage, label1, label2)

Value

A data frame with an additional column "Custom_Labels" containing the stratified custom labels.

Arguments

df

A data frame to be stratified.

group_col

A character string specifying the column name to group by.

label_percentage

A numeric value between 0 and 100 indicating the percentage of the first label to assign within each group.

label1

A character string representing the first label.

label2

A character string representing the second label.

Examples

Run this code
result <- stratified_custom_labels(iris, group_col = "Species",
                                   label_percentage = 50,
                                   label1 = "High", label2 = "Low")

Run the code above in your browser using DataLab