Description Usage Arguments Details Value Author(s) See Also Examples
This is the main function for the user. It can be used to generate a table of descriptive statistics with p-values obtained in tests for difference between the groups. There are five options for the output: pdf, tex, knitr, word file or an Output in R. knitr is not really useful as an output file but for the use within a knitr file.
1 2 3 4 5 6 7 8 | des.print(dat, group, create = "pdf", file, index = T, fsize = 11, paired = F,
nonparametric = F, var.equal = T, correct.cat = F, correct.wilcox = T,
t.log = c(), which.col = c("groups", "total", "p-values"),
groupsize = F, n.or.miss = c("n", "miss", "miss.cat"), group.miss = F,
percent.vertical = T, var.names, data.names = T, caption, tab.caption,
landscape = F, pos.pagebr = NULL, label = NULL, digits.m = 1,
digits.sd = 2, digits.qu = c(), digits.minmax = 1, digits.p = 1,
silent = T, ...)
|
dat |
Data frame. The data set to be analyzed. Can contain continuous or factor (also ordered) variables. |
group |
The (optional) grouping variable. |
create |
Which output document should be produced (one of "pdf", "tex", "knitr","word" or "R"). Choose "custom" if you add more arguments see |
file |
File name, which can included the directory (has to have the proper file extension, i.e. .pdf, .tex, or .docx). directory.
Only for |
index |
Logical. Should the tests used be labeled by footnotes? |
fsize |
The fontsize in the Output-Document. |
paired |
Logical. Should paired tests be applied? The groups must have the same length. |
nonparametric |
Logical or vector of indices. If logical / vector of indices then all / only these continuous variables will be tested using non-parametric methods. |
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 |
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. |
which.col |
Which columns should be provided ("groups", "total", "p-values")? Combinations are allowed. "groups" or "total" must be listed. Only "total" and "p-values" is not possible.
Type of p-value calculation see |
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. Should add a column for the Missings in group? For both cases in |
percent.vertical |
Logical. Should "vertical" percentages for categorical variables be provided? |
var.names |
Optional. Vector of names to be used in the table for the analyzed variables. |
data.names |
Logical. If |
caption |
Optional. Vector of names of the categories of group. |
tab.caption |
Optional. The caption of the table. |
landscape |
Logical. Should the table be in landscape? Only useful for |
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. |
label |
Character. If tex (or knitr) in |
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. |
silent |
Logical. Should intermediate stages be shown (more for technical reasons)? |
... |
further arguments to be passed to or from methods. |
The aim of this function is to help the user to create well-formated descriptive statistics tables.
The format can then be fine-tuned in the word, tex or knitr file itself. Only the pdf file is (more or less) unchangeable.
Even though it is supposed to be a good starting point for a descriptive analysis, care has to be taken when using the results and a detailed check of the results might be necessary. For instance, in case of missing values in the group variable and group.miss = FALSE
the respective observations will be omitted also in the total column. A warning will be displayed.
If no group variable is specified only the total column (see parameter which.col
) will be returned.
Only by using create == "R"
an R object will be returned. However, depending on the value of the create parameter either pdf, word, tex or an file optimized for use in connection with knitr will be created containing the descriptive statistics table and saved in a file as specified in the file parameter.
Lorenz Uhlmann, Csilla van Lunteren
descr
f.r
formatr
inqur
m.cat
m.cont
med.new
minmax
p.cat
p.cont
autofit
flextable
set_header_df
merge_h
merge_at
align
style
border
bold
width
height
body_add_flextable
fp_text
fp_cell
fp_border
read_docx
xtable
texi2dvi
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 48 49 50 | ## Not run:
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
file <- "C:/Users/lunteren/Desktop/infert/DescriptiveStatisticTable.docx"
#Version 1
des.print(dat = infert, group = 5, create = "word", file=file, fsize = 10, var.names = c("education", "age", "parity","induced", "spontaneous", "stratum", "pooled.stratum"), caption = c("Group 1", "Group 2"))
#Version 2
des.print(dat = infert, group = case, create = "word", file=file, fsize = 10, var.names = c("education", "age", "parity","induced", "spontaneous", "stratum", "pooled.stratum"), caption = c("Group 1", "Group 2"))
#Version 3
group <- case
dat <- infert[,-5]
des.print(dat = dat, group = group, create = "word", file=file, fsize = 10, var.names = c("education", "age", "parity","induced", "spontaneous", "stratum", "pooled.stratum"), caption = c("Group 1", "Group 2"))
##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
file <- "C:/Users/lunteren/Desktop/ChickWeight/DescriptiveStatisticTable.docx"
#Version 1
des.print(dat = ChickWeight, group = 4, create = "word", file = file, fsize = 10, var.names = c("weight", "Time", "Chick"), caption = c("Group 1", "Group 2", "Group 3", "Group 4"))
#Version 2
des.print(dat = ChickWeight, group = Diet, create = "word", file = file, fsize = 10, var.names = c("weight", "Time", "Chick"), caption = c("Group 1", "Group 2", "Group 3", "Group 4"))
#Version 3
group <- Diet
dat <- ChickWeight[,-4]
des.print(dat = dat, group = group, create = "word", file = file, fsize = 10, var.names = c("weight", "Time", "Chick"), caption = c("Group 1", "Group 2", "Group 3", "Group 4"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.