Learn R Programming

Presentation-Quality Tables, Displayed Using ggplot2

tablesgg is an R package that displays presentation-quality tables as plots on an R graphics device. Although there are other packages that format tables for display, this package is unique in combining two features:

  • It is aware of the logical structure of the table being presented, and makes

use of that for automatic layout and styling of the table. This avoids the need for most manual adjustments to achieve an attractive result.

  • It displays tables using ggplot2 graphics. Therefore a table can

be presented anywhere a graph could be, with no more effort. External software such as LaTeX or HTML or their viewers is not required.

Methods are included to display matrices; data frames; tables created by R's ftable(), table(), and xtabs() functions; and tables created by the tables and xtable packages. Methods can be added to display other table-like objects.

Other package features:

  • A full set of tools is provided to control the appearance

of tables, including titles, footnotes and reference marks, horizontal and vertical rules, and spacing of rows and columns. Many properties can be set automatically by specifying styles. Default styles are included, and the user can define custom styles.

  • There are tools for low-level manipulation of the appearance of

individual table elements if desired.

  • All sizes and dimensions in displayed tables are specified in physical

units (points for font size, millimeters for everything else). Therefore a plotted table has a well-defined physical size, independent of the size of the graphics device on which it is displayed. The user can easily increase or decrease the displayed size by a scale factor, maintaining the relative proportions of table elements.

  • Since the plotted tables are ordinary ggplot objects,

the facilities of ggplot2 and its various extension packages are available to modify or manipulate the table. For example, the table can be inserted as an image within another plot.

A vignette is included that illustrates usage and options available in the package.

Copy Link

Version

Install

install.packages('tablesgg')

Monthly Downloads

184

Version

0.9-1

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Richard Raubertas

Last Published

January 27th, 2024

Functions in tablesgg (0.9-1)

as.tblEntries

Promote a Data Frame to a tblentries Object
element_block

Specify Visual Properties for Table Blocks
element_hvrule

Specify Visual Properties for Table Rules
element_entry

Specify Visual Properties for Table Entries and their Cells
element_refmark

Specify a Reference Mark that can be Added to Table Entries
entries<-

Update the Table Entries of a Plot-Ready or Plotted Table
coord_justif

Calculate X, y Positions and H|vjust Values for Entries
elements

Extract Table Elements from a Plotted Table
df_from_spec

Create a Data Frame from a Specification
dfSpecs

Specifications for Fields Used in Certain Object Classes
calc_rcsize

Constrained Display Sizes of Each Table Row, Column and Entry
eval_conditions

Evaluate a Set of Logical Conditions Within a Data Frame
entries

Extract the prentries Object from a Plot-Ready or Plotted Table
hvrules<-

Update the Hvrules of a Plot-Ready or Plotted Table
grSpecs

Specifications for Graphical Properties for an Element Type
entries_by_block

Find the Entries that are Contained Within a Set of Table Blocks
format_xtable

Format Entries in an xtable into Character Strings
headerRuns

Runs of Repeated Values in a Header Matrix
hvrules

Extract the prhvrules Object from a Plot-Ready or Plotted Table
make_rowgroups

Group Rows of a Table into Sets of Fixed Size
iris2_tab

Table of Summary Statistics for Anderson's Iris Data
fill_NA_idx

Indices to Impute NA Elements of a Vector by LOCF
entrySize_mm

Calculate the Sizes of Table Entries, in Mm
notANumber

Identify Strings that Cannot be Interpreted as Numbers
make_header_entries

Convert a Matrix of Headers to Table Entries, with Merging of Runs
paste_text

Paste Strings that may Include plotmath or Markdown
plot.tblEntries

A Plot Method for tblentries Objects
plot.textTable

A Plot Method for texttable Objects
plot.pltdTable

Display a pltdtable Object on a Graphics Device
plot.prTable

A Plot Method for prtable Objects
mtcars_xtab

Table of Data from Motor Trend Magazine
print.pltdTable

Print (Draw) a pltdtable Object
plot.tabular

A Plot Method for tabular Objects
pltdSize

Width and Height of a pltdtable Object
prTable.pltdTable

Extract/Update a Plot-Ready Table from a Plotted Table
prHvrules

Create Hvrules and Assign Them Graphical Properties
prEntries

Assign Graphical Properties to Table Entries
ids

Get the Identifier Strings for Parts or Elements of a Table
props<-

Update Graphical Properties for Selected Table Elements
plot.prEntries

A Plot Method for prentries Objects
prBlocks

Assign Graphical Properties to Table Blocks
print.summary.textTable

Print the Dimensions of a Table and Its Parts
prTable

Create or Update a Fully Styled Table Ready for Plotting
propsa<-

Update Graphical Properties for Selected Table Elements
propsd<-

Update Graphical Properties for Selected Table Elements
iris2

A Reshaped Version of Anderson's Iris Data
props_mod

Update Graphical Properties for Selected Table Elements
rowhead_inside

Move the Outermost Layer of Row Headers Inside a Table
print.summary.pltdTable

Print the Dimensions and Display Options of a Plotted Table
prTable.prEntries

Create a Plot-Ready Table from Plot-Ready Entry, Block, and Hvrule Objects
sci_fmt_pm

Convert ASCII Scientific Notation into plotmath Form
spec_from_text

textspec Values Based on String Prefixes
prefix_text

Add or Remove the Prefix Associated with textspec Values
summary.pltdTable

Summarize the Dimensions and Options of a Plotted Table
summary.textTable

Summarize the Dimensions of a Table and Its Parts
tablesggSetOpt

Set the Values of Package Options
styleObj

Create a Style Object
textTable.ftable

Create a texttable from an ftable
tablesgg-package

Presentation-Quality Tables, Displayed Using ggplot2
tablesggOpt

Get or Reset Package Options
tblHvrules

Create Horizontal and Vertical Rules for a Table
textTable.matrix

Create a texttable from a Matrix
tblEntries

Assemble Information About Each Entry in a Table into a Data Frame
tblParts

Extract Dimensions of the Various Parts of a Table
textTable

Create a Structure Representing a 2D Table
update.textTable

Update a texttable Object
textTable.table

Create a texttable from a table or xtabs Object
update.pltdTable

Update a pltdtable (Plotted Table) Object
textTable.tabular

Create a texttable from a tabular Object
undo_rowhead_inside

Reverse the Effect of rowhead_inside
textTable.xtableList

Create a texttable from an xtablelist Object
textTable.tblEntries

Reconstruct a texttable Object from a tblentries Object
styles_pkg

Built-In Styles for Table Elements
textTable.xtable

Create a texttable from an xtable Object
tblBlocks

Define Blocks of Cells that Reflect the Logical Structure of a Table
tli_xtab

Table of Test Scores and Demographics for 20 Students
textTable.data.frame

Create a texttable as a Simple Listing of a Data Frame
textTable.default

Create a texttable Object from a Suitable List
update.prObj

Update Style or Scale for Plot-Ready Table Elements
update.prTable

Update a prtable (Plot-Ready Table) Object
addBlock

Define a New Block of Cells in a Table
adim

Dimensions of the Augmented Row-Column Grid for a Table
acol

Column Numbers Within the Augmented Row-Column Grid for a Table
angle_adj

Horizontal and Vertical Dimensions of a Rectangle after Rotation
addRefmark

Add a Reference Mark to Entries in a Table
[.textTable

Extract a Subset of a texttable Object
addHvrule

Add a Horizontal or Vertical Rule (Hvrule) to a Table
arow

Row Numbers Within the Augmented Row-Column Grid for a Table
as.dfObj

Promote a Data Frame to Another Object Class
as.prBlocks

Promote a Data Frame to a prblocks Object
as.prEntries

Promote a Data Frame to a prentries Object
add_refmark

Add a Reference Mark to a Character Vector or Matrix
as.tblBlocks

Promote a Data Frame to a tblblocks Object
apply_style

Apply a Style to Table Elements
blocks

Extract the prblocks Object from a Plot-Ready or Plotted Table
blocks<-

Update the Blocks of a Plot-Ready or Plotted Table
as.prHvrules

Promote a Data Frame to a prhvrules Object
adjacent_blocks

Identify Adjacent Blocks of Table Cells
apply_scale

Apply a Scale Factor to Table Elements