Learn R Programming

crunch (version 1.30.4)

Insertions-class: Insert categories in transformations

Description

Insertions allow you to insert new categories into a categorical-like response on a variable's transformations.

Usage

Insertions(..., data = NULL)

Insertion(...)

.Insertion(..., data = NULL)

anchor(x, ...)

anchors(x)

anchor(x) <- value

arguments(x, ...)

arguments(x) <- value

func(x)

funcs(x)

# S4 method for Insertion anchor(x) <- value

# S4 method for Subtotal anchor(x) <- value

# S4 method for Heading anchor(x) <- value

# S4 method for SummaryStat anchor(x) <- value

# S4 method for Insertion,ANY subtotals(x) <- value

# S4 method for Insertion arguments(x) <- value

# S4 method for Subtotal arguments(x) <- value

# S4 method for Heading arguments(x) <- value

# S4 method for SummaryStat arguments(x) <- value

# S4 method for Insertion arguments(x)

# S4 method for Subtotal arguments(x, var_items)

# S4 method for Heading arguments(x)

# S4 method for SummaryStat arguments(x, var_items)

# S4 method for Insertion anchor(x, ...)

# S4 method for Subtotal anchor(x, var_items)

# S4 method for Heading anchor(x, var_items)

# S4 method for SummaryStat anchor(x, var_items)

# S4 method for Insertion func(x)

# S4 method for Subtotal func(x)

# S4 method for Heading func(x)

# S4 method for SummaryStat func(x)

# S4 method for Insertions anchors(x)

# S4 method for Insertions funcs(x)

Arguments

...

additional arguments to [, ignored

data

For the constructor functions Insertion and Insertions, you can either pass in attributes via ... or you can create the objects with a fully defined list representation of the objects via the data argument. See the examples.

x

For the attribute getters and setters, an object of class Insertion or Insertions

value

For [<-, the replacement Insertion to insert

var_items

categories (from categories()) or subvariables (from subvariables() to used by the arguments and anchor methods when needed to translate between category/subvariable names and category ids/aliases.

Working with Insertions

Insertions are used to add information about a variable or CrunchCube that extends the data in the dataset but does not alter it. This new data includes: aggregations like subtotals that sum the count of more than on category together or headings which can be added between categories.

Insertions objects are containers for individual Insertion objects. The individual Insertions contain all the information needed to calculate, apply, and display insertions to CrunchCubes and categorical variables.

An Insertion must have two properties:

  • anchor - which is the id of the category the insertion should follow

  • name - the string to display

Additionally, Insertions may also have the following two properties (though if they have one, they must have the other):

  • function - the function to use to aggregate (e.g. "subtotal")

  • args - the category ids to use as operands to the function above.

Although it is possible to make both subtotals and headings using Insertion alone, it is much easier and safer to use the functions Subtotal() and Heading() instead. Not only are they more transparent, they also are quicker to type, accept both category names as well as ids, and have easier to remember argument names.