create_table_graphic: Function creates a graphic table from a data frame

View source: R/create_table_graphic.R

create_table_graphicR Documentation

Function creates a graphic table from a data frame

Description

Function creates a simple, non-scrollable static table to be laid out with other ggplot2 graphics. The functoin is based on grid along with the gtable package. Use grid::grid.draw() to draw the returned grob object or use RplotterPkg::multi_panel_grid() to incorporate it with other ggplot2 plot objects as shown in the demo for this function in the table_graphic folder.

Usage

create_table_graphic(
  df,
  table_width = 8,
  head_color = "black",
  head_fill = "white",
  head_font_sz = 14,
  cell_color = "black",
  cell_fill = "white",
  cell_font_sz = 11,
  cell_just = "center",
  cell_hor_pos = 0.5,
  title = NULL,
  title_font_sz = 16,
  show_row_names = TRUE,
  row_names_width = 0.5,
  display_plot = TRUE
)

Arguments

df

The target data frame from which to graph.

table_width

The overall table width in inches.

head_color

Color of the headings foreground.

head_fill

Color of the headings background.

head_font_sz

Font size of the headings.

cell_color

Color of the cells foreground.

cell_fill

Color of the cells background.

cell_font_sz

Font size of the cells.

cell_just

An string that sets justification of the cell content. Acceptable values are “left” and “right” and “center”.

cell_hor_pos

A numeric that sets the starting horizontal location of text in a cell. Acceptable range from 0.0 to 1.0.

title

A string that sets the table title.

title_font_sz

Font size of the title.

show_row_names

A logical that controls the appearance of row names in the data frame.

row_names_width

The width of the column for row names in inches.

display_plot

A logical that if TRUE will display the plot

Details

For estimating the overall height of the table consider that each row of the table is 0.2 inches high, .54 inches for heading and if a title is defined then add an additional 0.5 inches.

Value

A grob object. Note that if display_plot is set to FALSE, then to produce graphical output you must use grid::grid.draw() on the returned grob object.

Author(s)

Rick Dean


deandevl/RplotterPkg documentation built on Feb. 1, 2024, 8:02 p.m.