-
Notifications
You must be signed in to change notification settings - Fork 7
/
9.3.5-tables.Rmd
29 lines (19 loc) · 1.92 KB
/
9.3.5-tables.Rmd
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
## Tables in Markdown Format {- #tables}
View the underlying source code to understand how this page was composed at: https://github.com/ontheline/otl-bookdown/blob/main/9.3.5-tables.Rmd
Two approaches to tables: long, complex, or dynamic in Datawrapper, versus short or static in Markdown
For long, complex or dymamic tables that may be updated often, create a Google Sheet, link to Datawrapper, and save backup CSV or XLSX in GitHub repo. Follow iframe image guidelines, including a PNG download. Unless data has specific historical year, start file name with `datawrapper-keywords.png`.
For short or static tables, create in Markdown format, since it produces good output for HTML, PDF, Word, and Markdown. Use a tool such as [Tables Generator](https://www.tablesgenerator.com/markdown_tables) to import significant table data in CSV format, format the column alignment as desired, and press Generate button to create table in Markdown format. For significant table data, save the CSV version in a GitHub repo for potential later use.
Add the Markdown table code shown below to auto-number (Table x) in HTML, PDF, Word.
...as shown in Table \@ref(tab:left-table).
Table: (\#tab:left-table) Left-justify content, remember blank Line
| Much Much Longer Header | Short Header | Short Header |
|:---------|:---|:---|
| Left-justify text content with left-colons | Less | Here |
| Use more hyphens to grant more space to some columns | Less | Here |
Table: (\#tab:right-table) Right-justify content, remember blank line
| Header1 | Header2 | Header3 |
|-----:|-----:|-----:|
| 123 | 456 | 789 |
| Right-justify | numerical content | with right-colons |
| Use equal hyphens | to make equal space | for all columns |
Note that Bookdown creates the Markdown file with tables in HTML format, not Markdown format. If necessary, one workaround is to paste the individual Markdown-formatted tables directly from the .Rmd into a *modified* full-book .md file.