blob: 9deb046a553531940b5626c8434310168bafccfc [file] [log] [blame]
Hao Zhu5fe235c2020-08-26 00:26:49 -04001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/mini_plots.R
3\name{spec_hist}
4\alias{spec_hist}
5\alias{spec_boxplot}
6\title{Helper functions to generate inline sparklines}
7\usage{
8spec_hist(
9 x,
10 width = 200,
11 height = 50,
12 res = 300,
13 breaks = "Sturges",
14 same_lim = TRUE,
15 lim = NULL,
16 xaxt = "n",
17 yaxt = "n",
18 ann = FALSE,
19 col = "lightgray",
20 border = NULL,
21 dir = if (is_latex()) rmd_files_dir() else tempdir(),
22 file = NULL,
23 file_type = if (is_latex()) "png" else "svg",
24 ...
25)
26
27spec_boxplot(
28 x,
29 width = 200,
30 height = 50,
31 res = 300,
32 add_label = FALSE,
33 label_digits = 2,
34 same_lim = TRUE,
35 lim = NULL,
36 xaxt = "n",
37 yaxt = "n",
38 ann = FALSE,
39 col = "lightgray",
40 border = NULL,
41 boxlty = 0,
42 medcol = "red",
43 medlwd = 1,
44 dir = if (is_latex()) rmd_files_dir() else tempdir(),
45 file = NULL,
46 file_type = if (is_latex()) "png" else "svg",
47 ...
48)
49}
50\arguments{
51\item{x}{Vector of values or List of vectors of values.}
52
53\item{width}{The width of the plot in pixel}
54
55\item{height}{The height of the plot in pixel}
56
57\item{res}{The resolution of the plot. Default is 300.}
58
59\item{breaks}{one of:
60 \itemize{
61 \item a vector giving the breakpoints between histogram cells,
62 \item a function to compute the vector of breakpoints,
63 \item a single number giving the number of cells for the histogram,
64 \item a character string naming an algorithm to compute the
65 number of cells (see \sQuote{Details}),
66 \item a function to compute the number of cells.
67 }
68 In the last three cases the number is a suggestion only; as the
69 breakpoints will be set to \code{\link{pretty}} values, the number
70 is limited to \code{1e6} (with a warning if it was larger). If
71 \code{breaks} is a function, the \code{x} vector is supplied to it
72 as the only argument (and the number of breaks is only limited by
73 the amount of available memory).
74 }
75
76\item{same_lim}{T/F. If x is a list of vectors, should all the plots be
77plotted in the same range? Default is True.}
78
79\item{lim}{Manually specify plotting range in the form of \code{c(0, 10)}.}
80
81\item{xaxt}{On/Off for xaxis text}
82
83\item{yaxt}{On/Off for yaxis text}
84
85\item{ann}{On/Off for annotations (titles and axis titles)}
86
87\item{col}{Color for the fill of the histogram bar/boxplot box.}
88
89\item{border}{Color for the border.}
90
91\item{dir}{Directory of where the images will be saved.}
92
93\item{file}{File name. If not provided, a random name will be used}
94
95\item{file_type}{Graphic device. Support \code{png} or \code{svg}. SVG is recommended
96for HTML output}
97
98\item{...}{further arguments and \link[graphics]{graphical parameters} passed to
99 \code{\link[graphics]{plot.histogram}} and thence to \code{\link[graphics]{title}} and
100 \code{\link[graphics]{axis}} (if \code{plot = TRUE}).}
101
102\item{add_label}{For boxplot. T/F to add labels for min, mean and max.}
103
104\item{label_digits}{If T for add_label, rounding digits for the label.
105Default is 2.}
106
107\item{boxlty}{Boxplot - box boarder type}
108
109\item{medcol}{Boxplot - median line color}
110
111\item{medlwd}{Boxplot - median line width}
112}
113\description{
114These functions helps you quickly generate sets of sparkline
115style plots using base R plotting system. Currently, we support histogram
116and boxplot. You can use them together with \code{column_spec} to
117generate inline plot in tables. By default, this function will save images
118in a folder called "kableExtra" and return the address of the file.
119}