prepare_ext_obs_table {ExPanDaR} | R Documentation |
Prepares a Table Displaying Extreme Observations
Description
Reads a data frame, sorts it by the given variable and displays the top and bottom n observations.
Usage
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 |
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
t <- prepare_ext_obs_table(russell_3000, n = 10,
cs_id = c("coid", "coname"),
ts_id = "period", var = "sales")
t$df