Learn R Programming

crunch (version 1.30.4)

cubeMeasureType: Get measure type of cube result

Description

Returns a string describing the measure type of the cube result, such as "count", "mean", "sd", etc.

Usage

cubeMeasureType(x, measure = NULL)

# S4 method for CrunchCube cubeMeasureType(x, measure = 1)

Value

A string describing the cube's measure type

Arguments

x

A CrunchCube

measure

Which measure in the cube to check, can index by position with numbers or by name. NULL, the default, will select a "sum" type measure first, "mean" if no sum is available, and will use the cube's names in alphabetic order if there are no "sum" or "mean" measures (or if a tie breaker between two measure types is needed).

Examples

Run this code
if (FALSE) {
cube1 <- crtabs(~allpets, ds)
cubeMeasureType(cube1)
#> "count"

cube2 <- crtabs(list(a = n(), b = mean(age)) ~ allpets, ds)
cubeMeasureType(cube2)
#> "count"
cubeMeasureType(cube2, "b")
#> "mean"
}

Run the code above in your browser using DataLab