SortRows: Sort rows of a table

View source: R/tidytools.R

SortRowsR Documentation

Sort rows of a table

Description

Sorts the rows of the table based on the values in the specified column

Usage

SortRows(x, decreasing = FALSE, column = NULL, exclude = "NET, SUM, Total")

Arguments

x

Input matrix or dataframe which is being sorted. Values must be numeric. Vectors and 1-d arrays will be converted to a matrix.

decreasing

Order to sort values.

column

The column to sort by. If none is specified and the 'Column n' statistic is present in the table, it will use the column with the largest value of 'Column n'. Otherwise it will pick the right-most column.

exclude

A string containing a comma-separated list of rows (either by name or index) which should not be sorted. These rows will remain at the bottom of the output table

Details

This function differs from the QScript in a number of ways. 1) Sorting does not respect spans. 2) The default column in based on 'Column n' in 'Statistics - Below'. This is not available to R. Instead we pick the column with the largest sum. If there is a tie between columns, we will pick the rightmost column 3) There is no parameter for 'Never exclude from sort'. This is because we require that entries in 'Exclude from sort' must match the rowname exactly, instead of a partial match used in the QScript


NumbersInternational/flipTables documentation built on Feb. 26, 2024, 6:42 a.m.