Percent pseudo-function is used to specify
a statistic that depends on other values in the table.
How the reference set (the denominator in case of a percentage calculation) should be calculated. See below.
The two argument function to calculate the statistic.
fn will be called with two
arguments. The first argument is the usual “value vector”
corresponding to this cell in the table,
and the second
is another vector of reference values, determined
The default value of
fn is the
function(x, y) 100*length(x)/length(y). This
gives the ratio of the number of values in the current cell
relative to the reference values, expressed as a percentage.
fn = function(x, y) 100*sum(x)/sum(y) would give
the percentage of the sum of the values in the current cell to
the sum in the reference set.
With the default
denom = "all", all values of the
analysis variable in the dataset are used as the reference. Other possibilities
denom = "row" or
denom = "col", for which
the values of the variable corresponding to the current row
or column subset are used.
The special syntax
denom = Equal(...) will record
each expression in
reference set will be the cases with equal values of all
... to those of the current cell.
The similar form
denom = Unequal(...)
sets the reference values to be those that differ in any
... expressions from the current cell. (In
fact, these can be used somewhat more generally; see the
vignette for details.)
Finally, other possible
are a logical vector, in which
case the values marked
TRUE are used, or anything else, which will
be passed to
Percent is a “pseudo-function”: it takes the form of a function call, but is
never actually called: it is
handled specially by
are also pseudo-functions, but are only special when used
denom argument to
Arguments for a different way to specify
a multiple argument analysis function.
1 2 3 4 5 6 7
x <- factor(sample(LETTERS[1:2], 1000, rep=TRUE)) y <- factor(sample(letters[3:4], 1000, rep=TRUE)) z <- factor(sample(LETTERS[5:6], 1000, rep=TRUE)) # These both do the same thing: tabular( (x + 1)*(y + 1) ~ (z + 1)*(1+(RowPct=Percent("row")))) tabular( (x + 1)*(y + 1) ~ (z + 1)*(1+(xyPct=Percent(Equal(x, y)))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.