Merge branch 'master' of github.com:haozhu233/kableExtra
diff --git a/DESCRIPTION b/DESCRIPTION
index 59e15c5..a338828 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: kableExtra
Type: Package
Title: Construct Complex Table with 'kable' and Pipe Syntax
-Version: 1.2.1
+Version: 1.2.1.9000
Authors@R: c(
person('Hao', 'Zhu', email = 'haozhu233@gmail.com', role = c('aut', 'cre'),
comment = c(ORCID = '0000-0002-3386-6076')),
diff --git a/R/mini_plots.R b/R/mini_plots.R
index 8f13706..e1c65d3 100644
--- a/R/mini_plots.R
+++ b/R/mini_plots.R
@@ -12,34 +12,19 @@
#' @param res The resolution of the plot. Default is 300.
#' @param same_lim T/F. If x is a list of vectors, should all the plots be
#' plotted in the same range? Default is True.
-#' @param lim,xlim,ylim Manually specify plotting range in the form of
-#' `c(0, 10)`. `lim` is used in `spec_hist` and `spec_boxplot`; `xlim`
-#' and `ylim` are used in `spec_line`.
+#' @param lim Manually specify plotting range in the form of
+#' `c(0, 10)`.
#' @param xaxt On/Off for xaxis text
#' @param yaxt On/Off for yaxis text
#' @param ann On/Off for annotations (titles and axis titles)
#' @param col Color for the fill of the histogram bar/boxplot box.
#' @param border Color for the border.
-#' @param frame.plot On/Off for surrounding box (`spec_line` only). Default
-#' is False.
-#' @param lwd Line width for `spec_line`; within `spec_line`, the `minmax`
-#' argument defaults to use this value for `cex` for points. Default is 2.
-#' @param minmax,min,max Arguments passed to `points` to highlight minimum
-#' and maximum values in `spec_line`. If `min` or `max` are `NULL`, they
-#' default to the value of `minmax`. Set to an empty `list()` to disable.
#' @param dir Directory of where the images will be saved.
#' @param file File name. If not provided, a random name will be used
#' @param file_type Graphic device. Support `png` or `svg`. SVG is recommended
#' for HTML output
-#' @param add_label For boxplot. T/F to add labels for min, mean and max.
-#' @param label_digits If T for add_label, rounding digits for the label.
-#' Default is 2.
-#' @param boxlty Boxplot - box boarder type
-#' @param medcol Boxplot - median line color
-#' @param medlwd Boxplot - median line width
+#' @param ... extra parameters sending to `hist()`
#'
-#' @inheritParams graphics::hist
-#' @inheritParams graphics::boxplot
#' @export
spec_hist <- function(x, width = 200, height = 50, res = 300,
breaks = "Sturges",
@@ -104,7 +89,40 @@
return(out)
}
-#' @rdname spec_hist
+#' 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, and line. 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.
+#'
+#' @param x Vector of values or List of vectors of values.
+#' @param width The width of the plot in pixel
+#' @param height The height of the plot in pixel
+#' @param res The resolution of the plot. Default is 300.
+#' @param add_label For boxplot. T/F to add labels for min, mean and max.
+#' @param label_digits If T for add_label, rounding digits for the label.
+#' Default is 2.
+#' @param same_lim T/F. If x is a list of vectors, should all the plots be
+#' plotted in the same range? Default is True.
+#' @param lim,xlim,ylim Manually specify plotting range in the form of
+#' `c(0, 10)`. `lim` is used in `spec_hist` and `spec_boxplot`; `xlim`
+#' and `ylim` are used in `spec_line`.
+#' @param xaxt On/Off for xaxis text
+#' @param yaxt On/Off for yaxis text
+#' @param ann On/Off for annotations (titles and axis titles)
+#' @param col Color for the fill of the histogram bar/boxplot box.
+#' @param border Color for the border.
+#' @param boxlty Boxplot - box boarder type
+#' @param medcol Boxplot - median line color
+#' @param medlwd Boxplot - median line width
+#' @param dir Directory of where the images will be saved.
+#' @param file File name. If not provided, a random name will be used
+#' @param file_type Graphic device. Support `png` or `svg`. SVG is recommended
+#' for HTML output
+#' @param ... extraparameters passing to boxplot
+#'
#' @export
spec_boxplot <- function(x, width = 200, height = 50, res = 300,
add_label = FALSE, label_digits = 2,
@@ -196,7 +214,40 @@
return(fig_dir_name)
}
-#' @rdname spec_hist
+#' 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, and line. 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.
+#'
+#' @param x,y Vector of values or List of vectors of values. y is optional.
+#' @param width The width of the plot in pixel
+#' @param height The height of the plot in pixel
+#' @param res The resolution of the plot. Default is 300.
+#' @param same_lim T/F. If x is a list of vectors, should all the plots be
+#' plotted in the same range? Default is True.
+#' @param xlim,ylim Manually specify plotting range in the form of
+#' `c(0, 10)`.
+#' @param xaxt On/Off for xaxis text
+#' @param yaxt On/Off for yaxis text
+#' @param ann On/Off for annotations (titles and axis titles)
+#' @param col Color for the fill of the histogram bar/boxplot box.
+#' @param border Color for the border.
+#' @param frame.plot On/Off for surrounding box (`spec_line` only). Default
+#' is False.
+#' @param lwd Line width for `spec_line`; within `spec_line`, the `minmax`
+#' argument defaults to use this value for `cex` for points. Default is 2.
+#' @param minmax,min,max Arguments passed to `points` to highlight minimum
+#' and maximum values in `spec_line`. If `min` or `max` are `NULL`, they
+#' default to the value of `minmax`. Set to an empty `list()` to disable.
+#' @param dir Directory of where the images will be saved.
+#' @param file File name. If not provided, a random name will be used
+#' @param file_type Graphic device. Support `png` or `svg`. SVG is recommended
+#' for HTML output.
+#' @param ... extra parameters passing to `plot`
+#'
#' @export
spec_line <- function(x, y = NULL, width = 200, height = 50, res = 300,
same_lim = TRUE, xlim = NULL, ylim = NULL,
diff --git a/man/spec_boxplot.Rd b/man/spec_boxplot.Rd
new file mode 100644
index 0000000..1591f5d
--- /dev/null
+++ b/man/spec_boxplot.Rd
@@ -0,0 +1,82 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mini_plots.R
+\name{spec_boxplot}
+\alias{spec_boxplot}
+\title{Helper functions to generate inline sparklines}
+\usage{
+spec_boxplot(
+ x,
+ width = 200,
+ height = 50,
+ res = 300,
+ add_label = FALSE,
+ label_digits = 2,
+ same_lim = TRUE,
+ lim = NULL,
+ xaxt = "n",
+ yaxt = "n",
+ ann = FALSE,
+ col = "lightgray",
+ border = NULL,
+ boxlty = 0,
+ medcol = "red",
+ medlwd = 1,
+ dir = if (is_latex()) rmd_files_dir() else tempdir(),
+ file = NULL,
+ file_type = if (is_latex()) "png" else "svg",
+ ...
+)
+}
+\arguments{
+\item{x}{Vector of values or List of vectors of values.}
+
+\item{width}{The width of the plot in pixel}
+
+\item{height}{The height of the plot in pixel}
+
+\item{res}{The resolution of the plot. Default is 300.}
+
+\item{add_label}{For boxplot. T/F to add labels for min, mean and max.}
+
+\item{label_digits}{If T for add_label, rounding digits for the label.
+Default is 2.}
+
+\item{same_lim}{T/F. If x is a list of vectors, should all the plots be
+plotted in the same range? Default is True.}
+
+\item{lim, xlim, ylim}{Manually specify plotting range in the form of
+\code{c(0, 10)}. \code{lim} is used in \code{spec_hist} and \code{spec_boxplot}; \code{xlim}
+and \code{ylim} are used in \code{spec_line}.}
+
+\item{xaxt}{On/Off for xaxis text}
+
+\item{yaxt}{On/Off for yaxis text}
+
+\item{ann}{On/Off for annotations (titles and axis titles)}
+
+\item{col}{Color for the fill of the histogram bar/boxplot box.}
+
+\item{border}{Color for the border.}
+
+\item{boxlty}{Boxplot - box boarder type}
+
+\item{medcol}{Boxplot - median line color}
+
+\item{medlwd}{Boxplot - median line width}
+
+\item{dir}{Directory of where the images will be saved.}
+
+\item{file}{File name. If not provided, a random name will be used}
+
+\item{file_type}{Graphic device. Support \code{png} or \code{svg}. SVG is recommended
+for HTML output}
+
+\item{...}{extraparameters passing to boxplot}
+}
+\description{
+These functions helps you quickly generate sets of sparkline
+style plots using base R plotting system. Currently, we support histogram,
+boxplot, and line. You can use them together with \code{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.
+}
diff --git a/man/spec_hist.Rd b/man/spec_hist.Rd
index cfdeed3..ae97578 100644
--- a/man/spec_hist.Rd
+++ b/man/spec_hist.Rd
@@ -2,8 +2,6 @@
% Please edit documentation in R/mini_plots.R
\name{spec_hist}
\alias{spec_hist}
-\alias{spec_boxplot}
-\alias{spec_line}
\title{Helper functions to generate inline sparklines}
\usage{
spec_hist(
@@ -24,54 +22,6 @@
file_type = if (is_latex()) "png" else "svg",
...
)
-
-spec_boxplot(
- x,
- width = 200,
- height = 50,
- res = 300,
- add_label = FALSE,
- label_digits = 2,
- same_lim = TRUE,
- lim = NULL,
- xaxt = "n",
- yaxt = "n",
- ann = FALSE,
- col = "lightgray",
- border = NULL,
- boxlty = 0,
- medcol = "red",
- medlwd = 1,
- dir = if (is_latex()) rmd_files_dir() else tempdir(),
- file = NULL,
- file_type = if (is_latex()) "png" else "svg",
- ...
-)
-
-spec_line(
- x,
- y = NULL,
- width = 200,
- height = 50,
- res = 300,
- same_lim = TRUE,
- xlim = NULL,
- ylim = NULL,
- xaxt = "n",
- yaxt = "n",
- ann = FALSE,
- col = "lightgray",
- border = NULL,
- frame.plot = FALSE,
- lwd = 2,
- minmax = list(pch = ".", cex = lwd, col = "red"),
- min = minmax,
- max = minmax,
- dir = if (is_latex()) rmd_files_dir() else tempdir(),
- file = NULL,
- file_type = if (is_latex()) "png" else "svg",
- ...
-)
}
\arguments{
\item{x}{Vector of values or List of vectors of values.}
@@ -82,29 +32,11 @@
\item{res}{The resolution of the plot. Default is 300.}
-\item{breaks}{one of:
- \itemize{
- \item a vector giving the breakpoints between histogram cells,
- \item a function to compute the vector of breakpoints,
- \item a single number giving the number of cells for the histogram,
- \item a character string naming an algorithm to compute the
- number of cells (see \sQuote{Details}),
- \item a function to compute the number of cells.
- }
- In the last three cases the number is a suggestion only; as the
- breakpoints will be set to \code{\link{pretty}} values, the number
- is limited to \code{1e6} (with a warning if it was larger). If
- \code{breaks} is a function, the \code{x} vector is supplied to it
- as the only argument (and the number of breaks is only limited by
- the amount of available memory).
- }
-
\item{same_lim}{T/F. If x is a list of vectors, should all the plots be
plotted in the same range? Default is True.}
-\item{lim, xlim, ylim}{Manually specify plotting range in the form of
-\code{c(0, 10)}. \code{lim} is used in \code{spec_hist} and \code{spec_boxplot}; \code{xlim}
-and \code{ylim} are used in \code{spec_line}.}
+\item{lim}{Manually specify plotting range in the form of
+\code{c(0, 10)}.}
\item{xaxt}{On/Off for xaxis text}
@@ -123,30 +55,7 @@
\item{file_type}{Graphic device. Support \code{png} or \code{svg}. SVG is recommended
for HTML output}
-\item{...}{further arguments and \link[graphics]{graphical parameters} passed to
- \code{\link[graphics]{plot.histogram}} and thence to \code{\link[graphics]{title}} and
- \code{\link[graphics]{axis}} (if \code{plot = TRUE}).}
-
-\item{add_label}{For boxplot. T/F to add labels for min, mean and max.}
-
-\item{label_digits}{If T for add_label, rounding digits for the label.
-Default is 2.}
-
-\item{boxlty}{Boxplot - box boarder type}
-
-\item{medcol}{Boxplot - median line color}
-
-\item{medlwd}{Boxplot - median line width}
-
-\item{frame.plot}{On/Off for surrounding box (\code{spec_line} only). Default
-is False.}
-
-\item{lwd}{Line width for \code{spec_line}; within \code{spec_line}, the \code{minmax}
-argument defaults to use this value for \code{cex} for points. Default is 2.}
-
-\item{minmax, min, max}{Arguments passed to \code{points} to highlight minimum
-and maximum values in \code{spec_line}. If \code{min} or \code{max} are \code{NULL}, they
-default to the value of \code{minmax}. Set to an empty \code{list()} to disable.}
+\item{...}{extra parameters sending to \code{hist()}}
}
\description{
These functions helps you quickly generate sets of sparkline
diff --git a/man/spec_line.Rd b/man/spec_line.Rd
new file mode 100644
index 0000000..8d881d1
--- /dev/null
+++ b/man/spec_line.Rd
@@ -0,0 +1,82 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mini_plots.R
+\name{spec_line}
+\alias{spec_line}
+\title{Helper functions to generate inline sparklines}
+\usage{
+spec_line(
+ x,
+ y = NULL,
+ width = 200,
+ height = 50,
+ res = 300,
+ same_lim = TRUE,
+ xlim = NULL,
+ ylim = NULL,
+ xaxt = "n",
+ yaxt = "n",
+ ann = FALSE,
+ col = "lightgray",
+ border = NULL,
+ frame.plot = FALSE,
+ lwd = 2,
+ minmax = list(pch = ".", cex = lwd, col = "red"),
+ min = minmax,
+ max = minmax,
+ dir = if (is_latex()) rmd_files_dir() else tempdir(),
+ file = NULL,
+ file_type = if (is_latex()) "png" else "svg",
+ ...
+)
+}
+\arguments{
+\item{x, y}{Vector of values or List of vectors of values. y is optional.}
+
+\item{width}{The width of the plot in pixel}
+
+\item{height}{The height of the plot in pixel}
+
+\item{res}{The resolution of the plot. Default is 300.}
+
+\item{same_lim}{T/F. If x is a list of vectors, should all the plots be
+plotted in the same range? Default is True.}
+
+\item{xlim, ylim}{Manually specify plotting range in the form of
+\code{c(0, 10)}.}
+
+\item{xaxt}{On/Off for xaxis text}
+
+\item{yaxt}{On/Off for yaxis text}
+
+\item{ann}{On/Off for annotations (titles and axis titles)}
+
+\item{col}{Color for the fill of the histogram bar/boxplot box.}
+
+\item{border}{Color for the border.}
+
+\item{frame.plot}{On/Off for surrounding box (\code{spec_line} only). Default
+is False.}
+
+\item{lwd}{Line width for \code{spec_line}; within \code{spec_line}, the \code{minmax}
+argument defaults to use this value for \code{cex} for points. Default is 2.}
+
+\item{minmax, min, max}{Arguments passed to \code{points} to highlight minimum
+and maximum values in \code{spec_line}. If \code{min} or \code{max} are \code{NULL}, they
+default to the value of \code{minmax}. Set to an empty \code{list()} to disable.}
+
+\item{dir}{Directory of where the images will be saved.}
+
+\item{file}{File name. If not provided, a random name will be used}
+
+\item{file_type}{Graphic device. Support \code{png} or \code{svg}. SVG is recommended
+for HTML output.}
+
+\item{...}{extra parameters passing to \code{plot}}
+}
+\description{
+These functions helps you quickly generate sets of sparkline
+style plots using base R plotting system. Currently, we support histogram,
+boxplot, and line. You can use them together with \code{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.
+}