descriptive_table: Descriptive Statistics Table

View source: R/descriptive_table.R

descriptive_tableR Documentation

Descriptive Statistics Table

Description

[Stable]
This function generates a table of descriptive statistics (mainly using psych::describe()) and or a correlation table. User can export this to a csv file (optionally, using the file_path argument). Users can open the csv file with MS Excel then copy and paste the table into MS Word table.

Usage

descriptive_table(
  data,
  cols,
  ...,
  digits = 3,
  descriptive_indicator = c("mean", "sd", "cor"),
  file_path = NULL,
  streamline = FALSE,
  quite = FALSE,
  return_result = FALSE
)

Arguments

data

data.frame

cols

column(s) need to be included in the table. Support dplyr::select() syntax.

...

additional arguments passed to cor_test. See ?cor_test.

digits

number of digit for the descriptive table

descriptive_indicator

Default is mean, sd, cor. Options are missing (missing value count), non_missing (non-missing value count), cor (correlation table), n, mean, sd, median, trimmed (trimmed mean), median, mad (median absolute deviation from the median), min, max, range, skew, kurtosis, se (standard error)

file_path

file path for export. The function will implicitly pass this argument to the write.csv(file = file_path)

streamline

print streamlined output

quite

suppress printing output

return_result

If it is set to TRUE, it will return the data frame of the descriptive table

Value

a data.frame of the descriptive table

Examples

descriptive_table(iris, cols = where(is.numeric)) # all numeric columns

descriptive_table(iris,
  cols = where(is.numeric),
  # get missing count, non-missing count, and mean & sd & correlation table
  descriptive_indicator = c("missing", "non_missing", "mean", "sd", "cor")
)

psycModel documentation built on Nov. 2, 2023, 6:02 p.m.