<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>R Markdown on Stats and R</title>
    <link>https://statsandr.com/tags/r-markdown/</link>
    <description>Recent content in R Markdown on Stats and R</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Tue, 18 Feb 2020 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="https://statsandr.com/tags/r-markdown/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Getting started in R markdown</title>
      <link>https://statsandr.com/blog/getting-started-in-r-markdown/</link>
      <pubDate>Tue, 18 Feb 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/getting-started-in-r-markdown/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#r-markdown-what-why-and-how&#34; id=&#34;toc-r-markdown-what-why-and-how&#34;&gt;R Markdown: what, why and how?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#before-you-start&#34; id=&#34;toc-before-you-start&#34;&gt;Before you start&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#components-of-a-.rmd-file&#34; id=&#34;toc-components-of-a-.rmd-file&#34;&gt;Components of a &lt;code&gt;.Rmd&lt;/code&gt; file&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#yaml-header&#34; id=&#34;toc-yaml-header&#34;&gt;YAML header&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#code-chunks&#34; id=&#34;toc-code-chunks&#34;&gt;Code chunks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#text&#34; id=&#34;toc-text&#34;&gt;Text&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#code-inside-text&#34; id=&#34;toc-code-inside-text&#34;&gt;Code inside text&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#highlight-text-like-it-is-code&#34; id=&#34;toc-highlight-text-like-it-is-code&#34;&gt;Highlight text like it is code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#images&#34; id=&#34;toc-images&#34;&gt;Images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#tables&#34; id=&#34;toc-tables&#34;&gt;Tables&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#additional-notes-and-useful-resources&#34; id=&#34;toc-additional-notes-and-useful-resources&#34;&gt;Additional notes and useful resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/getting-started-in-r-markdown.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you have spent some time writing code in R, you probably have heard of generating dynamic reports incorporating R code, R outputs (results) and text or comments. In this article, I will explain how R Markdown works and give you the basic elements you need to get started easily in the production of these dynamic reports.&lt;/p&gt;
&lt;div id=&#34;r-markdown-what-why-and-how&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;R Markdown: what, why and how?&lt;/h1&gt;
&lt;p&gt;R Markdown allows to generate a report (most of the time in PDF, HTML, Word or as a beamer presentation) that is automatically generated from a file written within RStudio. The generated documents can serve as a neat record of your analysis that can be shared and published in a detailed and complete report. Even if you never expect to present the results to someone else, it can also be used as a personal notebook to look back so you can see what you did at that time. A R Markdown file has the extension &lt;code&gt;.Rmd&lt;/code&gt;, while a R script file has the extension &lt;code&gt;.R&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The first main advantage of using R Markdown over R is that, in a R Markdown document, you can combine three important parts of any statistical analysis:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;R code to show how the analyses have been done. For instance, the data and the functions you used. This allows readers to follow your code and to check that the analyses were correctly performed.&lt;/li&gt;
&lt;li&gt;Results of the code, that is, the output of your analyses. For example, the output of your linear model, plots, or results of the hypothesis test you just coded. This allows readers to see the results of your analyses.&lt;/li&gt;
&lt;li&gt;Text, comments and interpretations of the results. For instance, after computing the main &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; and plotting some graphs, you can interpret them in the context of your problem and highlight important findings. This enables readers to understand your results thanks to your interpretations and your comments, delivered as if you wrote a document explaining your work.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Another advantage of R Markdown is that the reports are dynamic and reproducible by anyone who has access to the &lt;code&gt;.Rmd&lt;/code&gt; file (and the data if external data are used of course), making it perfectly suited to collaboration and dissemination of results. By dynamic, we mean that if your data changes, your results and your interpretations will change accordingly, without any work from your side.&lt;/p&gt;
&lt;p&gt;The production of the reports is done in two stages:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The &lt;code&gt;.Rmd&lt;/code&gt; file which contains blocks of R code (called chunks) and text is provided to the &lt;code&gt;{knitr}&lt;/code&gt; package which will execute the R code to get the output, and create a document in markdown (&lt;code&gt;.md&lt;/code&gt;) format. This document then contains the R code, the results (or outputs), and the text.&lt;/li&gt;
&lt;li&gt;This &lt;code&gt;.md&lt;/code&gt; file is then converted to the desired format (HTML, PDF or Word), by the &lt;code&gt;markdown&lt;/code&gt; package based on pandoc (i.e., a document conversion tool).&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;before-you-start&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Before you start&lt;/h1&gt;
&lt;p&gt;To create a new R Markdown document (&lt;code&gt;.Rmd&lt;/code&gt;), you first need to install and load the following packages:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(c(&amp;quot;knitr&amp;quot;, &amp;quot;rmarkdown&amp;quot;, &amp;quot;markdown&amp;quot;))

library(knitr)
library(rmarkdown)
library(markdown)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then click on File -&amp;gt; New File -&amp;gt; R Markdown or click on the small white sheet with a green cross in the top left corner and select &lt;code&gt;R Markdown&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-17%20at%2020.15.02.png&#34; alt=&#34;Create a new R Markdown document&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Create a new R Markdown document&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A window will open, choose the title and the author and click on OK. The default output format is HTML. It can be changed later to PDF or Word.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-17%20at%2020.39.46.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;After you have clicked on OK, a new &lt;code&gt;.Rmd&lt;/code&gt; file which serves as example has been created. We are going to use this file as starting point to our more complex and more personalized file.&lt;/p&gt;
&lt;p&gt;To compile your R Markdown document into a HTML document, click on the &lt;code&gt;Knit&lt;/code&gt; button located at the top:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-17%20at%2020.49.02.png&#34; alt=&#34;Knit a R Markdown document&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Knit a R Markdown document&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A preview of the HTML report appears and it is also saved in your working directory (see a reminder of what is a &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;working directory&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;components-of-a-.rmd-file&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Components of a &lt;code&gt;.Rmd&lt;/code&gt; file&lt;/h1&gt;
&lt;p&gt;Below the main components of a R Markdown document:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Components%20of%20a%20R%20Markdown%20document.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;These components are detailed in the following sections.&lt;/p&gt;
&lt;div id=&#34;yaml-header&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;YAML header&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;.Rmd&lt;/code&gt; file starts with the YAML header, enclosed by two series of &lt;code&gt;---&lt;/code&gt;. By default, this includes the title, author, date and the format of the report. If you want to generate the report in a PDF document, replace &lt;code&gt;output: html_document&lt;/code&gt; by&lt;code&gt;output: pdf_document&lt;/code&gt;. These information from the YAML header will appear at the top of the generated report after you compile it (i.e., after knitting the document).&lt;/p&gt;
&lt;p&gt;To add a table of contents to your documents, replace &lt;code&gt;output: html_document&lt;/code&gt; by&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;output:
  html_document:
    toc: true&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here are my usual settings regarding the format of a HTML document (remove everything after &lt;code&gt;number_sections: true&lt;/code&gt; if you render the document in PDF, as PDF documents do not accept these options in the YAML header):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;output:
  html_document:
    toc: true
    toc_depth: 6
    number_sections: true
    toc_float: true
    code_folding: hide
    theme: flatly
    code_download: true&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In addition to adding a table of contents, it sets its depth, adds a section numbering, the table of contents is floating when scrolling down the document, the code is hidden by default, the &lt;code&gt;flatly&lt;/code&gt; theme is used and it adds the possibility to download the &lt;code&gt;.Rmd&lt;/code&gt; document.&lt;/p&gt;
&lt;p&gt;You can visualize your table of contents even before knitting the document, or go directly to a specific section by clicking on the small icon in the top right corner. Your table of contents will appear, click on a section to go to this section in your &lt;code&gt;.Rmd&lt;/code&gt; document:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-17%20at%2022.15.21.png&#34; alt=&#34;Visualize your table of contents&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Visualize your table of contents&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In addition to this enhanced table of contents, I usually set the following date in the YAML header:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-18%20at%2014.15.33.png&#34; alt=&#34;Dynamic date in R Markdown&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Dynamic date in R Markdown&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This piece of code allows to write the current date, without having to change it myself. This is very convenient for projects that last several weeks or months to always have an updated date at the top of the document.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;code-chunks&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Code chunks&lt;/h2&gt;
&lt;p&gt;Below the YAML header, there is a first code chunk which is used for the setup options of your &lt;strong&gt;entire&lt;/strong&gt; document. It is best to leave it like this at the moment, we can change it later if needed.&lt;/p&gt;
&lt;p&gt;Code chunks in R Markdown documents are used to write R code. Every time you want to include R code, you will need to enclose it with three backwards apostrophes. For instance, to compute the mean of the values 1, 7 and 11, we first need to insert a R code chunk by clicking on the &lt;code&gt;Insert&lt;/code&gt; button located at the top and select R (see below a picture), then we need to write the corresponding code inside the code chunk we just inserted:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-18%20at%2014.42.48.png&#34; alt=&#34;Insert R code chunk in R Markdown&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Insert R code chunk in R Markdown&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-17%20at%2021.04.54.png&#34; alt=&#34;Example of code chunk&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Example of code chunk&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the example file, you can see that the first R code chunk (except the setup code chunk) includes the function &lt;code&gt;summary()&lt;/code&gt; of the preloaded dataset &lt;code&gt;cars&lt;/code&gt;: &lt;code&gt;summary(cars)&lt;/code&gt;. If you look at the HTML document that is generated from this example file, you will see that the summary measures are displayed just after the code chunk.&lt;/p&gt;
&lt;p&gt;The next code chunk in this example file is &lt;code&gt;plot(pressure)&lt;/code&gt;, which will produce a plot. Try writing other R codes and knit (i.e., compile the document by clicking on the knit button) the document to see if your code is generated correctly.&lt;/p&gt;
&lt;p&gt;If you already wrote code in a R script and want to reuse it in your R Markdown document, you can simply copy paste your code inside code chunks. Do not forget to always include your code inside code chunks or R will throw an error when compiling your document.&lt;/p&gt;
&lt;p&gt;As you can see, there are two additional arguments in the code chunk of the plot compared to my code chunk of the mean presented above. The first argument following the letter &lt;code&gt;r&lt;/code&gt; (without comma between the two) is used to set the name of the chunk. In general, do not bother with this, it is mainly used to refer to a specific code chunk. You can remove the name of the chunk, but do not remove the letter &lt;code&gt;r&lt;/code&gt; between the &lt;code&gt;{}&lt;/code&gt; as it tells R that the code that follows corresponds to R code (yes you read it well, that also means you can include code from another programming language, e.g., Python, SQL, etc.).&lt;/p&gt;
&lt;p&gt;After the name of the chunk (after &lt;code&gt;pressure&lt;/code&gt; in the example file), you can see that there is an additional argument: &lt;code&gt;echo = FALSE&lt;/code&gt;. This argument, called an option, indicates that you want to hide the code, and display only the output of the code. Try removing it (or change it to &lt;code&gt;echo = TRUE&lt;/code&gt;), and you will see that after knitting the document, both the code AND the output will appear, while only the results appeared previously.&lt;/p&gt;
&lt;p&gt;You can specify if you want to hide or display the code alongside the output of that code for each code chunk separately, for instance if you want to show the code for some code chunks, but not for others. Alternatively, if you want to always hide/display the code together with the output for the entire document, you can specify it in the setup code chunk located just after the YAML header. The options passed to this setup code chunk will determine the options for all code chunks, except for those that have been specifically modified.&lt;/p&gt;
&lt;p&gt;By default, the only setup option when you open a new R Markdown file is &lt;code&gt;knitr::opts_chunk$set(echo = TRUE)&lt;/code&gt;, meaning that by default, all outputs will be accompanied by its corresponding code. If you want to display only the results without the code for the whole document, replace it by &lt;code&gt;knitr::opts_chunk$set(echo = FALSE)&lt;/code&gt;. Two other options often passed to this setup code chunk are &lt;code&gt;warning = FALSE&lt;/code&gt; and &lt;code&gt;message = FALSE&lt;/code&gt; to prevent warnings and messages to be displayed on the report. If you want to pass several options, do not forget to separate them with a comma:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-17%20at%2022.05.12.png&#34; alt=&#34;Several options for a code chunk&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Several options for a code chunk&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also choose to display the code, but not the result. For this, pass the option &lt;code&gt;results = &#34;hide&#34;&lt;/code&gt;. Alternatively, with the option &lt;code&gt;include = FALSE&lt;/code&gt;, you can prevent code and results from appearing in the finished file while R still runs the code in order to use it at a later stage. If you want to prevent the code and the results to appear, and do not want R to run the code, use &lt;code&gt;eval = FALSE&lt;/code&gt;. To edit the width and height of figures, use the options &lt;code&gt;fig.width&lt;/code&gt; and &lt;code&gt;fig.height&lt;/code&gt;. Another very interesting option is the &lt;code&gt;tidy = &#39;styler&#39;&lt;/code&gt; option which automatically &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#styler&#34;&gt;reformats the R code&lt;/a&gt; shown in the output.&lt;/p&gt;
&lt;p&gt;See all options and their description &lt;a href=&#34;https://yihui.org/knitr/options/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; or see the list of the default options by running &lt;code&gt;str(knitr::opts_chunk$get())&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: When writing in R Markdown, you will very often need to insert new R code chunks. To insert a new R code chunk more rapidly, press &lt;code&gt;CTRL + ALT + I&lt;/code&gt; on Windows or &lt;code&gt;command + option + I&lt;/code&gt; on Mac. If you are interested in such shortcuts making you more efficient, see other &lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/&#34;&gt;tips and tricks in R Markdown&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that a code chunk can be run without the need to compile the entire document, if you want to check the results of a specific code chunk for instance. In order to run a specific code chunk, select the code and run it as you would do in a R script (&lt;code&gt;.R&lt;/code&gt;), by clicking on run or by pressing &lt;code&gt;CTRL + Enter&lt;/code&gt; on Windows or &lt;code&gt;command + Enter&lt;/code&gt; on Mac. Results of this code chunk will be displayed directly in the R Markdown document, just below the code chunk.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;text&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Text&lt;/h2&gt;
&lt;p&gt;Text can be added everywhere outside code chunks. R Markdown documents use the Markdown syntax for the formatting of the text. In our example file just below the setup code chunk, some text has been inserted. To insert text, you simply write text without any enclosing. Try adding some sentences and knit the document to see how it appears in the HTML document.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-18%20at%2014.49.47.png&#34; alt=&#34;Example of text below an example of R code chunk&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Example of text below an example of R code chunk&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Markdown syntax can be used to change the formatting of your text appearing in the output file, for example to format some text in &lt;em&gt;italics&lt;/em&gt;, in &lt;strong&gt;bold&lt;/strong&gt;, etc. Below some common formatting commands:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Title: &lt;code&gt;# Title&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Subtitle: &lt;code&gt;## Subtitle&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Subsubtitle: &lt;code&gt;### Subsubtitle&lt;/code&gt;. These headings will automatically be included in the table of contents if you included one.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;italics&lt;/em&gt;: &lt;code&gt;*italics*&lt;/code&gt; or &lt;code&gt;_italics_&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;bold&lt;/strong&gt;: &lt;code&gt;**bold**&lt;/code&gt; or &lt;code&gt;__bold__&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/&#34;&gt;Link&lt;/a&gt;: &lt;code&gt;[link](https://statsandr.com/)&lt;/code&gt; (do not forget &lt;code&gt;https://&lt;/code&gt; or &lt;code&gt;http://&lt;/code&gt; if it is an external URL)&lt;/li&gt;
&lt;li&gt;Equations:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Enclose your equation (written in LaTeX) with one &lt;code&gt;$&lt;/code&gt; to have it in the text:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$A = \pi*r^{2}$&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a well-know equation &lt;span class=&#34;math inline&#34;&gt;\(A = \pi*r^{2}\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Enclose your LaTeX equation with two &lt;code&gt;$$&lt;/code&gt; to have it centered on a new line:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$$A = \pi*r^{2}$$&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is another well-known equation:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[E = mc^2\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Lists:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Unordered list, item 1: &lt;code&gt;* Unordered list, item 1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Unordered list, item 2: &lt;code&gt;* Unordered list, item 2&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Ordered list, item 1: &lt;code&gt;1. Ordered list, item 1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Ordered list, item 2: &lt;code&gt;2. Ordered list, item 2&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;code-inside-text&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Code inside text&lt;/h3&gt;
&lt;p&gt;Before going further, I would like to introduce an important feature of R Markdown. It is often the case that, when writing interpretations or detailing an analysis, we would like to refer to a result directly in our text. For instance, suppose we work on the &lt;code&gt;iris&lt;/code&gt; dataset (preloaded in R). We may want to explain in words, that the mean of the length of the petal is a certain value, while the median is another value.&lt;/p&gt;
&lt;p&gt;Without R Markdown, the user would need to compute the mean and median, and then report it manually. Thanks to R Markdown, it is possible to report these two &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;descriptive statistics&lt;/a&gt; directly in the text, without manually encoding it. Even better, if the dataset happens to change because we removed some observations, the mean and median reported in the generated document will change automatically, without any change in the text from our side.&lt;/p&gt;
&lt;p&gt;We can insert results directly in the interpretations (i.e., in the text) by placing a backward apostrophe, the letter &lt;code&gt;r&lt;/code&gt;, a space, the code, and then close it with another backward apostrophe:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-03-15%20at%2011.14.50.png&#34; alt=&#34;Inline code in R Markdown&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Inline code in R Markdown&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here is an illustration with the mean and median of the length of the sepal for the &lt;code&gt;iris&lt;/code&gt; dataset integrated in a sentence:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-17%20at%2023.10.07.png&#34; alt=&#34;Example of inline code and text&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Example of inline code and text&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This combination of text and code will give the following output in the generated report:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The mean of the length of the sepal is 5.8433333 and the standard deviation is 0.8280661.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This technique, referred as &lt;em&gt;inline code&lt;/em&gt;, allows you to insert results directly into the text of a R Markdown document. And as mentioned, if the dataset changes, the results incorporated inside the text (the mean and standard deviation in our case) will automatically be adjusted to the new dataset, exactly like the output of a code chunk is dynamically updated if the dataset changes.&lt;/p&gt;
&lt;p&gt;This technique of inline code and the fact that it is possible to combine code, outputs of code, and text to comment the outputs makes R Markdown my favorite tool when it comes to statistical analyses. Since I discovered the power of R Markdown (and I am still learning as it has a huge amount of possibilities and features), I almost never write R code in scripts anymore. Every R code I write is supplemented by text and inline code in a R Markdown document, resulting in a professional and complete final document ready to be shared, published, or stored for future usage. If you are unfamiliar to this type of document, I invite you to learn more about it and to try it with your next analysis, you will most likely not go back to R scripts anymore.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;highlight-text-like-it-is-code&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Highlight text like it is code&lt;/h3&gt;
&lt;p&gt;Alternatively to the inline code technique, you may want to make some text appears as if it is a piece of code in the generated report, without actually running it.&lt;/p&gt;
&lt;p&gt;For this, surround your text with back ticks (the same backward apostrophe used for inline code) without the letter &lt;code&gt;r&lt;/code&gt;. Writing the following:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-03-15%20at%2011.30.04.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;will produce this in the generated report:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For example, in this sentence I would like to highlight the variable name &lt;code&gt;Species&lt;/code&gt; from the dataframe &lt;code&gt;iris&lt;/code&gt; as if it is a piece of code.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The word “Species” and “iris” appear and are highlighted as if it is a piece of code.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;images&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Images&lt;/h2&gt;
&lt;p&gt;In addition to code, results and text, you can also insert images in your final document. To insert an image, place it in your current working directory, and outside a code chunk write:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;![](path_to_your_image.jpg)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Note that the the file/url path is NOT quoted. To add an alt text to your image, add it between the square brackets &lt;code&gt;[]&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;![alt text here](path_to_your_image.jpg)&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tables&lt;/h2&gt;
&lt;p&gt;There are two options to insert tables in R Markdown documents:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the &lt;code&gt;kable()&lt;/code&gt; function from the &lt;code&gt;{knitr}&lt;/code&gt; package&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;pander()&lt;/code&gt; function from the &lt;code&gt;{pander}&lt;/code&gt; package&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here are an example of a table without any formatting, and the same code with the two functions applied on the &lt;code&gt;iris&lt;/code&gt; dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# without formatting
summary(iris)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
##  Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100  
##  1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300  
##  Median :5.800   Median :3.000   Median :4.350   Median :1.300  
##  Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199  
##  3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800  
##  Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500  
##        Species  
##  setosa    :50  
##  versicolor:50  
##  virginica :50  
##                 
##                 
## &lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# with kable()
library(knitr)
kable(summary(iris))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-18%20at%2015.27.34.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# with pander()
library(pander)
pander(summary(iris))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/getting-started-in-r-markdown_files/Screenshot%202020-02-18%20at%2015.27.41.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The advantage of &lt;code&gt;pander()&lt;/code&gt; over &lt;code&gt;kable()&lt;/code&gt; is that it can be used for many more different outputs than table. Try on your own code, with results of a &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt; or a simple vector for example.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-notes-and-useful-resources&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Additional notes and useful resources&lt;/h1&gt;
&lt;p&gt;For more advanced users, R Markdown files can also be used to create &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny apps&lt;/a&gt;, websites (this website is built thanks to R Markdown and the &lt;code&gt;{blogdown}&lt;/code&gt; package), to write scientific papers based on templates from several international journals (with the &lt;code&gt;{rticles}&lt;/code&gt; package), or even to write books (with the &lt;code&gt;{bookdown}&lt;/code&gt; package).&lt;/p&gt;
&lt;p&gt;To continue learning about R Markdown, see two complete cheat sheets from the R Studio team &lt;a href=&#34;https://rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;https://rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;, and a more complete guide &lt;a href=&#34;https://bookdown.org/yihui/rmarkdown/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; written by Yihui Xie, J. J. Allaire and Garrett Grolemund.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article convinced you to use R Markdown for your future projects. See more &lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/&#34;&gt;tips and tricks in R Markdown&lt;/a&gt; to increase even further your efficiency in R Markdown.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>RStudio addins, or how to make your coding life easier?</title>
      <link>https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/</link>
      <pubDate>Sun, 26 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-are-rstudio-addins&#34; id=&#34;toc-what-are-rstudio-addins&#34;&gt;What are RStudio addins?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#installation&#34; id=&#34;toc-installation&#34;&gt;Installation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#addins&#34; id=&#34;toc-addins&#34;&gt;Addins&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#esquisse&#34; id=&#34;toc-esquisse&#34;&gt;Esquisse&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#ggthemeassist&#34; id=&#34;toc-ggthemeassist&#34;&gt;ggThemeAssist&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#questionr&#34; id=&#34;toc-questionr&#34;&gt;Questionr&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#recoding-factors&#34; id=&#34;toc-recoding-factors&#34;&gt;Recoding factors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#reordering-factors&#34; id=&#34;toc-reordering-factors&#34;&gt;Reordering factors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#categorize-a-numeric-variable&#34; id=&#34;toc-categorize-a-numeric-variable&#34;&gt;Categorize a numeric variable&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#remedy&#34; id=&#34;toc-remedy&#34;&gt;Remedy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#styler&#34; id=&#34;toc-styler&#34;&gt;Styler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#snakecaser&#34; id=&#34;toc-snakecaser&#34;&gt;Snakecaser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#viewpipesteps&#34; id=&#34;toc-viewpipesteps&#34;&gt;ViewPipeSteps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ymlthis&#34; id=&#34;toc-ymlthis&#34;&gt;Ymlthis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#reprex&#34; id=&#34;toc-reprex&#34;&gt;Reprex&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#blogdown&#34; id=&#34;toc-blogdown&#34;&gt;Blogdown&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addins.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;what-are-rstudio-addins&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What are RStudio addins?&lt;/h1&gt;
&lt;p&gt;Although I have been using RStudio for several years, I only recently discovered RStudio addins. Since then, I am using these addins almost every time I use RStudio.&lt;/p&gt;
&lt;p&gt;What are RStudio addins? RStudio addins are extensions which provide a simple mechanism for executing advanced R functions from within RStudio. In simpler words, when executing an addin (by clicking a button in the Addins menu), the corresponding code is executed without you having to write the code. If it is still not clear, remember that for &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;importing a dataset in RStudio&lt;/a&gt;, you have two options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;import it by writing the code (thanks to the &lt;code&gt;read.csv()&lt;/code&gt; function for instance)&lt;/li&gt;
&lt;li&gt;or you can import it by clicking on the “Import Dataset” button in the Environment pane, set the importing settings, then click on “Import”&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An RStudio addin is exactly like the Import Dataset button but for other common functionalities. So you could write code as you can import a dataset by writing code, but thanks to RStudio addins you can execute code without actually writing the necessary code. By using the RStudio addins, RStudio will run the required code for you. RStudio addins can be as simple as a function that inserts a commonly used snippet of code, and as complex as a Shiny application that accepts input from the user to draw a plot. RStudio addins have the advantage that they allow you to execute complex and advanced code much more easily than if you would have to write it yourself.&lt;/p&gt;
&lt;p&gt;I believe addins are worth trying for all R users. Beginners will have the possibility to use functions that they would not have used otherwise because the code is too complex, whereas advanced users may find them useful to speed up the writing of their code in some circumstances. For other tips in R, see the article “&lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/&#34;&gt;Tips and tricks in RStudio and R Markdown&lt;/a&gt;”.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Installation&lt;/h1&gt;
&lt;p&gt;RStudio Addins are distributed as R packages. So before being able to use them, you need to install them.&lt;/p&gt;
&lt;p&gt;You can install an addin exactly the same way you &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;install a package&lt;/a&gt;: &lt;code&gt;install.packages(&#34;name_of_addin&#34;)&lt;/code&gt;. Once you have installed the R package that contains the addin, it will immediately become available within RStudio, via the Addins menu located at the top.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addins-toolbar.png&#34; alt=&#34;RStudio addins toolbar&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;RStudio addins toolbar&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;See this &lt;a href=&#34;https://rstudio.github.io/rstudioaddins/#registering-addins&#34; target=&#34;_blank&#34;&gt;guide&lt;/a&gt; if you want to install a personal package as addin. In short, you have to create an R package, put your functions in a specific file and RStudio will automatically discover and register these addins when your package is installed.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;addins&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Addins&lt;/h1&gt;
&lt;p&gt;If you are still not convinced, see below a list of the addins I find most useful together with concrete examples in the following sections.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#esquisse&#34;&gt;Esquisse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#questionr&#34;&gt;Questionr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#remedy&#34;&gt;Remedy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#styler&#34;&gt;Styler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#snakecaser&#34;&gt;Snakecaser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#viewpipesteps&#34;&gt;ViewPipeSteps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#ymlthis&#34;&gt;Ymlthis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#reprex&#34;&gt;Reprex&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#blogdown&#34;&gt;Blogdown&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that this list is not exhaustive and you are likely to find others useful too depending on what type of analyses you do on RStudio. Feel free to comment at the end of the article to let me know (and other readers) addins you found worth using.&lt;/p&gt;
&lt;div id=&#34;esquisse&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Esquisse&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;{esquisse}&lt;/code&gt; is an addin developed by a French company called &lt;a href=&#34;https://www.dreamrs.fr/&#34; target=&#34;_blank&#34;&gt;dreamRs&lt;/a&gt;. Here is how they define it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This addin allows you to interactively explore your data by visualizing it with the ggplot2 package. It allows you to draw bar plots, curves, scatter plots, histograms, boxplot and sf objects, then export the graph or retrieve the code to reproduce the graph.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;With this addin you can easily create beautiful graphs from the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt; and the best part according to me is that you can retrieve the code to reproduce the graph. Compared to the default &lt;code&gt;{graphics}&lt;/code&gt; package, it is true that graphs from the &lt;code&gt;{ggplot2}&lt;/code&gt; package look usually better but the code is also longer and more complex. With this addin, you can draw graphs from the &lt;code&gt;{ggplot2}&lt;/code&gt; package by dragging and dropping variables of interest in an user-friendly and interactive window, and then use the generated code in your script.&lt;/p&gt;
&lt;p&gt;For the sake of illustration, let’s say we want to create a scatter plot of the variables &lt;code&gt;Sepal.Length&lt;/code&gt; and &lt;code&gt;Petal.Length&lt;/code&gt; of the dataset &lt;code&gt;iris&lt;/code&gt; and color the points by the variable &lt;code&gt;Species&lt;/code&gt;. For this, follow these steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;load the dataset and rename it:&lt;a href=&#34;#fn1&#34; class=&#34;footnote-ref&#34; id=&#34;fnref1&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iris&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;install the package &lt;code&gt;{esquisse}&lt;/code&gt;. This must be done only once&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;esquisse&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;open the ‘ggplot2’ builder from the RStudio Addins menu:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/esquisse-RStudio-addin.png&#34; alt=&#34;Step 3: Open ‘ggplot2’ builder from the RStudio addins menu&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Open ‘ggplot2’ builder from the RStudio addins menu&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;4&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Select the dataset you want to work on (in this case &lt;code&gt;dat&lt;/code&gt;) and click on “Validate imported data” after checking that the number of observations and variables are correct (green box):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/esquisse-rstudio-addin2.png&#34; alt=&#34;Step 4: Select dataset and validate the imported data&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 4: Select dataset and validate the imported data&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;5&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Drag and drop the variables of interest in the corresponding areas. In this case, we would like to draw a scatter plot of the variables &lt;code&gt;Sepal.Length&lt;/code&gt; and &lt;code&gt;Petal.Length&lt;/code&gt; and color points based on the variable &lt;code&gt;Species&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/esquisse-rstudio-addin3.png&#34; alt=&#34;Step 5: Drag and drop the variables in the corresponding areas&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 5: Drag and drop the variables in the corresponding areas&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;6&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Click on “&amp;lt;/&amp;gt; Export &amp;amp; code” at the bottom right of the window. You can either copy the code and paste it where you want to place it in your script, or you can click on “Insert code in script” to place the code where your cursor is located in your script:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/esquisse-rstudio-addin4.png&#34; alt=&#34;Step 6: Retrieve the code to use it in your script&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 6: Retrieve the code to use it in your script&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you chose the second option, the following code should appear where your cursor was located:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Sepal.Length, y = Petal.Length, colour = Species) +
  geom_point(shape = &amp;quot;circle&amp;quot;, size = 1.5) +
  scale_color_hue(direction = 1) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/figure-html/unnamed-chunk-4-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Many different options and customizations are possible (e.g., axis labels, colors, legend position, theme, data filtering, etc.). For this, use the buttons located at the bottom of the window (“Labels &amp;amp; title”, “Plot options” and “Data”). You can see the changes instantly in the window, and when the plot corresponds to your needs, export the code into your script.&lt;/p&gt;
&lt;p&gt;I will not go into more details regarding the different types of plots and the customizations, but make sure to try other types of plots by moving variables and customize it to see what is possible.&lt;/p&gt;
&lt;div id=&#34;ggthemeassist&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;ggThemeAssist&lt;/h3&gt;
&lt;p&gt;Note that there is another addin called &lt;code&gt;{ggThemeAssist}&lt;/code&gt; which helps you to edit the &lt;code&gt;theme()&lt;/code&gt; layer of a &lt;code&gt;{ggplot2}&lt;/code&gt; plot.&lt;/p&gt;
&lt;p&gt;This layer allows you to modify the appearance of the background, grids, axes, labels, legend, (sub)title, caption, etc.&lt;/p&gt;
&lt;p&gt;To use this addin:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write the code of the plot in &lt;code&gt;{ggplot2}&lt;/code&gt; (it does not work for a plot written in base R)&lt;/li&gt;
&lt;li&gt;Highlight the code&lt;/li&gt;
&lt;li&gt;Select the &lt;code&gt;{ggThemeAssist}&lt;/code&gt; addin in the addins menu&lt;/li&gt;
&lt;li&gt;Customize your plot according to your needs&lt;/li&gt;
&lt;li&gt;Click on the button Done and your code will be edited with your changes:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Sepal.Length, y = Petal.Length, colour = Species) +
  geom_point(shape = &amp;quot;circle&amp;quot;, size = 1.5) +
  scale_color_hue(direction = 1) +
  theme_minimal() +
  theme(
    panel.grid.major = element_line(linetype = &amp;quot;blank&amp;quot;),
    panel.grid.minor = element_line(linetype = &amp;quot;blank&amp;quot;),
    legend.position = c(0.88, 0.22)
  ) +
  theme(plot.caption = element_text(face = &amp;quot;italic&amp;quot;)) +
  labs(
    title = &amp;quot;Sepal &amp;amp; petal length by species&amp;quot;,
    x = &amp;quot;Sepal length&amp;quot;, y = &amp;quot;Petal length&amp;quot;,
    caption = &amp;quot;Data: iris&amp;quot;
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/figure-html/unnamed-chunk-5-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Find more information about the &lt;code&gt;theme()&lt;/code&gt; layer in this &lt;a href=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/ggplot_theme_system_cheatsheet.pdf&#34;&gt;cheatsheet&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;questionr&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Questionr&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;{questionr}&lt;/code&gt; addin is useful for survey analysis and when dealing with &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factor variables&lt;/a&gt;. With this addin, you can easily reorder and recode factor variables. The addin also allows to easily transform a numeric variable into factors (i.e., categorize a continuous variable) thanks to the &lt;code&gt;cut()&lt;/code&gt; function. Like any other addin, after having installed the &lt;code&gt;{questionr}&lt;/code&gt; package, you should see it appearing in the addins menu at the top. From the addins dropdown menu, choose whether you want to reorder or recode your factor variable, or categorize your numeric variable.&lt;/p&gt;
&lt;div id=&#34;recoding-factors&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Recoding factors&lt;/h3&gt;
&lt;p&gt;Instead of writing the &lt;code&gt;recode()&lt;/code&gt; function from the &lt;code&gt;{dplyr}&lt;/code&gt; package, we can use the &lt;code&gt;{questionr}&lt;/code&gt; addin.&lt;/p&gt;
&lt;p&gt;For this example, let’s say we want to recode the &lt;code&gt;Species&lt;/code&gt; variable to shorten the length of the factors, and then store this new variable as &lt;code&gt;Species_rec&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.04.35.png&#34; alt=&#34;Step 1: Select the variable to be recoded and the recoding settings&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Select the variable to be recoded and the recoding settings&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.04.39.png&#34; alt=&#34;Step 2: Specify the names of the new factors&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Specify the names of the new factors&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.04.42.png&#34; alt=&#34;Step 3: Check the results thanks to the contingency table and use the code at the top&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Check the results thanks to the contingency table and use the code at the top&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;reordering-factors&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Reordering factors&lt;/h3&gt;
&lt;p&gt;Similar to recoding, we can reorder factors thanks to the &lt;code&gt;{questionr}&lt;/code&gt; addin. Let’s say we want to reorder the 3 factors of the &lt;code&gt;Species&lt;/code&gt; variable such that the order is &lt;code&gt;versicolor&lt;/code&gt; then &lt;code&gt;virginica&lt;/code&gt; and finally &lt;code&gt;setosa&lt;/code&gt;. This can be done as follows:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.06.28.png&#34; alt=&#34;Step 1: Select the variable to reorder and the new variable name&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Select the variable to reorder and the new variable name&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.06.31.png&#34; alt=&#34;Step 2: Specify the order you want&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Specify the order you want&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.06.36.png&#34; alt=&#34;Step 3: Use the code at the top in your script&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Use the code at the top in your script&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;categorize-a-numeric-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Categorize a numeric variable&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;{questionr}&lt;/code&gt; addin also allows to transform a numeric variable into a categorical variable. This is often done for the age, when age is transformed into age groups for instance. For this example, let’s say we want to create 3 categories of the variable &lt;code&gt;Sepal.Length&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.39.12.png&#34; alt=&#34;Step 1: Choose the variable to be transformed and the new variable name&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Choose the variable to be transformed and the new variable name&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.39.41.png&#34; alt=&#34;Step 2: Set the number of breaks equal to 3&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Set the number of breaks equal to 3&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;(Try by yourself the other cutting methods and see the results directly in the window.)&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.40.15.png&#34; alt=&#34;Step 3: Check the result thanks to the barplot at the bottom&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Check the result thanks to the barplot at the bottom&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.40.23.png&#34; alt=&#34;Step 4: Use the code in your script&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 4: Use the code in your script&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;remedy&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Remedy&lt;/h2&gt;
&lt;p&gt;If you often write in R Markdown, the &lt;code&gt;{remedy}&lt;/code&gt; addins will greatly facilitate your work. The addins allow you to add bold, creating lists, urls, italics, title (H1 to H6), footnote, etc. in an efficient way. I reckon that some of these tasks can be done faster by using the code directly rather than by going through the addins menu and then selecting the transformations you want. However, I personally cannot remember the code for all transformations, and it is quicker to apply it through the menu than by searching for the answer on Google or on your Markdown cheat sheet.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;styler&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Styler&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;{styler}&lt;/code&gt; addin allows to reformat your code in a more readable format by running &lt;code&gt;styler::tidyverse_style()&lt;/code&gt;. It works both for R scripts and R Markdown documents. You can either reformat the selected code, the active file or the active package. I find this addin particularly useful before sharing or publishing my code, so that it respects the most common styling guidelines for code.&lt;/p&gt;
&lt;p&gt;For instance, a piece of code like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1+1
#this is a comment
  for(i in 1:10){if(!i%%2){next}
print(i)
 }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;becomes much more neat and readable:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1 + 1
# this is a comment
for (i in 1:10) {
  if (!i %% 2) {
    next
  }
  print(i)
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;snakecaser&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Snakecaser&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;{snakecaser}&lt;/code&gt; addins converts a character string to the snake case styling. Snake case styling is the practice of writing character strings of several words separated by space into character strings with words separated with an underscore (&lt;code&gt;_&lt;/code&gt;). Moreover, it replaces capital letters with lowercases. For instance, the following string:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;This is the Test 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;will be transformed to:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;this_is_the_test_1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The snake case styling is particularly useful (and even recommended by many R users) for variables, functions and file names, etc.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;viewpipesteps&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;ViewPipeSteps&lt;/h2&gt;
&lt;p&gt;Thanks to a reader of this article, I discovered the &lt;code&gt;ViewPipeSteps&lt;/code&gt; addin. This addin allows to print or view the output of your pipe chain after each step.&lt;/p&gt;
&lt;p&gt;For instance, here is a chain with the dataset &lt;code&gt;diamonds&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tidyverse)

diamonds %&amp;gt;%
  select(carat, cut, color, clarity, price) %&amp;gt;%
  group_by(color) %&amp;gt;%
  summarise(n = n(), price = mean(price)) %&amp;gt;%
  arrange(desc(color))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 × 3
##   color     n price
##   &amp;lt;ord&amp;gt; &amp;lt;int&amp;gt; &amp;lt;dbl&amp;gt;
## 1 J      2808 5324.
## 2 I      5422 5092.
## 3 H      8304 4487.
## 4 G     11292 3999.
## 5 F      9542 3725.
## 6 E      9797 3077.
## 7 D      6775 3170.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are unsure about your pipe chain or want to debug it, you can view the output after each step by highlighting your entire chain then clicking on “View Pipe Chain Steps” from the addins menu:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-03-11%20at%2018.06.01.png&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the addins menu, you can choose to either print the result to the console, or view the result in a new pane (as if you called the function &lt;code&gt;View()&lt;/code&gt; after each step of the pipe). Clicking on View Pipe Chain Steps will open a new window with the output of each step:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-03-11%20at%2018.09.59.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that you have to use the following command to install the &lt;code&gt;ViewPipeSteps&lt;/code&gt; addin:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;devtools::install_github(&amp;quot;daranzolin/ViewPipeSteps&amp;quot;)
library(ViewPipeSteps)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, you have no more excuses to use this pipe operator!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ymlthis&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Ymlthis&lt;/h2&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/ymlthis%20addin%20to%20write%20YAML%20header%20for%20R%20Markdown%20documents.png&#34; style=&#34;width:100.0%&#34; alt=&#34;ymlthis addin to easily write YAML header&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;ymlthis addin to easily write YAML header&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;a href=&#34;https://ymlthis.r-lib.org/index.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;ymlthis&lt;/code&gt; addin&lt;/a&gt; makes it easy to write YAML front matter for R Markdown and related documents. The addin will create YAML for you and put it in a file, such as an &lt;code&gt;.Rmd&lt;/code&gt; file, or on your clipboard.&lt;/p&gt;
&lt;p&gt;This addin is particularly useful if you want to write (more complicated) &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/#yaml-header&#34;&gt;YAML header&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;reprex&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Reprex&lt;/h2&gt;
&lt;p&gt;If you often ask the R community for help, this addin may be very useful!&lt;/p&gt;
&lt;p&gt;It is important to remember that when you ask someone for help, you have to help them help you by giving a precise and clear overview of your problem. This helps the community to quickly understand your issue and thus reduces the response time.&lt;/p&gt;
&lt;p&gt;In most cases, this involves providing a reproducible example, that is to say a piece of code (as small and as readable as possible) reproducing the problem encountered.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;{reprex}&lt;/code&gt; addin allows you to transform your reproducible example so that it can easily be shared on platforms such as GitHub, Stack Overflow, RStudio community, etc. The layout of your reproducible example will be adapted to the platform, and you can even include information about your R session.&lt;a href=&#34;#fn2&#34; class=&#34;footnote-ref&#34; id=&#34;fnref2&#34;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is how to use it steps by steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;First create your reproducible example in R (remember to keep it as short and readable as possible to save time to potential helpers):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example1.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Minimal reproducible example&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Minimal reproducible example&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Select the &lt;code&gt;{reprex}&lt;/code&gt; addin in the list of addins:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example2.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Select the {reprex} addin&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Select the {reprex} addin&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Select the platform on which you will post your issue (and check “Append session info” if you want to display your session info at the end of your reproducible example):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example3.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Set options in the {reprex} addin&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Set options in the {reprex} addin&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;4&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;You can now see the output of your reproducible example (right panel), but more importantly, it has been copied in your clipboard and it is now ready to be pasted on the platform of your choice:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example4.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Your reprex is copied in your clipboard&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Your reprex is copied in your clipboard&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;5&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Paste your reprex on the platform of your choice (here, it is posted as an issue on GitHub):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example5.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Paste your reprex&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Paste your reprex&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;6&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Check the final result of your reproducible example:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example6.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Final result&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Final result&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;(Visit this GitHub &lt;a href=&#34;https://github.com/AntoineSoetewey/statsandr/issues/12&#34; target=&#34;_blank&#34;&gt;issue&lt;/a&gt; to see the final result.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;blogdown&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Blogdown&lt;/h2&gt;
&lt;p&gt;I put this addin at the end of the list because it will be of interest for only a limited number of RStudio users: people maintaining a blog written in R like this one (see why I recommend everyone to &lt;a href=&#34;https://statsandr.com/blog/7-benefits-of-sharing-your-code-in-a-data-science-blog/&#34;&gt;start a technical blog&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The most useful functionalities in this addin are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;New post: create a new post with &lt;code&gt;blogdown::new_post()&lt;/code&gt;. It can be used to create new pages as well, not only posts&lt;/li&gt;
&lt;li&gt;Insert image: insert an external image into a blog post&lt;/li&gt;
&lt;li&gt;Update metadata: update the title, author, date, categories and tags of the current blog post&lt;/li&gt;
&lt;li&gt;Serve site: run &lt;code&gt;blogdown::serve_site()&lt;/code&gt; to live preview your website locally&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope that you will find these addins useful for your future R-related projects. See other &lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/&#34;&gt;tips and tricks in RStudio and R Markdown&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes footnotes-end-of-document&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;You actually do not need to rename it. However, I often rename the datasets I work on with the same generic name &lt;code&gt;dat&lt;/code&gt; so when I reuse codes from a previous project for a new project, I do not have to change the name of the dataset in the code.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn2&#34;&gt;&lt;p&gt;Thanks to Josep for the &lt;a href=&#34;https://medium.com/@josepmporra/great-post-you-could-have-a-look-to-reprex-addins-to-build-reproducible-examples-26bcdc0f8ed4&#34; target=&#34;_blank&#34;&gt;suggestion&lt;/a&gt;.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Tips and tricks in RStudio and R Markdown</title>
      <link>https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/</link>
      <pubDate>Tue, 21 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#run-code&#34; id=&#34;toc-run-code&#34;&gt;Run code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#insert-a-comment-in-r-and-r-markdown&#34; id=&#34;toc-insert-a-comment-in-r-and-r-markdown&#34;&gt;Insert a comment in R and R Markdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#knit-a-r-markdown-document&#34; id=&#34;toc-knit-a-r-markdown-document&#34;&gt;Knit a R Markdown document&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#code-snippets&#34; id=&#34;toc-code-snippets&#34;&gt;Code snippets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ordered-list-in-r-markdown&#34; id=&#34;toc-ordered-list-in-r-markdown&#34;&gt;Ordered list in R Markdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#new-code-chunk-in-r-markdown&#34; id=&#34;toc-new-code-chunk-in-r-markdown&#34;&gt;New code chunk in R Markdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#reformat-code&#34; id=&#34;toc-reformat-code&#34;&gt;Reformat code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#rstudio-addins&#34; id=&#34;toc-rstudio-addins&#34;&gt;RStudio addins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#pander-and-report-for-aesthetics&#34; id=&#34;toc-pander-and-report-for-aesthetics&#34;&gt;&lt;code&gt;{pander}&lt;/code&gt; and &lt;code&gt;{report}&lt;/code&gt; for aesthetics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#extract-equation-model-with-equatiomatic&#34; id=&#34;toc-extract-equation-model-with-equatiomatic&#34;&gt;Extract equation model with &lt;code&gt;{equatiomatic}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#print-models-parameters&#34; id=&#34;toc-print-models-parameters&#34;&gt;Print model’s parameters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#pipe-operator&#34; id=&#34;toc-pipe-operator&#34;&gt;Pipe operator &lt;code&gt;%&amp;gt;%&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#others&#34; id=&#34;toc-others&#34;&gt;Others&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/tips-and-tricks-in-r-markdown_files/tips-and-tricks-rstudio-and-r-markdown.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you have the chance to work with an experienced programmer, you may be amazed by how fast she can write code. In this article, I share some tips and shortcuts you can use in RStudio and &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt; to speed up the writing of your code.&lt;/p&gt;
&lt;div id=&#34;run-code&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Run code&lt;/h1&gt;
&lt;p&gt;You most probably already know this shortcut but I still mention it for new R users. From your script you can run a chunk of code with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + Enter on Mac
Ctrl + Enter on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;insert-a-comment-in-r-and-r-markdown&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Insert a comment in R and R Markdown&lt;/h1&gt;
&lt;p&gt;To insert a comment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + Shift + C on Mac
Ctrl + Shift + C on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This shortcut can be used both for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;R code when you want to comment your code. It will add a &lt;code&gt;#&lt;/code&gt; at the beginning of the line&lt;/li&gt;
&lt;li&gt;for text in R Markdown. It will add &lt;code&gt;&amp;lt;!--&lt;/code&gt; and &lt;code&gt;--&amp;gt;&lt;/code&gt; around the text&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that if you want to comment more than one line, select all the lines you want to comment then use the shortcut. If you want to uncomment a comment, apply the same shortcut.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;knit-a-r-markdown-document&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Knit a R Markdown document&lt;/h1&gt;
&lt;p&gt;You can knit R Markdown documents by using this shortcut:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + Shift + K on Mac
Ctrl + Shift + K on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;code-snippets&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Code snippets&lt;/h1&gt;
&lt;p&gt;Code snippets is usually a few characters long and is used as a shortcut to insert a common piece of code. You simply type a few characters then press &lt;code&gt;Tab&lt;/code&gt; and it will complete your code with a larger code. &lt;code&gt;Tab&lt;/code&gt; is then used again to navigate through the code where customization is required. For instance, if you type &lt;code&gt;fun&lt;/code&gt; then press &lt;code&gt;Tab&lt;/code&gt;, it will auto-complete the code with the required code to create a function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;name &amp;lt;- function(variables) {
  
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pressing &lt;code&gt;Tab&lt;/code&gt; again will jump through the placeholders for you to edit it. So you can first edit the name of the function, then the variables and finally the code inside the function (try by yourself!).&lt;/p&gt;
&lt;p&gt;There are many code snippets by default in RStudio. Here are the code snippets I use most often:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;lib&lt;/code&gt; to call &lt;code&gt;library()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(package)&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mat&lt;/code&gt; to create a matrix&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;matrix(data, nrow = rows, ncol = cols)&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;el&lt;/code&gt;, and &lt;code&gt;ei&lt;/code&gt; to create conditional expressions such as &lt;code&gt;if() {}&lt;/code&gt;, &lt;code&gt;else {}&lt;/code&gt; and &lt;code&gt;else if () {}&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;if (condition) {
  
}

else {
  
}

else if (condition) {
  
}&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fun&lt;/code&gt; to create a function&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;name &amp;lt;- function(variables) {

}&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;for&lt;/code&gt; to create for loops&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;for (variable in vector) {

}&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ts&lt;/code&gt; to insert a comment with the current date and time (useful if you have very long code and share it with others so they see when it has been edited)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Tue Jan 21 20:20:14 2020 ------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;shinyapp&lt;/code&gt; every time I create a new &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;shiny app&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(shiny)

ui &amp;lt;- fluidPage()

server &amp;lt;- function(input, output, session) {

}

shinyApp(ui, server)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see all default code snippets and add yours by clicking on Tools &amp;gt; Global Options… &amp;gt; Code (left sidebar) &amp;gt; Edit Snippets…&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ordered-list-in-r-markdown&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Ordered list in R Markdown&lt;/h1&gt;
&lt;p&gt;In R Markdown, when creating an ordered list such as this one:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Item 1&lt;/li&gt;
&lt;li&gt;Item 2&lt;/li&gt;
&lt;li&gt;Item 3&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Instead of bothering with the numbers and typing&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Item 1
2. Item 2
3. Item 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you can simply type&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Item 1
1. Item 2
1. Item 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;for the exact same result (try it yourself or check the code of this article!). This way you do not need to bother which number is next when creating a new item.&lt;/p&gt;
&lt;p&gt;To go even further, any numeric will actually render the same result as long as the first item is the number you want to start from. For example, you could type:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Item 1
7. Item 2
3. Item 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which renders&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Item 1&lt;/li&gt;
&lt;li&gt;Item 2&lt;/li&gt;
&lt;li&gt;Item 3&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;However, I suggest always using the number you want to start from for all items because if you move one item at the top, the list will start with this new number. For instance, if we move &lt;code&gt;7. Item 2&lt;/code&gt; from the previous list at the top, the list becomes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;7. Item 2
1. Item 1
3. Item 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which incorrectly renders&lt;/p&gt;
&lt;ol start=&#34;7&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Item 2&lt;/li&gt;
&lt;li&gt;Item 1&lt;/li&gt;
&lt;li&gt;Item 3&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;new-code-chunk-in-r-markdown&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;New code chunk in R Markdown&lt;/h1&gt;
&lt;p&gt;When editing R Markdown documents, you will need to insert a new R code chunk many times. The following shortcuts will make your life easier:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + option + I on Mac (or command + alt + I depending on your keyboard)
Ctrl + ALT + I on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/tips-and-tricks-in-r-markdown_files/new%20R%20code%20chunk.png&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;New R code chunk in R Markdown&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;reformat-code&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Reformat code&lt;/h1&gt;
&lt;p&gt;A clear and readable code is always easier and faster to read (and look more professional when sharing it to collaborators). To automatically apply the most common coding guidelines such as whitespaces, indents, etc., use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cmd + Shift + A on Mac
Ctrl + Shift + A on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So for example the following code which does not respect the guidelines (and which is not easy to read):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1+1
  for(i in 1:10){if(!i%%2){next}
print(i)
 }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;becomes much more neat and readable:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1 + 1
for (i in 1:10) {
  if (!i %% 2) {
    next
  }
  print(i)
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-addins&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;RStudio addins&lt;/h1&gt;
&lt;p&gt;RStudio addins are extensions which provide a simple mechanism for executing advanced R functions from within RStudio. In simpler words, when executing an addin (by clicking a button in the Addins menu), the corresponding code is executed without you having to write the code. RStudio addins have the advantage that they allow you to execute complex and advanced code much more easily than if you would have to write it yourself.&lt;/p&gt;
&lt;p&gt;The addin I use most often is probably the &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#esquisse&#34;&gt;&lt;code&gt;{esquisse}&lt;/code&gt; addin&lt;/a&gt;, which allows to draw plots with the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt; in a user-friendly and interactive way, and without having to write the code myself.&lt;/p&gt;
&lt;p&gt;RStudio addins are quite diverse and require a more detailed explanation, so I wrote an article focusing on these addins. See the article &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;pander-and-report-for-aesthetics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;&lt;code&gt;{pander}&lt;/code&gt; and &lt;code&gt;{report}&lt;/code&gt; for aesthetics&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;pander()&lt;/code&gt; function from the &lt;code&gt;{pander}&lt;/code&gt; package is very useful for &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt; documents and reporting. It is not actually a shortcut but it greatly improves the aesthetics of R outputs.&lt;/p&gt;
&lt;p&gt;For instance, see below the difference between the default output of a &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;Chi-square test of independence&lt;/a&gt; and the output from the same test with the &lt;code&gt;pander()&lt;/code&gt; function (using the &lt;code&gt;diamonds&lt;/code&gt; dataset from the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)
dat &amp;lt;- diamonds

test &amp;lt;- chisq.test(table(dat$cut, dat$color))
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Pearson&amp;#39;s Chi-squared test
## 
## data:  table(dat$cut, dat$color)
## X-squared = 310.32, df = 24, p-value &amp;lt; 2.2e-16&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(pander)
pander(test)&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;width:56%;&#34;&gt;
&lt;caption&gt;Pearson’s Chi-squared test: &lt;code&gt;table(dat$cut, dat$color)&lt;/code&gt;&lt;/caption&gt;
&lt;colgroup&gt;
&lt;col width=&#34;23%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;25%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;Test statistic&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;df&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;P value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;310.3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;24&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.395e-51 * * *&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;All information that you need are displayed in an elegant table. The &lt;code&gt;pander()&lt;/code&gt; function works on many statistical tests (not to say all of them, but I have not tried it on &lt;em&gt;all&lt;/em&gt; available tests in R) and on &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;regression models&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Linear model with lm()
model &amp;lt;- lm(price ~ carat + x + y + z,
  data = dat
)
model&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = price ~ carat + x + y + z, data = dat)
## 
## Coefficients:
## (Intercept)        carat            x            y            z  
##      1921.2      10233.9       -884.2        166.0       -576.2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(model)&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;width:90%;&#34;&gt;
&lt;caption&gt;Fitting linear model: price ~ carat + x + y + z&lt;/caption&gt;
&lt;colgroup&gt;
&lt;col width=&#34;25%&#34; /&gt;
&lt;col width=&#34;15%&#34; /&gt;
&lt;col width=&#34;18%&#34; /&gt;
&lt;col width=&#34;13%&#34; /&gt;
&lt;col width=&#34;18%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt; &lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Estimate&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Std. Error&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;t value&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Pr(&amp;gt;|t|)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;(Intercept)&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1921&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;104.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;18.41&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.977e-75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;carat&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;10234&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;62.94&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;162.6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;x&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-884.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;40.47&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-21.85&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2.317e-105&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;y&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;166&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;25.86&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;6.421&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.365e-10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;z&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-576.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;39.28&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-14.67&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.277e-48&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The pander function also makes datasets, tables, vectors, etc. more readable in R Markdown output. For example, see the differences below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(dat)[1:7] # first 6 observations of the first 7 variables&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 × 7
##   carat cut       color clarity depth table price
##   &amp;lt;dbl&amp;gt; &amp;lt;ord&amp;gt;     &amp;lt;ord&amp;gt; &amp;lt;ord&amp;gt;   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;int&amp;gt;
## 1  0.23 Ideal     E     SI2      61.5    55   326
## 2  0.21 Premium   E     SI1      59.8    61   326
## 3  0.23 Good      E     VS1      56.9    65   327
## 4  0.29 Premium   I     VS2      62.4    58   334
## 5  0.31 Good      J     SI2      63.3    58   335
## 6  0.24 Very Good J     VVS2     62.8    57   336&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(head(dat)[1:7])&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;width:86%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;16%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;13%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;carat&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;cut&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;color&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;clarity&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;depth&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;table&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;price&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.23&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Ideal&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;E&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;61.5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;55&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;326&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.21&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Premium&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;E&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;59.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;61&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;326&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.23&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Good&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;E&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VS1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;56.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;65&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;327&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.29&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Premium&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;I&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VS2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;62.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;58&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;334&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.31&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Good&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;J&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;63.3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;58&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;335&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.24&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Very Good&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;J&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VVS2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;62.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;57&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;336&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(dat) # main descriptive statistics&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      carat               cut        color        clarity          depth      
##  Min.   :0.2000   Fair     : 1610   D: 6775   SI1    :13065   Min.   :43.00  
##  1st Qu.:0.4000   Good     : 4906   E: 9797   VS2    :12258   1st Qu.:61.00  
##  Median :0.7000   Very Good:12082   F: 9542   SI2    : 9194   Median :61.80  
##  Mean   :0.7979   Premium  :13791   G:11292   VS1    : 8171   Mean   :61.75  
##  3rd Qu.:1.0400   Ideal    :21551   H: 8304   VVS2   : 5066   3rd Qu.:62.50  
##  Max.   :5.0100                     I: 5422   VVS1   : 3655   Max.   :79.00  
##                                     J: 2808   (Other): 2531                  
##      table           price             x                y         
##  Min.   :43.00   Min.   :  326   Min.   : 0.000   Min.   : 0.000  
##  1st Qu.:56.00   1st Qu.:  950   1st Qu.: 4.710   1st Qu.: 4.720  
##  Median :57.00   Median : 2401   Median : 5.700   Median : 5.710  
##  Mean   :57.46   Mean   : 3933   Mean   : 5.731   Mean   : 5.735  
##  3rd Qu.:59.00   3rd Qu.: 5324   3rd Qu.: 6.540   3rd Qu.: 6.540  
##  Max.   :95.00   Max.   :18823   Max.   :10.740   Max.   :58.900  
##                                                                   
##        z         
##  Min.   : 0.000  
##  1st Qu.: 2.910  
##  Median : 3.530  
##  Mean   : 3.539  
##  3rd Qu.: 4.040  
##  Max.   :31.800  
## &lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(summary(dat))&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;caption&gt;Table continues below&lt;/caption&gt;
&lt;colgroup&gt;
&lt;col width=&#34;22%&#34; /&gt;
&lt;col width=&#34;23%&#34; /&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;carat&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;cut&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;color&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;clarity&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;depth&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Min. :0.2000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Fair : 1610&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;D: 6775&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI1 :13065&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. :43.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.:0.4000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Good : 4906&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;E: 9797&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VS2 :12258&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.:61.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Median :0.7000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Very Good:12082&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;F: 9542&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI2 : 9194&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median :61.80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Mean :0.7979&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Premium :13791&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;G:11292&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VS1 : 8171&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean :61.75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.:1.0400&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Ideal :21551&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;H: 8304&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VVS2 : 5066&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.:62.50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Max. :5.0100&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;I: 5422&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VVS1 : 3655&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :79.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;J: 2808&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;(Other): 2531&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table&gt;
&lt;colgroup&gt;
&lt;col width=&#34;19%&#34; /&gt;
&lt;col width=&#34;19%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;table&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;price&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;x&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;y&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;z&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Min. :43.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. : 326&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. : 0.000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. : 0.000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. : 0.000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.:56.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.: 950&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.: 4.710&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.: 4.720&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.: 2.910&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Median :57.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median : 2401&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median : 5.700&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median : 5.710&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median : 3.530&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Mean :57.46&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean : 3933&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean : 5.731&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean : 5.735&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean : 3.539&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.:59.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.: 5324&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.: 6.540&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.: 6.540&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.: 4.040&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Max. :95.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :18823&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :10.740&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :58.900&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :31.800&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(dat$cut, dat$color) # contingency table&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##            
##                D    E    F    G    H    I    J
##   Fair       163  224  312  314  303  175  119
##   Good       662  933  909  871  702  522  307
##   Very Good 1513 2400 2164 2299 1824 1204  678
##   Premium   1603 2337 2331 2924 2360 1428  808
##   Ideal     2834 3903 3826 4884 3115 2093  896&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(table(dat$cut, dat$color))&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;width:90%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;22%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt; &lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;D&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;E&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;F&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;G&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;H&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;I&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;J&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Fair&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;163&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;224&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;312&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;314&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;303&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;175&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;119&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Good&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;662&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;933&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;909&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;871&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;702&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;522&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;307&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Very Good&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1513&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2400&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2164&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2299&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1824&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1204&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;678&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Premium&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1603&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2337&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2331&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2924&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2360&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1428&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;808&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Ideal&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2834&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3903&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3826&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4884&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3115&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2093&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;896&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(dat) # variable names&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;carat&amp;quot;   &amp;quot;cut&amp;quot;     &amp;quot;color&amp;quot;   &amp;quot;clarity&amp;quot; &amp;quot;depth&amp;quot;   &amp;quot;table&amp;quot;   &amp;quot;price&amp;quot;  
##  [8] &amp;quot;x&amp;quot;       &amp;quot;y&amp;quot;       &amp;quot;z&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(names(dat))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;carat&lt;/em&gt;, &lt;em&gt;cut&lt;/em&gt;, &lt;em&gt;color&lt;/em&gt;, &lt;em&gt;clarity&lt;/em&gt;, &lt;em&gt;depth&lt;/em&gt;, &lt;em&gt;table&lt;/em&gt;, &lt;em&gt;price&lt;/em&gt;, &lt;em&gt;x&lt;/em&gt;, &lt;em&gt;y&lt;/em&gt; and &lt;em&gt;z&lt;/em&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rnorm(4) # generates 4 observations from a standard normal distribution&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  1.3709584 -0.5646982  0.3631284  0.6328626&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(rnorm(4))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;0.4043&lt;/em&gt;, &lt;em&gt;-0.1061&lt;/em&gt;, &lt;em&gt;1.512&lt;/em&gt; and &lt;em&gt;-0.09466&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This trick is particularly useful when writing in &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt;, as the generated document will look much nicer.&lt;/p&gt;
&lt;p&gt;Another trick for the aesthetics is the &lt;code&gt;report()&lt;/code&gt; function from the &lt;code&gt;{report}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;Similar to &lt;code&gt;pander()&lt;/code&gt;, the &lt;code&gt;report()&lt;/code&gt; function allows to report test results in a more readable way—but it also interprets results for you. See for example with an &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;remotes&amp;quot;)
# remotes::install_github(&amp;quot;easystats/report&amp;quot;) # You only need to do that once
library(&amp;quot;report&amp;quot;) # Load the package every time you start R

report(aov(price ~ cut,
  data = dat
))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## The ANOVA (formula: price ~ cut) suggests that:
## 
##   - The main effect of cut is statistically significant and small (F(4, 53935) =
## 175.69, p &amp;lt; .001; Eta2 = 0.01, 95% CI [0.01, 1.00])
## 
## Effect sizes were labelled following Field&amp;#39;s (2013) recommendations.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In addition to the &lt;em&gt;p&lt;/em&gt;-value and the test statistic, the result of the test is displayed and interpreted for you.&lt;/p&gt;
&lt;p&gt;Note that the &lt;code&gt;report()&lt;/code&gt; function can be used for other analyses. See more examples in the package’s &lt;a href=&#34;https://easystats.github.io/report/&#34; target=&#34;_blank&#34;&gt;documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-equation-model-with-equatiomatic&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Extract equation model with &lt;code&gt;{equatiomatic}&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;If you often need to write equations corresponding to statistical models in R Markdown reports, the &lt;a href=&#34;https://CRAN.R-project.org/package=equatiomatic&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{equatiomatic}&lt;/code&gt;&lt;/a&gt; will help you to save time.&lt;/p&gt;
&lt;p&gt;Here is a basic example with a simple &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt; using the same dataset as above (i.e., &lt;code&gt;diamonds&lt;/code&gt; from &lt;code&gt;{ggplot2}&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;equatiomatic&amp;quot;)
library(equatiomatic)

# fit a basic multiple linear regression model
model &amp;lt;- lm(price ~ carat,
  data = dat
)

extract_eq(model,
  use_coefs = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\operatorname{\widehat{price}} = -2256.36 + 7756.43(\operatorname{carat})
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If the equation is long, you can display it on multiple lines by adding the argument &lt;code&gt;wrap = TRUE&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- lm(price ~ carat + x + y + z + depth,
  data = dat
)

extract_eq(model,
  use_coefs = TRUE,
  wrap = TRUE,
  terms_per_line = 2
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{aligned}
\operatorname{\widehat{price}} &amp;amp;= 12196.69 + 10615.5(\operatorname{carat})\ - \\
&amp;amp;\quad 1369.67(\operatorname{x}) + 97.6(\operatorname{y})\ + \\
&amp;amp;\quad 64.2(\operatorname{z}) - 156.62(\operatorname{depth})
\end{aligned}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you use it in R Markdown, you need to add &lt;code&gt;results = &#39;asis&#39;&lt;/code&gt; for that specific code chunk, otherwise the equation will be rendered as a LaTeX equation&lt;/li&gt;
&lt;li&gt;At the time of writing, it works only for PDF and HTML output and not for Word&lt;/li&gt;
&lt;li&gt;The default number of terms per line is 4. You can change that with the &lt;code&gt;terms_per_line&lt;/code&gt; argument&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{equatiomatic}&lt;/code&gt; supports output from logistic regression as well. See all supported models in the &lt;a href=&#34;https://cran.r-project.org/web/packages/equatiomatic/vignettes/equatiomatic.html&#34; target=&#34;_blank&#34;&gt;vignette&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;If you need the theoretical model without the actual parameter estimates, remove the &lt;code&gt;use_coefs&lt;/code&gt; argument:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;extract_eq(model,
  wrap = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{aligned}
\operatorname{price} &amp;amp;= \alpha + \beta_{1}(\operatorname{carat}) + \beta_{2}(\operatorname{x}) + \beta_{3}(\operatorname{y})\ + \\
&amp;amp;\quad \beta_{4}(\operatorname{z}) + \beta_{5}(\operatorname{depth}) + \epsilon
\end{aligned}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In that case, I prefer to use &lt;span class=&#34;math inline&#34;&gt;\(\beta_0\)&lt;/span&gt; as intercept instead of &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;. You can change that with the &lt;code&gt;intercept = &#34;beta&#34;&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;extract_eq(model,
  wrap = TRUE,
  intercept = &amp;quot;beta&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{aligned}
\operatorname{price} &amp;amp;= \beta_{0} + \beta_{1}(\operatorname{carat}) + \beta_{2}(\operatorname{x}) + \beta_{3}(\operatorname{y})\ + \\
&amp;amp;\quad \beta_{4}(\operatorname{z}) + \beta_{5}(\operatorname{depth}) + \epsilon
\end{aligned}
\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;print-models-parameters&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Print model’s parameters&lt;/h1&gt;
&lt;p&gt;Thanks to the &lt;code&gt;print_html()&lt;/code&gt; and &lt;code&gt;model_parameters()&lt;/code&gt; functions from the &lt;code&gt;{parameters}&lt;/code&gt; packages, you can print a summary of a model in a nicely formatted way to make the output more readable in your HTML file. See for instance with the multiple linear regression presented above:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(parameters)
library(gt)

print_html(model_parameters(model, summary = TRUE))&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;ntzrociyde&#34; style=&#34;padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;&#34;&gt;
&lt;style&gt;html {
  font-family: -apple-system, BlinkMacSystemFont, &#39;Segoe UI&#39;, Roboto, Oxygen, Ubuntu, Cantarell, &#39;Helvetica Neue&#39;, &#39;Fira Sans&#39;, &#39;Droid Sans&#39;, Arial, sans-serif;
}

#ntzrociyde .gt_table {
  display: table;
  border-collapse: collapse;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 100%;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#ntzrociyde .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#ntzrociyde .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#ntzrociyde .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#ntzrociyde .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 0;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#ntzrociyde .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ntzrociyde .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#ntzrociyde .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#ntzrociyde .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#ntzrociyde .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#ntzrociyde .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#ntzrociyde .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#ntzrociyde .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#ntzrociyde .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#ntzrociyde .gt_from_md &gt; :first-child {
  margin-top: 0;
}

#ntzrociyde .gt_from_md &gt; :last-child {
  margin-bottom: 0;
}

#ntzrociyde .gt_row {
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#ntzrociyde .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#ntzrociyde .gt_row_group_first td {
  border-top-width: 2px;
}

#ntzrociyde .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#ntzrociyde .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#ntzrociyde .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ntzrociyde .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#ntzrociyde .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#ntzrociyde .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ntzrociyde .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#ntzrociyde .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-left: 4px;
  padding-right: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#ntzrociyde .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_left {
  text-align: left;
}

#ntzrociyde .gt_center {
  text-align: center;
}

#ntzrociyde .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#ntzrociyde .gt_font_normal {
  font-weight: normal;
}

#ntzrociyde .gt_font_bold {
  font-weight: bold;
}

#ntzrociyde .gt_font_italic {
  font-style: italic;
}

#ntzrociyde .gt_super {
  font-size: 65%;
}

#ntzrociyde .gt_footnote_marks {
  font-style: italic;
  font-weight: normal;
  font-size: 75%;
  vertical-align: 0.4em;
}

#ntzrociyde .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#ntzrociyde .gt_indent_1 {
  text-indent: 5px;
}

#ntzrociyde .gt_indent_2 {
  text-indent: 10px;
}

#ntzrociyde .gt_indent_3 {
  text-indent: 15px;
}

#ntzrociyde .gt_indent_4 {
  text-indent: 20px;
}

#ntzrociyde .gt_indent_5 {
  text-indent: 25px;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34;&gt;
  
  &lt;thead class=&#34;gt_col_headings&#34;&gt;
    &lt;tr&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_left&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;Parameter&#34;&gt;Parameter&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;Coefficient&#34;&gt;Coefficient&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;SE&#34;&gt;SE&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;95% CI&#34;&gt;95% CI&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;t(53934)&#34;&gt;t(53934)&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;p&#34;&gt;p&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody class=&#34;gt_table_body&#34;&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;12196.69&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;367.64&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(11476.10, 12917.27)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;33.18&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;carat&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;10615.50&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;63.81&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(10490.43, 10740.56)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;166.37&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;x&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;-1369.67&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;43.48&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(-1454.89, -1284.45)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;-31.50&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;y&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;97.60&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;25.76&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(47.10, 148.10)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;3.79&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;z&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;64.20&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;44.75&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(-23.51, 151.91)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;1.43&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;0.151 &lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;depth&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;-156.62&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;5.38&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(-167.16, -146.09)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;-29.13&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;tfoot class=&#34;gt_sourcenotes&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;gt_sourcenote&#34; colspan=&#34;6&#34;&gt;Model: price ~ carat + x + y + z + depth (53940 Observations)&lt;br&gt;Residual standard deviation: 1512.175 (df = 53934)&lt;br&gt;R2: 0.856; adjusted R2: 0.856&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tfoot&gt;
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;pipe-operator&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Pipe operator &lt;code&gt;%&amp;gt;%&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;If you are using the &lt;code&gt;{dplyr}&lt;/code&gt;, &lt;code&gt;{tidyverse}&lt;/code&gt; or &lt;code&gt;{magrittr}&lt;/code&gt; packages often, here is a shortcut for the pipe operator &lt;code&gt;%&amp;gt;%&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + Shift + M on Mac
Ctrl + Shift + M on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;others&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Others&lt;/h1&gt;
&lt;p&gt;Similar to many other programs, you can also use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;command + Shift + N&lt;/code&gt; on Mac and &lt;code&gt;Ctrl + Shift + N&lt;/code&gt; on Windows to open a new R Script&lt;/li&gt;
&lt;li&gt;&lt;code&gt;command + S&lt;/code&gt; on Mac and &lt;code&gt;Ctrl + S&lt;/code&gt; on Windows to save your current script or R Markdown document&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope you find these tips and tricks useful. If you are using others, feel free to share them in the comment section. See this &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;starting guide in R Markdown&lt;/a&gt; if you are not familiar with it.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>