-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtables.html
523 lines (480 loc) · 24.5 KB
/
tables.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>第 6 章 Bookdown中的表格 | Bookdown中文书稿写作手册</title>
<meta name="description" content="bookdown写书体验非常好." />
<meta name="generator" content="bookdown 0.22 and GitBook 2.6.7" />
<meta property="og:title" content="第 6 章 Bookdown中的表格 | Bookdown中文书稿写作手册" />
<meta property="og:type" content="book" />
<meta property="og:url" content="https://tangyc8866.github.io/bookdown-tyc/" />
<meta property="og:description" content="bookdown写书体验非常好." />
<meta name="github-repo" content="tangyc8866.github.io/bookdown-tyc/" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="第 6 章 Bookdown中的表格 | Bookdown中文书稿写作手册" />
<meta name="twitter:description" content="bookdown写书体验非常好." />
<meta name="author" content="汤银才" />
<meta name="date" content="2021-07-21" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="prev" href="figures.html"/>
<link rel="next" href="textref.html"/>
<script src="libs/header-attrs-2.7/header-attrs.js"></script>
<script src="libs/jquery-2.2.3/jquery.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.0.1/anchor-sections.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.0.1/anchor-sections.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["input/TeX","output/SVG"],
extensions: ["tex2jax.js","MathMenu.js","MathZoom.js"],
TeX: {
Macros: {
bm: ["{\\boldsymbol #1}",1],
},
extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
}
});
</script>
<script type="text/javascript"
src="http://127.0.0.1/MathJax/MathJax.js">
</script>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<style type="text/css">
/* Used with Pandoc 2.11+ new --citeproc when CSL is used */
div.csl-bib-body { }
div.csl-entry {
clear: both;
}
.hanging div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}
</style>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><a href="./">bookdown排版模板</a></li>
<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>前言</a></li>
<li class="chapter" data-level="1" data-path="intro.html"><a href="intro.html"><i class="fa fa-check"></i><b>1</b> 引言</a>
<ul>
<li class="chapter" data-level="1.1" data-path="intro.html"><a href="intro.html#sec1-1"><i class="fa fa-check"></i><b>1.1</b> 中国图书出版的变化</a></li>
<li class="chapter" data-level="1.2" data-path="intro.html"><a href="intro.html#sec1-2"><i class="fa fa-check"></i><b>1.2</b> 统计类图书的核心要素</a></li>
<li class="chapter" data-level="1.3" data-path="intro.html"><a href="intro.html#sec1-3"><i class="fa fa-check"></i><b>1.3</b> 统计数据分析类图书模板的选择</a>
<ul>
<li class="chapter" data-level="1.3.1" data-path="intro.html"><a href="intro.html#sec1-3-1"><i class="fa fa-check"></i><b>1.3.1</b> 基于纯 <span class="math inline">\(\TeX\)</span> 模板</a></li>
<li class="chapter" data-level="1.3.2" data-path="intro.html"><a href="intro.html#sec1-3-2"><i class="fa fa-check"></i><b>1.3.2</b> <code>R</code>markdown与<span class="math inline">\(\TeX\)</span>的结合</a></li>
<li class="chapter" data-level="1.3.3" data-path="intro.html"><a href="intro.html#sec1-3-3"><i class="fa fa-check"></i><b>1.3.3</b> <code>Rmarkdown</code>向<code>Bookdown</code>过渡</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="2" data-path="bookdown.html"><a href="bookdown.html"><i class="fa fa-check"></i><b>2</b> <code>bookdown</code>速览</a>
<ul>
<li class="chapter" data-level="2.1" data-path="bookdown.html"><a href="bookdown.html#sec2-1"><i class="fa fa-check"></i><b>2.1</b> 关于<code>bookdown</code></a></li>
<li class="chapter" data-level="2.2" data-path="bookdown.html"><a href="bookdown.html#sec2-2"><i class="fa fa-check"></i><b>2.2</b> 快速排版的思路</a></li>
<li class="chapter" data-level="2.3" data-path="bookdown.html"><a href="bookdown.html#sec2-3"><i class="fa fa-check"></i><b>2.3</b> 书的基本设置</a>
<ul>
<li class="chapter" data-level="2.3.1" data-path="bookdown.html"><a href="bookdown.html#index.rmd文件"><i class="fa fa-check"></i><b>2.3.1</b> <code>index.Rmd</code>文件</a></li>
<li class="chapter" data-level="2.3.2" data-path="bookdown.html"><a href="bookdown.html#bookdown.yml文件"><i class="fa fa-check"></i><b>2.3.2</b> <code>_bookdown.yml</code>文件</a></li>
<li class="chapter" data-level="2.3.3" data-path="bookdown.html"><a href="bookdown.html#output.yml文件"><i class="fa fa-check"></i><b>2.3.3</b> <code>_output.yml</code>文件</a></li>
</ul></li>
<li class="chapter" data-level="2.4" data-path="bookdown.html"><a href="bookdown.html#sec2-4"><i class="fa fa-check"></i><b>2.4</b> 章节结构</a></li>
<li class="chapter" data-level="2.5" data-path="bookdown.html"><a href="bookdown.html#sec2-5"><i class="fa fa-check"></i><b>2.5</b> 书的编译</a></li>
<li class="chapter" data-level="2.6" data-path="bookdown.html"><a href="bookdown.html#sec2-6"><i class="fa fa-check"></i><b>2.6</b> 浮动对象标签与引用汇总</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="sections.html"><a href="sections.html"><i class="fa fa-check"></i><b>3</b> Bookdow中 的章节标题</a>
<ul>
<li class="chapter" data-level="3.1" data-path="sections.html"><a href="sections.html#sec3-1"><i class="fa fa-check"></i><b>3.1</b> 章节标题</a></li>
<li class="chapter" data-level="3.2" data-path="sections.html"><a href="sections.html#sec3-2"><i class="fa fa-check"></i><b>3.2</b> 章节标题标签的设定与引用</a></li>
</ul></li>
<li class="chapter" data-level="4" data-path="formulas.html"><a href="formulas.html"><i class="fa fa-check"></i><b>4</b> <code>Bookdown</code>中的公式与定理</a>
<ul>
<li class="chapter" data-level="4.1" data-path="formulas.html"><a href="formulas.html#sec4-1"><i class="fa fa-check"></i><b>4.1</b> 公式标签的设定</a></li>
<li class="chapter" data-level="4.2" data-path="formulas.html"><a href="formulas.html#sec4-2"><i class="fa fa-check"></i><b>4.2</b> 定理标签的设定</a></li>
<li class="chapter" data-level="4.3" data-path="formulas.html"><a href="formulas.html#sec4-3"><i class="fa fa-check"></i><b>4.3</b> 定理与公式的引用</a></li>
<li class="chapter" data-level="4.4" data-path="formulas.html"><a href="formulas.html#sec4-4"><i class="fa fa-check"></i><b>4.4</b> 数学公式的扩展</a></li>
</ul></li>
<li class="chapter" data-level="5" data-path="figures.html"><a href="figures.html"><i class="fa fa-check"></i><b>5</b> <code>Bookdown</code>中的图形</a>
<ul>
<li class="chapter" data-level="5.1" data-path="figures.html"><a href="figures.html#sec5-1"><i class="fa fa-check"></i><b>5.1</b> 由<code>R</code>生成单个图形示例</a></li>
<li class="chapter" data-level="5.2" data-path="figures.html"><a href="figures.html#sec5-2"><i class="fa fa-check"></i><b>5.2</b> 由<code>R</code>生成两个图形并置示例</a></li>
<li class="chapter" data-level="5.3" data-path="figures.html"><a href="figures.html#sec5-3"><i class="fa fa-check"></i><b>5.3</b> 由<code>R</code>生成两个图形堆叠示例</a></li>
<li class="chapter" data-level="5.4" data-path="figures.html"><a href="figures.html#sec5-4"><i class="fa fa-check"></i><b>5.4</b> 静态图形示例</a></li>
<li class="chapter" data-level="5.5" data-path="figures.html"><a href="figures.html#sec5-5"><i class="fa fa-check"></i><b>5.5</b> 图形引用</a></li>
</ul></li>
<li class="chapter" data-level="6" data-path="tables.html"><a href="tables.html"><i class="fa fa-check"></i><b>6</b> <code>Bookdown</code>中的表格</a>
<ul>
<li class="chapter" data-level="6.1" data-path="tables.html"><a href="tables.html#sec6-1"><i class="fa fa-check"></i><b>6.1</b> 表格示例1:由数据生成表格</a></li>
<li class="chapter" data-level="6.2" data-path="tables.html"><a href="tables.html#sec6-2"><i class="fa fa-check"></i><b>6.2</b> 表格示例2: 由数据框构造表格</a></li>
<li class="chapter" data-level="6.3" data-path="tables.html"><a href="tables.html#sec6-3"><i class="fa fa-check"></i><b>6.3</b> 表格引用</a></li>
</ul></li>
<li class="chapter" data-level="7" data-path="textref.html"><a href="textref.html"><i class="fa fa-check"></i><b>7</b> <code>Bookdown</code>中的文本参考</a>
<ul>
<li class="chapter" data-level="7.1" data-path="textref.html"><a href="textref.html#sec7-1"><i class="fa fa-check"></i><b>7.1</b> 文本标签的设定与引用</a></li>
<li class="chapter" data-level="7.2" data-path="textref.html"><a href="textref.html#sec7-2"><i class="fa fa-check"></i><b>7.2</b> 文本引用场景</a></li>
</ul></li>
<li class="chapter" data-level="8" data-path="bibs.html"><a href="bibs.html"><i class="fa fa-check"></i><b>8</b> <code>Bookdown</code>中的文献排版</a>
<ul>
<li class="chapter" data-level="8.1" data-path="bibs.html"><a href="bibs.html#sec8-1"><i class="fa fa-check"></i><b>8.1</b> 文献库建立样例</a></li>
<li class="chapter" data-level="8.2" data-path="bibs.html"><a href="bibs.html#sec8-2"><i class="fa fa-check"></i><b>8.2</b> 文献风格</a></li>
<li class="chapter" data-level="8.3" data-path="bibs.html"><a href="bibs.html#sec8-3"><i class="fa fa-check"></i><b>8.3</b> 中文文献风格的设置</a></li>
<li class="chapter" data-level="8.4" data-path="bibs.html"><a href="bibs.html#sec8-4"><i class="fa fa-check"></i><b>8.4</b> 文献库的建立工具</a></li>
</ul></li>
<li class="appendix"><span><b>附录</b></span></li>
<li class="chapter" data-level="A" data-path="mjx.html"><a href="mjx.html"><i class="fa fa-check"></i><b>A</b> <code>Mathjax</code>的离线安装与使用</a>
<ul>
<li class="chapter" data-level="A.1" data-path="mjx.html"><a href="mjx.html#sec9-1"><i class="fa fa-check"></i><b>A.1</b> mathjax 说明</a></li>
<li class="chapter" data-level="A.2" data-path="mjx.html"><a href="mjx.html#sec9-2"><i class="fa fa-check"></i><b>A.2</b> 调用远程服务器上的<code>mathjax</code></a></li>
<li class="chapter" data-level="A.3" data-path="mjx.html"><a href="mjx.html#sec9-3"><i class="fa fa-check"></i><b>A.3</b> <code>mathjax</code>本地服务器的安装与使用</a></li>
</ul></li>
<li class="chapter" data-level="B" data-path="biber.html"><a href="biber.html"><i class="fa fa-check"></i><b>B</b> 基于<code>biblatex</code>生成参考文献</a>
<ul>
<li class="chapter" data-level="B.1" data-path="biber.html"><a href="biber.html#sec10-1"><i class="fa fa-check"></i><b>B.1</b> bibtex 与 biber, natbib 与 biblatex 比较</a>
<ul>
<li class="chapter" data-level="B.1.1" data-path="biber.html"><a href="biber.html#概述"><i class="fa fa-check"></i><b>B.1.1</b> 概述</a></li>
<li class="chapter" data-level="B.1.2" data-path="biber.html"><a href="biber.html#natbib-的优点"><i class="fa fa-check"></i><b>B.1.2</b> <code>natbib</code> 的优点</a></li>
<li class="chapter" data-level="B.1.3" data-path="biber.html"><a href="biber.html#biblatex-的优缺点"><i class="fa fa-check"></i><b>B.1.3</b> biblatex 的优缺点</a></li>
</ul></li>
<li class="chapter" data-level="B.2" data-path="biber.html"><a href="biber.html#sec10-2"><i class="fa fa-check"></i><b>B.2</b> biblatex 的在<span class="math inline">\(\TeX\)</span>中的使用样例</a></li>
<li class="chapter" data-level="B.3" data-path="biber.html"><a href="biber.html#sec10-3"><i class="fa fa-check"></i><b>B.3</b> <code>biblatex</code>在<code>bookdown</code>中的使用</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="references.html"><a href="references.html"><i class="fa fa-check"></i>参考文献</a></li>
<li class="divider"></li>
<li><a href="https://bookdown.org" target="blank">本书由 bookdown 强力驱动</a></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Bookdown中文书稿写作手册</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="tables" class="section level1" number="6">
<h1><span class="header-section-number">第 6 章</span> <code>Bookdown</code>中的表格</h1>
<p>这是第 <a href="tables.html#tables">6</a> 章的内容, 讲述浮动对象图形的标签与引用. <span class="citation">(<a href="#ref-xie2015" role="doc-biblioref">Xie, 2015a</a>, <a href="#ref-bookdown2016" role="doc-biblioref">2016</a>)</span></p>
<div id="sec6-1" class="section level2" number="6.1">
<h2><span class="header-section-number">6.1</span> 表格示例1:由数据生成表格</h2>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb19-1"><a href="tables.html#cb19-1" aria-hidden="true" tabindex="-1"></a>knitr<span class="sc">::</span><span class="fu">kable</span>(</span>
<span id="cb19-2"><a href="tables.html#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">head</span>(mtcars[, <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>], <span class="dv">10</span>), <span class="at">booktabs =</span> <span class="cn">TRUE</span>,</span>
<span id="cb19-3"><a href="tables.html#cb19-3" aria-hidden="true" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">'mtcars数据的前5行.'</span></span>
<span id="cb19-4"><a href="tables.html#cb19-4" aria-hidden="true" tabindex="-1"></a>)</span></code></pre></div>
<table>
<caption><span id="tab:tab3-1">表 6.1: </span>mtcars数据的前5行.</caption>
<thead>
<tr class="header">
<th align="left"></th>
<th align="right">mpg</th>
<th align="right">cyl</th>
<th align="right">disp</th>
<th align="right">hp</th>
<th align="right">drat</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">Mazda RX4</td>
<td align="right">21.0</td>
<td align="right">6</td>
<td align="right">160.0</td>
<td align="right">110</td>
<td align="right">3.90</td>
</tr>
<tr class="even">
<td align="left">Mazda RX4 Wag</td>
<td align="right">21.0</td>
<td align="right">6</td>
<td align="right">160.0</td>
<td align="right">110</td>
<td align="right">3.90</td>
</tr>
<tr class="odd">
<td align="left">Datsun 710</td>
<td align="right">22.8</td>
<td align="right">4</td>
<td align="right">108.0</td>
<td align="right">93</td>
<td align="right">3.85</td>
</tr>
<tr class="even">
<td align="left">Hornet 4 Drive</td>
<td align="right">21.4</td>
<td align="right">6</td>
<td align="right">258.0</td>
<td align="right">110</td>
<td align="right">3.08</td>
</tr>
<tr class="odd">
<td align="left">Hornet Sportabout</td>
<td align="right">18.7</td>
<td align="right">8</td>
<td align="right">360.0</td>
<td align="right">175</td>
<td align="right">3.15</td>
</tr>
<tr class="even">
<td align="left">Valiant</td>
<td align="right">18.1</td>
<td align="right">6</td>
<td align="right">225.0</td>
<td align="right">105</td>
<td align="right">2.76</td>
</tr>
<tr class="odd">
<td align="left">Duster 360</td>
<td align="right">14.3</td>
<td align="right">8</td>
<td align="right">360.0</td>
<td align="right">245</td>
<td align="right">3.21</td>
</tr>
<tr class="even">
<td align="left">Merc 240D</td>
<td align="right">24.4</td>
<td align="right">4</td>
<td align="right">146.7</td>
<td align="right">62</td>
<td align="right">3.69</td>
</tr>
<tr class="odd">
<td align="left">Merc 230</td>
<td align="right">22.8</td>
<td align="right">4</td>
<td align="right">140.8</td>
<td align="right">95</td>
<td align="right">3.92</td>
</tr>
<tr class="even">
<td align="left">Merc 280</td>
<td align="right">19.2</td>
<td align="right">6</td>
<td align="right">167.6</td>
<td align="right">123</td>
<td align="right">3.92</td>
</tr>
</tbody>
</table>
</div>
<div id="sec6-2" class="section level2" number="6.2">
<h2><span class="header-section-number">6.2</span> 表格示例2: 由数据框构造表格</h2>
<table>
<caption><span id="tab:tab3-2">表 6.2: </span>遗传连接模型例子中观测到的频数 <span class="math inline">\(y_i\)</span> 和频率 <span class="math inline">\(p(y_i|\pi)\)</span>,<span class="math inline">\(i=1, \dots ,4\)</span>,197个动物.</caption>
<colgroup>
<col width="25%" />
<col width="25%" />
<col width="18%" />
<col width="18%" />
<col width="12%" />
</colgroup>
<thead>
<tr class="header">
<th align="left">Category</th>
<th align="left">1</th>
<th align="left">2</th>
<th align="left">3</th>
<th align="left">4</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">Frequency <span class="math inline">\(y_i\)</span></td>
<td align="left">125</td>
<td align="left">18</td>
<td align="left">20</td>
<td align="left">34</td>
</tr>
<tr class="even">
<td align="left">Probability <span class="math inline">\(p(y_i\mid\pi)\)</span></td>
<td align="left"><span class="math inline">\(\frac{1}{2}+\frac{\pi}{4}\)</span></td>
<td align="left"><span class="math inline">\(\frac{1}{4}(1-\pi)\)</span></td>
<td align="left"><span class="math inline">\(\frac{1}{4}(1-\pi)\)</span></td>
<td align="left"><span class="math inline">\(\frac{1}{4}\)</span></td>
</tr>
</tbody>
</table>
<p>注意:</p>
<ol style="list-style-type: decimal">
<li>表格中<code>%</code>用<code>\\%</code></li>
<li>表格中latex命令用<code>\\</code>代替<code>\</code></li>
</ol>
</div>
<div id="sec6-3" class="section level2" number="6.3">
<h2><span class="header-section-number">6.3</span> 表格引用</h2>
<p>表格引用由代码块的标签(设为<code>label</code>)引用实现, 并带前缀<code>tab:</code>, 由<code>\@ref(tab:label)</code>实现. 例如</p>
<pre><code>本章共出现二张表格,即表\@ref(tab:tab3-1)和表\@ref(tab:tab3-2).</code></pre>
<p>输出为:</p>
<p>本章共出现二张表格,即表<a href="tables.html#tab:tab3-1">6.1</a>和表<a href="tables.html#tab:tab3-2">6.2</a>.</p>
<p><strong>注</strong>: 表格中的caption(题图)由文本引用生成.</p>
</div>
</div>
<h3>参考文献</h3>
<div id="refs" class="references csl-bib-body hanging-indent" line-spacing="2">
<div id="ref-xie2015" class="csl-entry">
Xie, Y. (2015a). <em>Dynamic documents with <span>R</span> and knitr</em> (2nd ed.). Boca Raton, Florida: Chapman; Hall/CRC. Retrieved from <a href="http://yihui.name/knitr/">http://yihui.name/knitr/</a>
</div>
<div id="ref-bookdown2016" class="csl-entry">
Xie, Y. (2016). <em>Bookdown: Authoring books and technical documents with <span>R</span> markdown</em>. Boca Raton, Florida: Chapman; Hall/CRC. Retrieved from <a href="https://bookdown.org/yihui/bookdown">https://bookdown.org/yihui/bookdown</a>
</div>
</div>
</section>
</div>
</div>
</div>
<a href="figures.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="textref.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
</div>
</div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/lunr.js"></script>
<script src="libs/gitbook-2.6.7/js/clipboard.min.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-clipboard.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": true,
"facebook": false,
"twitter": true,
"linkedin": false,
"weibo": false,
"instapaper": false,
"vk": false,
"whatsapp": false,
"all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": "https://github.com/yihui/bookdown-chinese/edit/master/006-tables.Rmd",
"text": "编辑"
},
"history": {
"link": null,
"text": null
},
"view": {
"link": null,
"text": null
},
"download": ["bookdown-tutorial.pdf", "bookdown-tutorial.epub"],
"toc": {
"collapse": "subsection",
"scroll_highlight": true
}
});
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
var src = "true";
if (src === "" || src === "true") src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML";
if (location.protocol !== "file:")
if (/^https?:/.test(src))
src = src.replace(/^https?:/, '');
script.src = src;
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>