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.

All functions