Category
Function
Categorizes components of a field
Syntax
output = Categorize(input, name, sort);
Inputs
Name | Type | Default | Description |
---|---|---|---|
input | field | none | field to categorize |
name | string or string list | "data" | component to categorize |
sort | flag | 1 | 0: don't sort the added lookup component 1: sort the added lookup component |
Outputs
Name | Type | Description |
---|---|---|
output | field | with additional lookup components |
Functional Details
input | is the field containing the components to categorize |
name | is the name or names of the components to categorize |
sort | specifies whether the newly created lookup component should be sorted or left in insertion order when it is created. |
The Categorize module converts a component of any type to an integer array that references a newly created "lookup" component, which is a list of the unique values in the original component. This serves to
Each component that is categorized will yield its own lookup component named "compname lookup", where compname is the name of the categorized component.
For example, if the component name is "state" and its values are {"MO", "CA", "MO", "NH", "AK", "NH"} then Categorize(field, "state", 1) would convert component state to: {2, 1, 2, 3, 0, 3} and produce a new component, "state lookup" containing the values {"AK", "CA", "MO", "NH"} or Categorize(field, "state", 0) would convert component state to: {0, 1, 0, 2, 3} and produce a new component, "state lookup" containing the values {"MO", "CA", "NH", "AK"}
Notes:
Components
Modifies the components specified by name, replacing it by a list of indices. Adds a new component with the name "name lookup" which is a lookup table for component name.
Example Visual Programs
Duplicates.net Categorical.net (Categorize is called on import by ImportSpreadsheet)
See Also
CategoryStatistics, ImportSpreadsheet
[ OpenDX Home at IBM | OpenDX.org ]