Learn R Programming

ecr (version 2.1.1)

addUnionGroup: Grouping helpers

Description

Consider a data frame with results of multi-objective stochastic optimizers on a set of problems from different categories/groups (say indicated by column “group”). Occasionally, it is useful to unite the results of several groups into a meta-group. The function addUnionGroup aids in generation of such a meta-group while function addAllGroup is a wrapper around the former which generates a union of all groups.

Usage

addUnionGroup(df, col, group, values)

addAllGroup(df, col, group = "all")

Value

[data.frame] Modified data frame.

Arguments

df

[data.frame]
Data frame.

col

[character(1)]
Column name of group-column.

group

[character(1)]
Name for new group.

values

[character(1)]
Subset of values within the value range of column col.

Examples

Run this code
df = data.frame(
  group = c("A1", "A1", "A2", "A2", "B"),
  perf = runif(5),
  stringsAsFactors = FALSE)

df2 = addUnionGroup(df, col = "group", group = "A", values = c("A1", "A2"))
df3 = addAllGroup(df, col = "group", group = "ALL")

Run the code above in your browser using DataLab