desc.comp {rSPARCS} | R Documentation |
Generate a Descriptive Table
Description
Generate a comprehensive descriptive table with intergroup comparison.
Usage
desc.comp(data,variables,by,margin,avg.num,test.num)
Arguments
data |
a data.frame containing the variables to be described and a group variable |
variables |
a numeric variable indicating the columns of variables to be described. |
by |
a number indicating the column of the group variable |
margin |
calculate the proportion for categorical variables by 1 (row) or 2 (column). |
avg.num |
"mean", describe continuous variables with mean and standard deviation; "median", describe continuous variables with median and interquantile range; otherwise, normal distribution test will be conducted, for normal distributed variables, "mean" will be used, otherwise, "median" will be used. |
test.num |
"metric", t test or anova will be used for intergroup comparison; "nonmetric", Wilcoxon rank sum test or Kruskal-Wallis test will be used; otherwise, normal distribution test will be conducted, for normal distributed variables, "metric" will be used, otherwise, "nonmetric" will be used. |
Details
Not limited to hospital data, but also applicable to other surveillance data.
Value
A comprehensive descriptive table with statistics and P value for intergroup comparisons.
Examples
desc.comp(CO2,variables=2:5,by=1,margin=1)