relevelGroups | R Documentation |
Sets the ordering of the groups in a grouping variable. Affects the order in which they appear in plots.
relevelGroups(object, grouping, new_levels, ...)
object |
An object of class |
grouping |
Character value. The grouping variable of interest. Use
|
new_levels |
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.