Drop version due to CRAN resubmission; Add examples as requested
diff --git a/DESCRIPTION b/DESCRIPTION
index bb45a25..210c06b 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: kableExtra
Type: Package
Title: Construct Complex Table with 'kable' and Pipe Syntax
-Version: 0.2.1.9000
+Version: 0.2.1
Authors@R: c(
person('Hao', 'Zhu', email = 'haozhu233@gmail.com', role = c('aut', 'cre')),
person('Will', 'Beasley', email = 'wibeasley@hotmail.com', role = 'ctb'),
diff --git a/R/add_footnote.R b/R/add_footnote.R
index a6524a5..024df3b 100644
--- a/R/add_footnote.R
+++ b/R/add_footnote.R
@@ -13,7 +13,11 @@
#' @param notation You can select the format of your footnote notation from
#' `number`, `alphabet` and `symbol`.
#' @param threeparttable Boolean value indicating if a
-#' \href{https://www.ctan.org/pkg/threeparttable}{threeparttable} scheme should be used.
+#' \href{https://www.ctan.org/pkg/threeparttable}{threeparttable} scheme should
+#' be used.
+#'
+#' @examples x <- knitr::kable(head(mtcars), "html")
+#' add_footnote(x, c("footnote 1", "footnote 2"), notation = "symbol")
#'
#' @export
add_footnote <- function(input, label = NULL,
diff --git a/R/add_header_above.R b/R/add_header_above.R
index 92e2040..0f39d43 100644
--- a/R/add_header_above.R
+++ b/R/add_header_above.R
@@ -12,6 +12,11 @@
#' convenience, when `colspan` equals to 1, users can drop the ` = 1` part.
#' As a result, `c(" ", "title" = 2)` is the same as `c(" " = 1, "title" = 2)`.
#'
+#' @examples x <- knitr::kable(head(mtcars), "html")
+#' # Add a row of header with 3 columns on the top of the table. The column
+#' # span for the 2nd and 3rd one are 5 & 6.
+#' add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6))
+#'
#' @export
add_header_above <- function(kable_input, header = NULL) {
kable_format <- attr(kable_input, "format")
diff --git a/R/add_indent.R b/R/add_indent.R
index 6e71a44..33ad6f7 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -4,6 +4,10 @@
#' @param positions A vector of numeric row numbers for the rows that need to
#' be indented.
#'
+#' @examples x <- knitr::kable(head(mtcars), "html")
+#' # Add indentations to the 2nd & 4th row
+#' add_indent(x, c(2, 4))
+#'
#' @export
add_indent <- function(kable_input, positions) {
if (!is.numeric(positions)) {
diff --git a/R/column_spec.R b/R/column_spec.R
index 9748713..0c383d5 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -12,9 +12,13 @@
#' need to be bolded.
#' @param italic A T/F value to control whether the text of the selected column
#' need to be emphasized.
+#'
+#' @examples x <- knitr::kable(head(mtcars), "html")
+#' column_spec(x, 1, width = "20em", bold = TRUE, italic = TRUE)
+#'
#' @export
column_spec <- function(kable_input, column,
- width = NULL, bold = F, italic = F) {
+ width = NULL, bold = FALSE, italic = FALSE) {
if (!is.numeric(column)) {
stop("column must be a numeric value")
}
diff --git a/R/group_rows.R b/R/group_rows.R
index c768386..2df22ca 100644
--- a/R/group_rows.R
+++ b/R/group_rows.R
@@ -16,6 +16,10 @@
#' between the previous row and the group labeling row. Only useful for LaTeX
#' documents.
#'
+#' @examples x <- knitr::kable(head(mtcars), "html")
+#' # Put Row 2 to Row 5 into a Group and label it as "Group A"
+#' group_rows(x, "Group A", 2, 5)
+#'
#' @export
group_rows <- function(kable_input, group_label, start_row, end_row,
label_row_css = "border-bottom: 1px solid;",
diff --git a/R/kable_styling.R b/R/kable_styling.R
index c04029a..7e6f92a 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -32,6 +32,12 @@
#' imported.
#' @param font_size A numeric input for table font size
#'
+#' @examples x_html <- knitr::kable(head(mtcars), "html")
+#' kable_styling(x_html, "striped", position = "left", font_size = 7)
+#'
+#' x_latex <- knitr::kable(head(mtcars), "latex")
+#' kable_styling(x_latex, latex_options = "striped", position = "float_left")
+#'
#' @export
kable_styling <- function(kable_input,
bootstrap_options = "basic",
diff --git a/R/landscape.R b/R/landscape.R
index 5727fe6..75d9255 100644
--- a/R/landscape.R
+++ b/R/landscape.R
@@ -7,6 +7,8 @@
#' @param margin Customizable page margin for special needs. Values can be
#' "1cm", "1in" or similar.
#'
+#' @examples landscape(knitr::kable(head(mtcars), "latex"))
+#'
#' @export
landscape <- function(kable_input, margin = NULL) {
kable_format <- attr(kable_input, "format")
diff --git a/R/magic_mirror.R b/R/magic_mirror.R
index 088ee90..2e415f7 100644
--- a/R/magic_mirror.R
+++ b/R/magic_mirror.R
@@ -3,6 +3,8 @@
#' @description Mirror mirror tell me, how does this kable look like?
#'
#' @param kable_input The output of kable
+#'
+#' @examples magic_mirror(knitr::kable(head(mtcars), "html"))
#' @export
magic_mirror <- function(kable_input){
diff --git a/R/util.R b/R/util.R
index 66ee3be..c16b79d 100644
--- a/R/util.R
+++ b/R/util.R
@@ -26,6 +26,8 @@
#'
#' @param name The LaTeX package name
#' @param options The LaTeX options for the package
+#'
+#' @examples usepackage_latex("xcolor")
#' @export
usepackage_latex <- function(name, options = NULL) {
invisible(knit_meta_add(list(latex_dependency(name, options))))
diff --git a/man/add_footnote.Rd b/man/add_footnote.Rd
index e7104cc..d3839a3 100644
--- a/man/add_footnote.Rd
+++ b/man/add_footnote.Rd
@@ -18,7 +18,8 @@
`number`, `alphabet` and `symbol`.}
\item{threeparttable}{Boolean value indicating if a
-\href{https://www.ctan.org/pkg/threeparttable}{threeparttable} scheme should be used.}
+\href{https://www.ctan.org/pkg/threeparttable}{threeparttable} scheme should
+be used.}
}
\description{
Add footnote to your favorite kable output. So far this function
@@ -27,3 +28,8 @@
\code{threeparttable} package so you need to import this package in your
\code{YAML} header.
}
+\examples{
+x <- knitr::kable(head(mtcars), "html")
+add_footnote(x, c("footnote 1", "footnote 2"), notation = "symbol")
+
+}
diff --git a/man/add_header_above.Rd b/man/add_header_above.Rd
index b65516f..09b976d 100644
--- a/man/add_header_above.Rd
+++ b/man/add_header_above.Rd
@@ -21,3 +21,10 @@
function and adds an header row on top of it. This function can work with
both `HTML` and `LaTeX` outputs
}
+\examples{
+x <- knitr::kable(head(mtcars), "html")
+# Add a row of header with 3 columns on the top of the table. The column
+# span for the 2nd and 3rd one are 5 & 6.
+add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6))
+
+}
diff --git a/man/add_indent.Rd b/man/add_indent.Rd
index 2ee3d54..e141e70 100644
--- a/man/add_indent.Rd
+++ b/man/add_indent.Rd
@@ -15,3 +15,9 @@
\description{
Add indentations to row headers
}
+\examples{
+x <- knitr::kable(head(mtcars), "html")
+# Add indentations to the 2nd & 4th row
+add_indent(x, c(2, 4))
+
+}
diff --git a/man/column_spec.Rd b/man/column_spec.Rd
index d7a08ec..a107eb8 100644
--- a/man/column_spec.Rd
+++ b/man/column_spec.Rd
@@ -4,7 +4,8 @@
\alias{column_spec}
\title{Specify the look of the selected column}
\usage{
-column_spec(kable_input, column, width = NULL, bold = F, italic = F)
+column_spec(kable_input, column, width = NULL, bold = FALSE,
+ italic = FALSE)
}
\arguments{
\item{kable_input}{Output of `knitr::kable()` with `format` specified}
@@ -25,3 +26,8 @@
its look. Right now it supports the following three properties: column width,
bold text and italic text.
}
+\examples{
+x <- knitr::kable(head(mtcars), "html")
+column_spec(x, 1, width = "20em", bold = TRUE, italic = TRUE)
+
+}
diff --git a/man/group_rows.Rd b/man/group_rows.Rd
index 1a313e6..6cf58ee 100644
--- a/man/group_rows.Rd
+++ b/man/group_rows.Rd
@@ -30,3 +30,9 @@
\description{
Group a few rows in a table together under a label.
}
+\examples{
+x <- knitr::kable(head(mtcars), "html")
+# Put Row 2 to Row 5 into a Group and label it as "Group A"
+group_rows(x, "Group A", 2, 5)
+
+}
diff --git a/man/kable_styling.Rd b/man/kable_styling.Rd
index 2ba0b1c..09893d6 100644
--- a/man/kable_styling.Rd
+++ b/man/kable_styling.Rd
@@ -47,3 +47,11 @@
of HTML tables other than using the `table.attr` option in `knitr::kable()`.
Currenly, it assumes the HTML document has boot
}
+\examples{
+x_html <- knitr::kable(head(mtcars), "html")
+kable_styling(x_html, "striped", position = "left", font_size = 7)
+
+x_latex <- knitr::kable(head(mtcars), "latex")
+kable_styling(x_latex, latex_options = "striped", position = "float_left")
+
+}
diff --git a/man/landscape.Rd b/man/landscape.Rd
index 48bc501..793569b 100644
--- a/man/landscape.Rd
+++ b/man/landscape.Rd
@@ -16,3 +16,7 @@
This function will put the table on an single landscape page.
It's useful for wide tables that cann't be printed on a portrait page.
}
+\examples{
+landscape(knitr::kable(head(mtcars), "latex"))
+
+}
diff --git a/man/magic_mirror.Rd b/man/magic_mirror.Rd
index 56b3f79..5e1497c 100644
--- a/man/magic_mirror.Rd
+++ b/man/magic_mirror.Rd
@@ -12,3 +12,6 @@
\description{
Mirror mirror tell me, how does this kable look like?
}
+\examples{
+magic_mirror(knitr::kable(head(mtcars), "html"))
+}
diff --git a/man/usepackage_latex.Rd b/man/usepackage_latex.Rd
index 6b6b16c..62cabb8 100644
--- a/man/usepackage_latex.Rd
+++ b/man/usepackage_latex.Rd
@@ -15,3 +15,6 @@
Load a LaTeX package using R code. Just like `\\usepackage{}`
in LaTeX
}
+\examples{
+usepackage_latex("xcolor")
+}