Access Data Using Categorical Arrays
In this section...
“Select Data By Category” on page 8-30
“Common Ways to Access Data Using Categorical Arrays” on page 8-30
Select Data By Category
Selecting data based on its values is often useful. This type of data selection can involve
creating a logical vector based on values in one variable, and then using that logical
vector to select a subset of values in other variables. You can create a logical vector for
selecting data by finding values in a numeric array that fall within a certain range.
Additionally, you can create the logical vector by finding specific discrete values. When
using categorical arrays, you can easily:
- Select elements from particular categories. For categorical arrays, use the logical
operators == or ~= to select data that is in, or not in, a particular category. To select
data in a particular group of categories, use the ismember function.
For ordinal categorical arrays, use inequalities >, >=, <, or <= to find data in
categories above or below a particular category.
- Delete data that is in a particular category. Use logical operators to include or
exclude data from particular categories. - Find elements that are not in a defined category. Categorical arrays indicate
which elements do not belong to a defined category by. Use the
isundefined function to find observations without a defined value.
Common Ways to Access Data Using Categorical Arrays
This example shows how to index and search using categorical arrays. You can access
data using categorical arrays stored within a table in a similar manner.
Load Sample Data
Load sample data gathered from 100 patients.
load patients
whos
8 Categorical Arrays