8.2.59.69 table.restrict

Method: out = restrict (obj, expr)
Method: out = restrict (obj, ix)

Subset rows using variable expression or index.

Subsets a table row-wise, using either an index vector or an expression involving obj’s variables.

If the argument is a numeric or logical vector, it is interpreted as an index into the rows of this. (Just as with ‘subsetrows (this, index)‘.)

If the argument is a char, then it is evaulated as an M-code expression, with all of this’ variables available as workspace variables, as with evalWithVars. The output of expr must be a numeric or logical index vector (This form is a shorthand for out = subsetrows (this, evalWithVars (this, expr)).)

TODO: Decide whether to name this to "where" to be more like SQL instead of relational algebra.

Examples:

[s,p,sp] = table_examples.SpDb;
prettyprint (restrict (p, 'Weight >= 14 & strcmp(Color, "Red")'))