| Hao Zhu | 5fe235c | 2020-08-26 00:26:49 -0400 | [diff] [blame] | 1 | % 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} | 
| Bill Evans | cebc971 | 2020-08-30 19:55:24 -0700 | [diff] [blame] | 6 | \alias{spec_line} | 
| Hao Zhu | 5fe235c | 2020-08-26 00:26:49 -0400 | [diff] [blame] | 7 | \title{Helper functions to generate inline sparklines} | 
|  | 8 | \usage{ | 
|  | 9 | spec_hist( | 
|  | 10 | x, | 
|  | 11 | width = 200, | 
|  | 12 | height = 50, | 
|  | 13 | res = 300, | 
|  | 14 | breaks = "Sturges", | 
|  | 15 | same_lim = TRUE, | 
|  | 16 | lim = NULL, | 
|  | 17 | xaxt = "n", | 
|  | 18 | yaxt = "n", | 
|  | 19 | ann = FALSE, | 
|  | 20 | col = "lightgray", | 
|  | 21 | border = NULL, | 
|  | 22 | dir = if (is_latex()) rmd_files_dir() else tempdir(), | 
|  | 23 | file = NULL, | 
|  | 24 | file_type = if (is_latex()) "png" else "svg", | 
|  | 25 | ... | 
|  | 26 | ) | 
|  | 27 |  | 
|  | 28 | spec_boxplot( | 
|  | 29 | x, | 
|  | 30 | width = 200, | 
|  | 31 | height = 50, | 
|  | 32 | res = 300, | 
|  | 33 | add_label = FALSE, | 
|  | 34 | label_digits = 2, | 
|  | 35 | same_lim = TRUE, | 
|  | 36 | lim = NULL, | 
|  | 37 | xaxt = "n", | 
|  | 38 | yaxt = "n", | 
|  | 39 | ann = FALSE, | 
|  | 40 | col = "lightgray", | 
|  | 41 | border = NULL, | 
|  | 42 | boxlty = 0, | 
|  | 43 | medcol = "red", | 
|  | 44 | medlwd = 1, | 
|  | 45 | dir = if (is_latex()) rmd_files_dir() else tempdir(), | 
|  | 46 | file = NULL, | 
|  | 47 | file_type = if (is_latex()) "png" else "svg", | 
|  | 48 | ... | 
|  | 49 | ) | 
| Bill Evans | cebc971 | 2020-08-30 19:55:24 -0700 | [diff] [blame] | 50 |  | 
|  | 51 | spec_line( | 
|  | 52 | x, | 
|  | 53 | y = NULL, | 
|  | 54 | width = 200, | 
|  | 55 | height = 50, | 
|  | 56 | res = 300, | 
|  | 57 | same_lim = TRUE, | 
|  | 58 | xlim = NULL, | 
|  | 59 | ylim = NULL, | 
|  | 60 | xaxt = "n", | 
|  | 61 | yaxt = "n", | 
|  | 62 | ann = FALSE, | 
|  | 63 | col = "lightgray", | 
|  | 64 | border = NULL, | 
|  | 65 | frame.plot = FALSE, | 
|  | 66 | lwd = 2, | 
|  | 67 | minmax = list(pch = ".", cex = lwd, col = "red"), | 
|  | 68 | min = minmax, | 
|  | 69 | max = minmax, | 
|  | 70 | dir = if (is_latex()) rmd_files_dir() else tempdir(), | 
|  | 71 | file = NULL, | 
|  | 72 | file_type = if (is_latex()) "png" else "svg", | 
|  | 73 | ... | 
|  | 74 | ) | 
| Hao Zhu | 5fe235c | 2020-08-26 00:26:49 -0400 | [diff] [blame] | 75 | } | 
|  | 76 | \arguments{ | 
|  | 77 | \item{x}{Vector of values or List of vectors of values.} | 
|  | 78 |  | 
|  | 79 | \item{width}{The width of the plot in pixel} | 
|  | 80 |  | 
|  | 81 | \item{height}{The height of the plot in pixel} | 
|  | 82 |  | 
|  | 83 | \item{res}{The resolution of the plot. Default is 300.} | 
|  | 84 |  | 
|  | 85 | \item{breaks}{one of: | 
|  | 86 | \itemize{ | 
|  | 87 | \item a vector giving the breakpoints between histogram cells, | 
|  | 88 | \item a function to compute the vector of breakpoints, | 
|  | 89 | \item a single number giving the number of cells for the histogram, | 
|  | 90 | \item a character string naming an algorithm to compute the | 
|  | 91 | number of cells (see \sQuote{Details}), | 
|  | 92 | \item a function to compute the number of cells. | 
|  | 93 | } | 
|  | 94 | In the last three cases the number is a suggestion only; as the | 
|  | 95 | breakpoints will be set to \code{\link{pretty}} values, the number | 
|  | 96 | is limited to \code{1e6} (with a warning if it was larger).  If | 
|  | 97 | \code{breaks} is a function, the \code{x} vector is supplied to it | 
|  | 98 | as the only argument (and the number of breaks is only limited by | 
|  | 99 | the amount of available memory). | 
|  | 100 | } | 
|  | 101 |  | 
|  | 102 | \item{same_lim}{T/F. If x is a list of vectors, should all the plots be | 
|  | 103 | plotted in the same range? Default is True.} | 
|  | 104 |  | 
| Bill Evans | cebc971 | 2020-08-30 19:55:24 -0700 | [diff] [blame] | 105 | \item{lim, xlim, ylim}{Manually specify plotting range in the form of | 
|  | 106 | \code{c(0, 10)}. \code{lim} is used in \code{spec_hist} and \code{spec_boxplot}; \code{xlim} | 
|  | 107 | and \code{ylim} are used in \code{spec_line}.} | 
| Hao Zhu | 5fe235c | 2020-08-26 00:26:49 -0400 | [diff] [blame] | 108 |  | 
|  | 109 | \item{xaxt}{On/Off for xaxis text} | 
|  | 110 |  | 
|  | 111 | \item{yaxt}{On/Off for yaxis text} | 
|  | 112 |  | 
|  | 113 | \item{ann}{On/Off for annotations (titles and axis titles)} | 
|  | 114 |  | 
|  | 115 | \item{col}{Color for the fill of the histogram bar/boxplot box.} | 
|  | 116 |  | 
|  | 117 | \item{border}{Color for the border.} | 
|  | 118 |  | 
|  | 119 | \item{dir}{Directory of where the images will be saved.} | 
|  | 120 |  | 
|  | 121 | \item{file}{File name. If not provided, a random name will be used} | 
|  | 122 |  | 
|  | 123 | \item{file_type}{Graphic device. Support \code{png} or \code{svg}. SVG is recommended | 
|  | 124 | for HTML output} | 
|  | 125 |  | 
|  | 126 | \item{...}{further arguments and \link[graphics]{graphical parameters} passed to | 
|  | 127 | \code{\link[graphics]{plot.histogram}} and thence to \code{\link[graphics]{title}} and | 
|  | 128 | \code{\link[graphics]{axis}} (if \code{plot = TRUE}).} | 
|  | 129 |  | 
|  | 130 | \item{add_label}{For boxplot. T/F to add labels for min, mean and max.} | 
|  | 131 |  | 
|  | 132 | \item{label_digits}{If T for add_label, rounding digits for the label. | 
|  | 133 | Default is 2.} | 
|  | 134 |  | 
|  | 135 | \item{boxlty}{Boxplot - box boarder type} | 
|  | 136 |  | 
|  | 137 | \item{medcol}{Boxplot - median line color} | 
|  | 138 |  | 
|  | 139 | \item{medlwd}{Boxplot - median line width} | 
| Bill Evans | cebc971 | 2020-08-30 19:55:24 -0700 | [diff] [blame] | 140 |  | 
|  | 141 | \item{frame.plot}{On/Off for surrounding box (\code{spec_line} only). Default | 
|  | 142 | is False.} | 
|  | 143 |  | 
|  | 144 | \item{lwd}{Line width for \code{spec_line}; within \code{spec_line}, the \code{minmax} | 
|  | 145 | argument defaults to use this value for \code{cex} for points. Default is 2.} | 
|  | 146 |  | 
|  | 147 | \item{minmax, min, max}{Arguments passed to \code{points} to highlight minimum | 
|  | 148 | and maximum values in \code{spec_line}. If \code{min} or \code{max} are \code{NULL}, they | 
|  | 149 | default to the value of \code{minmax}. Set to an empty \code{list()} to disable.} | 
| Hao Zhu | 5fe235c | 2020-08-26 00:26:49 -0400 | [diff] [blame] | 150 | } | 
|  | 151 | \description{ | 
|  | 152 | These functions helps you quickly generate sets of sparkline | 
| Bill Evans | 5a383e5 | 2020-08-30 20:09:52 -0700 | [diff] [blame] | 153 | style plots using base R plotting system. Currently, we support histogram, | 
| Bill Evans | cebc971 | 2020-08-30 19:55:24 -0700 | [diff] [blame] | 154 | boxplot, and line. You can use them together with \code{column_spec} to | 
| Hao Zhu | 5fe235c | 2020-08-26 00:26:49 -0400 | [diff] [blame] | 155 | generate inline plot in tables. By default, this function will save images | 
|  | 156 | in a folder called "kableExtra" and return the address of the file. | 
|  | 157 | } |