Learn R Programming

broman (version 0.59-5)

excel_fig: 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, cellwidth = 80, cellheight = 26, textsize = 16,
  fig_width, fig_height, border = "#CECECE", headcol = "#E9E9E9",
  headborder = "#969696", headtextcol = "#626262", textcol = "black",
  row_names = FALSE, col_names = TRUE, hilitcells, hilitcolor = "#F0DCDB",
  lwd = 1, direct2svg = FALSE)

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 missing, taken from cellwidth); ignored when direct2svg=FALSE
fig_height
Height of figure, in pixels (if missing, 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 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
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 cat.

Examples

Run this code
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)

Run the code above in your browser using DataLab