Formulating the results of a comparison of means is quite common. This function assembles a descriptive text about the results of a t-test, describing group sizes, means, p-values and confidence intervals.

Phrase(x, g, glabels = NULL, xname = NULL, unit = NULL, lang = "engl", na.rm = FALSE)

Arguments

x

a (non-empty) numeric vector of data values.

g

a vector or factor object giving the group for the corresponding elements of x. The number of levels must equal 2.

glabels

the labels of the two groups, if left to NULL, the levels will be used.

xname

the name of the variable to be used in the text.

unit

an optional unit for be appended to the numeric results.

lang

the language to be used. Only english (default) and german implemented (so far).

na.rm

logical, should NAs be omitted? Defaults to FALSE.

Value

a text

Author

Andri Signorell <andri@signorell.net>

See also

Examples

data("cats", package = "MASS")
cat(Phrase(cats$Bwt, cats$Sex, xname="weight", unit="grams", glabels=c("female", "male")))
#> The entire group consists of a total of 144 elements. Of these, 47 are female (32.6%, mean weight 2.36 grams) and 97 male (67.4%, mean weight 2.90 grams).
#> The difference is significant (t-test, p = 8.83e-15) and is -0.540 grams [-0.663, -0.418] (95% CI).

# oder auf deutsch
cat(Phrase(cats$Bwt, cats$Sex, xname="Geburtsgewicht",
           glabels=c("weiblich", "maennlich"), lang="german"))
#> Das Kollektiv besteht aus insgesamt 144 Elementen. Davon sind 47 weiblich (32.6%, mittleres Geburtsgewicht 2.36) und 97 maennlich (67.4%, mittleres Geburtsgewicht 2.90).
#> Der Unterschied ist signifikant (t-test, p = 8.83e-15) und betraegt -0.540 [-0.663, -0.418] (95%-CI).