R Bookdown Example

This example provides documentations for using kableExtra to customize tables in bookdown projects. Golang UINT - 26 examples found. These are the top rated real world Golang examples of C.UINT extracted from open source projects. You can rate examples to help us improve the quality of examples. I am trying to estimate a pooled SUR in R. I am not able to replicate the results given in text. Link for dataset I.

Note that if kableExtra 0.9.0 doesn’t support the EPUB format. If you need to output tables in .epub, please upgrade to the dev version or version 1.0 on CRAN once it’s released. Zoom meeting firestick.

Python bookdown

He're a minimal example using a minimal example of a bookdown project. Restart endnote numbering after each GitBook-style web chapter in R Bookdown.

2.1 Use the “K-M” approach instead of “M-K”

Please read this chapter about the “K-M”/“M-K” approaches in bookdown:https://bookdown.org/yihui/bookdown/new-session.html

To generate cross-format tables with kableExtra in a multi-format bookdown project, you will have to use the “M-K” approach by setting new_session: true in _bookdown.yml. Somehow the “M-K” approach, which merges chapters to a big Rmd and then renders, shares the global environment across formats. For now, I’m not sure if this is a bug or intended behavior. It might be fixable in the future but please don’t count on that. By setting new_session: true, we force R to use a new session for every chapter for different formats. In this way, tables are generated differently in different formats.

Note that the “M-K” approach is slower than the “K-M” approach. At the same time, packages and data are not shared accross chapter.

2.2 Prepare Your Tables for All Formats

In most cases, functions in kable and kableExtra use the same API to accomplish the same styling task in HTML and LaTeX. However, you also need some format specific settings so your tables will look good in both formats. Some common items here include the booktabs and longtable settings in kable and the bootstrap_options and latex_options in kable_styling.

Here is an example for a table that will work in HTML, LaTeX & EPUB.


Here’s where I park littleexamplesfor myself about bookdown mechanics that I keep forgetting.

The bookdown book: https://bookdown.org/yihui/bookdown/

41.2 About labelling things

You can label chapter and section titles using {#label} after them, e.g., we can reference Section 41.2. If you do not manually label them, there will be automatic labels anyway, e.g., this reference to the unlabelled heading 41.1 uses the automatically generated label @ref(heading-blah-blah).

41.3 Cross-references

Add an explicit label by adding {#label} to the end of the section header. If you know you’re going to refer to something, this is probably a good idea.

To refer to in a chapter- or section-number-y way, use @ref(label).

  • @ref(install-git) example: In chapter 6 we explain how to install Git.

If you are happy with the section header as the link text, use it inside a single set of square brackets:

  • [A picture is worth a thousand words]: example “A picture is worth a thousand words” via A picture is worth a thousand words

There are two ways to specify custom link text:

  • [link text][Section header text], e.g., “pic = 1000 words” via pic = 1000 words
  • [link text](#label), e.g., “RStudio, meet Git” via RStudio, meet Git

The Pandoc documentation provides more details on automatic section IDs and implicit header references.

41.4 Figures, tables, citations

Figures and tables with captions will be placed in figure and table environments, respectively.

Figure 41.1: Here is a nice figure!

Reference a figure by its code chunk label with the fig: prefix, e.g., see Figure 41.1. Similarly, you can reference tables generated from knitr::kable(), e.g., see Table 41.1.

Table 41.1: Here is a nice table!

You can write citations, too. For example, we are using the bookdown package (Xie 2021) in this sample book, which was built on top of R Markdown and knitr(Xie 2015).

41.5 How the square bracket links work

Bookdown demo

Context: you prefer to link with text, not a chapter or section number.

Bookdown Example

  • GOOD! Here’s a link to Contributors.
  • BAD. You can see contributors in 2.

Facts and vocabulary

Bookdown Chinese

  • Each chapter is a file. These files should begin with the chapter title using a level-one header, e.g., # Chapter Title.
  • A chapter can be made up of sections, indicated by lower-level headers, e.g., ## A section within the chapter.
  • There are three ways to address a section when creating links within your book:
    • Explicit identifier: In # My header {#foo} the explicit identifier is foo.
    • Automatically generated identifier: my-header is the auto-identifier for # My header. Pandoc creates auto-identifiers according to rules laid out in Extension: auto_identifiers.
    • The header text, e.g., My header be used verbatim as an implicit header reference. See Extension: implicit_header_references for more.
  • All 3 forms can be used to create cross-references but you build the links differently.
  • Advantage of explicit identification: You are less likely to update the section header and then forget to make matching edits to references elsewhere in the book.

R Bookdown Examples

How to make text-based links using explicit identifiers, automatic identifiers, and implicit references:

  • Use implicit reference alone to get a link where the text is exactly the section header:
    • [Introduce yourself to Git]Introduce yourself to Git
    • [Success and operating systems]Success and operating systems
  • You can provide custom text for the link with all 3 methods of addressing a section:
    • Implicit header reference: [link text][Recommended Git clients]link text
    • Explicit identifier: [hello git! I'm Jenny](#hello-git)hello git! I’m Jenny
    • Automatic identifier: [Any text you want](#recommended-git-clients)Any text you want