Just like subtotals()
s, summary statistics can
be inserted into cubes. SummaryStat()
makes an object of type SummaryStat
which can be added on to a CrunchCube's insertions
to add the specified
summary statistic. Currently only mean
and median
are supported; both
use weighted algorithms to go from counts and numeric values of
categories to the expected statistic. Although SummaryStat
objects can be
made by hand, it is recommended instead to use the addSummaryStat()
function which is much quicker and easier to simply add a summary
statistic to an existing CrunchCube.
SummaryStat(
name,
stat,
categories = NULL,
position = c("relative", "top", "bottom"),
after = NULL,
before = NULL,
includeNA = FALSE
)
SummaryStat(
name,
stat,
categories = NULL,
position = c("relative", "top", "bottom"),
after = NULL,
before = NULL,
includeNA = FALSE
)
is.SummaryStat(x)
are.SummaryStats(x)
character the name of the summary statistic
a function to calculate the summary (e.g. mean
or median
)
character or numeric the category names or ids to be included in the summary statistic, if empty all categories
character one of "relative", "top", or "bottom". Determines the position of the subtotal or heading, either at the top, bottom, or relative to another category in the cube (default)
character or numeric if position
is "relative", then the
category name or id to position the subtotal or heading after
character or numeric if position
is relative (and the
insertion type allows it - currently only MR subtotals).
should missing categories be included in the summary?
for is.SummaryStat()
only, an object to test if
it is a SummaryStat
object
Summary statistics are intended only for CrunchCube objects, and are not able to be set on Crunch variables.
noTransforms()
is useful if you don't want to see or use any transformations like
Subtotals and Headings. This action only applies to the CrunchCube object in
R: it doesn't actually change the variables on Crunch servers or the query
that generated the CrunchCube.