Methods Available in 'squarebrackets'
Source:R/aaa01_squarebrackets_methods.R
aaa01_squarebrackets_methods.RdThis help page gives an overview of the methods available in 'squarebrackets'.
Main Methods
The main methods of 'squarebrackets' use the naming convention <indexform>_<operation>: <indexform> tells you what form of indices the method uses; <operation> tells you what operation is performed.
For the <indexform> part, the following is available:
ii_: operates on subsets of atomic/recursive vectors/arrays by interior indices.ss_: operates on subsets of atomic/recursive arrays of any dimensionality by subscripts.sbt_: operates on subsets of data.frames and atomic/recursive matrices by tabular indices.slice_: uses index-less, sequence-based, and efficient operations on (mutatomic) long vectors.slicev_: uses index-less & value-based and efficient operations on (mutatomic) long vectors.
For the <operation> part, the following is available:
_x: extract, exchange, or duplicate (if applicable) subsets._wo: returns the original object without the provided subsets._mod: modify subsets and return copy._set: modify subsets using pass-by-reference semantics.
To illustrate, let's take the methods used for extracting subsets
(_x):
If
yis a vector or array (of any dimension),ii_x(y, i)corresponds toy[i].If
yis a 3d array,ss_x(y, n(i, k), c(1, 3))corresponds toy[i, , k, drop = FALSE].If
yis a matrix or data.frame-like object,sbt_x(y, i, j)corresponds toy[i, j, drop = FALSE].
Other Methods
Besides the main methods, 'squarebrackets' provides some additional methods that do not neatly fit into the above methods.
First, there is the lst_ set of methods,
which deal with sub-set operations that are only relevant for (nested) lists,
but not for the other types of supported objects.
Second, there is idx method,
which works on both recursive and non-recursive objects,
and transforms/translates indices to be used in R's default copy-on-modify semantics.
Finally, there are the sb_ sets of methods,
which cover miscellaneous operations for atomic/recursive objects.
Finding the Appropriate Help Pages
With knowledge of the naming convention of the main methods,
one can easily find out information about a particular method by usign the ? operator.
So to find out about modifying objects by subscripts using Pass-by-Reference semantics,
type in: ?ss_set