Muutke küpsiste eelistusi

E-raamat: R Markdown Cookbook

Teised raamatud teemal:
  • Formaat - EPUB+DRM
  • Hind: 38,99 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
Teised raamatud teemal:

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

R Markdown is a powerful tool for combining analysis and reporting into the single document in the spirit of literate programming and reproducible research. Since the birth of the rmarkdown package in early 2014, R Markdown has grown substantially from a package that supports a few output formats (such as HTML, PDF, and Word) to an extensive and diverse ecosystem that enables the creation of books, blogs, scientific articles, websites, and more. Due to its rapid success, this ecosystem is hard to learn completely meaning that R Markdown users, from novices to advanced users, likely do not know all that these packages have to offer. The R Markdown Cookbook confronts this gap by showcasing short, practical examples of wide-ranging tips and tricks to get the most out of these tools.

After reading this book, you will learn how to:

Enhance your R Markdown content with diagrams, citations, and dynamically generated text

Streamline your workflow with child documents, code chunk references, and caching

Control the formatting and layout with Pandoc markdown syntax or by writing custom HTML and LaTeX templates

Utilize chunk options and hooks to fine-tune how your code is processed

Switch between different language engineers to seamlessly incorporate python, D3, and more into your analysis

Arvustused

"This book will be a popular addition on the desk of many professionals who regularly produce technical documents in the R language." ~Carl Boettiger, University of California, Berkeley

"Novices will benefit from reading this book because they will quickly find high quality solutions to the most common issues that users encounter. Experts will benefit because it will save them from constantly trying to rediscover that thread that explains how to do that one thing." ~ Dr. John Blischak, University of Chicago

"Though I am a frequent and longtime user of RMarkdown, there were multiple points where I learned new things and capabilities that Id never seen. Sometimes incredible features are hidden"; this book eposes features and tricks that this seasoned RMarkdown user was surprised and excited by." ~ Sharla Gelfand, R and Shiny Developer

"This book is useful for R stats users who, while using RMarkdown, come across certain problems that can be solved. It also provides advanced users with additional options to further customize RMarkdown to their personal needs. The many subchapters address a number of issues that a large majority of users can use as a reference book for their needs. There are examples for every user, no matter what previous knowledge is available and therefore this book is useful for any user group of markdown." ~Dr. Johannes Friedrich

"This book is interesting for a wide level of RMarkdown users." ~MSc. Yasumoto, Atsushi, HACARUS Inc. 'This book is an excellent resource for promoting the applications of R software. This book can be used more as a reference book for R Markdown and should find a place on the library shelves.'

- Shalabh, Journal of the Royal Statistical Society, August 2021 https://doi.org/10.1111/rssa.12743

'The book covers an enormous terrain: not only straightforward use with R, but also with other languages and system like Python, SAS and Stata. Specialized output to LaTeX and custom CSS-styled HTML is also covered. Typesetting beautiful tables is described extensively. And if you want to send emails from R, you will find the instructions here. This is a good cookbook, with many delicious recipes, from simple snacks to gourmet style dishes.'

- Paul Eilers, International Society for Clinical Biostatistics, 72, 2021

List of Tables
xv
List of Figures
xvii
Preface xix
About the Authors xxvii
1 Installation
1(6)
1.1 Use a Pandoc version not bundled with the RStudio IDE
1(2)
1.2 Install LaTeX (TinyTeX) for PDF reports
3(1)
1.3 Install missing LaTeX packages
4(3)
2 Conceptual Overview
7(12)
2.1 What happens when we render?
7(2)
2.2 R Markdown anatomy
9(7)
2.2.1 YAML metadata
9(2)
2.2.2 Narrative
11(1)
2.2.3 Code chunks
12(1)
2.2.4 Document body
13(3)
2.3 What can we change to change the results?
16(3)
3 Basics
19(8)
3.1 Code chunks and inline R code
19(1)
3.2 Write Markdown in the RStudio visual editor
20(1)
3.3 Render an R script to a report
20(4)
3.4 Convert R Markdown to R script
24(2)
3.5 R Markdown Notebooks
26(1)
4 Document Elements
27(32)
4.1 Insert page breaks
27(1)
4.2 Set the document title dynamically
28(1)
4.3 Access the document metadata in R code
29(1)
4.4 Unnumbered sections
30(1)
4.5 Bibliographies and citations
31(3)
4.5.1 Changing citation style
32(1)
4.5.2 Add an item to a bibliography without using it
33(1)
4.5.3 Add all items to the bibliography
33(1)
4.5.4 Include appendix after bibliography (*)
33(1)
4.6 Generate R package citations
34(4)
4.7 Cross-referencing within documents
38(1)
4.8 Update the date automatically
39(3)
4.9 Multiple authors in a document
42(1)
4.10 Numbered figure captions
43(1)
4.11 Combine words into a comma-separated phrase
44(1)
4.12 Preserve a large number of line breaks
45(2)
4.13 Convert models to equations
47(1)
4.14 Create an animation from multiple R plots
48(1)
4.15 Create diagrams
49(3)
4.15.1 Basic diagrams
50(1)
4.15.2 Adding parameters to plots
50(2)
4.15.3 Other packages for making diagrams
52(1)
4.16 Escape special characters
52(1)
4.17 Comment out text
53(1)
4.18 Omit a heading in the table of contents
53(1)
4.19 Put together all code in the appendix (*)
53(2)
4.20 Manipulate Markdown via Pandoc Lua filters (*)
55(4)
5 Formatting
59(18)
5.1 Fontcolor
60(3)
5.1.1 Using an R function to write raw HTML or LaTeX code
60(1)
5.1.2 Using a Pandoc Lua filter (*)
61(2)
5.2 Indent text
63(1)
5.3 Control the width of text output
64(2)
5.4 Control the size of plots/images
66(2)
5.5 Figure alignment
68(1)
5.6 Verbatim code chunks
68(2)
5.6.1 Show a verbatim inline expression
69(1)
5.7 Line numbers for code blocks (*)
70(1)
5.8 Multi-column layout (*)
71(6)
6 LaTeX Output
77(20)
6.1 Add LaTeX code to the preamble
77(2)
6.2 Pandoc options for LaTeX output
79(2)
6.3 Add logo to title page
81(2)
6.4 Include additional LaTeX packages
83(1)
6.4.1 Loading LaTeX packages
83(1)
6.4.2 Example packages
84(1)
6.5 Control the placement of figures
84(3)
6.5.1 Floating environments
84(1)
6.5.2 Prevent figures from floating
85(1)
6.5.3 Force floats forward
86(1)
6.5.4 Adjust LaTeX placement rules (*)
86(1)
6.6 LaTeX sub-figures
87(2)
6.7 Render documents containing Unicode characters
89(1)
6.8 Generate a LaTeX fragment
90(1)
6.9 Add custom headers and footers (*)
90(2)
6.10 Use a custom Pandoc LaTeX template (*)
92(1)
6.11 Write raw LaTeX code
93(1)
6.12 For hardcore LaTeX users (*)
94(3)
7 HTML Output
97(28)
7.1 Apply custom CSS
97(1)
7.2 Center section headings
98(1)
7.3 Style code blocks and text output
99(3)
7.4 Scrollable code blocks (*)
102(2)
7.5 Fold all code blocks but show some initially
104(2)
7.6 Put content in tabs
106(2)
7.7 Embed the Rmd source file in the HTML output file
108(1)
7.8 Embed arbitrary files in the HTML output file
109(1)
7.9 Use a custom HTML template (*)
110(2)
7.10 Include the content of an existing HTML file (*)
112(2)
7.11 Add a custom browser icon
114(1)
7.12 Use the <details> disclosure element
115(2)
7.13 Sharing HTML output on the web
117(2)
7.13.1 R-specific services
117(1)
7.13.2 Static website services
118(1)
7.14 Improve accessibility of HTML pages
119(2)
7.15 For hardcore HTML users (*)
121(4)
8 Word
125(8)
8.1 Custom Word templates
125(2)
8.2 The two-way workflow between R Markdown and Word
127(3)
8.3 Style individual elements
130(3)
9 Multiple Output Formats
133(16)
9.1 LaTeX or HTML output
133(3)
9.2 Display HTML widgets
136(1)
9.3 Embed a web page
136(2)
9.4 Multiple figures side by side
138(1)
9.5 Write raw content (*)
138(1)
9.6 Custom blocks (*)
139(10)
9.6.1 Syntax
140(2)
9.6.2 Adding a shaded box
142(2)
9.6.3 Including icons
144(5)
10 Tables
149(26)
10.1 The function knitr::kable()
149(18)
10.1.1 Supported table formats
149(3)
10.1.2 Change column names
152(1)
10.1.3 Specify column alignment
153(1)
10.1.4 Add a table caption
154(1)
10.1.5 Format numeric columns
154(2)
10.1.6 Display missing values
156(1)
10.1.7 Escape special characters
157(1)
10.1.8 Multiple tables side by side
158(1)
10.1.9 Generate multiple tables from a for-loop (*)
159(2)
10.1.10 Customize LaTeX tables (*)
161(4)
10.1.11 Customize HTML tables (*)
165(2)
10.2 The kableExtra package
167(4)
10.2.1 Set the font size
168(1)
10.2.2 Style specific rows/columns
168(1)
10.2.3 Group rows/columns
169(2)
10.2.4 Scaling down wide tables in LaTeX
171(1)
10.3 Other packages for creating tables
171(4)
11 Chunk Options
175(30)
11.1 Use variables in chunk options
175(1)
11.2 Do not stop on error
176(1)
11.3 Multiple graphical output formats for the same plot
177(1)
11.4 Cache time-consuming code chunks
178(1)
11.5 Cache a code chunk for multiple output formats
179(1)
11.6 Cache large objects
180(1)
11.7 Hide code, text output, messages, or plots
181(2)
11.8 Hide everything from a chunk
183(1)
11.9 Collapse text output blocks into source blocks
183(1)
11.10 Reformat R source code
184(2)
11.11 Output text as raw Markdown content (*)
186(3)
11.12 Remove leading hashes in text output
189(1)
11.13 Add attributes to text output blocks (*)
190(2)
11.14 Post-process plots (*)
192(2)
11.15 High-quality graphics (*)
194(3)
11.16 Step-by-step plots with low-level plotting functions (*)
197(1)
11.17 Customize the printing of objects in chunks (*)
197(3)
11.18 Option hooks (*)
200(5)
12 Output Hooks (*)
205(16)
12.1 Redact source code
208(2)
12.2 Add line numbers to source code
210(1)
12.3 Scrollable text output
211(3)
12.4 Truncate text output
214(3)
12.5 Output figures in the HTML5 format
217(4)
13 Chunk Hooks (*)
221(12)
13.1 Crop plots
223(2)
13.2 Optimize PNG plots
225(1)
13.3 Report how much time each chunk takes to run
225(2)
13.4 Show the chunk header in the output
227(2)
13.5 Embed an interactive 3D plot with rgl
229(4)
14 Miscellaneous knitr Tricks
233(20)
14.1 Reuse code chunks
233(3)
14.1.1 Embed one chunk in another chunk (*)
233(1)
14.1.2 Use the same chunk label in another chunk
234(1)
14.1.3 Use reference labels (*)
235(1)
14.2 Use an object before it is created (*)
236(2)
14.3 Exit knitting early
238(1)
14.4 Generate a plot and display it elsewhere
239(1)
14.5 Modify a plot in a previous code chunk
240(2)
14.6 Save a group of chunk options and reuse them (*)
242(1)
14.7 Use knitr::knit_expand() to generate Rmd source
243(1)
14.8 Allow duplicate labels in code chunks (*)
244(1)
14.9 A more transparent caching mechanism
245(8)
14.9.1 Invalidate the cache by changing code in the expression
246(1)
14.9.2 Invalidate the cache by changes in global variables
247(2)
14.9.3 Keep multiple copies of the cache
249(1)
14.9.4 Comparison with knitr/s caching
250(3)
15 Other Languages
253(18)
15.1 Register a custom language engine (*)
254(3)
15.2 Run Python code and interact with Python
257(1)
15.3 Execute content conditionally via the asis engine
258(1)
15.4 Execute Shell scripts
259(1)
15.5 Visualization with D3
260(1)
15.6 Write the chunk content to a file via the cat engine
261(4)
15.6.1 Write to a CSS file
262(1)
15.6.2 Include LaTeX code in the preamble
263(1)
15.6.3 Write YAML data to a file and also display it
264(1)
15.7 RunSAS code
265(1)
15.8 Run Stata code
265(1)
15.9 Create graphics with Asymptote
266(2)
15.9.1 Generate data in R and read it in Asymptote
267(1)
15.10 Style HTML pages with Sass/SCSS
268(3)
16 Managing Projects
271(20)
16.1 Source external R scripts
271(1)
16.2 Read external scripts into a chunk
272(1)
16.3 Read multiple code chunks from an external script (*)
273(1)
16.4 Child documents (*)
274(3)
16.5 Keep the plot files
277(1)
16.6 The working directory for R code chunks
278(4)
16.7 R package vignettes
282(2)
16.8 R Markdown templates in R packages
284(2)
16.8.1 Template use-cases
284(1)
16.8.2 Template setup
285(1)
16.9 Write books and long-form reports with bookdown
286(2)
16.10 Build websites with blogdown
288(3)
17 Workflow
291(10)
17.1 Use RStudio keyboard shortcuts
291(1)
17.2 Spell-check R Markdown
292(1)
17.3 Render R Markdown with rmarkdown:: render ()
292(2)
17.4 Parameterized reports
294(2)
17.5 Customize the Knit button (*)
296(3)
17.6 Collaborate on Rmd documents through Google Drive
299(1)
17.7 Organize an R Markdown project into a research website with workflowr
300(1)
17.8 Send emails based on R Markdown
301(2)
Appendix 301(18)
A knitr's Chunk and Package Options
303(16)
A.1 Chunk options
303(2)
A.1.1 Code evaluation
305(1)
A.1.2 Text output
305(2)
A.1.3 Code decoration
307(1)
A.1.4 Cache
308(2)
A.1.5 Plots
310(4)
A.1.6 Animation
314(1)
A.1.7 Code chunk
315(1)
A.1.8 Child documents
315(1)
A.1.9 Language engines
315(1)
A.1.10 Option templates
316(1)
A.1.11 Extracting source code
316(1)
A.1.12 Other chunk options
316(1)
A.2 Package options
316(3)
Bibliography 319(6)
Index 325
Yihui Xie is a software engineer at RStudio. He has authored and co-authored several R packages, including knitr, rmarkdown, bookdown, blogdown, pagedown, tinytex, and xaringan. He has published R Markdown: The Definitive Guide, Dynamic Documents with R and knitr, bookdown: Authoring Books and Technical Documents with R Markdown, and blogdown: Creating Websites with R Markdown."

Christophe Dervieux is an active member of the R community. Working with R since almost 10 years, he is interested in helping others get the most from R. As an R developer, he is a regular contributor to several R packages, such as "bookdown", "rmarkdown", and "knitr".

Emily Riederer is an active R user and developer. She has previously contributed to "knitr" and is best known for her article on "R Markdown Driven Development" based on her experience promoting R adoption in industry.