3.5.8.2 Catindex


Description

Returns the category index for each element of a categorical column, to a worksheet column.

Syntax

vector Catindex(vector vd)

Parameter

vd

a vector (column of categorical data) in an Origin worksheet.

Return

Returns the category index for each element of a categorical column vd.

Example

EX1

//fill col(A) with "q w q e e", and set as categorical
col(B)=catindex(col(A));//1 2 1 3 3
wks.col1.categorical.sort=1;
col(B)=catindex(col(A));//2 3 2 1 1

EX2

// create an empty book
newbook; 
// import the file automobile.dat into the new book
impASC fname:="C:\Program Files\OriginLab\Origin2020b\Samples\Statistics\automobile.dat";
// set column 2 as categorical and sort it in ascending order
wks.col2.categorical.type=2;
wks.col2.categorical.sort=1;
// add a new column H and use catindex function to fill it with the corresponding category index of element in column A
col(H)=catindex(col(B));

See Also

Category, Catrows, Cattext