These functions provide an interface like base::margin.table()
and base::prop.table()
for the CrunchCube object. CrunchCubes contain
richer metadata than standard R array
objects, and they also conceal
certain complexity in the data structures from the user. In particular,
multiple-response variables are generally represented as single dimensions
in result tables, but in the actual data, they may comprise two dimensions.
These methods understand the subtleties in the Crunch data types and
correctly compute margins and percentages off of them.
# S4 method for CrunchCube
margin.table(x, margin = NULL)# S4 method for CrunchCube
prop.table(x, margin = NULL)
# S4 method for CrunchCube
round(x, digits = 0)
# S4 method for CrunchCube
bases(x, margin = NULL)
# S4 method for MultitableResult
prop.table(x, margin = NULL)
# S4 method for TabBookResult
prop.table(x, margin = NULL)
# S4 method for TabBookResult
bases(x, margin = NULL)
# S4 method for MultitableResult
bases(x, margin = NULL)
a CrunchCube
index, or vector of indices to generate margin for. See
base::prop.table()
. bases()
accepts 0
as an additional valid
value for margin
, which yields the unweighted counts for the
query.
For round
, the number of decimal places to round to. See
base::round()
When called on CrunchCubes, these functions return an array
.
Calling prop.table on
a MultitableResult returns a list of prop.tables of the CrunchCubes it
contains. Likewise, prop.table on a TabBookResult returns a list of lists of
prop.tables.
These functions also generalize to MultitableResults and TabBookResults,
which are returned from a tabBook()
request. When called on one of those
objects, they effectively apply over each CrunchCube contained in them.
bases
is an additional method for CrunchCubes. When making weighted
requests, bases
allows you to access the unweighted counts for every
cell in the resulting table (array). The bases
function takes a
"margin" argument to work like margin.table
, or with margin=0
gives all cell counts.