relevelGroups.Rd
Sets the ordering of the groups in a grouping variable. Affects the order in which they appear in plots.
relevelGroups(object, grouping, new_levels, ...)
An object of class SPATA2
or, in case of S4 generics,
objects of classes for which a method has been defined.
Character value. The grouping variable of interest. Use
getGroupingOptions()
to obtain all valid input options.
Character vector of group names in the order in which the new ordering is supposed to be stored. Must contain all groups of the grouping variable.
Used to absorb deprecated arguments or functions.
The updated input object, containing the added, removed or computed results.
library(SPATA2)
library(patchwork)
data("example_data")
object <- example_data$object_UKF269T_diet
p_before <- plotSurface(object, color_by = "bayes_space")
plot(p_before)
getGroupNames(object, grouping = "bayes_space")
object <- relevelGroups(object, grouping = "bayes_space", new_levels = c("1", "2", "3", "7", "6", "5", "4"))
getGroupNames(object, grouping = "bayes_space")
p_afterwards <- plotSurface(object, color_by = "bayes_space")
# different levels -> different order -> different color assignment
p_before + p_afterwards