Learn R Programming

sjmisc (version 2.6.3)

descr: Basic descriptive statistics

Description

This function wraps the describe-function and prints a basic descriptive statistic, including variable labels.

Usage

descr(x, ..., max.length = NULL)

Arguments

x

A vector or a data frame. May also be a grouped data frame (see 'Note' and 'Examples').

...

Optional, unquoted names of variables that should be selected for further processing. Required, if x is a data frame (and no vector) and only selected variables from x should be processed. You may also use functions like : or dplyr's select_helpers. See 'Examples' or package-vignette.

max.length

Numeric, indicating the maximum length of variable labels in the output. If variable names are longer than max.length, they will be shortened to the last whole word within the first max.length chars.

Value

A data frame with basic descriptive statistics, derived from the describe-function. The additional column NA.prc informs about the percentage of missing values in a variable.

Examples

Run this code
# NOT RUN {
data(efc)
descr(efc, e17age, c160age)

library(dplyr)
efc %>% select(e42dep, e15relat, c172code) %>% descr()

# with grouped data frames
efc %>%
  group_by(e16sex) %>%
  select(e16sex, e42dep, e15relat, c172code) %>%
  descr()

# you can select variables also inside 'descr()'
efc %>%
  group_by(e16sex, c172code) %>%
  descr(e16sex, c172code, e17age, c160age)

# or even use select-helpers
descr(efc, contains("cop"), max.length = 20)

# }

Run the code above in your browser using DataLab