subset

value(index)

value(index) = replacement

subset(value, [index])

subset(value, [index], replacement)

Try it yourself:


subset(): Selecting Part of a Collection

subset() extracts or updates a selected portion of an array, matrix, or object using indexes or ranges. It is useful for slicing data, choosing columns, and controlled replacement.

Index safely

Confirm dimensions with size() and verify index conventions before selecting. Use row() or column() for simple matrix slices, and range() to build an index sequence.

When modifying a subset, ensure replacement values have compatible shape. Use clone() first when the original data should remain available.

Try Subset in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions