Learn R Programming

DescTools (version 0.99.37)

TwoGroups: Describe a Variable by a Factor with Two Levels

Description

This function describes a numeric variable by a grouping factor with two levels. First, a descriptive text listing the frequencies and means of the two groups and the results of the significance test is generated. The results of Desc(x~g) are reported as they are provided by the function, followed by a plot consisting of a density plot and a box plot. This description makes sense, for example, if the age distribution of a collective is to be represented for both sexes.

Usage

TwoGroups(x, g, test = t.test, main = NULL,
          font.txt = NULL, font.desc = NULL, wrd = NULL, ...)

Arguments

x

the numeric variable to describe.

g

the grouping factor (preferably with two levels.)

test

the test to be applied, default is t.test().

main

the main title.

font.txt

the font chosen for the introducing text, when sending the output to Word.

font.desc

the font chosen for the description, when sending the output to Word.

wrd

the pointer to a running MS Word instance, as created by GetNewWrd() (for a new one) or by GetCurrWrd() for an existing one. Default is NULL, which will report all results to the console.

the dots are sent to the internally used function Phrase(). They can be used to choose the language (lang) or provide variable name (xname).

Value

list with the results calculated by the used functions

See Also

Desc, PlotMultiDens, Phrase

Examples

Run this code
# NOT RUN {
x <- d.pizza$temperature
g <- factor(d.pizza$rabate)

# we can change the colors for the plot by setting the DescToolsOptions
DescToolsOptions(col=c(horange, hgreen))
TwoGroups(x, g, main="Temperature ~ Rebate")

# for an output to Word simply define the wrd argument
# wrd <- GetNewWrd()
# TwoGroups(x, g, font.desc=list(name="Consolas", size=8),
#           main="Temperature ~ Rebate", wrd=wrd)
# }

Run the code above in your browser using DataLab