Catrows

 

Description

Returns a pipe-separated list of all row indices by category, to a worksheet column.

Syntax

stringArray Catrows(vd,[option])$

Parameter

vd

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

option

option=0 (default, if not present), current result, return a dataset of all indexes
option=1, return a dataset containing 1st index of each category
option=2, return a dataset containing last index of each category

Return

Returns a pipe-separated listing of all row indices by category of a categorical column vd.

Example

EX1

//fill col(A) with "q w q w q", and set as categorical
col(B)=Catrows(col(A))$;
//1|3|5 //rows of q
//2|4 //rows of w

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;
// get column 2 into range variable rA
range rA = [automobile]automobile!"Make";
// create a new book and use category function to copy categories in rA to column A of newbook
// to column B, add row indices of occurrence for each category, as a pipe-separated list 
// increase column width for visibility
newbook;
col(A)=category(rA)$;
col(B)=catrows(rA)$;
wks.col2.Width=50;

See Also

Category, Catindex, Cattext, text2cols (X-Function)