Learn R Programming

DescTools (version 0.99.7)

DescWrd: Use Word as Reporting Tool for Describing Data

Description

Calculates descriptive statistics for x and uses Word as reporting tool.

Usage

## S3 method for class 'default':
DescWrd(x, wrd, caption = deparse(substitute(x)), ...)
## S3 method for class 'data.frame':
DescWrd(x, wrd, caption = deparse(substitute(x)), 
                 univar = TRUE, colpairs = FALSE, notch = TRUE, 
                 col0 = "#9A0941FF", col1 = "#8296C4FF", width = 100, 
                 fontname = "Consolas", fontsize = 7, ...)
## S3 method for class 'formula':
DescWrd(formula, data = parent.frame(), wrd, ...)

Arguments

x
the object to be described.
caption
the title of the decription. Default is name and class of the variable.
wrd
the pointer to a word instance. Can be a new one, created by GetNewWrd() or an existing one, created by GetCurrWrd(). Default is the last created pointer stored in getOption("lastWord").
formula
a formula of the form lhs ~ rhs where lhs gives the data values and rhs the corresponding groups.
data
an optional matrix or data frame containing the variables in the formula formula. By default the variables are taken from environment(formula).
univar
logical. Specifying if only univariate descriptions should be produced. Defaults to TRUE.
colpairs
logical. Specifying if pairwise bivariate descriptions should be produced. Defaults to FALSE.
notch
if notch is TRUE, a notch is drawn in each side of the boxes in a boxplot. See boxplot for the details.
col0
the first color used in mosaicplots.
col1
the last color used in mosaicplots.
width
integer. The linewidth of the results in characters. Defaults to 80.
fontname
the font of the text.
fontsize
the fontsize of the text.
...
further argument to be passed to methods.

Details

This function is not thought of being directly run by the enduser. It will normally be called automatically, when a pointer to a Word instance is passed to the function Desc. However DescWrd takes some more specific arguments concerning the Word output (like font or fontsize), which can make it necessary to call the function directly.

See Also

Desc

Examples

Run this code
# Output into word document ---------------------------------------------------------

# Windows-specific example

wrd <- GetNewWrd(header=TRUE)    # create a new word instance and insert title and contents

# let's have a subset
d.sub <- d.pizza[,c("driver","date","operator","price","wrongpizza")]

# do just the univariate analysis
Desc(d.sub, wrd=wrd) 

# do a full report
Desc(d.sub, wrd=wrd, colpairs=TRUE)

# do just bivariate analysis
Desc( d.sub, univar=FALSE, colpairs=TRUE, wrd=wrd) 

# selected bivariate analysis into word document
Desc(week ~ driver, data=d.pizza, wrd=wrd)   
Desc(price ~ operator, data=d.pizza, digits=c(2,2,2,2,0,3,0,0), wrd=wrd ) 
Desc(driver ~ operator, data=d.pizza, wrd=wrd) 
Desc(price ~ operator + driver + wrongpizza, data=d.pizza
     , digits=c(2,2,2,2,0,3,0,0), wrd=wrd) 

Desc(price ~ delivery_min, data=d.pizza, wrd=wrd ) 


# internal functions (not meant to be used by the enduser):
Desc.factor(d.pizza$driver, ord="n" )  # ordered by name
Desc.factor(d.pizza$driver, ord="l" )  # ordered by level
Desc.logical(d.pizza$wrongpizza)
Desc.integer(d.pizza$weekday, maxlevels=NA)
Desc.integer(d.pizza$weekday, maxlevels=3)
Desc.numeric(d.pizza$count, highlow=FALSE)
Desc.numeric(d.pizza$count, highlow=TRUE)
 
DescNumFact( x=d.pizza$delivery_min, grp=d.pizza$operator )
DescFactFact( x=d.pizza$driver, grp=d.pizza$operator)
DescNumNum( x=d.pizza$delivery_min, y=d.pizza$price )

Run the code above in your browser using DataLab