View source: R/auggrid_util.bare.R
arow | R Documentation |
Return the row numbers associated with a specified table part or element, or with a set of row header values, within the augmented row-column grid of a table.
arow(x, id=NULL, hpath=NULL)
x |
A |
id |
Character scalar containing the ID of a single table part, block, entry,
or hvrule. (If |
hpath |
Character vector with length between 0 and the number of layers in the row
header. The |
See the documentation for adim
for more information about the
augmented row-column grid of a table.
Only one of arguments id
and hpath
should be specified.
id
is searched for first among table parts (the only thing
available for a textTable
), then blocks, entries, and hvrules, in
that order. The search stops at the first match. It is an error if
id
is not found in any of these.
hpath
is short for "header path". It is used to obtain row numbers
associated with specified combinations of values of the row header
variables. Suppose there are L
layers of row headers. If the
length of hpath
is less than L
, NA values are added at the
end to reach that length. The function returns the intersection of the
row numbers for which the i
-th outermost of the header layers
equals the i
-th element of hpath
. An NA in hpath
is
taken to match all values in the correponding layer of row headers. Thus,
if L == 4
and hpath=c("a", NA, "c")
, the function will
return the row numbers for which the outermost row header has a value of
"a" _and_ the third outermost has a value of "c". If no row has the
combination of values specified by hpath
then the returned vector
will have length 0.
Since hpath
refers to values of row header variables, it cannot be
used to get row numbers associated with table annotation, or with the
column header. (Use id
instead.)
A numeric vector containing row numbers within the table's augmented
row-column grid. The row numbers are those partially or completely
occupied by the cells associated with id
or hpath
. They
will be increasing but not necessarily consecutive.
The returned vector may have length 0 if id
refers to a table part
or block that spans no rows, or if hpath
matches no set of row
header values.
Note that for a horizontal hvrule (hrule), the "row number" is actually a
half-integer, bracketed by the table row numbers between which the hrule
runs. For example, if the hrule runs between table rows 3 and 4, the
returned value will be c(3.5)
.
adim
to get the dimensions of the augmented row-column grid;
acol
for the corresponding operation on columns;
ids
ttbl <- textTable(iris2_tab, title=c("Title 1", "2nd title"), foot="Foot")
plt <- plot(ttbl)
arow(plt, id="title") # block "title" spans first two rows
arow(plt, id="body,4,2") # single entry
# Remove the first line of the column header:
plot(ttbl[-arow(ttbl, id="colhead")[1], ])
# Remove the "versicolor" species (a value in row header layer 1):
plot(ttbl[-arow(ttbl, hpath=c("versicolor")), ])
# Remove the means for all species (a value in row header layer 2):
plot(ttbl[-arow(ttbl, hpath=c(NA, "mean")), ])
# Remove the mean just for the versicolor species:
plot(ttbl[-arow(ttbl, hpath=c("versicolor", "mean")), ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.