define_grouping_property {CBASSED50}R Documentation

Define Grouping Property Column

Description

This function creates a new column 'GroupingProperty' in the provided dataset by merging specified columns using a specified separator. The new column is created as a factor variable.

Usage

define_grouping_property(dataset, grouping_properties, sep = "_")

Arguments

dataset

A data frame where the new 'GroupingProperty' column will be added.

grouping_properties

A character vector containing the names of the columns to be merged.

sep

A character string used as a separator when merging columns (default is "_").

Value

A data frame with the added 'GroupingProperty' column.

Examples

# Create a sample data frame
data <- data.frame(Category = c("A", "B", "C"),
                   Subcategory = c("X", "Y", "Z"),
                   Value = c(10, 20, 30))

# Define grouping property using 'Category' and 'Subcategory'
new_data <- define_grouping_property(data, c("Category", "Subcategory"), sep = "-")

# Resulting data frame:
#   Category Subcategory Value GroupingProperty
# 1        A           X    10              A-X
# 2        B           Y    20              B-Y
# 3        C           Z    30              C-Z

[Package CBASSED50 version 0.2.0 Index]