Learn R Programming

moonBook (version 0.1.1)

mytable: Produce table for descriptive statistics

Description

Produce table for descriptive statistics by groups for several variables easily. Depending on the nature of these variables, different descriptive statistical methods were used(t-test, ANOVA,Kruskal-Wallis, chisq, Fisher,...)

Usage

mytable(formula, data, max.ylev = 5, digits = 1, method = 1,
  show.all = FALSE)

Arguments

formula
An object of class "formula". Left side of ~ must contain the name of one grouping variable or two grouping variables in an additive way(e.g. sex+group~), and the right side of ~ must have variables in an additive way.
data
A data.frame contains data for analysis
max.ylev
An integer indicating the maximum number of levels of grouping variable ('y'). If a colummn have unique values less than max.ylev it is treated as a categorical variable. Default value is 5.
digits
An integer indicating the number of decimal places (round) or significant digits (signif) to be used. Default value is 1.
method
An integer indicating methods for continuous variables. Possible values in methods are [object Object],[object Object],[object Object] Default value is 1.
show.all
A logical value indicating whether or not all statistical values have to be shown in table. Default value is FALSE.

Value

  • An object of class "mytable". 'print' returns a table for descriptive statistics. 'summary' returns a table with all statistical values.

Examples

Run this code
data(acs)
mytable(Dx~.,data=acs)
mytable(Dx~age+sex+height+weight+TC+TG+HDLC,data=acs,method=3,digits=2)
mytable(am+cyl~.,data=mtcars)
out=mytable(sex~.,data=acs)
out
summary(out)
mylatex(out)

Run the code above in your browser using DataLab