Find Indices into 1 or 2-dim Dataset

DESCRIPTION:

Gives numerical indices into a 1- or 2-dimensional dataset corresponding to various index specifications.

USAGE:

index.rowcol(x, select.spec, which="columns", row.names=name.rows(x),
             col.names=name.cols(x), row.count=count.rows(x),
             col.count=count.cols(x), is.target.index=F,
             return.list=F)

REQUIRED ARGUMENTS:

x
a 1- or 2- dimensional dataset whose indices corresponding to select.spec will be returned. A 1-dimensional dataset is considered to be a single, unnamed column of length() rows.
select.spec
vector of index specifications for x, which can be of mode "logical", "numeric", and/or "character". To specify all rows or columns of x, use "@ALL" or ""; to specify the last row or column (plus one if is.target.index=T) of x, use "@END" or "". For mode "character", ranges (such as "Weight:Mileage") will be accepted, so long as both substrings on either side of the ":" are matched. Expressions that reference a column name of x do not need to use subscripting (e.g., reals > algebra - 2 may be used instead of testscores[,"reals"] > testscores[,"algebra"] - 2).

OPTIONAL ARGUMENTS:

which
character value, either "columns" (the default) or "rows", specifying whether to return indices of the columns or rows of x.
row.names
character vector specifying potential matches for select.spec if which="rows". The default is name.rows(x).
col.names
character vector specifying potential matches for select.spec if which="columns". The default is name.cols(x).
row.count
integer value specifying the index of the last row of x. The default is count.rows(x).
col.count
integer value specifying the index of the last column of x. The default is count.cols(x).
is.target.index
logical flag: if TRUE, then for each element of select.spec which is either "@END" or "", the corresponding return value will be row.count (if which="rows") or col.count (if which="columns") plus one; if FALSE, the corresponding return value will be row.count or col.count. Also if TRUE, then for each element of select.spec which is a character value not matching any of row.names (if which="rows") or col.names (if which="columns"), the corresponding return value will be row.count or col.count plus one and will be given the non-matching name as a name attribute.
return.list
logical flag: if TRUE, the return value will be of mode "list".

VALUE:

(if return.list=T, a list of) integer vector(s) the length of the matches in x of select.spec, and whose values are the index into x that is specified by the corresponding matching element of select.spec.

SEE ALSO:

, , , .

EXAMPLES:

# gives c(14, 16, 52, 53)
index.rowcol(fuel.frame, fuel.frame$Disp. > 300, which="rows")
# gives c(3, 2, 1)
index.rowcol(fuel.frame, "Mileage:Weight")
# gives numeric(0)
index.rowcol(fuel.frame, "Tires")
# gives structure(.Data = 6, .Names = "Tires")
index.rowcol(fuel.frame, "Tires", is.target.index=T)
# gives list(c(2), c(1, 2, 3, 4, 5))
index.rowcol(fuel.frame, list(2, "@ALL"), return.list=T)