improve lightable's look on add_header_above/group_rows
improve documentation
diff --git a/docs/awesome_table_in_html.html b/docs/awesome_table_in_html.html
index 28f5862..1a7cb46 100644
--- a/docs/awesome_table_in_html.html
+++ b/docs/awesome_table_in_html.html
@@ -1332,8 +1332,8 @@
margin-left: 5px;
margin-right: 5px;
}
-.lightable-minimal thead tr th {
-border-bottom: 2px solid black;
+.lightable-minimal thead tr:last-child th {
+border-bottom: 2px solid #00000050;
empty-cells: hide;
}
.lightable-minimal tbody tr:first-child td {
@@ -1342,12 +1342,11 @@
.lightable-minimal.lightable-hover tbody tr:hover {
background-color: #f5f5f5;
}
-.lightable-minimal.lightable-striped tr:nth-child(even) {
+.lightable-minimal.lightable-striped tbody tr:nth-child(even) {
background-color: #f5f5f5;
}
.lightable-classic {
border-top: 2px solid #111111;
-border-bottom: 2px solid #111111;
width: 100%;
margin-bottom: 10px;
}
@@ -1362,15 +1361,17 @@
.lightable-classic thead tr:last-child th {
border-bottom: 1px solid #111111;
}
+.lightable-classic tbody tr:last-child td {
+border-bottom: 2px solid #111111;
+}
.lightable-classic.lightable-hover tbody tr:hover {
background-color: #F9EEC1;
}
-.lightable-classic.lightable-striped tr:nth-child(even) {
+.lightable-classic.lightable-striped tbody tr:nth-child(even) {
background-color: #f5f5f5;
}
.lightable-classic-2 {
border-top: 3px double #111111;
-border-bottom: 3px double #111111;
width: 100%;
margin-bottom: 10px;
}
@@ -1382,13 +1383,16 @@
padding-left: 5px;
padding-right: 5px;
}
+.lightable-classic-2 tbody tr:last-child td {
+border-bottom: 3px double #111111;
+}
.lightable-classic-2 thead tr:last-child th {
border-bottom: 1px solid #111111;
}
.lightable-classic-2.lightable-hover tbody tr:hover {
background-color: #F9EEC1;
}
-.lightable-classic-2.lightable-striped tr:nth-child(even) {
+.lightable-classic-2.lightable-striped tbody tr:nth-child(even) {
background-color: #f5f5f5;
}
.lightable-material {
@@ -1414,10 +1418,10 @@
.lightable-material.lightable-hover tbody tr:hover {
background-color: #f5f5f5;
}
-.lightable-material.lightable-striped tr:nth-child(even) {
+.lightable-material.lightable-striped tbody tr:nth-child(even) {
background-color: #f5f5f5;
}
-.lightable-material.lightable-striped td {
+.lightable-material.lightable-striped tbody td {
border: 0;
}
.lightable-material.lightable-striped thead tr:last-child th {
@@ -1449,10 +1453,10 @@
.lightable-material-dark.lightable-hover tbody tr:hover {
background-color: #FFFFFF12;
}
-.lightable-material-dark.lightable-striped tr:nth-child(even) {
+.lightable-material-dark.lightable-striped tbody tr:nth-child(even) {
background-color: #FFFFFF12;
}
-.lightable-material-dark.lightable-striped td {
+.lightable-material-dark.lightable-striped tbody td {
border: 0;
}
.lightable-material-dark.lightable-striped thead tr:last-child th {
@@ -1462,7 +1466,7 @@
width: 100%;
margin-bottom: 10px;
}
-.lightable-paper th {
+.lightable-paper thead tr:last-child th {
color: #999;
vertical-align: bottom;
border-bottom: 1px solid #00000020;
@@ -1478,10 +1482,10 @@
.lightable-paper.lightable-hover tbody tr:hover {
background-color: #F9EEC1;
}
-.lightable-paper.lightable-striped tr:nth-child(even) {
+.lightable-paper.lightable-striped tbody tr:nth-child(even) {
background-color: #00000008;
}
-.lightable-material-dark.lightable-striped td {
+.lightable-paper.lightable-striped tbody td {
border: 0;
}
</style>
@@ -1746,23 +1750,19 @@
<h1>Getting Started</h1>
<p>Here we are using the first few columns and rows from dataset <code>mtcars</code></p>
<pre class="r"><code>library(knitr)
-library(kableExtra)</code></pre>
-<pre><code>##
-## Attaching package: 'kableExtra'</code></pre>
-<pre><code>## The following object is masked from 'package:knitr':
-##
-## kable</code></pre>
-<pre class="r"><code>dt <- mtcars[1:5, 1:6]</code></pre>
-<p>When you are using <code>kable()</code>, if you don’t specify <code>format</code>, by default it will generate a markdown table and let pandoc handle the conversion from markdown to HTML/PDF. This is the most favorable approach to render most simple tables as it is format independent. If you switch from HTML to pdf, you basically don’t need to change anything in your code. However, markdown doesn’t support complex table. For example, if you want to have a double-row header table, markdown just cannot provide you the functionality you need. As a result, when you have such a need, you should <strong>define <code>format</code> in <code>kable()</code></strong> as either “html” or “latex”. <em>You can also define a global option at the beginning using <code>options(knitr.table.format = "html")</code> so you don’t repeat the step everytime.</em></p>
-<p><strong>Starting from <code>kableExtra</code> 0.9.0</strong>, when you load this package (<code>library(kableExtra)</code>), <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #d9230f !important;">it will automatically set up the global option ‘knitr.table.format’ based on your current environment</span>. Unless you are rendering a PDF, <code>kableExtra</code> will try to render a HTML table for you. <strong>You no longer need to manually set either the global option or the <code>format</code> option in each <code>kable()</code> function</strong>. I’m still including the explanation above here in this vignette so you can understand what is going on behind the scene. Note that this is only an global option. You can manually set any format in <code>kable()</code> whenever you want. I just hope you can enjoy a peace of mind in most of your time.</p>
-<p>You can disable this behavior by setting <code>options(kableExtra.auto_format = FALSE)</code> before you load <code>kableExtra</code>.</p>
+library(kableExtra)
+dt <- mtcars[1:5, 1:6]</code></pre>
+<blockquote>
+<p><strong>Key Update:</strong> In the latest version of this package (1.2+), we provide a wrapper funciton <code>kbl</code> to the original <code>kable</code> function with detailed documentation of all the hidden html/latex options. It also does auto-formatting check in every function call instead of relying on the global environement variable. As a result, it also solves an issue for multi-format R Markdown documents. I encourage you start to use the new <code>kbl</code> function for all its convenience but the support for the original <code>kable</code> function is still there. In this doc, we will use <code>kbl</code> instead of <code>kable</code>.</p>
+</blockquote>
+<p><strong>This paragraph is a little outdated. It’s here only for education purpose because it’s helpful to understand how <code>kable</code> works under the hood</strong>. When you are using <code>kable()</code>, if you don’t specify <code>format</code>, by default it will generate a markdown table and let pandoc handle the conversion from markdown to HTML/PDF. This is the most favorable approach to render most simple tables as it is format independent. If you switch from HTML to pdf, you basically don’t need to change anything in your code. However, markdown doesn’t support complex table. For example, if you want to have a double-row header table, markdown just cannot provide you the functionality you need. As a result, when you have such a need, you should <strong>define <code>format</code> in <code>kable()</code></strong> as either “html” or “latex”. <em>You can also define a global option at the beginning using <code>options(knitr.table.format = "html")</code> so you don’t repeat the step everytime.</em> <strong>Starting from <code>kableExtra</code> 0.9.0</strong>, when you load this package (<code>library(kableExtra)</code>), it will automatically set up the global option ‘knitr.table.format’ based on your current environment. Unless you are rendering a PDF, <code>kableExtra</code> will try to render a HTML table for you. <strong>You no longer need to manually set either the global option or the <code>format</code> option in each <code>kable()</code> function</strong>. I’m still including the explanation above here in this vignette so you can understand what is going on behind the scene. Note that this is only an global option. You can manually set any format in <code>kable()</code> whenever you want. I just hope you can enjoy a peace of mind in most of your time. You can disable this behavior by setting <code>options(kableExtra.auto_format = FALSE)</code> before you load <code>kableExtra</code>.</p>
<pre class="r"><code># If you are using kableExtra < 0.9.0, you are recommended to set a global option first.
# options(knitr.table.format = "html")
## If you don't define format here, you'll need put `format = "html"` in every kable function.</code></pre>
<div id="basic-html-table" class="section level2">
<h2>Basic HTML table</h2>
<p>Basic HTML output of <code>kable</code> looks very crude. To the end, it’s just a plain HTML table without any love from css.</p>
-<pre class="r"><code>kable(dt)</code></pre>
+<pre class="r"><code>kbl(dt)</code></pre>
<table>
<thead>
<tr>
@@ -1909,9 +1909,9 @@
</div>
<div id="bootstrap-theme" class="section level2">
<h2>Bootstrap theme</h2>
-<p>When used on a HTML table, <code>kable_styling()</code> will automatically apply twitter bootstrap theme to the table. Now it should looks the same as the original pandoc output (the one when you don’t specify <code>format</code> in <code>kable()</code>) but this time, you are controlling it.</p>
+<p>When used on a HTML table, <code>kable_styling()</code> will automatically apply twitter bootstrap theme to the table. Now it should looks the same as the original pandoc output (the one when you don’t specify <code>format</code> in <code>kbl()</code>) but this time, you are controlling it.</p>
<pre class="r"><code>dt %>%
- kable() %>%
+ kbl() %>%
kable_styling()</code></pre>
<table class="table" style="margin-left: auto; margin-right: auto;">
<thead>
@@ -2061,7 +2061,7 @@
<h2>Alternative themes</h2>
<p><code>kableExtra</code> also offers a few in-house alternative HTML table themes other than the default bootstrap theme. Right now there are 6 of them: <code>kable_paper</code>, <code>kable_classic</code>, <code>kable_classic_2</code>, <code>kable_minimal</code>, <code>kable_material</code> and <code>kable_material_dark</code>. These functions are alternatives to <code>kable_styling</code>, which means that you can specify any additional formatting options in <code>kable_styling</code> in these functions too. The only difference is that <code>bootstrap_options</code> (as discussed in the next section) is replaced with <code>lightable_options</code> at the same location with only two choices <code>striped</code> and <code>hover</code> available.</p>
<pre class="r"><code>dt %>%
- kable() %>%
+ kbl() %>%
kable_paper("hover")</code></pre>
<table class=" lightable-paper lightable-hover" style="font-family: "Arial Narrow", arial, helvetica, sans-serif; margin-left: auto; margin-right: auto;">
<thead>
@@ -2207,7 +2207,7 @@
</tbody>
</table>
<pre class="r"><code>dt %>%
- kable() %>%
+ kbl() %>%
kable_classic()</code></pre>
<table class=" lightable-classic" style="font-family: "Arial Narrow", "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto;">
<thead>
@@ -2353,7 +2353,7 @@
</tbody>
</table>
<pre class="r"><code>dt %>%
- kable() %>%
+ kbl() %>%
kable_classic_2()</code></pre>
<table class=" lightable-classic-2" style="font-family: "Arial Narrow", "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto;">
<thead>
@@ -2499,9 +2499,9 @@
</tbody>
</table>
<pre class="r"><code>dt %>%
- kable() %>%
+ kbl() %>%
kable_minimal()</code></pre>
-<table class=" lightable-minimal" style="font-family: calibri, cambria, "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto;">
+<table class=" lightable-minimal" style="font-family: "Trebuchet MS", verdana, calibri, sans-serif; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="text-align:left;">
@@ -2645,7 +2645,7 @@
</tbody>
</table>
<pre class="r"><code>dt %>%
- kable() %>%
+ kbl() %>%
kable_material(c("striped", "hover"))</code></pre>
<table class=" lightable-material lightable-striped lightable-hover" style="font-family: "Source Sans Pro", helvetica, sans-serif; margin-left: auto; margin-right: auto;">
<thead>
@@ -2791,7 +2791,7 @@
</tbody>
</table>
<pre class="r"><code>dt %>%
- kable() %>%
+ kbl() %>%
kable_material_dark()</code></pre>
<table class=" lightable-material-dark" style="font-family: "Source Sans Pro", helvetica, sans-serif; margin-left: auto; margin-right: auto;">
<thead>
@@ -2945,7 +2945,7 @@
<h2>Bootstrap table classes</h2>
<p>If you are familiar with twitter bootstrap, you probably have already known its predefined classes, including <code>striped</code>, <code>bordered</code>, <code>hover</code>, <code>condensed</code> and <code>responsive</code>. If you are not familiar, no worries, you can take a look at their <a href="http://getbootstrap.com/css/#tables">documentation site</a> to get a sense of how they look like. All of these options are available here.</p>
<p>For example, to add striped lines (alternative row colors) to your table and you want to highlight the hovered row, you can simply type:</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling(bootstrap_options = c("striped", "hover"))</code></pre>
<table class="table table-striped table-hover" style="margin-left: auto; margin-right: auto;">
<thead>
@@ -3091,7 +3091,7 @@
</tbody>
</table>
<p>The option <code>condensed</code> can also be handy in many cases when you don’t want your table to be too large. It has slightly shorter row height.</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"))</code></pre>
<table class="table table-striped table-hover table-condensed" style="margin-left: auto; margin-right: auto;">
<thead>
@@ -3237,7 +3237,7 @@
</tbody>
</table>
<p>Tables with option <code>responsive</code> looks the same with others on a large screen. However, on a small screen like phone, they are horizontally scrollable. Please resize your window to see the result.</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))</code></pre>
<table class="table table-striped table-hover table-condensed table-responsive" style="margin-left: auto; margin-right: auto;">
<thead>
@@ -3386,7 +3386,7 @@
<div id="full-width" class="section level2">
<h2>Full width?</h2>
<p>By default, a bootstrap table takes 100% of the width. It is supposed to use together with its grid system to scale the table properly. However, when you are writing a rmarkdown document, you probably don’t want to write your own css/or grid. For some small tables with only few columns, a page wide table looks awful. To make it easier, you can specify whether you want the table to have <code>full_width</code> or not in <code>kable_styling</code>. By default, <code>full_width</code> is set to be <code>TRUE</code> for HTML tables (note that for LaTeX, the default is <code>FALSE</code> since I don’t want to change the “common” looks unless you specified it.)</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_paper(bootstrap_options = "striped", full_width = F)</code></pre>
<table class=" lightable-paper" style="font-family: "Arial Narrow", arial, helvetica, sans-serif; width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
@@ -3535,7 +3535,7 @@
<div id="position" class="section level2">
<h2>Position</h2>
<p>Table Position only matters when the table doesn’t have <code>full_width</code>. You can choose to align the table to <code>center</code>, <code>left</code> or <code>right</code> side of the page</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")</code></pre>
<table class="table table-striped" style="width: auto !important; ">
<thead>
@@ -3681,7 +3681,7 @@
</tbody>
</table>
<p>Becides these three common options, you can also wrap text around the table using the <code>float-left</code> or <code>float-right</code> options.</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "float_right")</code></pre>
<table class="table table-striped" style="width: auto !important; float: right; margin-left: 10px;">
<thead>
@@ -3831,7 +3831,7 @@
<div id="font-size" class="section level2">
<h2>Font size</h2>
<p>If one of your tables is huge and you want to use a smaller font size for that specific table, you can use the <code>font_size</code> option.</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling(bootstrap_options = "striped", font_size = 7)</code></pre>
<table class="table table-striped" style="font-size: 7px; margin-left: auto; margin-right: auto;">
<thead>
@@ -3980,7 +3980,7 @@
<div id="fixed-table-header-row" class="section level2">
<h2>Fixed Table Header Row</h2>
<p>If you happened to have a very long table, you may consider to use this <code>fixed_header</code> option to fix the header row on top as your readers scroll. By default, the background is set to white. If you need a different color, you can set <code>fixed_header = list(enabled = T, background = "red")</code>.</p>
-<pre class="r"><code>kable(mtcars[1:10, 1:5]) %>%
+<pre class="r"><code>kbl(mtcars[1:10, 1:5]) %>%
kable_styling(fixed_thead = T)</code></pre>
<table class="table" style="margin-left: auto; margin-right: auto;">
<thead>
@@ -4224,7 +4224,7 @@
)
)
-kable(text_tbl) %>%
+kbl(text_tbl) %>%
kable_styling(full_width = F) %>%
column_spec(1, bold = T, border_right = T) %>%
column_spec(2, width = "30em", background = "yellow")</code></pre>
@@ -4270,7 +4270,7 @@
<p><strong>Key Update</strong>: I understand the need of doing conditional formatting and the previous solution <code>cell_spec</code> is relatively hard to use. Therefore in kableExtra 1.2, I improved the functionality of <code>column_spec</code> so it can take vectorized input for most of its arguments (except <code>width</code>, <code>border_left</code> and <code>border_right</code>). It is really easy right now to format a column based on other values.</p>
</blockquote>
<pre class="r"><code>mtcars[1:8, 1:8] %>%
- kable() %>%
+ kbl() %>%
kable_paper(full_width = F) %>%
column_spec(2, color = spec_color(mtcars$mpg[1:8]),
link = "https://haozhu233.github.io/kableExtra") %>%
@@ -4548,7 +4548,7 @@
<div id="row-spec" class="section level2">
<h2>Row spec</h2>
<p>Similar with <code>column_spec</code>, you can define specifications for rows. Currently, you can either bold or italicize an entire row. Note that, similar with other row-related functions in <code>kableExtra</code>, for the position of the target row, you don’t need to count in header rows or the group labeling rows.</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling("striped", full_width = F) %>%
column_spec(5:7, bold = T) %>%
row_spec(3:5, bold = T, color = "white", background = "#D7261E")</code></pre>
@@ -4699,7 +4699,7 @@
<div id="header-rows" class="section level2">
<h2>Header Rows</h2>
<p>One special case of <code>row_spec</code> is that you can specify the format of the header row via <code>row_spec(row = 0, ...)</code>.</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling("striped", full_width = F) %>%
row_spec(0, angle = -45)</code></pre>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
@@ -4867,7 +4867,7 @@
c("#666666", "#999999", "#BBBBBB")))
) %>%
select(car, mpg, cyl) %>%
- kable(format = "html", escape = F) %>%
+ kbl(format = "html", escape = F) %>%
kable_styling("striped", full_width = F)</code></pre>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
@@ -5010,7 +5010,7 @@
Species, color = "white", bold = T,
background = spec_color(1:10, end = 0.9, option = "A", direction = -1)
)) %>%
- kable(escape = F, align = "c") %>%
+ kbl(escape = F, align = "c") %>%
kable_styling(c("striped", "condensed"), full_width = F)</code></pre>
<table class="table table-striped table-condensed" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
@@ -5254,7 +5254,7 @@
title = NULL, # title will add a Title Panel on top
position = popover_dt$position
))
-kable(popover_dt, escape = FALSE) %>%
+kbl(popover_dt, escape = FALSE) %>%
kable_styling("striped", full_width = FALSE)</code></pre>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
@@ -5323,21 +5323,21 @@
hp = color_bar("lightgreen")(hp)
) %>%
select(car, everything()) %>%
- kable(escape = F) %>%
+ kbl(escape = F) %>%
kable_styling("hover", full_width = F) %>%
column_spec(5, width = "3cm") %>%
add_header_above(c(" ", "Hello" = 2, "World" = 2))</code></pre>
<table class="table table-hover" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
-<th style="border-bottom:hidden" colspan="1">
+<th style="empty-cells: hide;border-bottom:hidden;" colspan="1">
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Hello
</div>
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
World
</div>
@@ -5456,26 +5456,26 @@
<div id="add-header-rows-to-group-columns" class="section level2">
<h2>Add header rows to group columns</h2>
<p>Tables with multi-row headers can be very useful to demonstrate grouped data. To do that, you can pipe your kable object into <code>add_header_above()</code>. The header variable is supposed to be a named character with the names as new column names and values as column span. For your convenience, if column span equals to 1, you can ignore the <code>=1</code> part so the function below can be written as `add_header_above(c(" “,”Group 1" = 2, “Group 2” = 2, “Group 3” = 2)).</p>
-<pre class="r"><code>kable(dt) %>%
- kable_styling("striped") %>%
+<pre class="r"><code>kbl(dt) %>%
+ kable_classic() %>%
add_header_above(c(" " = 1, "Group 1" = 2, "Group 2" = 2, "Group 3" = 2))</code></pre>
-<table class="table table-striped" style="margin-left: auto; margin-right: auto;">
+<table class=" lightable-classic" style="font-family: "Arial Narrow", "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto;">
<thead>
<tr>
-<th style="border-bottom:hidden" colspan="1">
+<th style="empty-cells: hide;" colspan="1">
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<div style="border-bottom: 1px solid #111111; margin-bottom: -1px; ">
Group 1
</div>
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<div style="border-bottom: 1px solid #111111; margin-bottom: -1px; ">
Group 2
</div>
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<div style="border-bottom: 1px solid #111111; margin-bottom: -1px; ">
Group 3
</div>
</th>
@@ -5622,51 +5622,51 @@
</tbody>
</table>
<p>In fact, if you want to add another row of header on top, please feel free to do so.</p>
-<pre class="r"><code>kable(dt) %>%
- kable_styling(c("striped", "bordered")) %>%
+<pre class="r"><code>kbl(dt) %>%
+ kable_paper() %>%
add_header_above(c(" ", "Group 1" = 2, "Group 2" = 2, "Group 3" = 2)) %>%
add_header_above(c(" ", "Group 4" = 4, "Group 5" = 2)) %>%
add_header_above(c(" ", "Group 6" = 6))</code></pre>
-<table class="table table-striped table-bordered" style="margin-left: auto; margin-right: auto;">
+<table class=" lightable-paper" style="font-family: "Arial Narrow", arial, helvetica, sans-serif; margin-left: auto; margin-right: auto;">
<thead>
<tr>
-<th style="border-bottom:hidden" colspan="1">
+<th style="empty-cells: hide;" colspan="1">
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="6">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="6">
+<div style="border-bottom: 1px solid #00000020; padding-bottom: 5px; ">
Group 6
</div>
</th>
</tr>
<tr>
-<th style="border-bottom:hidden" colspan="1">
+<th style="empty-cells: hide;" colspan="1">
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="4">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="4">
+<div style="border-bottom: 1px solid #00000020; padding-bottom: 5px; ">
Group 4
</div>
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<div style="border-bottom: 1px solid #00000020; padding-bottom: 5px; ">
Group 5
</div>
</th>
</tr>
<tr>
-<th style="border-bottom:hidden" colspan="1">
+<th style="empty-cells: hide;" colspan="1">
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<div style="border-bottom: 1px solid #00000020; padding-bottom: 5px; ">
Group 1
</div>
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<div style="border-bottom: 1px solid #00000020; padding-bottom: 5px; ">
Group 2
</div>
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
-<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
+<th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
+<div style="border-bottom: 1px solid #00000020; padding-bottom: 5px; ">
Group 3
</div>
</th>
@@ -5816,7 +5816,7 @@
<div id="group-rows-via-labeling" class="section level2">
<h2>Group rows via labeling</h2>
<p>Sometimes we want a few rows of the table being grouped together. They might be items under the same topic (e.g., animals in one species) or just different data groups for a categorical variable (e.g., age < 40, age > 40). With the function <code>group_rows()</code>/<code>pack_rows()</code> in <code>kableExtra</code>, this kind of task can be completed in one line. Please see the example below. Note that when you count for the start/end rows of the group, you don’t need to count for the header rows nor other group label rows. You only need to think about the row numbers in the “original R dataframe”.</p>
-<pre class="r"><code>kable(mtcars[1:10, 1:6], caption = "Group Rows") %>%
+<pre class="r"><code>kbl(mtcars[1:10, 1:6], caption = "Group Rows") %>%
kable_styling("striped", full_width = F) %>%
pack_rows("Group 1", 4, 7) %>%
pack_rows("Group 2", 8, 10)</code></pre>
@@ -6093,11 +6093,11 @@
</table>
<p>Another way to use <code>pack_rows</code> is to provide an grouping index, similar with <code>add_header_above()</code>. This feature is only available in kableExtra > 0.5.2.</p>
<pre class="r"><code># Not evaluated. This example generates the same table as above.
-kable(mtcars[1:10, 1:6], caption = "Group Rows") %>%
+kbl(mtcars[1:10, 1:6], caption = "Group Rows") %>%
kable_styling("striped", full_width = F) %>%
pack_rows(index = c(" " = 3, "Group 1" = 4, "Group 2" = 3))</code></pre>
<p>For advanced users, you can even define your own css for the group labeling.</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling("striped", full_width = F) %>%
pack_rows("Group 1", 3, 5, label_row_css = "background-color: #666; color: #fff;")</code></pre>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
@@ -6264,7 +6264,7 @@
<div id="row-indentation" class="section level2">
<h2>Row indentation</h2>
<p>Unlike <code>pack_rows()</code>, which will insert a labeling row, sometimes we want to list a few sub groups under a total one. In that case, <code>add_indent()</code> is probably more apporiate. For advanced users, you can even define your own css for the group labeling.</p>
-<pre class="r"><code>kable(dt) %>%
+<pre class="r"><code>kbl(dt) %>%
kable_styling("striped", full_width = F) %>%
add_indent(c(1, 3, 5))</code></pre>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
@@ -6418,7 +6418,7 @@
C2 = c(rep("c", 7), rep("d", 3), rep("c", 2), rep("d", 3)),
C3 = 1:15,
C4 = sample(c(0,1), 15, replace = TRUE))
-kable(collapse_rows_dt, align = "c") %>%
+kbl(collapse_rows_dt, align = "c") %>%
kable_styling(full_width = F) %>%
column_spec(1, bold = T) %>%
collapse_rows(columns = 1:2, valign = "top")</code></pre>
@@ -6451,7 +6451,7 @@
1
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -6475,7 +6475,7 @@
4
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -6483,7 +6483,7 @@
5
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -6548,7 +6548,7 @@
12
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -6559,7 +6559,7 @@
13
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -6589,14 +6589,14 @@
</blockquote>
<p>Documentations for <code>add_footnote</code> can be found <a href="http://haozhu233.github.io/kableExtra/legacy_features#add_footnote">here</a>.</p>
<p>There are four notation systems in <code>footnote</code>, namely <code>general</code>, <code>number</code>, <code>alphabet</code> and <code>symbol</code>. The last three types of footnotes will be labeled with corresponding marks while <code>general</code> won’t be labeled. You can pick any one of these systems or choose to display them all for fulfill the APA table footnotes requirements.</p>
-<pre class="r"><code>kable(dt, align = "c") %>%
- kable_styling(full_width = F) %>%
+<pre class="r"><code>kbl(dt, align = "c") %>%
+ kable_classic(full_width = F) %>%
footnote(general = "Here is a general comments of the table. ",
number = c("Footnote 1; ", "Footnote 2; "),
alphabet = c("Footnote A; ", "Footnote B; "),
symbol = c("Footnote Symbol 1; ", "Footnote Symbol 2")
)</code></pre>
-<table class="table" style="width: auto !important; margin-left: auto; margin-right: auto;">
+<table class=" lightable-classic" style="font-family: "Arial Narrow", "Source Sans Pro", sans-serif; width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="text-align:left;">
@@ -6782,7 +6782,7 @@
</tfoot>
</table>
<p>You can also specify title for each category by using the <code>***_title</code> arguments. Default value for <code>general_title</code> is “Note:” and "" for the rest three. You can also change the order using <code>footnote_order</code>. You can even display footnote as chunk texts (default is as a list) using <code>footnote_as_chunk</code>. The font format of the titles are controlled by <code>title_format</code> with options including “italic” (default), “bold” and “underline”.</p>
-<pre class="r"><code>kable(dt, align = "c") %>%
+<pre class="r"><code>kbl(dt, align = "c") %>%
kable_styling(full_width = F) %>%
footnote(general = "Here is a general comments of the table. ",
number = c("Footnote 1; ", "Footnote 2; "),
@@ -6960,12 +6960,10 @@
<p>If you need to add footnote marks in table, you need to do it manually (no fancy) using <code>footnote_mark_***()</code>. Remember that similar with <code>cell_spec</code>, you need to tell this function whether you want it to do it in <code>HTML</code> (default) or <code>LaTeX</code>. You can set it for all using the <code>knitr.table.format</code> global option. ALso, if you have ever use <code>footnote_mark_***()</code>, you need to put <code>escape = F</code> in your <code>kable</code> function to avoid escaping of special characters.</p>
<pre class="r"><code>dt_footnote <- dt
names(dt_footnote)[2] <- paste0(names(dt_footnote)[2],
- footnote_marker_symbol(1))</code></pre>
-<pre><code>## Setting footnote_marker_symbol format as html</code></pre>
-<pre class="r"><code>row.names(dt_footnote)[4] <- paste0(row.names(dt_footnote)[4],
- footnote_marker_alphabet(1))</code></pre>
-<pre><code>## Setting footnote_marker_alphabet format as html</code></pre>
-<pre class="r"><code>kable(dt_footnote, align = "c",
+ footnote_marker_symbol(1))
+row.names(dt_footnote)[4] <- paste0(row.names(dt_footnote)[4],
+ footnote_marker_alphabet(1))
+kbl(dt_footnote, align = "c",
# Remember this escape = F
escape = F) %>%
kable_styling(full_width = F) %>%
@@ -7135,7 +7133,7 @@
<h2>Scroll box</h2>
<p>If you have a huge table and you don’t want to reduce the font size to unreadable, you may want to put your HTML table in a scroll box, of which users can pick the part they like to read. Note that scroll box isn’t printer friendly, so be aware of that when you use this feature.</p>
<p>When you use <code>scroll_box</code>, you can specify either <code>height</code> or <code>width</code>. When you specify <code>height</code>, you will get a vertically scrollable box and vice versa. If you specify both, you will get a two-way scrollable box.</p>
-<pre class="r"><code>kable(cbind(mtcars, mtcars)) %>%
+<pre class="r"><code>kbl(cbind(mtcars, mtcars)) %>%
kable_styling() %>%
scroll_box(width = "500px", height = "200px")</code></pre>
<div style="border: 1px solid #ddd; padding: 0px; overflow-y: scroll; height:200px; overflow-x: scroll; width:500px; ">
@@ -9490,7 +9488,7 @@
</div>
<p><br></p>
<p>You can also specify width using a percentage.</p>
-<pre class="r"><code>kable(cbind(mtcars, mtcars)) %>%
+<pre class="r"><code>kbl(cbind(mtcars, mtcars)) %>%
add_header_above(c("a" = 5, "b" = 18)) %>%
kable_styling() %>%
scroll_box(width = "100%", height = "200px")</code></pre>
@@ -9498,12 +9496,12 @@
<table class="table" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; position: sticky; top:0; background-color: #FFFFFF;" colspan="5">
+<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; position: sticky; top:0; background-color: #FFFFFF;" colspan="5">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
a
</div>
</th>
-<th style="border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; position: sticky; top:0; background-color: #FFFFFF;" colspan="18">
+<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; position: sticky; top:0; background-color: #FFFFFF;" colspan="18">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
b
</div>
@@ -11861,7 +11859,7 @@
<div id="save-html-table-directly" class="section level2">
<h2>Save HTML table directly</h2>
<p>If you need to save those HTML tables but you don’t want to generate them through rmarkdown, you can try to use the <code>save_kable()</code> function. You can choose whether to let those HTML files be self contained (default is yes). Self contained files packed CSS into the HTML file so they are quite large when there are many.</p>
-<pre class="r"><code>kable(mtcars) %>%
+<pre class="r"><code>kbl(mtcars) %>%
kable_styling() %>%
save_kable(file = "table1.html", self_contained = T)</code></pre>
</div>