Skip to contents

Convert dataframe into ggplot object table

Usage

tbl_to_plot(
  datain,
  xvar = "XVAR",
  yvar,
  labelvar = yvar,
  colorvar = xvar,
  colors = rep("black", 10),
  text_size = 2.4,
  axis_opts = list(xsize = 8, xtsize = 6, xaxis_label = "")
)

Arguments

datain

Input dataframe

xvar

X axis variable, acts as table columns

yvar

Y axis variable, acts as values within columns

labelvar

Label variable

colorvar

Variable to color values by

colors

Vector of colors to be used per colorvar

text_size

Size of text printed in 'table'

axis_opts

Axis options, list containing xsize, and xaxis_label for X axis title; Include xtsize element for ticks (column headers).

Value

ggplot object

Examples

MPG <- ggplot2::mpg
MPG[["cyl"]] <- as.character(MPG[["cyl"]])
tbl_to_plot(
  MPG,
  "cyl",
  "manufacturer",
  "manufacturer"
)