describe_vars: Customized version of the function describe (psych) for...

View source: R/describe_vars.r

describe_varsR Documentation

Customized version of the function describe (psych) for single and multiple numeric variables

Description

This function is essentially a customized version of the function describe() included the package psych, but provides some additional benefits: First, it transforms the the output into a tibble. Second, it reduces the number of psychometrics down to the most important ones. Third, it allows to include item formulations drawn from an additional data frame (needs to have a variable "code" that includes similar variable codes as the original data frame and a variable named "item" that includes the item formulations). Overall, it provides enough functionality to create a printable "Table 1".

Usage

describe_vars(data, items = NULL, var_name = NULL, brief = FALSE,
  first_col = "code", n = FALSE, print = FALSE, digits = 2, ...)

Arguments

data

A data frame that includes that variables that should be evaluated. Can also be a vector with numeric values.

items

A data frame containing the variable codes (first column "code") and item formulations (second column "item").

var_name

If you are evaluating a single vector, you specify the variable name here.

brief

A logical value indicating wether all psychometrics or only the mean and the standard deviations should be printed

first_col

How should the first column be named? Defaults to "code".

n

Logical value indicating whether the number of valid cases should be included in the output.

print

Logical value indicating whether the output should be formated according to APA-guidelines (if true, the output can easily be printed with the function apa_table).

digits

A numeric value indicating how many digits should be printed (only works together with print = TRUE)

...

Further arguments that can be passed to describe.

Value

A data frame with relevant item statistics such as mean, standard deviation, minimum, maximum, skewness and kurtosis.

Examples

describe_vars(mtcars)
describe_vars(mtcars, n = TRUE, print = TRUE, digits = 3)
describe_vars(mtcars$cyl, var_name = "cylinder")

masurp/pmmisc documentation built on May 3, 2024, 7:13 p.m.