Subscripting and Subsetting in R

Subscripting:

i. A subscript consisting of a vector of positive integer values is taken to indicate a set of indexes to be extracted.

ii. A subscript that is larger than the length of the vector being subsetted produces an NA in the returned value.

iii. Subscripts that are zero are ignored and produce no corresponding values in the result.

iv. Subscripts that are NA produce an NA in the result. If the subscript vector is of length zero, then so is the result.

Subsetting:

Subsetting plays two roles in the S language. One is an extraction role, where a subset of a vector is identified by a set of supplied indices and the resulting subset is returned as a value. Venables and Ripley (2000) refer to this as indexing.

The second purpose is subset assignment, where the goal is to identify a subset of values that should have their values changed; we call this subset assignment.