prepare_ext_obs_table: Prepares a Table Displaying Extreme Observations

Description Usage Arguments Details Value Examples

View source: R/prepare_ext_obs_table.R

Description

Reads a data frame, sorts it by the given variable and displays the top and bottom n observations.

Usage

1
2
3
4
5
6
7
8
9
prepare_ext_obs_table(
  df,
  n = 5,
  cs_id = NULL,
  ts_id = NULL,
  var = utils::tail(colnames(df[sapply(df, is.numeric) & (!colnames(df) %in% c(cs_id,
    ts_id))]), n = 1),
  ...
)

Arguments

df

Data frame

n

The number of top/bottom observations that you want to report.

cs_id

The variable(s) identifying the cross-section in the data.

ts_id

The variable identifying the time-series in the data.

var

Variable to display. Defaults to the last numerical variable of the data frame.

...

Additional parameters that are passed to kable.

Details

When both cs_id and ts_id are omitted, all variables are tabulated. Otherwise, var is tabulated along with the identifiers. Infinite values in var are omitted. The default parameters for calling kable, are format = "html", digits = 3, format.args = list(big.mark = ','), row.names = FALSE.

Value

A list containing two items:

"df"

A data frame containing the top/bottom n observations

"kable_ret"

The return value provided by kable containing the formatted table

Examples

1
2
3
4
t <- prepare_ext_obs_table(russell_3000, n = 10,
                           cs_id = c("coid", "coname"),
                           ts_id = "period", var = "sales")
t$df

joachim-gassen/ExPanDaR documentation built on April 15, 2021, 6:07 p.m.