pander_sort: Sort and display a table

Description Usage Arguments Value Examples

View source: R/Helper_Functions.R

Description

Sort a table by a column, replace row names as 1:n, and return the table via pander for clean display. This is necessary after sorting because pander will display row names if they are not 1:n or NULL.

Usage

1

Arguments

data

A dataframe or object that can be coerced into a data frame (will be done via as.data.frame)

x

The column name to sort by, quoted or unquoted

...

Additional named parameters to be passed to pander()

Value

From pander: By default this function outputs (see: cat) the result. If you would want to catch the result instead, then call the function ending in .return.

Examples

1
2
3
4
5
6
7
8
x <- data.frame(fruit = c("banana", "apple", "kiwi"),
                weight = c(4.5, 3.6, 1.2))

## Sorting manually:
pander::pander(x[order(x$fruit),])

## Sorting and fixing row names:
pander_sort(x, fruit)

jpshanno/ecoflux documentation built on May 19, 2019, 11:51 p.m.