loc#

swordfish.function.loc()#

Access a group of rows and columns of a matrix by label(s) or a boolean vector.

Parameters:
  • obj (Constant) – A matrix object. It can be a standard matrix, an indexed series or an indexed matrix.

  • rowFilter (Constant) –

    Can be:

    • a Boolean vector - the rows/columns marked as true will be returned. The length of the vector must match the number of rows/columns of obj.

    • a scalar, a vector or a pair whose data type is compatible with the row/ column labels of obj. A pair indicates the selection range (both upper bound and lower bound are inclusive).

  • colFilter (Constant) –

    Can be:

    • a Boolean vector - the rows/columns marked as true will be returned. The length of the vector must match the number of rows/columns of obj.

    • a scalar, a vector or a pair whose data type is compatible with the row/ column labels of obj. A pair indicates the selection range (both upper bound and lower bound are inclusive).

    Note

    If rowFilter/colFilter is a pair, then obj must be an indexed series or an indexed matrix.

    Data type compatibility rules:

    • INT, SHORT, LONG and CHAR are compatible

    • FLOAT and DOUBLE are compatible

    • STRING and SYMBOL are compatible

  • view (Constant) – A Boolean value. The default value is false indicating the result will be a copy of the original matrix (deep copy). If set to true, the result will be a view on the original matrix (shallow copy) and changes made to the original matrix will be reflected in the view.

Returns:

A copy or a view of the original matrix.

Return type:

Constant