Description Usage Arguments Value Author(s) See Also Examples
Generate a table of descriptive statistics with p-values obtained in tests for difference between the groups.
1 2 3 4 | descr(dat, group, var.names, percent.vertical = T, data.names = T, nonparametric = c(), landscape = F,
pos.pagebr = NULL, paired = F, var.equal = T, correct.cat = F, correct.wilcox = T, silent = T,
p.values = T, groupsize = F, n.or.miss = "n", group.miss = F, t.log = c(), index = T,
create = "tex", digits.m = 1, digits.sd = 2, digits.qu = c(), digits.minmax = 1, digits.p = 1)
|
dat |
Data frame. The data set to be analyzed. Can contain continuous or factor (also ordered) variables. |
group |
Vector of the grouping variable. |
var.names |
Optional. Vector of names to be used in the table for the analyzed variables. |
percent.vertical |
Logical. Should "vertical" percentages for categorical variables be provided? |
data.names |
Logical. If |
nonparametric |
Logical or vector of indices. If logical / vector of indices then all / only these continuous variables will be tested using non-parametric methods. |
landscape |
Logical. Should the table be in landscape? Only useful if you want create a "pdf"- or "knitr"-document in the following. (see |
pos.pagebr |
Vector of positions of the pagebreak in tex (or pdf). This is a bit fuzzy. It is the number of lines after a pagebreak should be done. |
paired |
Logical. Should paired tests be applied? The groups must have the same length. |
var.equal |
Logical. Should variances be assumed to be equal when applying t-tests? |
correct.cat |
Logical. Should correction be used in chi-sqared tests (see |
correct.wilcox |
Logical. Should correction be used in wilcoxon tests (see |
silent |
Logical. Should intermediate stages be shown (more for technical reasons)? |
p.values |
Logical. Should calculate p-values? If you won't p-values |
groupsize |
Logical. Should be checked for each variable whether the groups contain at least two cases. Number.Instead of two any other number. |
n.or.miss |
Should the number of observations, missings for continuous variables, and/or missings for categorical variables be provided ("n", "miss", "miss.cat")? Combinations are allowed. |
group.miss |
Logical. Schould add a column for the Missings in group? |
t.log |
Vector of indices: The variables for which the log of the original data should be used when testing for a difference between the groups. |
index |
Logical. Should the tests used be labeled by footnotes? Only usefull if "p-values" in |
create |
Which output document should be produced in the following step (one of "pdf", "tex", "knitr", "word" or "R"). |
digits.m |
Number of digits for presentation in the table: For mean. |
digits.sd |
Number of digits for presentation in the table: For standard deviation. |
digits.qu |
Vector of numbers of digits for presentation in the table: For quantiles (if no value is specified it will be tried to provide a reasonable presentation). |
digits.minmax |
Number of digits for presentation in the table: For minimum and maximum. |
digits.p |
Number of digits for presentation in the table: For percentages. |
Depending on the value of the create parameter either pdf, word, tex, R or an file optimized for use in connection with knitr will be created containing the descriptive statistics table with the speak for the document to create in the following.
For example you choose create="pdf"
then the table is written in TeX
-Code.
Attention: the table has no caption and numbers of observations per group.
Lorenz Uhlmann, Csilla van Lunteren
med.new
inqur
minmax
f.r
formatr
m.cat
m.cont
p.cat
p.cont
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ## Not run:
##Dataset with two groups
infert
attach(infert)
#is.factor(education)
#is.factor(age)
#is.factor(parity)
#is.factor(induced)
#is.factor(case)
#infert$case<-as.factor(case)
#case<-as.factor(case)
#is.factor(spontaneous)
#is.factor(stratum)
#is.factor(pooled.stratum)
#we use case as Grouping variable
#Version 1
descr(dat = infert, group = case, var.names = c("education", "age", "parity", "induced", "spontaneous", "stratum", "pooled.stratum"),create = "word")
#Version 2
group <- case
dat <- infert[,-5]
descr(dat = dat, group = group, var.names = c("education", "age", "parity", "induced", "spontaneous", "stratum", "pooled.stratum"),create = "word")
##Dataset with more then two groups
ChickWeight
attach(ChickWeight)
#is.factor(weight)
#is.factor(Time)
#is.factor(Chick)
#is.factor(Diet)
#we use Diet as Grouping variable
#Version 1
descr(dat = ChickWeight, group = Diet, var.names = c("weight", "Time", "Chick"), create = "word")
#Version 4
group <- Diet
dat <- ChickWeight[,-4]
descr(dat = dat, group = group, var.names = c("weight", "Time", "Chick"), create = "word")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.