addHvrule: Add a Horizontal or Vertical Rule (Hvrule) to a Table

Description Usage Arguments Details Value See Also Examples

View source: R/addHvrule.bare.R


Add a horizontal or vertical rule (hvrule) to a table. The location, span, and graphical properties of the hvrule are specified explicitly, rather than being generated automatically from the logical structure of the table and a style.


addHvrule(x, direction, arows, acols, id, props=NULL, enabled=TRUE)



A plotted table (pltdTable) object.


Character string specifying whether the rule is to be horizontal (hrule) or vertical (vrule).

arows, acols

Numeric vectors specifying the location and span of the hvrule, with respect to the augmented row-column grid of the table. For an hrule, arows should be a single value: the half-integer bracketed by the table rows between which the rule runs. For example, an hrule running between rows 3 and 4 should have arows equal to 3.5. acols should be a vector of integers whose range specifies the column numbers spanned by the rule. For a vrule the roles of arows and acols are reversed: arows is a vector of integers whose range specifies the row numbers spanned by the rule, and acols is the half-integer bracketed by the table columns between which it runs.


Character string giving the ID to be assigned to the new hvrule. It is an error if there is already an hvrule with this ID in x. The default is to generate an ID of the form hvrule*, where * is an integer.


Optional element_hvrule object with graphical properties to assign to the new hvrule. Any graphical properties not specified in props will be taken from hvruleStyle_pkg_base in styles_pkg.


Logical scalar, whether the new hvrule is to be enabled for display. The default is TRUE.


Normally hvrules are generated automatically, based on the logical structure of the table and the style selected by the user. This function allows additional hvrules to be added "manually", explicitly specifying their position and span in terms of row and column numbers.

Row and column numbers are with respect to the augmented row-column grid of the table. See ?adim for more more information about this grid. The helper functions arow and acol can be used to specify arguments arows and acols in terms of table parts or previously defined blocks.

For an hrule, the default for acols is to span all table columns. For a vrule, the default for arows is to span the rows containing the body and column headers, but not the annotation.

Graphical properties for hvrules defined by this function will not be changed if a new hvrule style is applied to the plotted table. Use one of the props<- functions instead.

There is no way to remove an hvrule, other than recreating the plotted table object from scratch. However they can be disabled using a props<- function, and then will not be displayed or take up any space.


A plotted table object like x, with the new hvrule added.

See Also

arow, acol, adim, element_hvrule


plt <- plot(iris2_tab, title="The iris data")
plt <- addHvrule(plt, direction="vrule", acols=4.5, arows=arow(plt, "body"), 
                 props=element_hvrule(linetype=2, color="red"), enabled=TRUE)
# Can refer to the new hvrule by its ID:
props(plt, id="new_vrule") <- element_hvrule(enabled=FALSE)  # don't display it

tablesgg documentation built on June 3, 2021, 1:06 a.m.