desc: Making descriptive statistics

Description Usage Arguments Value Author(s) Examples

Description

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

Usage

1
2
3
4
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"

Value

A matrix of the descriptive statistics

Author(s)

Hugo Varet

Examples

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

Example output

Loading required package: survival
mean (sd) and t-test/anova for numeric variables
N (%) and khi-2 or Fisher exact test for categorical variables
                                                                             
 Covariate                         Whole sample  treat placebo   treat rIFN-g
                                        (N=203)        (N=120)         (N=83)
    center Harvard Medical Sch        4 (1.97%)       3 (2.5%)       1 (1.2%)
           Scripps Institute        36 (17.73%)    22 (18.33%)    14 (16.87%)
           Copenhagen                 5 (2.46%)      4 (3.33%)       1 (1.2%)
           NIH                       41 (20.2%)    20 (16.67%)     21 (25.3%)
           L.A. Children's Hosp       13 (6.4%)      8 (6.67%)      5 (6.02%)
           Mott Children's Hosp      20 (9.85%)    13 (10.83%)      7 (8.43%)
           Univ. of Utah              5 (2.46%)      2 (1.67%)      3 (3.61%)
           Univ. of Washington        4 (1.97%)      2 (1.67%)      2 (2.41%)
           Univ. of Minnesota        10 (4.93%)      7 (5.83%)      3 (3.61%)
           Univ. of Zurich          21 (10.34%)    13 (10.83%)      8 (9.64%)
           Texas Children's Hosp     11 (5.42%)      7 (5.83%)      4 (4.82%)
           Amsterdam                28 (13.79%)    16 (13.33%)    12 (14.46%)
           Mt. Sinai Medical Ctr      5 (2.46%)       3 (2.5%)      2 (2.41%)
       sex male                    168 (82.76%)   100 (83.33%)    68 (81.93%)
           female                   35 (17.24%)    20 (16.67%)    15 (18.07%)
       age                          13.7 (9.34)    13.57 (9.4)     13.9 (9.3)
    height                       138.12 (31.41) 136.68 (34.86) 140.19 (25.68)
    weight                        39.34 (21.83)  39.67 (23.68)  38.87 (18.96)
  steroids 0                       196 (96.55%)      114 (95%)     82 (98.8%)
           1                          7 (3.45%)         6 (5%)       1 (1.2%)
    status 0                       127 (62.56%)    64 (53.33%)     63 (75.9%)
           1                        76 (37.44%)    56 (46.67%)     20 (24.1%)
        
 p-value
        
 0.967  
        
        
        
        
        
        
        
        
        
        
        
        
 0.794  
        
 0.801  
 0.411  
 0.788  
 0.244  
        
 0.001  
        

packHV documentation built on May 2, 2019, 5:40 a.m.