desc function

Making descriptive statistics

Making descriptive statistics

Makes descriptive statistics of a data frame according to a group covariate or not, can export the results

desc( data, vars, group = NULL, whole = TRUE, vars.labels = vars, group.labels = NULL, type.quanti = "mean", test.quanti = "param", test = TRUE, noquote = TRUE, justify = TRUE, digits = 2, file.export = NULL, language = "english" )

Arguments

  • data: data frame to describe in which we can find vars and group
  • vars: vector of character strings of the covariates to describe
  • group: character string, statistics created for each levels of this covariate
  • whole: boolean, TRUE to add a column with the whole statistics when comparing groups (set to FALSE if group=NULL)
  • vars.labels: vector of character string for sweeter names of covariates in the output
  • group.labels: vector of character string for sweeter column names
  • type.quanti: character string, "med" to compute median [Q1;Q3], "mean" to compute mean (sd), "mean_med" to compute both mean (sd) and median [Q1;Q3] or "med_mm", "mean_mm" or "mean_med_mm" to add (min;max)
  • test.quanti: character string, "param" to compute parametric tests for quantitative covariates (t-test or ANOVA) or "nonparam" for non parametric tests (Wilcoxon test or Kruskal-Wallis test)
  • test: boolean, TRUE to perform tests (FALSE if group is NULL): Khi-2 or Fisher exact test for categorical covariates, t-test/ANOVA or Wilcoxon/Kruskal-Wallis Rank Sum Test for numerical covariates
  • noquote: boolean, TRUE to hide quotes when printing the table
  • justify: boolean, TRUE to justify columns on right or left (FALSE if export)
  • digits: number of digits of the statistics (mean, sd, median, min, max, Q1, Q3, %), p-values always have 3 digits
  • file.export: character string, name of the XLS file exported
  • language: character string, "french" or "english"

Returns

A matrix of the descriptive statistics

Examples

cgd$steroids=factor(cgd$steroids) cgd$status=factor(cgd$status) desc(cgd,vars=c("center","sex","age","height","weight","steroids","status"),group="treat")

Author(s)

Hugo Varet

  • Maintainer: Hugo Varet
  • License: GPL (>= 2)
  • Last published: 2025-03-24

Useful links