excel_fig: Excel-style figure displaying contents of a matrix

View source: R/excel_fig.R

excel_figR Documentation

Excel-style figure displaying contents of a matrix

Description

Turn a matrix of data into an SVG of how it might look in Excel

Usage

excel_fig(
  mat,
  file = NULL,
  cellwidth = 80,
  cellheight = 26,
  textsize = 16,
  fig_width = NULL,
  fig_height = NULL,
  border = "#CECECE",
  headcol = "#E9E9E9",
  headborder = "#969696",
  headtextcol = "#626262",
  textcol = "black",
  row_names = FALSE,
  col_names = TRUE,
  hilitcells = NULL,
  hilitcolor = "#F0DCDB",
  lwd = 1,
  direct2svg = FALSE,
  mar = rep(0.1, 4)
)

Arguments

mat

A matrix

file

Optional file name (must have extension .svg, .png, .jpg, or .pdf)

cellwidth

Width of each cell, in pixels

cellheight

Height of each cell, in pixels

textsize

Size for text (if file is provided or direct2svg=TRUE)

fig_width

Width of figure, in pixels (if NULL, taken from cellwidth); ignored when direct2svg=FALSE

fig_height

Height of figure, in pixels (if NULL, taken from cellheight); ignored when direct2svg=FALSE

border

Color of border of cells for the body of the matrix

headcol

Background color of cells on the top and left border

headborder

Color of border of cells on the top and left border

headtextcol

Color of text in cells on the top and left border

textcol

Color of text in cells in body of the matrix

row_names

If TRUE, and row names are present, include them as a first column

col_names

If TRUE, and column names are present, include them as a first row

hilitcells

Optional character vector of cells to highlight, like "A1" or "D4"

hilitcolor

Color to highlight cells, a vector of length 1 or the same length as hilitcells

lwd

Line width for rectangles

direct2svg

If TRUE, rather than R graphics, just print an SVG directly with base::cat().

mar

Plot margins, passed to graphics::par().

Examples

df <- data.frame(id=    c(101,  102,  103),
                 sex=   c("M",  "F",  "M"),
                 weight=c(22.3, 15.8, 19.7),
                 stringsAsFactors=FALSE)
excel_fig(df, col_names=TRUE)

broman documentation built on May 29, 2024, 7:18 a.m.

Related to excel_fig in broman...