Debian Codegraph @

inst/doc/pandoc_table.html

raw symbols SCIP
1 <!DOCTYPE html>
2
3 <html>
4
5 <head>
6
7 <meta charset="utf-8" />
8 <meta name="generator" content="pandoc" />
9 <meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
10
11 <meta name="viewport" content="width=device-width, initial-scale=1" />
12
13 <meta name="author" content="Roman Tsegelskyi, Gergely Daróczi" />
14
15 <meta name="date" content="2021-06-11" />
16
17 <title>Rendering tables with pandoc.table</title>
18
19 <script src="data:application/javascript;base64,Ly8gUGFuZG9jIDIuOSBhZGRzIGF0dHJpYnV0ZXMgb24gYm90aCBoZWFkZXIgYW5kIGRpdi4gV2UgcmVtb3ZlIHRoZSBmb3JtZXIgKHRvCi8vIGJlIGNvbXBhdGlibGUgd2l0aCB0aGUgYmVoYXZpb3Igb2YgUGFuZG9jIDwgMi44KS4KZG9jdW1lbnQuYWRkRXZlbnRMaXN0ZW5lcignRE9NQ29udGVudExvYWRlZCcsIGZ1bmN0aW9uKGUpIHsKICB2YXIgaHMgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCJkaXYuc2VjdGlvbltjbGFzcyo9J2xldmVsJ10gPiA6Zmlyc3QtY2hpbGQiKTsKICB2YXIgaSwgaCwgYTsKICBmb3IgKGkgPSAwOyBpIDwgaHMubGVuZ3RoOyBpKyspIHsKICAgIGggPSBoc1tpXTsKICAgIGlmICghL15oWzEtNl0kL2kudGVzdChoLnRhZ05hbWUpKSBjb250aW51ZTsgIC8vIGl0IHNob3VsZCBiZSBhIGhlYWRlciBoMS1oNgogICAgYSA9IGguYXR0cmlidXRlczsKICAgIHdoaWxlIChhLmxlbmd0aCA+IDApIGgucmVtb3ZlQXR0cmlidXRlKGFbMF0ubmFtZSk7CiAgfQp9KTsK"></script>
20
21 <style type="text/css">
22 code{white-space: pre-wrap;}
23 span.smallcaps{font-variant: small-caps;}
24 span.underline{text-decoration: underline;}
25 div.column{display: inline-block; vertical-align: top; width: 50%;}
26 div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
27 ul.task-list{list-style: none;}
28 </style>
29
30
31 <style type="text/css">
32 code {
33 white-space: pre;
34 }
35 .sourceCode {
36 overflow: visible;
37 }
38 </style>
39 <style type="text/css" data-origin="pandoc">
40 pre > code.sourceCode { white-space: pre; position: relative; }
41 pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
42 pre > code.sourceCode > span:empty { height: 1.2em; }
43 .sourceCode { overflow: visible; }
44 code.sourceCode > span { color: inherit; text-decoration: inherit; }
45 div.sourceCode { margin: 1em 0; }
46 pre.sourceCode { margin: 0; }
47 @media screen {
48 div.sourceCode { overflow: auto; }
49 }
50 @media print {
51 pre > code.sourceCode { white-space: pre-wrap; }
52 pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
53 }
54 pre.numberSource code
55 { counter-reset: source-line 0; }
56 pre.numberSource code > span
57 { position: relative; left: -4em; counter-increment: source-line; }
58 pre.numberSource code > span > a:first-child::before
59 { content: counter(source-line);
60 position: relative; left: -1em; text-align: right; vertical-align: baseline;
61 border: none; display: inline-block;
62 -webkit-touch-callout: none; -webkit-user-select: none;
63 -khtml-user-select: none; -moz-user-select: none;
64 -ms-user-select: none; user-select: none;
65 padding: 0 4px; width: 4em;
66 color: #aaaaaa;
67 }
68 pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
69 div.sourceCode
70 { }
71 @media screen {
72 pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
73 }
74 code span.al { color: #ff0000; font-weight: bold; } /* Alert */
75 code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
76 code span.at { color: #7d9029; } /* Attribute */
77 code span.bn { color: #40a070; } /* BaseN */
78 code span.bu { } /* BuiltIn */
79 code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
80 code span.ch { color: #4070a0; } /* Char */
81 code span.cn { color: #880000; } /* Constant */
82 code span.co { color: #60a0b0; font-style: italic; } /* Comment */
83 code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
84 code span.do { color: #ba2121; font-style: italic; } /* Documentation */
85 code span.dt { color: #902000; } /* DataType */
86 code span.dv { color: #40a070; } /* DecVal */
87 code span.er { color: #ff0000; font-weight: bold; } /* Error */
88 code span.ex { } /* Extension */
89 code span.fl { color: #40a070; } /* Float */
90 code span.fu { color: #06287e; } /* Function */
91 code span.im { } /* Import */
92 code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
93 code span.kw { color: #007020; font-weight: bold; } /* Keyword */
94 code span.op { color: #666666; } /* Operator */
95 code span.ot { color: #007020; } /* Other */
96 code span.pp { color: #bc7a00; } /* Preprocessor */
97 code span.sc { color: #4070a0; } /* SpecialChar */
98 code span.ss { color: #bb6688; } /* SpecialString */
99 code span.st { color: #4070a0; } /* String */
100 code span.va { color: #19177c; } /* Variable */
101 code span.vs { color: #4070a0; } /* VerbatimString */
102 code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
103
104 </style>
105 <script>
106 // apply pandoc div.sourceCode style to pre.sourceCode instead
107 (function() {
108 var sheets = document.styleSheets;
109 for (var i = 0; i < sheets.length; i++) {
110 if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
111 try { var rules = sheets[i].cssRules; } catch (e) { continue; }
112 for (var j = 0; j < rules.length; j++) {
113 var rule = rules[j];
114 // check if there is a div.sourceCode rule
115 if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue;
116 var style = rule.style.cssText;
117 // check if color or background-color is set
118 if (rule.style.color === '' && rule.style.backgroundColor === '') continue;
119 // replace div.sourceCode by a pre.sourceCode rule
120 sheets[i].deleteRule(j);
121 sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
122 }
123 }
124 })();
125 </script>
126
127
128
129
130 <link rel="stylesheet" href="data:text/css,body%20%7B%0Abackground%2Dcolor%3A%20%23fff%3B%0Amargin%3A%201em%20auto%3B%0Amax%2Dwidth%3A%20700px%3B%0Aoverflow%3A%20visible%3B%0Apadding%2Dleft%3A%202em%3B%0Apadding%2Dright%3A%202em%3B%0Afont%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014px%3B%0Aline%2Dheight%3A%201%2E35%3B%0A%7D%0A%23TOC%20%7B%0Aclear%3A%20both%3B%0Amargin%3A%200%200%2010px%2010px%3B%0Apadding%3A%204px%3B%0Awidth%3A%20400px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Aborder%2Dradius%3A%205px%3B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Afont%2Dsize%3A%2013px%3B%0Aline%2Dheight%3A%201%2E3%3B%0A%7D%0A%23TOC%20%2Etoctitle%20%7B%0Afont%2Dweight%3A%20bold%3B%0Afont%2Dsize%3A%2015px%3B%0Amargin%2Dleft%3A%205px%3B%0A%7D%0A%23TOC%20ul%20%7B%0Apadding%2Dleft%3A%2040px%3B%0Amargin%2Dleft%3A%20%2D1%2E5em%3B%0Amargin%2Dtop%3A%205px%3B%0Amargin%2Dbottom%3A%205px%3B%0A%7D%0A%23TOC%20ul%20ul%20%7B%0Amargin%2Dleft%3A%20%2D2em%3B%0A%7D%0A%23TOC%20li%20%7B%0Aline%2Dheight%3A%2016px%3B%0A%7D%0Atable%20%7B%0Amargin%3A%201em%20auto%3B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dcolor%3A%20%23DDDDDD%3B%0Aborder%2Dstyle%3A%20outset%3B%0Aborder%2Dcollapse%3A%20collapse%3B%0A%7D%0Atable%20th%20%7B%0Aborder%2Dwidth%3A%202px%3B%0Apadding%3A%205px%3B%0Aborder%2Dstyle%3A%20inset%3B%0A%7D%0Atable%20td%20%7B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dstyle%3A%20inset%3B%0Aline%2Dheight%3A%2018px%3B%0Apadding%3A%205px%205px%3B%0A%7D%0Atable%2C%20table%20th%2C%20table%20td%20%7B%0Aborder%2Dleft%2Dstyle%3A%20none%3B%0Aborder%2Dright%2Dstyle%3A%20none%3B%0A%7D%0Atable%20thead%2C%20table%20tr%2Eeven%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Ap%20%7B%0Amargin%3A%200%2E5em%200%3B%0A%7D%0Ablockquote%20%7B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Apadding%3A%200%2E25em%200%2E75em%3B%0A%7D%0Ahr%20%7B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%3A%20none%3B%0Aborder%2Dtop%3A%201px%20solid%20%23777%3B%0Amargin%3A%2028px%200%3B%0A%7D%0Adl%20%7B%0Amargin%2Dleft%3A%200%3B%0A%7D%0Adl%20dd%20%7B%0Amargin%2Dbottom%3A%2013px%3B%0Amargin%2Dleft%3A%2013px%3B%0A%7D%0Adl%20dt%20%7B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Aul%20%7B%0Amargin%2Dtop%3A%200%3B%0A%7D%0Aul%20li%20%7B%0Alist%2Dstyle%3A%20circle%20outside%3B%0A%7D%0Aul%20ul%20%7B%0Amargin%2Dbottom%3A%200%3B%0A%7D%0Apre%2C%20code%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0Aborder%2Dradius%3A%203px%3B%0Acolor%3A%20%23333%3B%0Awhite%2Dspace%3A%20pre%2Dwrap%3B%20%0A%7D%0Apre%20%7B%0Aborder%2Dradius%3A%203px%3B%0Amargin%3A%205px%200px%2010px%200px%3B%0Apadding%3A%2010px%3B%0A%7D%0Apre%3Anot%28%5Bclass%5D%29%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Acode%20%7B%0Afont%2Dfamily%3A%20Consolas%2C%20Monaco%2C%20%27Courier%20New%27%2C%20monospace%3B%0Afont%2Dsize%3A%2085%25%3B%0A%7D%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%7B%0Apadding%3A%202px%200px%3B%0A%7D%0Adiv%2Efigure%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Aimg%20%7B%0Abackground%2Dcolor%3A%20%23FFFFFF%3B%0Apadding%3A%202px%3B%0Aborder%3A%201px%20solid%20%23DDDDDD%3B%0Aborder%2Dradius%3A%203px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Amargin%3A%200%205px%3B%0A%7D%0Ah1%20%7B%0Amargin%2Dtop%3A%200%3B%0Afont%2Dsize%3A%2035px%3B%0Aline%2Dheight%3A%2040px%3B%0A%7D%0Ah2%20%7B%0Aborder%2Dbottom%3A%204px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Apadding%2Dbottom%3A%202px%3B%0Afont%2Dsize%3A%20145%25%3B%0A%7D%0Ah3%20%7B%0Aborder%2Dbottom%3A%202px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Afont%2Dsize%3A%20120%25%3B%0A%7D%0Ah4%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23f7f7f7%3B%0Amargin%2Dleft%3A%208px%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Ah5%2C%20h6%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23ccc%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Aa%20%7B%0Acolor%3A%20%230033dd%3B%0Atext%2Ddecoration%3A%20none%3B%0A%7D%0Aa%3Ahover%20%7B%0Acolor%3A%20%236666ff%3B%20%7D%0Aa%3Avisited%20%7B%0Acolor%3A%20%23800080%3B%20%7D%0Aa%3Avisited%3Ahover%20%7B%0Acolor%3A%20%23BB00BB%3B%20%7D%0Aa%5Bhref%5E%3D%22http%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0Aa%5Bhref%5E%3D%22https%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0A%0Acode%20%3E%20span%2Ekw%20%7B%20color%3A%20%23555%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Edt%20%7B%20color%3A%20%23902000%3B%20%7D%20%0Acode%20%3E%20span%2Edv%20%7B%20color%3A%20%2340a070%3B%20%7D%20%0Acode%20%3E%20span%2Ebn%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Efl%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Ech%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Est%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Eco%20%7B%20color%3A%20%23888888%3B%20font%2Dstyle%3A%20italic%3B%20%7D%20%0Acode%20%3E%20span%2Eot%20%7B%20color%3A%20%23007020%3B%20%7D%20%0Acode%20%3E%20span%2Eal%20%7B%20color%3A%20%23ff0000%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Efu%20%7B%20color%3A%20%23900%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Eer%20%7B%20color%3A%20%23a61717%3B%20background%2Dcolor%3A%20%23e3d2d2%3B%20%7D%20%0A" type="text/css" />
131
132
133
134
135 </head>
136
137 <body>
138
139
140
141
142 <h1 class="title toc-ignore">Rendering tables with pandoc.table</h1>
143 <h4 class="author">Roman Tsegelskyi, Gergely Daróczi</h4>
144 <h4 class="date">2021-06-11</h4>
145
146
147
148 <p>Core functionality of <code>pander</code> is centered around <code>pandoc.table</code>, which is aimed at rendering tables in <code>markdown</code>. In case of 2D tables, <code>pander</code> calls <code>pandoc.table</code> internally, thus in such cases <code>pander</code> and <code>pandoc.table</code> support the same argument and in this vignette will be used iterchangingly. <code>pandoc.table</code> has a wide variety of options (<a href="#highlighting-cells">highlighting</a>, <a href="#table-styles">styles</a>, etc.) and this vignette aims to give a more detailed overview of the most common options. <code>pander</code> comes with a variety of globally adjustable options, which have an effect on the result of your reports. You can query and update these options with the <code>panderOptions</code> function.</p>
149 <div id="table-styles" class="section level2">
150 <h2>Table styles</h2>
151 <p>Since <code>pander</code> aims at rendering R objects into <a href="https://pandoc.org/">Pandoc</a>’s markdown all four (<code>multiline</code>, <code>simple</code>, <code>grid</code>, <code>rmarkdown</code>) of <a href="https://johnmacfarlane.net/pandoc/README.html#tables">Pandoc</a>’s formats are supported. Users are advised to stick with the default <code>multiline</code> style, but if there is a need to change it either specify <code>style</code> argument when calling <code>pander/pandoc.table</code> or change the default <code>style</code> using <code>panderOptions</code>.</p>
152 <div id="multiline-tables" class="section level3">
153 <h3>multiline tables</h3>
154 <p><code>multiline</code> tables allow headers and table rows to span multiple lines of text (but cells that span multiple columns or rows of the table are not supported). Also note that, for simplicity, line breaks are removed from cells by default, so multiline cells are typically the result of <a href="#table-and-cell-width">splitting large cells</a> or setting <code>keep.line.breaks</code> to <code>TRUE</code>:</p>
155 <div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> <span class="fu">data.frame</span>(<span class="st">&#39;Value</span><span class="sc">\n</span><span class="st">1&#39;</span>, <span class="st">&#39;Value</span><span class="sc">\n</span><span class="st">2&#39;</span>)</span>
156 <span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">colnames</span>(m) <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">&#39;Multiline</span><span class="sc">\n</span><span class="st">Col1&#39;</span>, <span class="st">&#39;Multiline</span><span class="sc">\n</span><span class="st">Col2&#39;</span>)</span>
157 <span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m, <span class="at">keep.line.breaks =</span> <span class="cn">TRUE</span>)</span>
158 <span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
159 <span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -----------------------</span></span>
160 <span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Multiline Multiline </span></span>
161 <span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Col1 Col2 </span></span>
162 <span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------- -----------</span></span>
163 <span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Value Value </span></span>
164 <span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 2 </span></span>
165 <span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -----------------------</span></span>
166 <span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>]</span>
167 <span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m)</span>
168 <span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
169 <span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------</span></span>
170 <span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; mpg cyl disp hp </span></span>
171 <span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------------- ------ ----- ------ -----</span></span>
172 <span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 21 6 160 110 </span></span>
173 <span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
174 <span id="cb1-20"><a href="#cb1-20" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 Wag 21 6 160 110 </span></span>
175 <span id="cb1-21"><a href="#cb1-21" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
176 <span id="cb1-22"><a href="#cb1-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Datsun 710 22.8 4 108 93 </span></span>
177 <span id="cb1-23"><a href="#cb1-23" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------</span></span></code></pre></div>
178 </div>
179 <div id="simple-tables" class="section level3">
180 <h3>simple tables</h3>
181 <p><code>simple</code> tables are have more compact syntax that all other styles, but don’t they support multiline cells:</p>
182 <div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>]</span>
183 <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m, <span class="at">style =</span> <span class="st">&#39;simple&#39;</span>)</span>
184 <span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
185 <span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
186 <span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; mpg cyl disp hp </span></span>
187 <span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------------- ------ ----- ------ -----</span></span>
188 <span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 21 6 160 110 </span></span>
189 <span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 Wag 21 6 160 110 </span></span>
190 <span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Datsun 710 22.8 4 108 93</span></span>
191 <span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> <span class="fu">data.frame</span>(<span class="st">&#39;Value</span><span class="sc">\n</span><span class="st">1&#39;</span>, <span class="st">&#39;Value</span><span class="sc">\n</span><span class="st">2&#39;</span>)</span>
192 <span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="fu">colnames</span>(m) <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">&#39;Multiline</span><span class="sc">\n</span><span class="st">Col1&#39;</span>, <span class="st">&#39;Multiline</span><span class="sc">\n</span><span class="st">Col2&#39;</span>)</span>
193 <span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m, <span class="at">keep.line.breaks =</span> <span class="cn">TRUE</span>, <span class="at">style=</span><span class="st">&#39;simple&#39;</span>)</span>
194 <span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Error in tableExpand_cpp(cells, cols.width, justify, sep.cols, style): Pandoc does not support newlines in simple or Rmarkdown table format!</span></span></code></pre></div>
195 </div>
196 <div id="grid-tables" class="section level3">
197 <h3>grid tables</h3>
198 <p><code>grid</code> format is really handy for <code>emacs</code> users (<a href="https://table.sourceforge.net/">Emacs table mod</a>) and it does support block elements (multiple paragraphs, code blocks, lists, etc.) inside cells, but cells can’t span multiple columns or rows. Alignments are not supported for grid tables by most parsers, meaning that even though <code>pander</code> will produce a table with alignment, it will be lost during conversion from <code>markdown</code> to <code>HTML/PDF/DOCX</code>.</p>
199 <div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>]</span>
200 <span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m, <span class="at">style =</span> <span class="st">&#39;grid&#39;</span>)</span>
201 <span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
202 <span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
203 <span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+------+-----+------+-----+</span></span>
204 <span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | | mpg | cyl | disp | hp |</span></span>
205 <span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +===================+======+=====+======+=====+</span></span>
206 <span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 | 21 | 6 | 160 | 110 |</span></span>
207 <span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+------+-----+------+-----+</span></span>
208 <span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 Wag | 21 | 6 | 160 | 110 |</span></span>
209 <span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+------+-----+------+-----+</span></span>
210 <span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Datsun 710 | 22.8 | 4 | 108 | 93 |</span></span>
211 <span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+------+-----+------+-----+</span></span>
212 <span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> <span class="fu">data.frame</span>(<span class="st">&#39;Value</span><span class="sc">\n</span><span class="st">1&#39;</span>, <span class="st">&#39;Value</span><span class="sc">\n</span><span class="st">2&#39;</span>)</span>
213 <span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a><span class="fu">colnames</span>(m) <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">&#39;Multiline</span><span class="sc">\n</span><span class="st">Col1&#39;</span>, <span class="st">&#39;Multiline</span><span class="sc">\n</span><span class="st">Col2&#39;</span>)</span>
214 <span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m, <span class="at">keep.line.breaks =</span> <span class="cn">TRUE</span>, <span class="at">style=</span><span class="st">&#39;grid&#39;</span>)</span>
215 <span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
216 <span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
217 <span id="cb3-19"><a href="#cb3-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-----------+-----------+</span></span>
218 <span id="cb3-20"><a href="#cb3-20" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Multiline | Multiline |</span></span>
219 <span id="cb3-21"><a href="#cb3-21" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Col1 | Col2 |</span></span>
220 <span id="cb3-22"><a href="#cb3-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +===========+===========+</span></span>
221 <span id="cb3-23"><a href="#cb3-23" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Value | Value |</span></span>
222 <span id="cb3-24"><a href="#cb3-24" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | 1 | 2 |</span></span>
223 <span id="cb3-25"><a href="#cb3-25" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-----------+-----------+</span></span></code></pre></div>
224 </div>
225 <div id="rmarkdown-tables" class="section level3">
226 <h3>rmarkdown tables</h3>
227 <p><code>rmarkdown</code> or pipe table format, is often used directly with <code>knitr</code>, since it was supported by the first versions of the <code>markdown</code> package. It is similar to <code>simple</code> table in that multiline cells are also not supported. The beginning and ending pipe characters are optional, but pipes are required between all columns:</p>
228 <div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>]</span>
229 <span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m, <span class="at">style =</span> <span class="st">&#39;rmarkdown&#39;</span>)</span>
230 <span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
231 <span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
232 <span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | | mpg | cyl | disp | hp |</span></span>
233 <span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; |:-----------------:|:----:|:---:|:----:|:---:|</span></span>
234 <span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 | 21 | 6 | 160 | 110 |</span></span>
235 <span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 Wag | 21 | 6 | 160 | 110 |</span></span>
236 <span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Datsun 710 | 22.8 | 4 | 108 | 93 |</span></span>
237 <span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> <span class="fu">data.frame</span>(<span class="st">&#39;Value</span><span class="sc">\n</span><span class="st">1&#39;</span>, <span class="st">&#39;Value</span><span class="sc">\n</span><span class="st">2&#39;</span>)</span>
238 <span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a><span class="fu">colnames</span>(m) <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">&#39;Multiline</span><span class="sc">\n</span><span class="st">Col1&#39;</span>, <span class="st">&#39;Multiline</span><span class="sc">\n</span><span class="st">Col2&#39;</span>)</span>
239 <span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m, <span class="at">keep.line.breaks =</span> <span class="cn">TRUE</span>, <span class="at">style=</span><span class="st">&#39;rmarkdown&#39;</span>)</span>
240 <span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Error in tableExpand_cpp(cells, cols.width, justify, sep.cols, style): Pandoc does not support newlines in simple or Rmarkdown table format!</span></span></code></pre></div>
241 </div>
242 </div>
243 <div id="cell-alignment" class="section level2">
244 <h2>Cell alignment</h2>
245 <p><code>pander</code> allows users to control cell alignment (<code>left</code>, <code>right</code> or <code>center/centre</code>) in a table directly by setting the <code>justify</code> parameter when calling <code>pander/pandoc.table</code>. Note that it is possible to specify alignment for each column separately by supplying a vector to justify:</p>
246 <div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(<span class="fu">head</span>(iris[,<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>], <span class="dv">2</span>), <span class="at">justify =</span> <span class="st">&#39;right&#39;</span>)</span>
247 <span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
248 <span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------------------------------------</span></span>
249 <span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sepal.Length Sepal.Width Petal.Length</span></span>
250 <span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------- ------------- --------------</span></span>
251 <span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 5.1 3.5 1.4</span></span>
252 <span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
253 <span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 4.9 3 1.4</span></span>
254 <span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------------------------------------</span></span>
255 <span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(<span class="fu">head</span>(iris[,<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>], <span class="dv">2</span>), <span class="at">justify =</span> <span class="fu">c</span>(<span class="st">&#39;right&#39;</span>, <span class="st">&#39;center&#39;</span>, <span class="st">&#39;left&#39;</span>))</span>
256 <span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
257 <span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------------------------------------</span></span>
258 <span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sepal.Length Sepal.Width Petal.Length </span></span>
259 <span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------- ------------- --------------</span></span>
260 <span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 5.1 3.5 1.4 </span></span>
261 <span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
262 <span id="cb5-17"><a href="#cb5-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 4.9 3 1.4 </span></span>
263 <span id="cb5-18"><a href="#cb5-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------------------------------------</span></span></code></pre></div>
264 <p>Another way to define alignment is by using a permanent option <code>table.alignment.default/table.alignment.rownames</code> in <code>panderOptions</code> (preferred way) or by using <code>set.alignment</code> function (legacy way of setting alignment for next table or permanently) which support setting alignment separately for cells and rownames:</p>
265 <div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">set.alignment</span>(<span class="st">&#39;left&#39;</span>, <span class="at">row.names =</span> <span class="st">&#39;right&#39;</span>) <span class="co"># set only for next table since permanent parameter is falce</span></span>
266 <span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">2</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>])</span>
267 <span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
268 <span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------------</span></span>
269 <span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; mpg cyl disp hp drat </span></span>
270 <span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------------- ----- ----- ------ ----- ------</span></span>
271 <span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 21 6 160 110 3.9 </span></span>
272 <span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
273 <span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 Wag 21 6 160 110 3.9 </span></span>
274 <span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------------</span></span></code></pre></div>
275 <p>Interesting application for this functionality is specifying a function that takes the R object as its argument to compute some unique alignment for your table based on e.g. column values or variable types:</p>
276 <div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">panderOptions</span>(<span class="st">&#39;table.alignment.default&#39;</span>,</span>
277 <span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">function</span>(df)</span>
278 <span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">ifelse</span>(<span class="fu">sapply</span>(df, mean) <span class="sc">&gt;</span> <span class="dv">2</span>, <span class="st">&#39;left&#39;</span>, <span class="st">&#39;right&#39;</span>))</span>
279 <span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(<span class="fu">head</span>(iris[,<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>], <span class="dv">2</span>))</span>
280 <span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
281 <span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------------------------------------</span></span>
282 <span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sepal.Length Sepal.Width Petal.Length</span></span>
283 <span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------- ------------- --------------</span></span>
284 <span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 5.1 3.5 1.4</span></span>
285 <span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
286 <span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 4.9 3 1.4</span></span>
287 <span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------------------------------------------</span></span>
288 <span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a><span class="fu">panderOptions</span>(<span class="st">&#39;table.alignment.default&#39;</span>, <span class="st">&#39;center&#39;</span>)</span></code></pre></div>
289 </div>
290 <div id="highlighting-cells" class="section level2">
291 <h2>Highlighting cells</h2>
292 <p>One of the great features of <code>pander</code> is the ease of highlighting rows, columns and cells in a table. This is a native <code>markdown</code> feature without custom <code>HTML</code> or <code>LaTeX</code>-only tweaks, so all <code>HTML/PDF/MS Word/OpenOffice</code> etc. formats are supported.</p>
293 <p>This can be achieved by specifying one of the arguments below when calling <code>pander</code>/<code>pandoc.table</code> or change default style using <code>panderOptions</code>:</p>
294 <ul>
295 <li>emphasize.italics.rows</li>
296 <li>emphasize.italics.cols</li>
297 <li>emphasize.italics.cells</li>
298 <li>emphasize.strong.rows</li>
299 <li>emphasize.strong.cols</li>
300 <li>emphasize.strong.cells</li>
301 <li>emphasize.verbatim.rows</li>
302 <li>emphasize.verbatim.cols</li>
303 <li>emphasize.verbatim.cells</li>
304 </ul>
305 <p>The <code>emphasize.italics</code> helpers would turn the affected cells to <em>italic</em>, <code>emphasize.strong</code> would apply a <strong>bold</strong> style to the cell and <code>emphasize.verbatim</code> would apply a <code>verbatim</code> style to the cell. A cell can be also <em>italic</em>, <strong>bold</strong> and <code>verbatim</code> at the same time.</p>
306 <p>Those functions and arguments ending in rows or cols take a vector (like which columns or rows to emphasize in a table), while the cells argument take either a vector (for one dimensional “tables”) or an array-like data structure with two columns holding row and column indexes of cells to be emphasized – just like what <code>which(..., arr.ind = TRUE)</code> returns:</p>
307 <div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>t <span class="ot">&lt;-</span> mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>]</span>
308 <span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="fu">emphasize.italics.cols</span>(<span class="dv">1</span>)</span>
309 <span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="fu">emphasize.italics.rows</span>(<span class="dv">1</span>)</span>
310 <span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="fu">emphasize.strong.cells</span>(<span class="fu">which</span>(t <span class="sc">&gt;</span> <span class="dv">20</span>, <span class="at">arr.ind =</span> <span class="cn">TRUE</span>))</span>
311 <span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(t)</span>
312 <span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
313 <span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------------------------------------------------</span></span>
314 <span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; mpg cyl disp hp drat </span></span>
315 <span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------------- ------ ----- ------ ----- ------</span></span>
316 <span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 21 6 160 110 3.9 </span></span>
317 <span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
318 <span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 Wag 21 6 160 110 3.9 </span></span>
319 <span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
320 <span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Datsun 710 22.8 4 108 93 3.85 </span></span>
321 <span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------------------------------------------------</span></span>
322 <span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(t, <span class="at">emphasize.verbatim.rows =</span> <span class="dv">1</span>, <span class="at">emphasize.strong.cells =</span> <span class="fu">which</span>(t <span class="sc">&gt;</span> <span class="dv">20</span>, <span class="at">arr.ind =</span> <span class="cn">TRUE</span>))</span>
323 <span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
324 <span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------------------------------------------------</span></span>
325 <span id="cb8-19"><a href="#cb8-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; mpg cyl disp hp drat </span></span>
326 <span id="cb8-20"><a href="#cb8-20" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------------- ------ ----- ------ ----- ------</span></span>
327 <span id="cb8-21"><a href="#cb8-21" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 21 6 160 110 3.9 </span></span>
328 <span id="cb8-22"><a href="#cb8-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
329 <span id="cb8-23"><a href="#cb8-23" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 Wag 21 6 160 110 3.9 </span></span>
330 <span id="cb8-24"><a href="#cb8-24" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
331 <span id="cb8-25"><a href="#cb8-25" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Datsun 710 22.8 4 108 93 3.85 </span></span>
332 <span id="cb8-26"><a href="#cb8-26" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------------------------------------------------</span></span></code></pre></div>
333 <p>For more elaborative examples, please see our blog post - <a href="http://blog.rapporter.net/2013/04/hihglight-cells-in-markdown-tables.html">Highlight cells in markdown tables</a>.</p>
334 </div>
335 <div id="table-and-cell-width" class="section level2">
336 <h2>Table and Cell width</h2>
337 <p><code>pander/pandoc.table</code> is able to deal with wide tables. Ever had an issue in <code>LaTeX</code> or <code>MS Word</code> when trying to print a correlation matrix of 40 variables? This problem is carefully addressed with <code>split.table</code> parameter:</p>
338 <div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">2</span>, ], <span class="at">style =</span> <span class="st">&quot;grid&quot;</span>, <span class="at">caption =</span> <span class="st">&quot;Wide table to be split!&quot;</span>)</span>
339 <span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
340 <span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
341 <span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+-----+-----+------+-----+------+-------+-------+</span></span>
342 <span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | | mpg | cyl | disp | hp | drat | wt | qsec |</span></span>
343 <span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +===================+=====+=====+======+=====+======+=======+=======+</span></span>
344 <span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.46 |</span></span>
345 <span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+-----+-----+------+-----+------+-------+-------+</span></span>
346 <span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 | 2.875 | 17.02 |</span></span>
347 <span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+-----+-----+------+-----+------+-------+-------+</span></span>
348 <span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
349 <span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Table: Wide table to be split! (continued below)</span></span>
350 <span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
351 <span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
352 <span id="cb9-15"><a href="#cb9-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
353 <span id="cb9-16"><a href="#cb9-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+----+----+------+------+</span></span>
354 <span id="cb9-17"><a href="#cb9-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | | vs | am | gear | carb |</span></span>
355 <span id="cb9-18"><a href="#cb9-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +===================+====+====+======+======+</span></span>
356 <span id="cb9-19"><a href="#cb9-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 | 0 | 1 | 4 | 4 |</span></span>
357 <span id="cb9-20"><a href="#cb9-20" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+----+----+------+------+</span></span>
358 <span id="cb9-21"><a href="#cb9-21" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 Wag | 0 | 1 | 4 | 4 |</span></span>
359 <span id="cb9-22"><a href="#cb9-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+----+----+------+------+</span></span></code></pre></div>
360 <p><code>split.table</code> defaults to 80 characters and to turn it off, set <code>split.table</code> to <code>Inf</code>:</p>
361 <div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">2</span>, ], <span class="at">style =</span> <span class="st">&quot;grid&quot;</span>,</span>
362 <span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">&quot;Wide table to be split!&quot;</span>, <span class="at">split.table =</span> <span class="cn">Inf</span>)</span>
363 <span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
364 <span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
365 <span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+-----+-----+------+-----+------+-------+-------+----+----+------+------+</span></span>
366 <span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | | mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb |</span></span>
367 <span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +===================+=====+=====+======+=====+======+=======+=======+====+====+======+======+</span></span>
368 <span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.46 | 0 | 1 | 4 | 4 |</span></span>
369 <span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+-----+-----+------+-----+------+-------+-------+----+----+------+------+</span></span>
370 <span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 | 2.875 | 17.02 | 0 | 1 | 4 | 4 |</span></span>
371 <span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+-----+-----+------+-----+------+-------+-------+----+----+------+------+</span></span>
372 <span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
373 <span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Table: Wide table to be split!</span></span></code></pre></div>
374 <p>Also, <code>pander</code> tries to split too wide cells into multiline cells. The maximum number of characters in a cell is specified by the <code>split.cells</code> parameter (defaults to 30), which can be a single value, vector (values for each column separately) and relative vector (percentages of <code>split.tables</code> parameter). Please not that this only works for <code>multiline</code> and <code>grid</code> tables:</p>
375 <div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>df <span class="ot">&lt;-</span> <span class="fu">data.frame</span>(<span class="at">a =</span> <span class="st">&#39;Lorem ipsum&#39;</span>, <span class="at">b =</span> <span class="st">&#39;dolor sit&#39;</span>, <span class="at">c =</span> <span class="st">&#39;amet&#39;</span>)</span>
376 <span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(df, <span class="at">split.cells =</span> <span class="dv">5</span>)</span>
377 <span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
378 <span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------------------</span></span>
379 <span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; a b c </span></span>
380 <span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------- ------- ------</span></span>
381 <span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Lorem dolor amet </span></span>
382 <span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ipsum sit </span></span>
383 <span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------------------</span></span>
384 <span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(df, <span class="at">split.cells =</span> <span class="fu">c</span>(<span class="dv">5</span>, <span class="dv">20</span>, <span class="dv">5</span>))</span>
385 <span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
386 <span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; --------------------------</span></span>
387 <span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; a b c </span></span>
388 <span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------- ----------- ------</span></span>
389 <span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Lorem dolor sit amet </span></span>
390 <span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ipsum </span></span>
391 <span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; --------------------------</span></span>
392 <span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(df, <span class="at">split.cells =</span> <span class="fu">c</span>(<span class="st">&quot;80%&quot;</span>, <span class="st">&quot;10%&quot;</span>, <span class="st">&quot;10%&quot;</span>))</span>
393 <span id="cb11-19"><a href="#cb11-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
394 <span id="cb11-20"><a href="#cb11-20" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------------------------</span></span>
395 <span id="cb11-21"><a href="#cb11-21" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; a b c </span></span>
396 <span id="cb11-22"><a href="#cb11-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------- ------- ------</span></span>
397 <span id="cb11-23"><a href="#cb11-23" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Lorem ipsum dolor amet </span></span>
398 <span id="cb11-24"><a href="#cb11-24" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; sit </span></span>
399 <span id="cb11-25"><a href="#cb11-25" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ----------------------------</span></span>
400 <span id="cb11-26"><a href="#cb11-26" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(df, <span class="at">split.cells =</span> <span class="dv">5</span>, <span class="at">style =</span> <span class="st">&#39;simple&#39;</span>)</span>
401 <span id="cb11-27"><a href="#cb11-27" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
402 <span id="cb11-28"><a href="#cb11-28" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
403 <span id="cb11-29"><a href="#cb11-29" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; a b c </span></span>
404 <span id="cb11-30"><a href="#cb11-30" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------- ----------- ------</span></span>
405 <span id="cb11-31"><a href="#cb11-31" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Lorem ipsum dolor sit amet</span></span></code></pre></div>
406 <p>In some cases it is also useful to split too long words with hyphens, and <code>pander</code> uses <code>sylly</code> functionality for that. Just specify <code>use.hyphening</code> argument and have <code>sylly</code> installed:</p>
407 <div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(<span class="fu">data.frame</span>(<span class="at">baz =</span> <span class="st">&#39;foobar&#39;</span>, <span class="at">foo=</span><span class="st">&#39;accoutrements&#39;</span>),</span>
408 <span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="at">use.hyphening =</span> <span class="cn">TRUE</span>, <span class="at">split.cells =</span> <span class="dv">3</span>)</span>
409 <span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
410 <span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; --------------</span></span>
411 <span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; baz foo </span></span>
412 <span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------ -------</span></span>
413 <span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; foo- ac- </span></span>
414 <span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; bar cou- </span></span>
415 <span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; tre- </span></span>
416 <span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ments </span></span>
417 <span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; --------------</span></span></code></pre></div>
418 </div>
419 <div id="rounding-and-number-formatting" class="section level2">
420 <h2>Rounding and number formatting</h2>
421 <p><code>pander/pandoc.table</code> deals with formatting numbers by having 4 parameters:</p>
422 <ul>
423 <li><code>round</code> to the number of decimal places.</li>
424 <li><code>digits</code> to specify how many significant digits are to be used for numeric</li>
425 <li><code>decimal.mark/big.mark</code> to specify character for decimal point/orders of magnitude</li>
426 </ul>
427 <p><code>round</code> and <code>digits</code> parameter can be a vector specifying values for each column (has to be the same length as number of columns). Values for non-numeric columns will be disregarded.</p>
428 <p>Now let’s get to some examples:</p>
429 <div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>r <span class="ot">&lt;-</span> <span class="fu">matrix</span>(<span class="fu">c</span>(<span class="fl">283764.97430</span>, <span class="fl">29.12345678901</span>, <span class="sc">-</span><span class="fl">7.1234</span>, <span class="sc">-</span><span class="fl">100.1</span>), <span class="at">ncol =</span> <span class="dv">2</span>)</span>
430 <span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(r, <span class="at">round =</span> <span class="dv">2</span>)</span>
431 <span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
432 <span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------- --------</span></span>
433 <span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 283765 -7.12 </span></span>
434 <span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
435 <span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 29.12 -100.1 </span></span>
436 <span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------- --------</span></span>
437 <span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(r, <span class="at">round =</span> <span class="fu">c</span>(<span class="dv">4</span>,<span class="dv">2</span>)) <span class="co"># vector for each column</span></span>
438 <span id="cb13-10"><a href="#cb13-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
439 <span id="cb13-11"><a href="#cb13-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------- --------</span></span>
440 <span id="cb13-12"><a href="#cb13-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 283765 -7.12 </span></span>
441 <span id="cb13-13"><a href="#cb13-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
442 <span id="cb13-14"><a href="#cb13-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 29.12 -100.1 </span></span>
443 <span id="cb13-15"><a href="#cb13-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------- --------</span></span>
444 <span id="cb13-16"><a href="#cb13-16" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(r, <span class="at">digits =</span> <span class="dv">2</span>)</span>
445 <span id="cb13-17"><a href="#cb13-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
446 <span id="cb13-18"><a href="#cb13-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------- ------</span></span>
447 <span id="cb13-19"><a href="#cb13-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 283765 -7.1 </span></span>
448 <span id="cb13-20"><a href="#cb13-20" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
449 <span id="cb13-21"><a href="#cb13-21" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 29 -100 </span></span>
450 <span id="cb13-22"><a href="#cb13-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------- ------</span></span>
451 <span id="cb13-23"><a href="#cb13-23" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(r, <span class="at">digits =</span> <span class="fu">c</span>(<span class="dv">1</span>, <span class="dv">5</span>)) <span class="co"># vector for each column</span></span>
452 <span id="cb13-24"><a href="#cb13-24" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
453 <span id="cb13-25"><a href="#cb13-25" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------- ---------</span></span>
454 <span id="cb13-26"><a href="#cb13-26" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3e+05 -7.1234 </span></span>
455 <span id="cb13-27"><a href="#cb13-27" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
456 <span id="cb13-28"><a href="#cb13-28" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 29 -100.1 </span></span>
457 <span id="cb13-29"><a href="#cb13-29" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------- ---------</span></span>
458 <span id="cb13-30"><a href="#cb13-30" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(r, <span class="at">big.mark =</span> <span class="st">&#39;,&#39;</span>)</span>
459 <span id="cb13-31"><a href="#cb13-31" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
460 <span id="cb13-32"><a href="#cb13-32" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; --------- --------</span></span>
461 <span id="cb13-33"><a href="#cb13-33" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 283,765 -7.123 </span></span>
462 <span id="cb13-34"><a href="#cb13-34" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
463 <span id="cb13-35"><a href="#cb13-35" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 29.12 -100.1 </span></span>
464 <span id="cb13-36"><a href="#cb13-36" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; --------- --------</span></span>
465 <span id="cb13-37"><a href="#cb13-37" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(r, <span class="at">decimal.mark =</span> <span class="st">&#39;,&#39;</span>)</span>
466 <span id="cb13-38"><a href="#cb13-38" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
467 <span id="cb13-39"><a href="#cb13-39" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------- --------</span></span>
468 <span id="cb13-40"><a href="#cb13-40" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 283765 -7,123 </span></span>
469 <span id="cb13-41"><a href="#cb13-41" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
470 <span id="cb13-42"><a href="#cb13-42" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 29,12 -100,1 </span></span>
471 <span id="cb13-43"><a href="#cb13-43" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; -------- --------</span></span></code></pre></div>
472 </div>
473 <div id="other-options" class="section level2">
474 <h2>Other options</h2>
475 <p>Functionality described in other sections is most notable, but <code>pander/pandoc.table</code> also has smaller nifty features that are worth mentioning:</p>
476 <ul>
477 <li><code>plain.ascii</code> - allows to have the output without <code>markdown</code> markup:</li>
478 </ul>
479 <div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>])</span>
480 <span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
481 <span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------</span></span>
482 <span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; mpg cyl disp hp </span></span>
483 <span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------------- ------ ----- ------ -----</span></span>
484 <span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 21 6 160 110 </span></span>
485 <span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
486 <span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 Wag 21 6 160 110 </span></span>
487 <span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
488 <span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Datsun 710 22.8 4 108 93 </span></span>
489 <span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------</span></span>
490 <span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>], <span class="at">plain.ascii =</span> <span class="cn">TRUE</span>)</span>
491 <span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
492 <span id="cb14-14"><a href="#cb14-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------</span></span>
493 <span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; mpg cyl disp hp </span></span>
494 <span id="cb14-16"><a href="#cb14-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------------- ------ ----- ------ -----</span></span>
495 <span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 21 6 160 110 </span></span>
496 <span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
497 <span id="cb14-19"><a href="#cb14-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 Wag 21 6 160 110 </span></span>
498 <span id="cb14-20"><a href="#cb14-20" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
499 <span id="cb14-21"><a href="#cb14-21" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Datsun 710 22.8 4 108 93 </span></span>
500 <span id="cb14-22"><a href="#cb14-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------</span></span></code></pre></div>
501 <ul>
502 <li><code>caption</code> - set caption (string) to be shown under the table:</li>
503 </ul>
504 <div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>], <span class="at">style =</span> <span class="st">&quot;grid&quot;</span>, <span class="at">caption =</span> <span class="st">&quot;My caption!&quot;</span>)</span>
505 <span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
506 <span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
507 <span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+------+-----+------+-----+------+</span></span>
508 <span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | | mpg | cyl | disp | hp | drat |</span></span>
509 <span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +===================+======+=====+======+=====+======+</span></span>
510 <span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 |</span></span>
511 <span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+------+-----+------+-----+------+</span></span>
512 <span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 |</span></span>
513 <span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+------+-----+------+-----+------+</span></span>
514 <span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; | Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 |</span></span>
515 <span id="cb15-12"><a href="#cb15-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; +-------------------+------+-----+------+-----+------+</span></span>
516 <span id="cb15-13"><a href="#cb15-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
517 <span id="cb15-14"><a href="#cb15-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Table: My caption!</span></span></code></pre></div>
518 <ul>
519 <li><code>missing</code> - set a string to replace missing values:</li>
520 </ul>
521 <div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a>m <span class="ot">&lt;-</span> mtcars[<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>]</span>
522 <span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a>m<span class="sc">$</span>mpg <span class="ot">&lt;-</span> <span class="cn">NA</span></span>
523 <span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="fu">pandoc.table</span>(m, <span class="at">missing =</span> <span class="st">&#39;?&#39;</span>)</span>
524 <span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
525 <span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------------</span></span>
526 <span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; mpg cyl disp hp drat </span></span>
527 <span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ------------------- ----- ----- ------ ----- ------</span></span>
528 <span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 ? 6 160 110 3.9 </span></span>
529 <span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
530 <span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Mazda RX4 Wag ? 6 160 110 3.9 </span></span>
531 <span id="cb16-11"><a href="#cb16-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
532 <span id="cb16-12"><a href="#cb16-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Datsun 710 ? 4 108 93 3.85 </span></span>
533 <span id="cb16-13"><a href="#cb16-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; ---------------------------------------------------</span></span></code></pre></div>
534 </div>
535
536
537
538 <!-- code folding -->
539
540
541 <!-- dynamically load mathjax for compatibility with self-contained -->
542 <script>
543 (function () {
544 var script = document.createElement("script");
545 script.type = "text/javascript";
546 script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
547 document.getElementsByTagName("head")[0].appendChild(script);
548 })();
549 </script>
550
551 </body>
552 </html>