summaries | R Documentation |
Simple univariate summary functions which are applied to each level of a grouping factor. These functions include arguments for labeling and formatting the summary.
nequals(x, lab = NULL) npct(x, lab = NULL, ref = NULL, dig = 0, p = NULL, p.args = NULL, ...) mediqr(x, lab = NULL, dig = 0, p = NULL, p.args = NULL, ...) meansd(x, lab = NULL, dig = 0, p = NULL, p.args = NULL, ...)
x |
The variable to summarize. If | ||||
lab |
A length-one character vector indicating the label to give to the summary. | ||||
ref |
A length-one character vector indicating the single
“reference level” to use for a number-and-percentage
summary provided by | ||||
dig |
The number of digits past the decimal place to display in the formatted summary. | ||||
p |
The abbreviation for the function to call for calculating a p-value.
| ||||
p.args |
A list of further arguments that is passed to the p-value
function. For example, | ||||
... |
Currently ignored. |
a character vector giving the number
at each level of x
in the form of the level followed
by the number in parentheses. For example,
c("<group1> (n=<number1>)", ...)
. This kind of output
often appears at the top of a summary table.
a character vector giving, by default, the number and
percentage at each level of x
. If ref
is
specified, the result is a length-one character vector giving
the number and percent for just the “reference” level.
a length-one character vector providing the formatted
numeric summary of the median and inter-quartile range of x
.
a length-one character vector providing the formatted
numeric summary of the mean and SD of x
.
Each of these functions attaches the value of lab
as a
comment
attribute. For the npct
function, the
comment
will be a character vector where the first
element is the value of lab
and the other elements are the
categories or levels summarized. This use (or abuse) of the
comment
attribute stems from model.frame
allowing the comment
attribute to “pass through”
to the resulting data.frame.
If these functions are called on a vector of data the p
and
p.args
arguments are ignored. It is only when these functions
are used in a formula with a grouping variable on the left hand side
that yat
will calculate a p-value.
Stephen Weigand <weigand.stephen@mayo.edu>
set.seed(1) nequals(rpois(25, 1), lab = "Poisson lambda=1") npct(factor(rbinom(25, size = 1, prob = 0.5), labels = c("Heads", "Tails")), lab = "Number (%)", ref = "Heads") mediqr(rnorm(25), dig = 1) ## 'p' ignored in univariate case mediqr(rnorm(25), dig = 1, p = "tt") meansd(rnorm(25), lab = "Mean (SD) of 25 N(0, 1)s", dig = 1) data(warpbreaks) yat(1 + wool ~ meansd(breaks, p = "tt"), data = warpbreaks) yat(1 + wool ~ npct(tension) + mediqr(breaks), warpbreaks)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.