Merge groups into one group.

mergeGroups(object, grouping, grouping_new, merge, new_group, verbose = NULL)

Arguments

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

grouping

Character value. The grouping variable whose groups are supposed to be merged.

grouping_new

Character value or NULL. If character, the results are stored in a new variable named accordingly. If NULL, the grouping variable is updated - DEA results will be discarded.

merge

Character vector or NULL. If character, specifies the groups that are merged together.

new_group

Character value. The new group name of the merge.

verbose

Logical. If TRUE, informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

Details

Only one argument of keep or merge must be specified. If grouping_new is NULL DEA results of the specified grouping variable is resetted.

Examples


library(SPATA2)
library(tidyverse)

object <- loadExampleObject("UKF275T", meta = TRUE)

object <-
  mergeGroups(
    object = object,
    grouping = "bayes_space",
    grouping_new = "bayes_space_merged",
    merge = c("B1", "B6"),
    new_group = "B1B6_merged"
   )

plotSurface(object, color_by = "bayes_space")
plotSurface(object, color_by = "bayes_space_merged")