Skip to contents

Sums the columns named in columns or matching pattern in each row and ranks the rows (rank 1 = largest sum by default; ties keep the row order).

Usage

PlotDataRankRows(
  data,
  id,
  columns = NULL,
  pattern = NULL,
  decreasing = TRUE,
  ids = NULL
)

Arguments

data

Wide data frame with one row per item.

id

Identifier column.

columns

Columns to add up.

pattern

Regular expression selecting further columns.

decreasing

Rank the largest sum first.

ids

Optional identifiers to keep (a vector, or a data frame whose first column holds them); other rows are dropped.

Value

A data frame with id, value and rank, sorted by rank.

Examples

d <- data.frame(p = c("a", "b", "c"), "CN1 T" = c(10, 40, 20), check.names = FALSE)
PlotDataRankRows(d, "p", pattern = "^CN1 ")
#>   p value rank
#> 1 b    40    1
#> 2 c    20    2
#> 3 a    10    3