Access Data Using Categorical Arrays
In this section...
“Select Data By Category” on page 8-24
“Common Ways to Access Data Using Categorical Arrays” on page 8-24
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
Name
Size
Bytes Class
Attributes
Age
100x1
800 double
Diastolic
100x1
800 double
Gender
100x1
11412 cell
Height
100x1
800 double
LastName
100x1
11616 cell
Location
100x1
14208 cell
SelfAssessedHealthStatus
100x1
11540 cell
Smoker
100x1
100 logical
Systolic
100x1
800 double
Weight
100x1
800 double
8 Categorical Arrays
8-24
Précédent

- 328/1450

Suivant