Skip to contents

Reorder rows based on the active metadata component. When rows are active, arranges by row_data and reorders matrix rows accordingly. When columns are active, arranges by col_data and reorders matrix columns accordingly. Cannot arrange when matrix is active.

Usage

# S3 method for class 'tidymatrix'
arrange(.data, ...)

Arguments

.data

A tidymatrix object

...

Variables to arrange by

Value

A tidymatrix object with reordered data

Details

Reordering invalidates any stored analyses (see get_analysis), since objects such as hclust and prcomp refer to the original row/column positions.

Examples

library(dplyr, warn.conflicts = FALSE)
tm <- tidymatrix(big5_responses, big5_respondents, big5_items)

# Order items by trait; the matrix columns are reordered to match
tm |>
  activate(columns) |>
  arrange(trait, position)
#> # A tidymatrix: 400 x 30 matrix
#> # Active: columns
#> #
#> # Row data: 400 rows x 8 columns
#> # Column data: 30 rows x 5 columns
#> #
#> # Active data (columns):
#>   item_id         trait reversed
#> 1      A1 Agreeableness    FALSE
#> 2      A2 Agreeableness    FALSE
#> 3      A3 Agreeableness    FALSE
#> 4      A4 Agreeableness    FALSE
#> 5      A5 Agreeableness     TRUE
#> 6      A6 Agreeableness     TRUE
#>                                         item_text position
#> 1      I sympathise with other people's feelings.        2
#> 2                     I take time out for others.        7
#> 3                    I trust what people tell me.       12
#> 4                          I am quick to forgive.       17
#> 5        I can be blunt to the point of rudeness.       22
#> 6 I am not really interested in others' problems.       27