Skip to contents

For each pair of consecutive models starting from the first one, this function will rearrange segment labels for the second model in the pair such that the number of respondents whose segment index number does not change is as big as possible. Plainly speaking, if segment i in model 1 is largely equivalent to segment j in model 2, this function will relocate the j-th segment of the second model to the i-th position. Please note that this function is already integrated into the seg_rack_nmf function, and therefore there is no need to apply it separately to the output of seg_rack_nmf.

Usage

rack_align_segments(rack, recode_to_sequential = FALSE)

Arguments

rack

A model rack.

recode_to_sequential

Should segment names be converted to sequential natural numbers after alignment? The default behavior of this function is to reorder segments while keeping their original names. If segment names do not have any meaningful information, use this option to recode them into sequentially ordered natural numbers for ease of use.

Examples

# by default segments are aligned between each two consecutive models
# drop the second model to break the alignment
smaller_rack <- example_seg_rack[-2,]
rack_segment_alluvial_plot(smaller_rack)


smaller_rack_aligned <- 
  rack_align_segments(smaller_rack, recode_to_sequential = TRUE)
rack_segment_alluvial_plot(smaller_rack_aligned)