Skip to content

Commit

Permalink
Updated vignettes and fixed bug when table_id was FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
gforge committed Oct 19, 2016
1 parent 234541c commit 036bd87
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
2 changes: 2 additions & 0 deletions R/htmlTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ htmlTable.default <- function(x,
table_id <- sprintf(" id='%s'", label)
}else if(is.numeric(table_id)){
table_id <- paste0(" id='table_", table_id, "'")
}else if(table_id == FALSE){
table_id <- ""
}

# A column counter that is used for <td colspan="">
Expand Down
2 changes: 1 addition & 1 deletion inst/doc/general.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ output <- matrix(1:4,
htmlTable(output)

## ------------------------------------------------------------------------
htmlTable(output,
htmlTable(output, ctable=c("solid", "double"),
caption="A table caption above")

## ------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion inst/doc/general.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Table caption
The table caption is simply the table description and can be either located above or below:

```{r}
htmlTable(output,
htmlTable(output, ctable=c("solid", "double"),
caption="A table caption above")
```

Expand Down
24 changes: 12 additions & 12 deletions inst/doc/general.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<meta name="author" content="Max Gordon" />

<meta name="date" content="2016-07-24" />
<meta name="date" content="2016-10-19" />

<title>The htmlTable package</title>

Expand Down Expand Up @@ -70,7 +70,7 @@

<h1 class="title toc-ignore">The htmlTable package</h1>
<h4 class="author"><em>Max Gordon</em></h4>
<h4 class="date"><em>2016-07-24</em></h4>
<h4 class="date"><em>2016-10-19</em></h4>


<div id="TOC">
Expand Down Expand Up @@ -144,7 +144,7 @@ <h1>Basics</h1>
<div id="table-caption" class="section level2">
<h2>Table caption</h2>
<p>The table caption is simply the table description and can be either located above or below:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">htmlTable</span>(output,
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">htmlTable</span>(output, <span class="dt">ctable=</span><span class="kw">c</span>(<span class="st">&quot;solid&quot;</span>, <span class="st">&quot;double&quot;</span>),
<span class="dt">caption=</span><span class="st">&quot;A table caption above&quot;</span>)</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
Expand Down Expand Up @@ -177,13 +177,13 @@ <h2>Table caption</h2>
</td>
</tr>
<tr>
<td style="border-bottom: 2px solid grey; text-align: left;">
<td style="border-bottom: 4px double grey; text-align: left;">
Row 2
</td>
<td style="border-bottom: 2px solid grey; text-align: center;">
<td style="border-bottom: 4px double grey; text-align: center;">
2
</td>
<td style="border-bottom: 2px solid grey; text-align: center;">
<td style="border-bottom: 4px double grey; text-align: center;">
4
</td>
</tr>
Expand Down Expand Up @@ -2848,7 +2848,7 @@ <h2>Table footer</h2>
<p>The footer usually contains specifics regarding variables and is always located at the foot of the table:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">htmlTable</span>(mx[<span class="dv">1</span>:<span class="dv">2</span>,<span class="dv">1</span>:<span class="dv">2</span>],
<span class="dt">tfoot=</span><span class="st">&quot;A table footer&quot;</span>)</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-bottom: 1px solid grey; border-top: 2px solid grey;">
Expand Down Expand Up @@ -2899,7 +2899,7 @@ <h2>Zebra coloring (or banded colors)</h2>
<p>Zebra coloring is also know as an alternating color pattern or row shading. It is most commonly applied to rows:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">htmlTable</span>(mx,
<span class="dt">col.rgroup =</span> <span class="kw">c</span>(<span class="st">&quot;none&quot;</span>, <span class="st">&quot;#F7F7F7&quot;</span>))</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-bottom: 1px solid grey; border-top: 2px solid grey;">
Expand Down Expand Up @@ -3116,7 +3116,7 @@ <h2>Zebra coloring (or banded colors)</h2>
<span class="dt">col.rgroup =</span> <span class="kw">c</span>(<span class="st">&quot;none&quot;</span>, <span class="st">&quot;#F7F7F7&quot;</span>),
<span class="dt">rgroup =</span> <span class="kw">c</span>(<span class="kw">paste</span>(<span class="st">&quot;Group&quot;</span>, LETTERS[<span class="dv">1</span>:<span class="dv">2</span>]), <span class="st">&quot;&quot;</span>),
<span class="dt">n.rgroup =</span> <span class="kw">c</span>(<span class="dv">2</span>,<span class="dv">2</span>,<span class="kw">nrow</span>(mx) -<span class="st"> </span><span class="dv">4</span>))</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-bottom: 1px solid grey; border-top: 2px solid grey;">
Expand Down Expand Up @@ -3341,7 +3341,7 @@ <h2>Zebra coloring (or banded colors)</h2>
<p>We can also color the columns:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">htmlTable</span>(mx,
<span class="dt">col.columns =</span> <span class="kw">c</span>(<span class="st">&quot;none&quot;</span>, <span class="st">&quot;#F7F7F7&quot;</span>))</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-bottom: 1px solid grey; border-top: 2px solid grey;">
Expand Down Expand Up @@ -3557,7 +3557,7 @@ <h2>Zebra coloring (or banded colors)</h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">htmlTable</span>(mx,
<span class="dt">col.rgroup =</span> <span class="kw">c</span>(<span class="st">&quot;none&quot;</span>, <span class="st">&quot;#F9FAF0&quot;</span>),
<span class="dt">col.columns =</span> <span class="kw">c</span>(<span class="st">&quot;none&quot;</span>, <span class="st">&quot;#F1F0FA&quot;</span>))</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-bottom: 1px solid grey; border-top: 2px solid grey;">
Expand Down Expand Up @@ -3788,7 +3788,7 @@ <h2>Putting it all together</h2>
<span class="kw">rep</span>(<span class="st">&quot;#F5FBFF&quot;</span>, <span class="dv">4</span>)),
<span class="dt">col.rgroup =</span> <span class="kw">c</span>(<span class="st">&quot;none&quot;</span>, <span class="st">&quot;#F7F7F7&quot;</span>),
<span class="dt">css.cell =</span> <span class="st">&quot;padding-left: .5em; padding-right: .2em;&quot;</span>)</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<td colspan="9" style="text-align: left;">
Expand Down
18 changes: 9 additions & 9 deletions inst/doc/tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<meta name="author" content="Max Gordon" />

<meta name="date" content="2016-07-24" />
<meta name="date" content="2016-10-19" />

<title>Tables with htmlTable and some alternatives</title>

Expand Down Expand Up @@ -70,7 +70,7 @@

<h1 class="title toc-ignore">Tables with htmlTable and some alternatives</h1>
<h4 class="author"><em>Max Gordon</em></h4>
<h4 class="date"><em>2016-07-24</em></h4>
<h4 class="date"><em>2016-10-19</em></h4>


<div id="TOC">
Expand Down Expand Up @@ -126,7 +126,7 @@ <h2>The <code>htmlTable</code>-package</h2>
<span class="dt">n.cgroup =</span> <span class="kw">c</span>(<span class="dv">2</span>,<span class="dv">2</span>),
<span class="dt">caption=</span><span class="st">&quot;Basic table with both column spanners (groups) and row groups&quot;</span>,
<span class="dt">tfoot=</span><span class="st">&quot;&amp;dagger; A table footer commment&quot;</span>)</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<td colspan="6" style="text-align: left;">
Expand Down Expand Up @@ -396,7 +396,7 @@ <h3>Example based upon Swedish statistics</h3>
<span class="dt">n.rgroup =</span> <span class="kw">rep</span>(<span class="dv">5</span>, <span class="dv">3</span>),
<span class="dt">tfoot =</span> <span class="kw">txtMergeLines</span>(<span class="st">&quot;&amp;Delta;&lt;sub&gt;int&lt;/sub&gt; correspnds to the change since start&quot;</span>,
<span class="st">&quot;&amp;Delta;&lt;sub&gt;std&lt;/sub&gt; corresponds to the change compared to national average&quot;</span>))</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-top: 2px solid grey;">
Expand Down Expand Up @@ -1980,7 +1980,7 @@ <h3>Example based upon Swedish statistics</h3>
<span class="dt">n.rgroup =</span> <span class="kw">rep</span>(<span class="dv">5</span>, <span class="dv">3</span>),
<span class="dt">tfoot =</span> <span class="kw">txtMergeLines</span>(<span class="st">&quot;&amp;Delta;&lt;sub&gt;int&lt;/sub&gt; correspnds to the change since start&quot;</span>,
<span class="st">&quot;&amp;Delta;&lt;sub&gt;std&lt;/sub&gt; corresponds to the change compared to national average&quot;</span>))</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-top: 2px solid grey;">
Expand Down Expand Up @@ -3566,7 +3566,7 @@ <h3>Example based upon Swedish statistics</h3>
<span class="dt">n.rgroup =</span> <span class="kw">rep</span>(<span class="dv">5</span>, <span class="dv">3</span>),
<span class="dt">tfoot =</span> <span class="kw">txtMergeLines</span>(<span class="st">&quot;&amp;Delta;&lt;sub&gt;int&lt;/sub&gt; correspnds to the change since start&quot;</span>,
<span class="st">&quot;&amp;Delta;&lt;sub&gt;std&lt;/sub&gt; corresponds to the change compared to national average&quot;</span>))</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-top: 2px solid grey;">
Expand Down Expand Up @@ -5157,7 +5157,7 @@ <h3>Example based upon Swedish statistics</h3>
<span class="dt">tfoot =</span> <span class="kw">txtMergeLines</span>(<span class="st">&quot;&amp;Delta;&lt;sub&gt;int&lt;/sub&gt; correspnds to the change since start&quot;</span>,
<span class="st">&quot;&amp;Delta;&lt;sub&gt;std&lt;/sub&gt; corresponds to the change compared to national average&quot;</span>),
<span class="dt">cspan.rgroup =</span> <span class="dv">1</span>)</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<th style="border-top: 2px solid grey;">
Expand Down Expand Up @@ -6965,7 +6965,7 @@ <h3>Example based upon Swedish statistics</h3>
<span class="dt">tfoot =</span> <span class="kw">txtMergeLines</span>(<span class="st">&quot;&amp;Delta;&lt;sub&gt;int&lt;/sub&gt; correspnds to the change since start&quot;</span>,
<span class="st">&quot;&amp;Delta;&lt;sub&gt;std&lt;/sub&gt; corresponds to the change compared to national average&quot;</span>),
<span class="dt">cspan.rgroup =</span> <span class="dv">1</span>)</code></pre></div>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;" FALSE>
<table class="gmisc_table" style="border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;">
<thead>
<tr>
<td colspan="30" style="text-align: left;">
Expand Down Expand Up @@ -9983,7 +9983,7 @@ <h3>The <code>xtable</code>-package</h3>
<span class="dt">align =</span> <span class="kw">c</span>(<span class="st">&quot;l&quot;</span>, <span class="st">&quot;c&quot;</span>, <span class="st">&quot;r&quot;</span>)),
<span class="dt">type=</span><span class="st">&quot;html&quot;</span>)</code></pre></div>
<!-- html table generated in R 3.3.1 by xtable 1.8-2 package -->
<!-- Sun Jul 24 11:41:14 2016 -->
<!-- Wed Oct 19 10:15:13 2016 -->
<table border="1">
<caption align="bottom">
A test table
Expand Down

0 comments on commit 036bd87

Please sign in to comment.