Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

spec_pointrange

Helper functions to generate inline sparklines


Description

These functions helps you quickly generate sets of sparkline style plots using base R plotting system. Currently, we support histogram, boxplot, line, scatter and pointrange plots. You can use them together with column_spec to generate inline plot in tables. By default, this function will save images in a folder called "kableExtra" and return the address of the file.

Usage

spec_pointrange(
  x,
  xmin,
  xmax,
  vline = NULL,
  width = 200,
  height = 50,
  res = 300,
  same_lim = TRUE,
  lim = NULL,
  xaxt = "n",
  yaxt = "n",
  ann = FALSE,
  col = "red",
  cex = 0.3,
  frame.plot = FALSE,
  dir = if (is_latex()) rmd_files_dir() else tempdir(),
  file = NULL,
  file_type = if (is_latex()) "pdf" else svglite::svglite,
  ...
)

Arguments

x, xmin, xmax

A scalar value or List of scalar values for dot, left and right errorbar.

vline

A scalar value for where to draw a vertical line.

width

The width of the plot in pixel

height

The height of the plot in pixel

res

The resolution of the plot. Default is 300.

same_lim

T/F. If x is a list of vectors, should all the plots be plotted in the same range? Default is True.

lim

Manually specify plotting range in the form of c(0, 10).

xaxt

On/Off for xaxis text

yaxt

On/Off for yaxis text

ann

On/Off for annotations (titles and axis titles)

col

Color for the fill of the histogram bar/boxplot box.

cex

size of the mean dot and error bar size.

frame.plot

T/F for whether to plot the plot frames.

dir

Directory of where the images will be saved.

file

File name. If not provided, a random name will be used

file_type

Graphic device. Can be character (e.g., "pdf") or a graphics device function (grDevices::pdf). This defaults to "pdf" if the rendering is in LaTeX and "svg" otherwise. for HTML output

...

extra parameters sending to hist()


kableExtra

Construct Complex Table with 'kable' and Pipe Syntax

v1.3.4
MIT + file LICENSE
Authors
Hao Zhu [aut, cre] (<https://orcid.org/0000-0002-3386-6076>), Thomas Travison [ctb], Timothy Tsai [ctb], Will Beasley [ctb], Yihui Xie [ctb], GuangChuang Yu [ctb], Stéphane Laurent [ctb], Rob Shepherd [ctb], Yoni Sidi [ctb], Brian Salzer [ctb], George Gui [ctb], Yeliang Fan [ctb], Duncan Murdoch [ctb], Bill Evans [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.