sort_matrix_rows | R Documentation |
Sorts a numeric matrix or data frame by a specified column or by row names. The function can only
handle sorting by a single column. It offers options to sort in increasing or decreasing order,
and to control the placement of NA
values.
sort_matrix_rows(
df,
column = NULL,
rownames = FALSE,
decrease = FALSE,
na_last = TRUE
)
df |
A numeric matrix or data frame to be sorted. Default: none. |
column |
A column name or index by which to sort. The function can handle only single-column sorting. Default: none. |
rownames |
Logical. If |
decrease |
Logical. If |
na_last |
Logical. If |
A sorted version of the input matrix or data frame.
df <- data.frame(AA = c(1, 2, 3), BB = c(3, 2, 1), row.names = letters[7:5])
sort_matrix_rows(df, "AA")
sort_matrix_rows(df, "AA", decrease = TRUE)
sort_matrix_rows(df, "A", rownames = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.