change valign's default to middle in collapse_rows. update vignette as requested by CRAN
diff --git a/R/collapse_rows.R b/R/collapse_rows.R
index 961601e..ee05cc8 100644
--- a/R/collapse_rows.R
+++ b/R/collapse_rows.R
@@ -8,7 +8,9 @@
#'
#' @param kable_input Output of `knitr::kable()` with `format` specified
#' @param columns Numeric column positions where rows need to be collapsed.
-#' @param valign Select from "top"(default), "middle", "bottom"
+#' @param valign Select from "top", "middle"(default), "bottom". The reason why
+#' "top" is not default is that the multirow package on CRAN win-builder is
+#' not up to date.
#' @param latex_hline Option controlling the behavior of adding hlines to table.
#' Choose from `full`, `major`, `none`, `custom`.
#' @param custom_latex_hline Numeric column positions whose collapsed rows will
@@ -27,7 +29,7 @@
#'
#' @export
collapse_rows <- function(kable_input, columns = NULL,
- valign = c("top", "middle", "bottom"),
+ valign = c("middle", "top", "bottom"),
latex_hline = c("full", "major", "none", "custom"),
row_group_label_position = c('identity', 'stack'),
custom_latex_hline = NULL,
@@ -40,7 +42,7 @@
"for details.")
return(kable_input)
}
- valign <- match.arg(valign, c("top", "middle", "bottom"))
+ valign <- match.arg(valign, c("middle", "top", "bottom"))
if (kable_format == "html") {
return(collapse_rows_html(kable_input, columns, valign))
}
diff --git a/docs/awesome_table_in_html.Rmd b/docs/awesome_table_in_html.Rmd
index 473ecf0..3af994c 100644
--- a/docs/awesome_table_in_html.Rmd
+++ b/docs/awesome_table_in_html.Rmd
@@ -452,4 +452,4 @@
Since the structure of `kable` is relatively simple, it shouldn't be too difficult to convert HTML or LaTeX tables generated by other packages to a `kable` object and then use `kableExtra` to modify the outputs. If you are a package author, feel free to reach out to me and we can collaborate.
## `tables`
-The latest version of [`tables`](https://cran.r-project.org/web/packages/tables/index.html) comes with a `toKable()` function, which is compatiable with functions in `kableExtra` (>=0.9.0).
+The latest version of [`tables`](https://CRAN.R-project.org/package=tables) comes with a `toKable()` function, which is compatiable with functions in `kableExtra` (>=0.9.0).
diff --git a/docs/awesome_table_in_html.html b/docs/awesome_table_in_html.html
index ea829e1..a2b79c7 100644
--- a/docs/awesome_table_in_html.html
+++ b/docs/awesome_table_in_html.html
@@ -3556,7 +3556,7 @@
2
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3572,7 +3572,7 @@
4
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3588,7 +3588,7 @@
6
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3596,7 +3596,7 @@
7
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3607,7 +3607,7 @@
8
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3615,7 +3615,7 @@
9
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3623,7 +3623,7 @@
10
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3645,7 +3645,7 @@
12
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3664,7 +3664,7 @@
14
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -8952,7 +8952,7 @@
<p>Since the structure of <code>kable</code> is relatively simple, it shouldn’t be too difficult to convert HTML or LaTeX tables generated by other packages to a <code>kable</code> object and then use <code>kableExtra</code> to modify the outputs. If you are a package author, feel free to reach out to me and we can collaborate.</p>
<div id="tables" class="section level2">
<h2><code>tables</code></h2>
-<p>The latest version of <a href="https://cran.r-project.org/web/packages/tables/index.html"><code>tables</code></a> comes with a <code>toKable()</code> function, which is compatiable with functions in <code>kableExtra</code> (>=0.9.0).</p>
+<p>The latest version of <a href="https://CRAN.R-project.org/package=tables"><code>tables</code></a> comes with a <code>toKable()</code> function, which is compatiable with functions in <code>kableExtra</code> (>=0.9.0).</p>
</div>
</div>
diff --git a/docs/awesome_table_in_pdf.Rmd b/docs/awesome_table_in_pdf.Rmd
index a5965db..5be9621 100644
--- a/docs/awesome_table_in_pdf.Rmd
+++ b/docs/awesome_table_in_pdf.Rmd
@@ -359,7 +359,7 @@
## Group rows via multi-row cell
Function `group_rows` is great for showing simple structural information on rows but sometimes people may need to show structural information with multiple layers. When it happens, you may consider using `collapse_rows` instead, which will put repeating cells in columns into multi-row cells.
-In LaTeX, `collapse_rows` adds some extra hlines to help differentiate groups. You can customize this behavior using the `latex_hline` argument. You can choose from `full` (default), `major` and `none`. Vertical alignment of cells is controlled by the `valign` option. You can choose from "top"(default), "middle" and "bottom".
+In LaTeX, `collapse_rows` adds some extra hlines to help differentiate groups. You can customize this behavior using the `latex_hline` argument. You can choose from `full` (default), `major` and `none`. Vertical alignment of cells is controlled by the `valign` option. You can choose from "top", "middle"(default) and "bottom". Be cautious that the vertical alignment option was only introduced in multirow in 2016. If you are using a legacy LaTeX distribution, you will run into trouble if you set `valign` to be either "top" or "bottom".
```{r}
collapse_rows_dt <- data.frame(C1 = c(rep("a", 10), rep("b", 5)),
@@ -368,7 +368,7 @@
C4 = sample(c(0,1), 15, replace = TRUE))
kable(collapse_rows_dt, "latex", booktabs = T, align = "c") %>%
column_spec(1, bold=T) %>%
- collapse_rows(columns = 1:2, latex_hline = "major", valign = "top")
+ collapse_rows(columns = 1:2, latex_hline = "major", valign = "middle")
```
Right now, you can't automatically make striped rows based on collapsed rows but you can do it manually via the `extra_latex_after` option in `row_spec`. This feature is not officially supported. I'm only document it here if you want to give it a try.
@@ -524,4 +524,4 @@
Since the structure of `kable` is relatively simple, it shouldn't be too difficult to convert HTML or LaTeX tables generated by other packages to a `kable` object and then use `kableExtra` to modify the outputs. If you are a package author, feel free to reach out to me and we can collaborate.
## `tables`
-The latest version of [`tables`](https://cran.r-project.org/web/packages/tables/index.html) comes with a `toKable()` function, which is compatiable with functions in `kableExtra` (>=0.9.0).
+The latest version of [`tables`](https://CRAN.R-project.org/package=tables) comes with a `toKable()` function, which is compatiable with functions in `kableExtra` (>=0.9.0).
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index 4ba5441..90d7b15 100644
--- a/docs/awesome_table_in_pdf.pdf
+++ b/docs/awesome_table_in_pdf.pdf
Binary files differ
diff --git a/man/collapse_rows.Rd b/man/collapse_rows.Rd
index 3609041..9508bd4 100644
--- a/man/collapse_rows.Rd
+++ b/man/collapse_rows.Rd
@@ -4,7 +4,7 @@
\alias{collapse_rows}
\title{Collapse repeated rows to multirow cell}
\usage{
-collapse_rows(kable_input, columns = NULL, valign = c("top", "middle",
+collapse_rows(kable_input, columns = NULL, valign = c("middle", "top",
"bottom"), latex_hline = c("full", "major", "none", "custom"),
row_group_label_position = c("identity", "stack"),
custom_latex_hline = NULL, row_group_label_fonts = NULL,
@@ -15,7 +15,9 @@
\item{columns}{Numeric column positions where rows need to be collapsed.}
-\item{valign}{Select from "top"(default), "middle", "bottom"}
+\item{valign}{Select from "top", "middle"(default), "bottom". The reason why
+"top" is not default is that the multirow package on CRAN win-builder is
+not up to date.}
\item{latex_hline}{Option controlling the behavior of adding hlines to table.
Choose from \code{full}, \code{major}, \code{none}, \code{custom}.}
diff --git a/vignettes/awesome_table_in_html.Rmd b/vignettes/awesome_table_in_html.Rmd
index 473ecf0..3af994c 100644
--- a/vignettes/awesome_table_in_html.Rmd
+++ b/vignettes/awesome_table_in_html.Rmd
@@ -452,4 +452,4 @@
Since the structure of `kable` is relatively simple, it shouldn't be too difficult to convert HTML or LaTeX tables generated by other packages to a `kable` object and then use `kableExtra` to modify the outputs. If you are a package author, feel free to reach out to me and we can collaborate.
## `tables`
-The latest version of [`tables`](https://cran.r-project.org/web/packages/tables/index.html) comes with a `toKable()` function, which is compatiable with functions in `kableExtra` (>=0.9.0).
+The latest version of [`tables`](https://CRAN.R-project.org/package=tables) comes with a `toKable()` function, which is compatiable with functions in `kableExtra` (>=0.9.0).
diff --git a/vignettes/awesome_table_in_pdf.Rmd b/vignettes/awesome_table_in_pdf.Rmd
index a5965db..5be9621 100644
--- a/vignettes/awesome_table_in_pdf.Rmd
+++ b/vignettes/awesome_table_in_pdf.Rmd
@@ -359,7 +359,7 @@
## Group rows via multi-row cell
Function `group_rows` is great for showing simple structural information on rows but sometimes people may need to show structural information with multiple layers. When it happens, you may consider using `collapse_rows` instead, which will put repeating cells in columns into multi-row cells.
-In LaTeX, `collapse_rows` adds some extra hlines to help differentiate groups. You can customize this behavior using the `latex_hline` argument. You can choose from `full` (default), `major` and `none`. Vertical alignment of cells is controlled by the `valign` option. You can choose from "top"(default), "middle" and "bottom".
+In LaTeX, `collapse_rows` adds some extra hlines to help differentiate groups. You can customize this behavior using the `latex_hline` argument. You can choose from `full` (default), `major` and `none`. Vertical alignment of cells is controlled by the `valign` option. You can choose from "top", "middle"(default) and "bottom". Be cautious that the vertical alignment option was only introduced in multirow in 2016. If you are using a legacy LaTeX distribution, you will run into trouble if you set `valign` to be either "top" or "bottom".
```{r}
collapse_rows_dt <- data.frame(C1 = c(rep("a", 10), rep("b", 5)),
@@ -368,7 +368,7 @@
C4 = sample(c(0,1), 15, replace = TRUE))
kable(collapse_rows_dt, "latex", booktabs = T, align = "c") %>%
column_spec(1, bold=T) %>%
- collapse_rows(columns = 1:2, latex_hline = "major", valign = "top")
+ collapse_rows(columns = 1:2, latex_hline = "major", valign = "middle")
```
Right now, you can't automatically make striped rows based on collapsed rows but you can do it manually via the `extra_latex_after` option in `row_spec`. This feature is not officially supported. I'm only document it here if you want to give it a try.
@@ -524,4 +524,4 @@
Since the structure of `kable` is relatively simple, it shouldn't be too difficult to convert HTML or LaTeX tables generated by other packages to a `kable` object and then use `kableExtra` to modify the outputs. If you are a package author, feel free to reach out to me and we can collaborate.
## `tables`
-The latest version of [`tables`](https://cran.r-project.org/web/packages/tables/index.html) comes with a `toKable()` function, which is compatiable with functions in `kableExtra` (>=0.9.0).
+The latest version of [`tables`](https://CRAN.R-project.org/package=tables) comes with a `toKable()` function, which is compatiable with functions in `kableExtra` (>=0.9.0).