# descr: Univariate Statistics for Numerical Data In summarytools: Tools to Quickly and Neatly Summarize Data

 descr R Documentation

## Univariate Statistics for Numerical Data

### Description

Calculates mean, sd, min, Q1*, median, Q3*, max, MAD, IQR*, CV, skewness*, SE.skewness*, and kurtosis* on numerical vectors. (*) Not available when using sampling weights.

### Usage

```descr(
x,
var = NULL,
stats = st_options("descr.stats"),
na.rm = TRUE,
round.digits = st_options("round.digits"),
transpose = st_options("descr.transpose"),
order = "sort",
style = st_options("style"),
plain.ascii = st_options("plain.ascii"),
justify = "r",
display.labels = st_options("display.labels"),
split.tables = 100,
weights = NA,
rescale.weights = FALSE,
...
)
```

### Arguments

 `x` A numerical vector or a data frame. `var` Unquoted expression referring to a specific column in `x`. Provides support for piped function calls (e.g. `my_df %>% descr(my_var)`. `stats` Character. Which stats to produce. Either “all” (default), “fivenum”, “common” (see Details), or a selection of : “mean”, “sd”, “min”, “q1”, “med”, “q3”, “max”, “mad”, “iqr”, “cv”, “skewness”, “se.skewness”, “kurtosis”, “n.valid”, and “pct.valid”. Can be set globally via `st_options`, option “descr.stats”. `na.rm` Logical. Argument to be passed to statistical functions. Defaults to `TRUE`. `round.digits` Numeric. Number of significant digits to display. Defaults to `2`. Can be set globally with `st_options`. `transpose` Logical. Make variables appears as columns, and stats as rows. Defaults to `FALSE`. Can be set globally with `st_options`, option “descr.transpose”. `order` Character. When analyzing more than one variable, this parameter determines how to order variables. Valid values are “sort” (or simply “s”), “preserve” (or “p”), or a vector containing all variable names in the desired order. Defaults to “sort”. `style` Character. Style to be used by `pander`. One of “simple” (default), “grid”, “rmarkdown”, or “jira”. Can be set globally with `st_options`. `plain.ascii` Logical. `pander` argument; when `TRUE` (default), no markup characters will be used (useful when printing to console). If `style = 'rmarkdown'` is specified, value is set to `FALSE` automatically. Can be set globally using `st_options`. `justify` Character. Alignment of numbers in cells; “l” for left, “c” for center, or “r” for right (default). Has no effect on html tables. `headings` Logical. Set to `FALSE` to omit heading section. Can be set globally via `st_options`. `TRUE` by default. `display.labels` Logical. Show variable / data frame labels in heading section. Defaults to `TRUE`. Can be set globally with `st_options`. `split.tables` Character. `pander` argument that specifies how many characters wide a table can be. `100` by default. `weights` Numeric. Vector of weights having same length as x. `NA` (default) indicates that no weights are used. `rescale.weights` Logical. When set to `TRUE`, a global constant is apply to make the total count equal `nrow(x)`. `FALSE` by default. `...` Additional arguments passed to `pander` or `format`.

### Value

An object having classes “matrix” and “summarytools” containing the statistics, with extra attributes used by `print` method and view function.

### Author(s)

Dominic Comtois, dominic.comtois@gmail.com

### Examples

```data("exams")

# All stats for all numerical variabls
descr(exams)

# Only common statistics
descr(exams, stats = "common")

# Arbitrary selection of statistics, transposed
descr(exams, stats = c("mean", "sd", "min", "max"), transpose = TRUE)

descr(exams, plain.ascii = FALSE, style = "rmarkdown")

# Grouped statistics
data("tobacco")
with(tobacco, stby(BMI, gender, descr))

# Grouped statistics, transposed
with(tobacco, stby(BMI, age.gr, descr, stats = "common", transpose = TRUE))

## Not run:
# Show in Viewer (or browser if not in RStudio)
view(descr(exams))

# Save to html file with title
print(descr(exams),
file = "descr_exams.html",
report.title = "BMI by Age Group",
footnote = "<b>Schoolyear:</b> 2018-2019<br/><b>Semester:</b> Fall")

## End(Not run)

```

summarytools documentation built on May 20, 2022, 9:06 a.m.