<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>R on Stats and R</title>
    <link>https://statsandr.com/tags/r/</link>
    <description>Recent content in R on Stats and R</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Wed, 19 Aug 2026 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="https://statsandr.com/tags/r/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>McNemar&#39;s test in R</title>
      <link>https://statsandr.com/blog/mcnemars-test-in-r/</link>
      <pubDate>Wed, 19 Aug 2026 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/mcnemars-test-in-r/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;images/mcnemars-test-in-r.jpg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In a previous article, we showed how to perform the &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;Chi-square test of independence in R&lt;/a&gt; in order to test whether two qualitative variables are related. As mentioned in that article (and in the one showing how to do the &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-by-hand/&#34;&gt;Chi-square test of independence by hand&lt;/a&gt;), this test requires that observations are &lt;strong&gt;independent&lt;/strong&gt;. When observations are dependent, that is, when the two measurements are collected on the &lt;em&gt;same&lt;/em&gt; subjects (paired samples), the McNemar’s or Cochran’s Q tests should be used instead.&lt;/p&gt;
&lt;p&gt;This article is dedicated to the first one: the &lt;strong&gt;McNemar’s test&lt;/strong&gt;. It is used to compare two related (paired) proportions measured on a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative variable&lt;/a&gt; with only two possible levels. In practice, it is mostly used when the same subjects are measured twice (typically before and after an intervention), or when two raters or two conditions are applied to the same subjects.&lt;/p&gt;
&lt;p&gt;In a way, the McNemar’s test is to two paired proportions what the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;paired Student’s t-test&lt;/a&gt; is to two paired means: in both cases we take advantage of the fact that the two measurements belong to the same individuals, the difference being that here the variable of interest is binary instead of quantitative.&lt;/p&gt;
&lt;p&gt;Note also that the McNemar’s test is limited to exactly two related measurements. If you have more than two (for example, the same question asked at three different time points), the appropriate extension is the Cochran’s Q test, of which the McNemar’s test is the special case for two measurements. If you are unsure about which test is appropriate for your own data, see this &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;overview of the most common statistical tests&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the remaining of the article, we present the data used for the illustration, the aim, hypotheses and assumptions of the test, and finally how to perform it in R and how to interpret its results.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;A dataset with a paired binary structure is not so easy to find among the datasets shipped with R, so we simulate our own data for this article.&lt;/p&gt;
&lt;p&gt;Suppose that we ask 200 randomly selected citizens whether they are in favor of a new policy in their city (answer “Yes” or “No”), that we then have them watch a public debate on this policy, and that we ask them exactly the same question again right after the debate:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of respondents
n &amp;lt;- 200

# opinion before the debate
before &amp;lt;- sample(c(&amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;),
  size = n,
  replace = TRUE,
  prob = c(0.4, 0.6)
)

# opinion after the debate (respondents who were in favor
# tend to keep their opinion, while those who were against
# are more likely to change their mind)
after &amp;lt;- ifelse(before == &amp;quot;Yes&amp;quot;,
  sample(c(&amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;), size = n, replace = TRUE, prob = c(0.9, 0.1)),
  sample(c(&amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;), size = n, replace = TRUE, prob = c(0.4, 0.6))
)

# dataset
dat &amp;lt;- data.frame(
  respondent = 1:n,
  before = factor(before, levels = c(&amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;)),
  after = factor(after, levels = c(&amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;))
)

head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   respondent before after
## 1          1    Yes   Yes
## 2          2    Yes   Yes
## 3          3     No   Yes
## 4          4    Yes   Yes
## 5          5    Yes   Yes
## 6          6     No    No&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Note that a seed has been set in the background with &lt;code&gt;set.seed(42)&lt;/code&gt;, so the simulated data and all results below are reproducible.)&lt;/p&gt;
&lt;p&gt;Each row corresponds to one respondent and contains two measurements of the same binary variable: the opinion before and the opinion after the debate. The two samples are thus paired, since the two answers on a given row belong to the same person.&lt;/p&gt;
&lt;p&gt;As always, it is a good practice to start with some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt;. Here, the proportion of respondents in favor of the policy at each of the two time points:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;dplyr&amp;quot;)
library(dplyr)

dat %&amp;gt;%
  summarise(
    prop_before = mean(before == &amp;quot;Yes&amp;quot;),
    prop_after = mean(after == &amp;quot;Yes&amp;quot;)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   prop_before prop_after
## 1        0.46       0.61&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In our sample, the proportion of respondents in favor of the policy went from 46% before the debate to 61% after the debate.&lt;/p&gt;
&lt;p&gt;These two proportions are computed on the same people, so comparing them as if they came from two independent groups would ignore the pairing. What matters for the McNemar’s test is the way each respondent moved (or did not move) from one answer to the other, and this information is contained in the 2 &lt;span class=&#34;math inline&#34;&gt;\(\times\)&lt;/span&gt; 2 contingency table of the paired answers:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab &amp;lt;- table(dat$before, dat$after,
  dnn = c(&amp;quot;Before&amp;quot;, &amp;quot;After&amp;quot;)
)

tab&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       After
## Before Yes No
##    Yes  81 11
##    No   41 67&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This table must be read pair by pair, and not cell by cell as we usually do:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the two cells on the diagonal are the &lt;strong&gt;concordant pairs&lt;/strong&gt;: 81 respondents answered “Yes” twice and 67 answered “No” twice, so these 148 respondents did not change their mind,&lt;/li&gt;
&lt;li&gt;the two cells outside the diagonal are the &lt;strong&gt;discordant pairs&lt;/strong&gt;: 11 respondents were in favor before the debate but against after, while 41 were against before but in favor after.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Only the discordant pairs carry information about a change of opinion (a respondent who gave twice the same answer tells us nothing about the effect of the debate), and this is precisely what the McNemar’s test is built on.&lt;/p&gt;
&lt;p&gt;The same information can be visualized with a simple barplot of the paired counts:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;ggplot2&amp;quot;)
library(ggplot2)

ggplot(dat) +
  aes(x = before, fill = after) +
  geom_bar(position = &amp;quot;dodge&amp;quot;) +
  labs(
    x = &amp;quot;Opinion before the debate&amp;quot;,
    y = &amp;quot;Number of respondents&amp;quot;,
    fill = &amp;quot;Opinion after the debate&amp;quot;
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/mcnemars-test-in-r/index_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;From the table and the plot, we see that the changes of opinion do not balance out: many more respondents switched from “No” to “Yes” than the opposite. The question is now whether this imbalance is large enough to be declared significant, or whether it could reasonably be explained by chance alone (that is, by sampling fluctuations).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;mcnemars-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;McNemar’s test&lt;/h1&gt;
&lt;div id=&#34;aim-and-hypotheses&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Aim and hypotheses&lt;/h2&gt;
&lt;p&gt;The McNemar’s test is used to compare two related proportions, so it allows to determine whether the proportion of subjects belonging to a given category changed between two dependent measurements.&lt;/p&gt;
&lt;p&gt;The null and alternative hypotheses of the McNemar’s test are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: the two related proportions are equal (marginal homogeneity, that is, there is no systematic change between the two measurements)&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: the two related proportions are different (there is a significant change between the two measurements)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Since concordant pairs bring no information about a change, the test is based only on the two discordant cells. Denoting by &lt;span class=&#34;math inline&#34;&gt;\(b\)&lt;/span&gt; the number of subjects who answered “Yes” then “No”, and by &lt;span class=&#34;math inline&#34;&gt;\(c\)&lt;/span&gt; the number of subjects who answered “No” then “Yes”, the hypotheses can equivalently be written as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: p_b = p_c\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1: p_b \ne p_c\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(p_b\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(p_c\)&lt;/span&gt; are the probabilities of the two possible types of change. Under the null hypothesis, a change in one direction is as likely as a change in the other direction, so the test statistic&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\chi^2 = \frac{(b - c)^2}{b + c}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;follows a Chi-square distribution with 1 degree of freedom. By default, R applies a continuity correction (see more on this below), which replaces the numerator by &lt;span class=&#34;math inline&#34;&gt;\((|b - c| - 1)^2\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In the context of our example, the McNemar’s test helps us to answer the following question: “Did the public debate significantly change the proportion of citizens in favor of the new policy?”.&lt;/p&gt;
&lt;p&gt;Rejecting &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; would mean that the proportion of citizens in favor of the policy is significantly different before and after the debate, so that the changes of opinion observed in our sample are unlikely to be due to chance only. On the contrary, not rejecting &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; would mean that we do not have enough evidence to conclude that opinions changed: the switches observed in the two directions would then be compatible with random fluctuations.&lt;/p&gt;
&lt;p&gt;Note that, as for many tests, the McNemar’s test does not indicate the &lt;em&gt;direction&lt;/em&gt; of the change. The direction must be read from the contingency table or from the marginal proportions computed in the previous section.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;assumptions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Assumptions&lt;/h2&gt;
&lt;p&gt;For the results of the McNemar’s test to be valid, the following assumptions must be met:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;Paired measurements on a binary variable.&lt;/strong&gt; The two measurements must be collected on the same subjects, or on matched pairs (twins, or patients matched on age and sex for instance), and the variable of interest must be qualitative with exactly two levels (“Yes”/“No”, success/failure, present/absent, etc.). If the two samples are independent instead of paired, use the &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;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data organized in a 2 &lt;span class=&#34;math inline&#34;&gt;\(\times\)&lt;/span&gt; 2 contingency table of the paired outcomes.&lt;/strong&gt; Each subject contributes to one and only one cell of the table, so the sum of the four cells equals the number of subjects (200 in our case), and not twice this number.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pairs are independent of each other.&lt;/strong&gt; Within a pair, the two measurements are of course dependent, and this is precisely the reason why we use this test. Between pairs, however, independence is required: one subject’s answers must not influence another subject’s answers. As for many statistical tests, this assumption is usually verified based on the design of the experiment rather than via a formal test. A random and representative &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt; of the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt; of interest is generally sufficient. In our example, respondents have been selected at random and answered the question individually, so we consider this assumption as met.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enough discordant pairs.&lt;/strong&gt; The &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value returned by &lt;code&gt;mcnemar.test()&lt;/code&gt; is based on a Chi-square approximation, which is reliable only if the number of discordant pairs is large enough. A common rule of thumb is that &lt;span class=&#34;math inline&#34;&gt;\(b + c\)&lt;/span&gt; should be at least 25. In our sample, &lt;span class=&#34;math inline&#34;&gt;\(b + c\)&lt;/span&gt; = 52, so the approximation can be used safely.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When the number of discordant pairs is small, it is preferable to use the exact version of the test, which is based on a binomial distribution instead of the Chi-square approximation. It boils down to testing whether, among the discordant pairs, changes in one direction are as frequent as changes in the other direction, so it can be performed in base R with the &lt;code&gt;binom.test()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# exact version of the McNemar&amp;#39;s test
binom.test(tab[1, 2], tab[1, 2] + tab[2, 1], p = 0.5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Exact binomial test
## 
## data:  tab[1, 2] and tab[1, 2] + tab[2, 1]
## number of successes = 11, number of trials = 52, p-value = 3.589e-05
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1106115 0.3470376
## sample estimates:
## probability of success 
##              0.2115385&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the &lt;code&gt;{exact2x2}&lt;/code&gt; package also provides a dedicated &lt;code&gt;mcnemar.exact()&lt;/code&gt; function, which returns the same &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value together with a confidence interval for the odds ratio.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;In R&lt;/h2&gt;
&lt;p&gt;The McNemar’s test can be performed in R with the &lt;code&gt;mcnemar.test()&lt;/code&gt; function, applied on the contingency table of the paired outcomes:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mcnemar.test(tab)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	McNemar&amp;#39;s Chi-squared test with continuity correction
## 
## data:  tab
## McNemar&amp;#39;s chi-squared = 16.173, df = 1, p-value = 5.781e-05&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The test can also be applied directly on the two variables, without building the contingency table first (results are of course identical):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mcnemar.test(dat$before, dat$after)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	McNemar&amp;#39;s Chi-squared test with continuity correction
## 
## data:  dat$before and dat$after
## McNemar&amp;#39;s chi-squared = 16.173, df = 1, p-value = 5.781e-05&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output shows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the title of the test, together with the mention that a continuity correction has been applied,&lt;/li&gt;
&lt;li&gt;the data which have been used,&lt;/li&gt;
&lt;li&gt;the test statistic (&lt;code&gt;McNemar&#39;s chi-squared&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the degrees of freedom (always equal to 1 for a 2 &lt;span class=&#34;math inline&#34;&gt;\(\times\)&lt;/span&gt; 2 table) and&lt;/li&gt;
&lt;li&gt;the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As mentioned above, R applies a continuity correction by default. This correction makes the test slightly more conservative (that is, it gives a larger &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value), and it can be removed thanks to the &lt;code&gt;correct = FALSE&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mcnemar.test(tab, correct = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	McNemar&amp;#39;s Chi-squared test
## 
## data:  tab
## McNemar&amp;#39;s chi-squared = 17.308, df = 1, p-value = 3.179e-05&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With 52 discordant pairs, both versions lead to the same conclusion. The correction really matters only when the number of discordant pairs is small, and in that case the exact version presented in the previous section is a better option anyway.&lt;/p&gt;
&lt;p&gt;It is the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value which is of interest to conclude the test. If you are not familiar with &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values, I invite you to read this &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;section&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;interpretations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Interpretations&lt;/h2&gt;
&lt;p&gt;Based on the McNemar’s test, we reject the null hypothesis and we conclude that the proportion of citizens in favor of the new policy is significantly different before and after the debate (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001).&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(\Rightarrow\)&lt;/span&gt; In our context, rejecting the null hypothesis means that the debate is associated with a significant change of opinion. Looking at the direction of this change, the proportion of citizens in favor of the policy increased from 46% before the debate to 61% after the debate.&lt;/p&gt;
&lt;p&gt;(&lt;em&gt;For the sake of illustration&lt;/em&gt;, if the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value had been larger than the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;: we could not have rejected the null hypothesis, so we could not have concluded that the proportion of citizens in favor of the policy was different before and after the debate.)&lt;/p&gt;
&lt;p&gt;Contrary to the tests comparing three groups or more, no post-hoc test is required after a significant McNemar’s test: only two related measurements are compared, so a significant result already tells us which two proportions differ. Post-hoc comparisons become relevant again with more than two related measurements, in which case you should turn to the Cochran’s Q test.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Summary&lt;/h1&gt;
&lt;p&gt;In this article, we reviewed the aim and the hypotheses of the McNemar’s test, which is used to compare two related proportions measured on the same subjects, together with its underlying assumptions (paired measurements on a binary variable, independence between pairs and a sufficient number of discordant pairs). We then showed how to perform it in R with the &lt;code&gt;mcnemar.test()&lt;/code&gt; function, applied either on the 2 &lt;span class=&#34;math inline&#34;&gt;\(\times\)&lt;/span&gt; 2 contingency table of the paired answers or directly on the two variables, and how to interpret its results by comparing the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value with the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;. Remember that it is the special case of the Cochran’s Q test for exactly two related measurements, and that with independent samples the &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; should be preferred.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article helped you to understand the McNemar’s test and how to perform it in R.&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>Bayesian Neural Networks in {tidymodels} with {kindling}</title>
      <link>https://statsandr.com/blog/bayesian-neural-networks-in-tidymodels-with-kindling/</link>
      <pubDate>Fri, 20 Mar 2026 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/bayesian-neural-networks-in-tidymodels-with-kindling/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;images/bayesian-neural-networks-in-tidymodels-with-kindling.jpg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;what-are-bayesian-neural-networks&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What Are Bayesian Neural Networks?&lt;/h1&gt;
&lt;p&gt;Standard neural networks learn fixed weights during training and produce a single point estimate for each input — with no sense of how confident the model is. &lt;strong&gt;Bayesian Neural Networks (BNNs)&lt;/strong&gt; replace those fixed weights with &lt;em&gt;probability distributions&lt;/em&gt; &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-neal2012bayesian&#34;&gt;Neal 2012&lt;/a&gt;)&lt;/span&gt;. Instead of learning a single value per weight, the network learns a mean and a variance, and samples from that distribution at every forward pass.&lt;/p&gt;
&lt;p&gt;Formally, a BNN places a prior &lt;span class=&#34;math inline&#34;&gt;\(p(\mathbf{w})\)&lt;/span&gt; over the weights and updates it with observed data &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{D}\)&lt;/span&gt; via Bayes’ theorem:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[p(\mathbf{w} \mid \mathcal{D}) = \frac{p(\mathcal{D} \mid \mathbf{w})\, p(\mathbf{w})}{p(\mathcal{D})}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For large and deep networks, the posterior &lt;span class=&#34;math inline&#34;&gt;\(p(\mathbf{w} \mid \mathcal{D})\)&lt;/span&gt; is intractable. BNNs typically use &lt;em&gt;variational inference&lt;/em&gt; to approximate it with a tractable distribution &lt;span class=&#34;math inline&#34;&gt;\(q_\phi(\mathbf{w})\)&lt;/span&gt; by minimising the KL divergence between the two &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-blundell2015weight&#34;&gt;Blundell et al. 2015&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;div id=&#34;from-point-estimates-to-distributions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;From point estimates to distributions&lt;/h2&gt;
&lt;p&gt;A standard linear layer computes &lt;span class=&#34;math inline&#34;&gt;\(\mathbf{y} = \mathbf{W}\mathbf{x} + \mathbf{b}\)&lt;/span&gt;, where &lt;span class=&#34;math inline&#34;&gt;\(\mathbf{W}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\mathbf{b}\)&lt;/span&gt; are fixed. In a Bayesian linear layer, they are random variables. We place a Gaussian prior over the weights:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\mathbf{W} \sim \mathcal{N}(\mu_{\text{prior}},\ \sigma_{\text{prior}}^2)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and during training we learn a &lt;strong&gt;variational posterior&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[q(\mathbf{W}) = \mathcal{N}(\mu_W,\ \sigma_W^2)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Each weight therefore has two learnable scalars: a mean &lt;span class=&#34;math inline&#34;&gt;\(\mu_W\)&lt;/span&gt; and a log-standard-deviation &lt;span class=&#34;math inline&#34;&gt;\(\log \sigma_W\)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-reparameterisation-trick&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The reparameterisation trick&lt;/h2&gt;
&lt;p&gt;Sampling directly from &lt;span class=&#34;math inline&#34;&gt;\(q(\mathbf{W})\)&lt;/span&gt; is not differentiable with respect to &lt;span class=&#34;math inline&#34;&gt;\(\mu_W\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\sigma_W\)&lt;/span&gt;. We resolve this with the &lt;strong&gt;reparameterisation trick&lt;/strong&gt; &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-kingma2013auto&#34;&gt;Kingma and Welling 2013&lt;/a&gt;)&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\mathbf{W} = \mu_W + \sigma_W \odot \varepsilon, \quad \varepsilon \sim \mathcal{N}(\mathbf{0}, \mathbf{I})\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We store &lt;span class=&#34;math inline&#34;&gt;\(\log \sigma_W\)&lt;/span&gt; (not &lt;span class=&#34;math inline&#34;&gt;\(\sigma_W\)&lt;/span&gt; directly) to ensure positivity during unconstrained optimisation:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\sigma_W = \exp(\texttt{weight}_{\log\sigma})\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This yields the sampled weight used in the forward pass:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\mathbf{W}_{\text{sample}} = \mu_W + \exp(\texttt{weight}_{\log\sigma}) \odot \varepsilon_W\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and similarly for the bias:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\mathbf{b}_{\text{sample}} = \mu_b + \exp(\texttt{bias}_{\log\sigma}) \odot \varepsilon_b\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;is-it-possible&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Is it possible?&lt;/h1&gt;
&lt;p&gt;At the moment, &lt;code&gt;{tidymodels}&lt;/code&gt; offers limited APIs for neural network architectures, mostly around standard MLPs. A few packages make &lt;code&gt;{torch}&lt;/code&gt; easier to use at a higher level:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;{brulee}&lt;/code&gt; bridges &lt;code&gt;{torch}&lt;/code&gt; with &lt;code&gt;{tidymodels}&lt;/code&gt;. It is ergonomic, but currently focused on MLPs for tabular data.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{cito}&lt;/code&gt; does not integrate with &lt;code&gt;{tidymodels}&lt;/code&gt; and leans more toward statistical applications.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;{torch}&lt;/code&gt; team maintains &lt;code&gt;{luz}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{tabnet}&lt;/code&gt; integrates with &lt;code&gt;{tidymodels}&lt;/code&gt;, but is dedicated to the TabNet architecture.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;code&gt;{kindling}&lt;/code&gt; does not replace these packages. However, it helps close some of these gaps by supporting custom architectures with flexible depth. As a result, custom neural network architectures, including BNNs, can be used within &lt;code&gt;{tidymodels}&lt;/code&gt; workflows. For a broader overview of what &lt;code&gt;{kindling}&lt;/code&gt; enables in R, see this &lt;a href=&#34;https://statsandr.com/blog/you-can-do-more-for-neural-networks-in-r-with-kindling/&#34;&gt;earlier post&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;setup&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Setup&lt;/h1&gt;
&lt;p&gt;On March 3, 2026, &lt;code&gt;{kindling}&lt;/code&gt; v0.3.0 was released on &lt;a href=&#34;https://cran.r-project.org/package=kindling&#34;&gt;CRAN&lt;/a&gt;. Remember that &lt;code&gt;utils::install.packages()&lt;/code&gt; in R always installs the latest version.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;kindling&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want the development version, you can retrieve the package by installing it from GitHub:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pak::pak(&amp;quot;joshuamarie/kindling&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I recommend using &lt;code&gt;{pak}&lt;/code&gt;: it is fast and very good at resolving package dependencies across environments, including system libraries and &lt;code&gt;{renv}&lt;/code&gt;-managed projects.&lt;/p&gt;
&lt;p&gt;Before using &lt;code&gt;{kindling}&lt;/code&gt;, install LibTorch — the C++ backend shared by PyTorch and the &lt;code&gt;{torch}&lt;/code&gt; R package &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-falbel2023torch&#34;&gt;Falbel and Luraschi 2023&lt;/a&gt;)&lt;/span&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;torch::install_torch()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;loading-namespace&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Loading namespace&lt;/h1&gt;
&lt;p&gt;When teaching R, I recommend using &lt;code&gt;box::use()&lt;/code&gt; and qualifying the names you import. Create a &lt;code&gt;bnn&lt;/code&gt; folder in your project root, then clone this repository to use BNNs in R (this module is adapted from &lt;code&gt;torchbnn&lt;/code&gt; &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-kim2020torchbnn&#34;&gt;Kim 2020&lt;/a&gt;)&lt;/span&gt;): &lt;a href=&#34;https://github.com/joshuamarie/RTorchBNN&#34; class=&#34;uri&#34;&gt;https://github.com/joshuamarie/RTorchBNN&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can run a specific command:&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;git clone --branch main https://github.com/joshuamarie/RTorchBNN bnn&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, load the following:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;box::use(
  bnn = . / bnn,
  kindling[train_nnsnip, nn_arch, act_funs],
  parsnip[fit, augment],
  yardstick[metrics]
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then register the models in &lt;code&gt;{parsnip}&lt;/code&gt; with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;loadNamespace(&amp;quot;kindling&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;the-train_nnsnip-interface&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;The &lt;code&gt;train_nnsnip()&lt;/code&gt; Interface&lt;/h1&gt;
&lt;p&gt;In &lt;code&gt;{kindling}&lt;/code&gt; v0.3.0, &lt;code&gt;train_nnsnip()&lt;/code&gt; was introduced as a &lt;code&gt;{parsnip}&lt;/code&gt;-compatible model specification that bridges the generalized neural network trainer with the &lt;code&gt;{tidymodels}&lt;/code&gt; ecosystem. Unlike &lt;code&gt;mlp_kindling()&lt;/code&gt;, which is specific to feedforward networks, &lt;code&gt;train_nnsnip()&lt;/code&gt; is architecture-agnostic: you describe the layer topology via &lt;code&gt;nn_arch()&lt;/code&gt;, allowing BNN-style or other custom layer types to slot in without changing the training logic.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;classification-iris&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Classification: Iris&lt;/h1&gt;
&lt;p&gt;We train a Bayesian Neural Network model to predict species in the &lt;code&gt;iris&lt;/code&gt; dataset via &lt;code&gt;train_nnsnip()&lt;/code&gt;, by configuring &lt;code&gt;arch&lt;/code&gt; with &lt;code&gt;nn_arch()&lt;/code&gt;. Inside &lt;code&gt;nn_arch()&lt;/code&gt;, set &lt;code&gt;nn_layer&lt;/code&gt; to &lt;code&gt;bnn$BayesLinear&lt;/code&gt; instead of the default linear layer, then define the arguments for each layer with &lt;code&gt;layer_arg_fn&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nn_model &amp;lt;-
  train_nnsnip(
    mode = &amp;quot;classification&amp;quot;,
    arch = nn_arch(
      nn_layer = bnn$BayesLinear,
      out_nn_layer = torch::nn_linear,
      layer_arg_fn = ~ if (.is_output) {
        list(.in, .out)
      } else {
        list(
          in_features = .in,
          out_features = .out,
          prior_mu = 0,
          prior_sigma = 0.1
        )
      }
    ),
    hidden_neurons = c(64, 32),
    activations = act_funs(relu, elu),
    loss = &amp;quot;cross_entropy&amp;quot;,
    epochs = 50,
    verbose = TRUE,
    learn_rate = 1e-3,
    optimizer_args = list(weight_decay = 0.01)
  ) |&amp;gt;
  fit(Species ~ ., data = iris)

nn_model |&amp;gt;
  augment(new_data = iris) |&amp;gt;
  metrics(truth = Species, estimate = .pred_class)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2 × 3
##   .metric  .estimator .estimate
##   &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;
## 1 accuracy multiclass      0.68
## 2 kap      multiclass      0.52&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Averaging predictions over multiple forward passes gives both a point estimate and a measure of predictive spread — all within a standard &lt;code&gt;{tidymodels}&lt;/code&gt; pipeline.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-drawbacks&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;The drawbacks&lt;/h1&gt;
&lt;p&gt;For now, there is no built-in option to update the loss dynamically during training. To use a custom objective such as the &lt;strong&gt;Evidence Lower Bound&lt;/strong&gt; (ELBO), you currently need to define it manually and retrain with that loss.&lt;/p&gt;
&lt;div id=&#34;updating-the-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Updating the model&lt;/h2&gt;
&lt;p&gt;That said, you can still apply a custom loss by setting the &lt;code&gt;loss&lt;/code&gt; parameter to a &lt;code&gt;torch&lt;/code&gt; function, for example &lt;code&gt;torch::nnf_mse_loss()&lt;/code&gt;. If you want to train the model with an ELBO-style loss, do the following:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;make_elbo_loss &amp;lt;- function(bnn_model, n_obs, kl_weight = 1.0) {
  box::use(
    torch[nnf_cross_entropy, torch_tensor]
  )

  function(input, target) {
    ce &amp;lt;- nnf_cross_entropy(input, target)
    device &amp;lt;- input$device
    kl_val &amp;lt;- torch_tensor(0.0, device = device, requires_grad = FALSE)
    for (m in bnn_model$modules) {
      if (inherits(m, &amp;quot;BayesLinear&amp;quot;) &amp;amp;&amp;amp; !is.null(m$kl)) {
        kl_val &amp;lt;- kl_val + m$kl
      }
    }

    ce + kl_weight * kl_val / n_obs
  }
}

elbo_loss &amp;lt;- make_elbo_loss(nn_model$fit$model, n_obs = nrow(iris), kl_weight = 1.0)

nn_model2 &amp;lt;-
  train_nnsnip(
    mode = &amp;quot;classification&amp;quot;,
    arch = nn_arch(
      nn_layer = bnn$BayesLinear,
      out_nn_layer = torch::nn_linear,
      layer_arg_fn = ~ if (.is_output) {
        list(.in, .out)
      } else {
        list(
          in_features = .in,
          out_features = .out,
          prior_mu = 0,
          prior_sigma = 0.1
        )
      }
    ),
    hidden_neurons = c(64, 32),
    activations = act_funs(relu, elu),
    loss = elbo_loss,
    epochs = 50,
    verbose = TRUE,
    learn_rate = 1e-3,
    optimizer_args = list(weight_decay = 0.01)
  ) |&amp;gt;
  fit(Species ~ ., data = iris)

nn_model2 |&amp;gt;
  augment(new_data = iris) |&amp;gt;
  metrics(truth = Species, estimate = .pred_class)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2 × 3
##   .metric  .estimator .estimate
##   &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;
## 1 accuracy multiclass      0.72
## 2 kap      multiclass      0.58&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As always, if you have any question related to the topic covered in this post, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-blundell2015weight&#34; class=&#34;csl-entry&#34;&gt;
Blundell, Charles, Julien Cornebise, Koray Kavukcuoglu, and Daan Wierstra. 2015. &lt;span&gt;“Weight Uncertainty in Neural Network.”&lt;/span&gt; &lt;em&gt;International Conference on Machine Learning&lt;/em&gt;, 1613–22.
&lt;/div&gt;
&lt;div id=&#34;ref-falbel2023torch&#34; class=&#34;csl-entry&#34;&gt;
Falbel, Daniel, and Javier Luraschi. 2023. &lt;em&gt;Torch: Tensors and Neural Networks with GPU Acceleration&lt;/em&gt;. &lt;a href=&#34;https://github.com/mlverse/torch&#34;&gt;https://github.com/mlverse/torch&lt;/a&gt;.
&lt;/div&gt;
&lt;div id=&#34;ref-kim2020torchbnn&#34; class=&#34;csl-entry&#34;&gt;
Kim, Harry. 2020. &lt;em&gt;Bayesian Neural Network for PyTorch [Torchbnn]&lt;/em&gt;. &lt;a href=&#34;https://github.com/Harry24k/bayesian-neural-network-pytorch&#34;&gt;https://github.com/Harry24k/bayesian-neural-network-pytorch&lt;/a&gt;.
&lt;/div&gt;
&lt;div id=&#34;ref-kingma2013auto&#34; class=&#34;csl-entry&#34;&gt;
Kingma, Diederik P, and Max Welling. 2013. &lt;span&gt;“Auto-Encoding Variational Bayes.”&lt;/span&gt; &lt;em&gt;arXiv Preprint arXiv:1312.6114&lt;/em&gt;.
&lt;/div&gt;
&lt;div id=&#34;ref-neal2012bayesian&#34; class=&#34;csl-entry&#34;&gt;
Neal, Radford M. 2012. &lt;em&gt;Bayesian Learning for Neural Networks&lt;/em&gt;. Vol. 118. Springer Science &amp;amp; Business Media.
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>You can do more for neural networks in R with {kindling}</title>
      <link>https://statsandr.com/blog/you-can-do-more-for-neural-networks-in-r-with-kindling/</link>
      <pubDate>Thu, 19 Feb 2026 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/you-can-do-more-for-neural-networks-in-r-with-kindling/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;images/you-can-do-more-for-neural-networks-in-r-with-kindling.jpg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;why-this-post-matters&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Why this post matters&lt;/h1&gt;
&lt;p&gt;Neural networks in R are no longer niche. Today, we can choose among:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{nnet}&lt;/code&gt; for classic, small-scale neural nets,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{neuralnet}&lt;/code&gt; another classic neural nets package besides &lt;code&gt;{nnet}&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{keras}&lt;/code&gt; / &lt;code&gt;{keras3}&lt;/code&gt; for the Keras API (typically with Python backends such as TensorFlow/JAX/Torch),&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{torch}&lt;/code&gt; for native-R deep learning with explicit model and training control.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So why discuss another package?&lt;/p&gt;
&lt;p&gt;In our experience, many day-to-day projects sit in the middle: we want more flexibility than a classical model, but less boilerplate than writing a full &lt;code&gt;{torch}&lt;/code&gt; training loop. &lt;code&gt;{kindling}&lt;/code&gt; is designed for that middle ground.&lt;/p&gt;
&lt;p&gt;In this article, we focus on what &lt;code&gt;{kindling}&lt;/code&gt; does well, where it helps, and where it is still limited.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-problem-kindling-solves-and-what-it-does-not&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What problem &lt;code&gt;{kindling}&lt;/code&gt; solves (and what it does not)&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;{kindling}&lt;/code&gt; is a higher-level interface built on top of &lt;code&gt;{torch}&lt;/code&gt;. In practice, it reduces repetitive code for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;defining common network architectures,&lt;/li&gt;
&lt;li&gt;training feedforward and recurrent models,&lt;/li&gt;
&lt;li&gt;integrating with &lt;code&gt;{tidymodels}&lt;/code&gt; (&lt;code&gt;{parsnip}&lt;/code&gt;, &lt;code&gt;{recipes}&lt;/code&gt;, &lt;code&gt;{workflows}&lt;/code&gt;, &lt;code&gt;{tune}&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It does &lt;strong&gt;not&lt;/strong&gt; replace low-level &lt;code&gt;{torch}&lt;/code&gt; for highly customized research code, and it does &lt;strong&gt;not&lt;/strong&gt; make hardware setup disappear. You still need a working LibTorch installation and an environment that can use CPU/GPU properly.&lt;/p&gt;
&lt;p&gt;At the time of writing (CRAN version 0.2.0), core built-in architectures include FFNN/MLP and recurrent variants (RNN/LSTM/GRU).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;setup&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Setup&lt;/h1&gt;
&lt;p&gt;Install this package in two different ways:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Solely install &lt;code&gt;{kindling}&lt;/code&gt; (as it installs the package dependencies internally)&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;kindling&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;You can install the package dependencies separately:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(c(
  &amp;quot;kindling&amp;quot;,
  # dependencies
  &amp;quot;torch&amp;quot;, &amp;quot;dplyr&amp;quot;, &amp;quot;rsample&amp;quot;, &amp;quot;recipes&amp;quot;, &amp;quot;yardstick&amp;quot;,
  &amp;quot;workflows&amp;quot;, &amp;quot;parsnip&amp;quot;, &amp;quot;tibble&amp;quot;, &amp;quot;ggplot2&amp;quot;, &amp;quot;mlbench&amp;quot;, &amp;quot;vip&amp;quot;
))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then load the packages in two ways:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Using &lt;code&gt;library()&lt;/code&gt; traditionally:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(kindling)
library(torch)
library(dplyr)
library(rsample)
library(recipes)
library(yardstick)
library(workflows)
library(parsnip)
library(tibble)
library(ggplot2)
library(mlbench)
library(vip)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this article, we use &lt;code&gt;library()&lt;/code&gt; for clarity and copy-paste reproducibility.&lt;/p&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;If you prefer a module-based and more explicit import style, use &lt;code&gt;box::use()&lt;/code&gt; (read
&lt;a href=&#34;https://joshuamarie.github.io/modules-in-r/&#34;&gt;&lt;em&gt;Box: Placing module system into R&lt;/em&gt;&lt;/a&gt; for more details).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;Here’s the equivalent code as above:&lt;/em&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;box::use(
kindling[...],
dplyr[...],
rsample[...],
recipes[...],
yardstick[...],
workflows[...],
parsnip[...],
tibble[...],
ggplot2[...],
mlbench[...],
vip[...]
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;{kindling}&lt;/code&gt; uses &lt;code&gt;{torch}&lt;/code&gt; as backend, so LibTorch must be installed once:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;if (!torch::torch_is_installed()) {
  torch::install_torch()
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;three-levels-of-interaction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Three levels of interaction&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;{kindling}&lt;/code&gt; is useful because you can work at different abstraction levels. Here are three ways to interact with the package, ordered from lowest to highest level of abstraction:&lt;/p&gt;
&lt;div id=&#34;generate-model-code-_generator&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;1) Generate model code (&lt;code&gt;*_generator()&lt;/code&gt;)&lt;/h2&gt;
&lt;p&gt;If you want to inspect architecture code before training:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ffnn_generator(
  nn_name = &amp;quot;MyNet&amp;quot;,
  hd_neurons = c(64, 32, 16),
  no_x = 10,
  no_y = 1,
  activations = act_funs(
    relu,
    &amp;quot;softplus(beta = 0.5)&amp;quot;,
    selu
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## torch::nn_module(&amp;quot;MyNet&amp;quot;, initialize = function () 
## {
##     self$fc1 = torch::nn_linear(10, 64, bias = TRUE)
##     self$fc2 = torch::nn_linear(64, 32, bias = TRUE)
##     self$fc3 = torch::nn_linear(32, 16, bias = TRUE)
##     self$out = torch::nn_linear(16, 1, bias = TRUE)
## }, forward = function (x) 
## {
##     x = self$fc1(x)
##     x = torch::nnf_relu(x)
##     x = self$fc2(x)
##     x = torch::nnf_softplus(x, beta = 0.5)
##     x = self$fc3(x)
##     x = torch::nnf_selu(x)
##     x = self$out(x)
##     x
## })&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Technical note: To specify a parametric activation functions like &lt;a href=&#34;https://docs.pytorch.org/docs/stable/generated/torch.nn.functional.softplus.html&#34;&gt;Softplus&lt;/a&gt; under &lt;code&gt;act_funs()&lt;/code&gt; function, set &lt;code&gt;softplus = args(beta = 0.5)&lt;/code&gt; or &lt;code&gt;softplus[beta = 0.5]&lt;/code&gt; (available in v0.3.x and later), not just in a stringly typed expression, e.g. &lt;code&gt;&#34;softplus(beta = 0.5)&#34;&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This returns an unevaluated &lt;code&gt;torch::nn_module&lt;/code&gt; expression you can inspect or modify.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;direct-training&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;2) Direct Training&lt;/h2&gt;
&lt;p&gt;The functions available (for now) are &lt;code&gt;ffnn()&lt;/code&gt; and &lt;code&gt;rnn()&lt;/code&gt;. For many applied tasks, this is the fastest way to fit a network from a formula.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mini_direct &amp;lt;- ffnn(
  mpg ~ .,
  data = mtcars,
  hidden_neurons = 8,
  activations = act_funs(relu),
  epochs = 20,
  verbose = FALSE
)

predict(mini_direct, newdata = head(mtcars, 3))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.01706841 -0.04320815 -0.71570069&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;ml-framework-integration-tidymodels-with-mlp_kindling-rnn_kindling&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;3) ML Framework Integration: &lt;code&gt;{tidymodels}&lt;/code&gt; with &lt;code&gt;mlp_kindling()&lt;/code&gt; / &lt;code&gt;rnn_kindling()&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;{kindling}&lt;/code&gt; functions to directly train the said models also (currently) integrates with &lt;code&gt;{tidymodels}&lt;/code&gt;. This level is ideal when we want recipes, workflows, resampling, and tuning.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mini_spec &amp;lt;- mlp_kindling(
  mode = &amp;quot;regression&amp;quot;,
  hidden_neurons = 8,
  activations = act_funs(relu), # or just &amp;quot;relu&amp;quot;
  epochs = 20,
  verbose = FALSE
)

mini_wf &amp;lt;- workflow() |&amp;gt;
  add_formula(mpg ~ .) |&amp;gt;
  add_model(mini_spec)

mini_fit &amp;lt;- fit(mini_wf, data = mtcars)

predict(mini_fit, new_data = head(mtcars, 3))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 1
##   .pred
##   &amp;lt;dbl&amp;gt;
## 1  9.28
## 2  9.31
## 3  5.63&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we’ve covered the three levels of interaction, let’s see &lt;code&gt;{kindling}&lt;/code&gt; in action with two “realistic” examples. We’ll demonstrate how to structure reproducible workflows, handle feature preprocessing, and evaluate results properly. Along the way, you’ll see which abstraction level works best for different scenarios.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;example-1-iris-classification-with-reproducible-good-practice&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Example 1: Iris classification with reproducible good practice&lt;/h1&gt;
&lt;p&gt;This first example uses direct training with &lt;code&gt;ffnn()&lt;/code&gt;, but still follows practical steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;train/test split,&lt;/li&gt;
&lt;li&gt;feature scaling,&lt;/li&gt;
&lt;li&gt;validation split during training,&lt;/li&gt;
&lt;li&gt;regularization,&lt;/li&gt;
&lt;li&gt;out-of-sample evaluation.&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;data-preprocessing&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Preprocessing&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Train/test split&lt;/strong&gt; is performed to prevent evaluating only on training data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data(iris)

iris_split &amp;lt;- initial_split(iris, prop = 0.8, strata = Species)
iris_train &amp;lt;- training(iris_split)
iris_test &amp;lt;- testing(iris_split)

iris_recipe &amp;lt;- recipe(Species ~ ., data = iris_train) |&amp;gt;
  step_normalize(all_predictors())
iris_prep &amp;lt;- prep(iris_recipe, training = iris_train)
iris_train_processed &amp;lt;- bake(iris_prep, new_data = NULL)
iris_test_processed &amp;lt;- bake(iris_prep, new_data = iris_test)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;mlp-with-2-hidden-layers&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;MLP with 2 Hidden Layers&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;set.seed(20260218)

iris_mlp &amp;lt;- ffnn(
  Species ~ .,
  data = iris_train_processed,
  hidden_neurons = c(32, 16),
  activations = act_funs(relu, &amp;quot;softplus(beta = 0.5)&amp;quot;),
  loss = &amp;quot;cross_entropy&amp;quot;,
  optimizer = &amp;quot;adam&amp;quot;,
  learn_rate = 0.01,
  penalty = 1e-4,
  mixture = 0,
  batch_size = 16,
  epochs = 200,
  validation_split = 0.2,
  verbose = FALSE
)

iris_mlp&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## ======================= Feedforward Neural Networks (MLP) ======================
## 
## 
## -- FFNN Model Summary ----------------------------------------------------------
## 
## 
## -------------------------------------------------------------------------------------
##   NN Model Type           :             FFNN    n_predictors :                    4
##   Number of Epochs        :              200    n_response   :                    3
##   Hidden Layer Units      :           32, 16    reg.         :   [λ = 1e-04, α = 0]
##   Number of Hidden Layers :                2    Device       :                  mps
##   Pred. Type              :   classification                 :                     
## -------------------------------------------------------------------------------------
## 
## 
## 
## -- Activation function ---------------------------------------------------------
## 
## 
##                -------------------------------------------------
##                  1st Layer {32}    :                      relu
##                  2nd Layer {16}    :      softplus(beta = 0.5)
##                  Output Activation :   No act function applied
##                -------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;iris_pred &amp;lt;- predict(iris_mlp, newdata = iris_test_processed, type = &amp;quot;response&amp;quot;)

iris_eval &amp;lt;- tibble(
  truth = iris_test_processed$Species,
  .pred_class = iris_pred
)

metrics(iris_eval, truth = truth, estimate = .pred_class)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2 × 3
##   .metric  .estimator .estimate
##   &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;
## 1 accuracy multiclass     0.933
## 2 kap      multiclass     0.9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;conf_mat(iris_eval, truth = truth, estimate = .pred_class)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             Truth
## Prediction   setosa versicolor virginica
##   setosa         10          0         0
##   versicolor      0          9         1
##   virginica       0          1         9&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;why-these-choices&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Why these choices?&lt;/h3&gt;
&lt;p&gt;Here’s the brief explanation on how we set up the models from &lt;code&gt;{kindling}&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Architecture (&lt;code&gt;c(32, 16)&lt;/code&gt;)&lt;/strong&gt;: The architecture has 2 layers with 32 units for the 1st layer and 16 for the 2nd layer. It is enough capacity for Iris, but still simple.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Activations&lt;/strong&gt;: The architecture has 2 hidden layers, each layer is specified with different activation functions.&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;relu&lt;/code&gt;: Also called Rectified Linear Unit (ReLU); the most stable default for hidden layers.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;softplus&lt;/code&gt;: Similar to ReLU but much &lt;em&gt;smoother&lt;/em&gt; in approximation; beta is adjusted to &lt;code&gt;0.5&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scaling&lt;/strong&gt;: crucial because neural networks are sensitive to predictor scale.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Regularization (&lt;code&gt;penalty&lt;/code&gt; and &lt;code&gt;mixture&lt;/code&gt;)&lt;/strong&gt;: helps reduce overfitting even on small data. &lt;code&gt;mixture&lt;/code&gt; is set to 0, which means the optimization is performed with L2 regularization.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Validation split&lt;/strong&gt;: monitors generalization during training.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;example-2-a-more-realistic-tabular-benchmark-sonar&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Example 2: A more realistic tabular benchmark (Sonar)&lt;/h1&gt;
&lt;p&gt;Iris is useful for teaching, but sometimes considered (too) easy. The Sonar dataset (60 numeric predictors, binary outcome) is a better stress test for tabular classification.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data(&amp;quot;Sonar&amp;quot;, package = &amp;quot;mlbench&amp;quot;)

sonar &amp;lt;- Sonar |&amp;gt;
  mutate(Class = factor(Class))

sonar_split &amp;lt;- initial_split(sonar, prop = 0.8, strata = Class)
sonar_train &amp;lt;- training(sonar_split)
sonar_test &amp;lt;- testing(sonar_split)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now fit through &lt;code&gt;{tidymodels}&lt;/code&gt; so preprocessing and modeling stay in one pipeline:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sonar_rec &amp;lt;- recipe(Class ~ ., data = sonar_train) |&amp;gt;
  step_normalize(all_predictors())

sonar_spec &amp;lt;- mlp_kindling(
  mode = &amp;quot;classification&amp;quot;,
  hidden_neurons = c(64, 32),
  activations = act_funs(relu, relu),
  optimizer = &amp;quot;adam&amp;quot;,
  learn_rate = 0.001,
  penalty = 1e-4,
  mixture = 0,
  batch_size = 16,
  epochs = 250,
  validation_split = 0.2,
  verbose = FALSE
)

sonar_wf &amp;lt;- workflow() |&amp;gt;
  add_recipe(sonar_rec) |&amp;gt;
  add_model(sonar_spec)

set.seed(20260218)
sonar_fit &amp;lt;- fit(sonar_wf, data = sonar_train)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sonar_pred &amp;lt;- augment(sonar_fit, new_data = sonar_test)

metrics(sonar_pred, truth = Class, estimate = .pred_class)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2 × 3
##   .metric  .estimator .estimate
##   &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;
## 1 accuracy binary         0.860
## 2 kap      binary         0.720&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In practice, this setup is often a strong baseline for tabular binary classification before trying larger architectures.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;about-early-stopping-and-callbacks&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;About early stopping and callbacks&lt;/h1&gt;
&lt;p&gt;If you come from Keras/TensorFlow, you may be used to callback objects (early stopping, learning-rate schedules, etc.).&lt;/p&gt;
&lt;p&gt;With &lt;code&gt;{kindling}&lt;/code&gt; 0.2.0, practical overfitting control is usually handled through:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;validation_split&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;regularization (&lt;code&gt;penalty&lt;/code&gt;, &lt;code&gt;mixture&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;tuning model size and training length (&lt;code&gt;epochs&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;proper resampling with &lt;code&gt;{tidymodels}&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In other words, we can approximate early-stopping behavior by selecting &lt;code&gt;epochs&lt;/code&gt; via validation/resampling, even without a callback-heavy workflow.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;supported-architectures-current-scope&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Supported architectures (current scope)&lt;/h1&gt;
&lt;div id=&#34;guekwttyav&#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;#guekwttyav table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#guekwttyav thead, #guekwttyav tbody, #guekwttyav tfoot, #guekwttyav tr, #guekwttyav td, #guekwttyav th {
  border-style: none;
}

#guekwttyav p {
  margin: 0;
  padding: 0;
}

#guekwttyav .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: 100%;
  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;
}

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

#guekwttyav .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;
}

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

#guekwttyav .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;
}

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

#guekwttyav .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;
}

#guekwttyav .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;
}

#guekwttyav .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;
}

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

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

#guekwttyav .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%;
}

#guekwttyav .gt_spanner_row {
  border-bottom-style: hidden;
}

#guekwttyav .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;
}

#guekwttyav .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;
}

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

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

#guekwttyav .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#guekwttyav .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;
}

#guekwttyav .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;
}

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

#guekwttyav .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#guekwttyav .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;
}

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

#guekwttyav .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;
}

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

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

#guekwttyav .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;
}

#guekwttyav .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;
}

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

#guekwttyav .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;
}

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

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

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

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

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

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

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

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

#guekwttyav .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#guekwttyav .gt_indent_5 {
  text-indent: 25px;
}

#guekwttyav .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#guekwttyav div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;Architecture&#34;&gt;Architecture&lt;/th&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;Main-function(s)&#34;&gt;Main function(s)&lt;/th&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;Typical-use&#34;&gt;Typical use&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;Architecture&#34; class=&#34;gt_row gt_left&#34;&gt;Feedforward (MLP/FFNN)&lt;/td&gt;
&lt;td headers=&#34;Main function(s)&#34; class=&#34;gt_row gt_left&#34; style=&#34;font-family: monospace;&#34;&gt;ffnn(), mlp_kindling()&lt;/td&gt;
&lt;td headers=&#34;Typical use&#34; class=&#34;gt_row gt_left&#34;&gt;Tabular regression/classification&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Architecture&#34; class=&#34;gt_row gt_left&#34;&gt;RNN&lt;/td&gt;
&lt;td headers=&#34;Main function(s)&#34; class=&#34;gt_row gt_left&#34; style=&#34;font-family: monospace;&#34;&gt;rnn_kindling(rnn_type = &#34;rnn&#34;)&lt;/td&gt;
&lt;td headers=&#34;Typical use&#34; class=&#34;gt_row gt_left&#34;&gt;Sequential patterns&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Architecture&#34; class=&#34;gt_row gt_left&#34;&gt;LSTM&lt;/td&gt;
&lt;td headers=&#34;Main function(s)&#34; class=&#34;gt_row gt_left&#34; style=&#34;font-family: monospace;&#34;&gt;rnn_kindling(rnn_type = &#34;lstm&#34;)&lt;/td&gt;
&lt;td headers=&#34;Typical use&#34; class=&#34;gt_row gt_left&#34;&gt;Longer-range sequence dependencies&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Architecture&#34; class=&#34;gt_row gt_left&#34;&gt;GRU&lt;/td&gt;
&lt;td headers=&#34;Main function(s)&#34; class=&#34;gt_row gt_left&#34; style=&#34;font-family: monospace;&#34;&gt;rnn_kindling(rnn_type = &#34;gru&#34;)&lt;/td&gt;
&lt;td headers=&#34;Typical use&#34; class=&#34;gt_row gt_left&#34;&gt;Sequence modeling with fewer parameters&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;variable-importance-ffnn&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Variable importance (FFNN)&lt;/h1&gt;
&lt;p&gt;Interpretability for neural networks is imperfect, but &lt;code&gt;{kindling}&lt;/code&gt; integrates established approaches for FFNN models.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# For FFNN fits:
garson(iris_mlp, bar_plot = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        x_names y_names  rel_imp
## 1 Petal.Length       y 34.31493
## 2  Sepal.Width       y 24.68379
## 3  Petal.Width       y 22.43818
## 4 Sepal.Length       y 18.56311&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;olden(iris_mlp, bar_plot = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        x_names y_names    rel_imp
## 1 Petal.Length       y -5.1100721
## 2  Petal.Width       y -2.9793542
## 3  Sepal.Width       y  0.8302629
## 4 Sepal.Length       y -0.1882139&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Via vip (Olden/Garson methods supported by kindling S3 methods)
vi(iris_mlp, type = &amp;quot;olden&amp;quot;) |&amp;gt;
  vip()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/you-can-do-more-for-neural-networks-in-r-with-kindling/index_files/figure-html/varimp-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We recommend using these as directional diagnostics, not as causal evidence.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;when-kindling-is-a-good-fit&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;When &lt;code&gt;{kindling}&lt;/code&gt; is a good fit&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;{kindling}&lt;/code&gt; is a practical choice when our projects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;work mostly in R and want to stay inside &lt;code&gt;{tidymodels}&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;need neural nets for tabular or moderate sequence tasks,&lt;/li&gt;
&lt;li&gt;want less boilerplate than raw &lt;code&gt;{torch}&lt;/code&gt; but still meaningful control.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It may be less ideal when our projects need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;custom research architectures and training loops,&lt;/li&gt;
&lt;li&gt;mature callback ecosystems similar to high-level Keras workflows,&lt;/li&gt;
&lt;li&gt;highly optimized distributed production pipelines.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;limitations-to-keep-in-mind&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Limitations to keep in mind&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Hardware setup still matters&lt;/strong&gt;: GPU usage depends on a correct &lt;code&gt;{torch}&lt;/code&gt;/LibTorch installation and supported hardware.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ecosystem maturity&lt;/strong&gt;: this is a young package; interfaces can evolve.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Debugging depth&lt;/strong&gt;: for deeply custom debugging, low-level &lt;code&gt;{torch}&lt;/code&gt; remains the reference path.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Model class assumptions&lt;/strong&gt;: recurrent models are for sequence-structured data; using them on plain tabular data is usually not appropriate.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;takeaways&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Takeaways&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;{kindling}&lt;/code&gt; is not about replacing &lt;code&gt;{torch}&lt;/code&gt; or &lt;code&gt;{keras3}&lt;/code&gt;. It is about reducing friction for common deep-learning workflows in R.&lt;/p&gt;
&lt;p&gt;For many applied projects, a robust pattern is:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;preprocess with &lt;code&gt;{recipes}&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;start with a modest MLP architecture,&lt;/li&gt;
&lt;li&gt;use validation split + regularization,&lt;/li&gt;
&lt;li&gt;evaluate on held-out test data,&lt;/li&gt;
&lt;li&gt;tune only after you have a strong baseline.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If this matches your workflow, &lt;code&gt;{kindling}&lt;/code&gt; is worth trying.&lt;/p&gt;
&lt;p&gt;As always, if you have any question related to the topic covered in this post, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>nycOpenData: A unified R interface to NYC Open Data APIs</title>
      <link>https://statsandr.com/blog/nycopendata-a-unified-r-interface-to-nyc-open-data-apis/</link>
      <pubDate>Tue, 27 Jan 2026 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/nycopendata-a-unified-r-interface-to-nyc-open-data-apis/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;images/nycopendata-a-unified-r-interface-to-nyc-open-data-apis.jpg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Guest post by Christian Martinez, developer of the nycOpenData package in R.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;nycopendata-a-unified-r-interface-to-nyc-open-data-apis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;nycOpenData: A unified R interface to NYC Open Data APIs&lt;/h1&gt;
&lt;p&gt;I am pleased to announce the release of &lt;code&gt;nycOpenData&lt;/code&gt;, an R package providing convenient, tidy access to dozens of datasets from the &lt;a href=&#34;https://opendata.cityofnewyork.us/&#34;&gt;New York City Open Data platform&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The package is designed as part of an open-science and reproducible-research effort, with the goal of lowering the friction between public data and statistical analysis—especially for teaching, exploratory research, and applied civic work.&lt;/p&gt;
&lt;div id=&#34;why-nycopendata&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Why nycOpenData?&lt;/h2&gt;
&lt;p&gt;NYC Open Data hosts hundreds of datasets covering topics such as public safety, housing, transportation, education, health, and city services. While these datasets are publicly accessible through the Socrata API, working with them directly often requires:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;knowing dataset identifiers,&lt;/li&gt;
&lt;li&gt;manually constructing API queries,&lt;/li&gt;
&lt;li&gt;handling pagination, timeouts, and rate limits,&lt;/li&gt;
&lt;li&gt;and performing repetitive data-cleaning steps.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These barriers can slow down exploratory analysis and make public data less accessible to students, researchers, and practitioners who primarily work in R.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;nycOpenData&lt;/code&gt; was built to remove these obstacles by providing a consistent, user-friendly interface that returns clean tibbles ready for analysis—without requiring users to interact directly with the API.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-does-the-package-do&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What does the package do?&lt;/h2&gt;
&lt;p&gt;The package provides a growing collection of wrapper functions, each corresponding to a specific NYC Open Data dataset or dataset family. All functions follow a shared design pattern and support:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;row limits,&lt;/li&gt;
&lt;li&gt;optional filtering via named lists,&lt;/li&gt;
&lt;li&gt;sorting,&lt;/li&gt;
&lt;li&gt;and graceful handling of API errors and timeouts.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Examples of currently supported domains include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;311 service requests&lt;/li&gt;
&lt;li&gt;Transportation and for-hire vehicles&lt;/li&gt;
&lt;li&gt;Motor vehicle collisions&lt;/li&gt;
&lt;li&gt;Department of Buildings permits and complaints&lt;/li&gt;
&lt;li&gt;Education and school reporting&lt;/li&gt;
&lt;li&gt;Juvenile justice and public safety&lt;/li&gt;
&lt;li&gt;Street trees and environmental data&lt;/li&gt;
&lt;li&gt;Permitted events (historical)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A typical call looks like this:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(nycOpenData)

nyc_311(
  limit = 1000,
  filters = list(borough = &amp;quot;BROOKLYN&amp;quot;)
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 × 40
##    unique_key created_date          agency agency_name complaint_type descriptor
##    &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;                 &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;       &amp;lt;chr&amp;gt;          &amp;lt;chr&amp;gt;     
##  1 67613985   2026-01-26T02:06:05.… NYPD   New York C… Noise - Resid… Banging/P…
##  2 67609553   2026-01-26T02:02:09.… NYPD   New York C… Noise - Resid… Banging/P…
##  3 67610990   2026-01-26T01:58:58.… NYPD   New York C… Illegal Parki… Blocked H…
##  4 67615428   2026-01-26T01:56:49.… NYPD   New York C… Noise - Resid… Banging/P…
##  5 67609568   2026-01-26T01:48:16.… NYPD   New York C… Noise - Resid… Loud Musi…
##  6 67612476   2026-01-26T01:47:10.… NYPD   New York C… Noise - Resid… Loud Musi…
##  7 67614152   2026-01-26T01:46:26.… DSNY   Department… Snow or Ice    Snow Trac…
##  8 67614054   2026-01-26T01:44:50.… DSNY   Department… Dirty Conditi… Trash     
##  9 67606570   2026-01-26T01:41:32.… NYPD   New York C… Noise - Resid… Banging/P…
## 10 67610091   2026-01-26T01:35:51.… NYPD   New York C… Noise - Vehic… Car/Truck…
## # ℹ 990 more rows
## # ℹ 34 more variables: location_type &amp;lt;chr&amp;gt;, incident_zip &amp;lt;chr&amp;gt;,
## #   incident_address &amp;lt;chr&amp;gt;, street_name &amp;lt;chr&amp;gt;, cross_street_1 &amp;lt;chr&amp;gt;,
## #   cross_street_2 &amp;lt;chr&amp;gt;, intersection_street_1 &amp;lt;chr&amp;gt;,
## #   intersection_street_2 &amp;lt;chr&amp;gt;, address_type &amp;lt;chr&amp;gt;, city &amp;lt;chr&amp;gt;,
## #   landmark &amp;lt;chr&amp;gt;, status &amp;lt;chr&amp;gt;, community_board &amp;lt;chr&amp;gt;,
## #   council_district &amp;lt;chr&amp;gt;, police_precinct &amp;lt;chr&amp;gt;, bbl &amp;lt;chr&amp;gt;, borough &amp;lt;chr&amp;gt;, …&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The result is returned as a tidy tibble of the 1,000 most recent NYC 311 requests, making it immediately compatible with the tidyverse ecosystem for visualization, modeling, and reporting.&lt;/p&gt;
&lt;div id=&#34;mini-analysis&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Mini analysis&lt;/h3&gt;
&lt;p&gt;One of the strongest qualities this function has is its ability to filter based on multiple columns. Let’s put everything together and get a dataset of the last &lt;em&gt;1,000&lt;/em&gt; 311 requests from the New York Police Department in Brooklyn.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Creating the dataset
brooklyn_nypd &amp;lt;- nyc_311(limit = 1000, filters = list(agency = &amp;quot;NYPD&amp;quot;, borough = &amp;quot;BROOKLYN&amp;quot;))

# Calling head of our new dataset
head(brooklyn_nypd)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 × 39
##   unique_key created_date           agency agency_name complaint_type descriptor
##   &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;                  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;       &amp;lt;chr&amp;gt;          &amp;lt;chr&amp;gt;     
## 1 67613985   2026-01-26T02:06:05.0… NYPD   New York C… Noise - Resid… Banging/P…
## 2 67609553   2026-01-26T02:02:09.0… NYPD   New York C… Noise - Resid… Banging/P…
## 3 67610990   2026-01-26T01:58:58.0… NYPD   New York C… Illegal Parki… Blocked H…
## 4 67615428   2026-01-26T01:56:49.0… NYPD   New York C… Noise - Resid… Banging/P…
## 5 67609568   2026-01-26T01:48:16.0… NYPD   New York C… Noise - Resid… Loud Musi…
## 6 67612476   2026-01-26T01:47:10.0… NYPD   New York C… Noise - Resid… Loud Musi…
## # ℹ 33 more variables: location_type &amp;lt;chr&amp;gt;, incident_zip &amp;lt;chr&amp;gt;,
## #   incident_address &amp;lt;chr&amp;gt;, street_name &amp;lt;chr&amp;gt;, cross_street_1 &amp;lt;chr&amp;gt;,
## #   cross_street_2 &amp;lt;chr&amp;gt;, intersection_street_1 &amp;lt;chr&amp;gt;,
## #   intersection_street_2 &amp;lt;chr&amp;gt;, address_type &amp;lt;chr&amp;gt;, city &amp;lt;chr&amp;gt;,
## #   landmark &amp;lt;chr&amp;gt;, status &amp;lt;chr&amp;gt;, community_board &amp;lt;chr&amp;gt;,
## #   council_district &amp;lt;chr&amp;gt;, police_precinct &amp;lt;chr&amp;gt;, bbl &amp;lt;chr&amp;gt;, borough &amp;lt;chr&amp;gt;,
## #   x_coordinate_state_plane &amp;lt;chr&amp;gt;, y_coordinate_state_plane &amp;lt;chr&amp;gt;, …&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Quick check to make sure our filtering worked
nrow(brooklyn_nypd)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1000&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;unique(brooklyn_nypd$agency)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;NYPD&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;unique(brooklyn_nypd$borough)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;BROOKLYN&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We successfully created our dataset that contains the 1,000 most recent requests regarding the NYPD in the borough Brooklyn.&lt;/p&gt;
&lt;p&gt;Now that we have successfully pulled the data and have it in R, let’s figure out what NYC residents in Brooklyn are complaining about to the NYPD.&lt;/p&gt;
&lt;p&gt;To do this, we will create a &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/#barplot&#34;&gt;bar graph&lt;/a&gt; of the complaint types.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Visualizing the distribution, ordered by frequency
library(ggplot2)

ggplot(brooklyn_nypd, aes(y = reorder(complaint_type, complaint_type, length))) +
  geom_bar(fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  labs(
    title = &amp;quot;Most Recent NYPD 311 Complaints (Brooklyn)&amp;quot;,
    subtitle = &amp;quot;Top 1,000 service requests&amp;quot;,
    x = &amp;quot;Number of Complaints&amp;quot;,
    y = &amp;quot;Type of Complaint&amp;quot;
  )&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34; style=&#34;text-align: center&#34;&gt;&lt;span style=&#34;display:block;&#34; id=&#34;fig:complaint-type-graph&#34;&gt;&lt;/span&gt;
&lt;img src=&#34;https://statsandr.com/blog/nycopendata-a-unified-r-interface-to-nyc-open-data-apis/index_files/figure-html/complaint-type-graph-1.png&#34; alt=&#34;Bar chart showing the frequency of NYPD-related 311 complaint types in Brooklyn from the 1,000 most recent service requests.&#34; width=&#34;100%&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;
Figure 1: Bar chart showing the frequency of NYPD-related 311 complaint types in Brooklyn from the 1,000 most recent service requests.
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;This graph shows us not only &lt;em&gt;which&lt;/em&gt; complaints were made, but &lt;em&gt;how many&lt;/em&gt; of each complaint were made.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;designed-for-reproducible-workflows&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Designed for reproducible workflows&lt;/h2&gt;
&lt;p&gt;A core design principle of &lt;code&gt;nycOpenData&lt;/code&gt; is reproducibility. Rather than downloading static CSV files that can change over time or be accidentally modified, analyses can explicitly document:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;which dataset was used,&lt;/li&gt;
&lt;li&gt;how many rows were requested,&lt;/li&gt;
&lt;li&gt;which filters were applied,&lt;/li&gt;
&lt;li&gt;and when the data were accessed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This makes the package particularly useful for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;reproducible research projects,&lt;/li&gt;
&lt;li&gt;classroom assignments,&lt;/li&gt;
&lt;li&gt;data journalism,&lt;/li&gt;
&lt;li&gt;and exploratory civic analysis.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The package is also designed to be API-polite, with configurable timeouts and safeguards that help prevent common failure modes when querying large public datasets.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;who-is-it-for&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Who is it for?&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;nycOpenData&lt;/code&gt; is intended for a broad audience, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;students learning statistics or data science using real-world data,&lt;/li&gt;
&lt;li&gt;instructors teaching reproducible research or applied data analysis,&lt;/li&gt;
&lt;li&gt;researchers conducting exploratory or descriptive analyses,&lt;/li&gt;
&lt;li&gt;data journalists and civic technologists,&lt;/li&gt;
&lt;li&gt;and anyone interested in working with NYC public data in R.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The goal is not to abstract away the data itself, but to make access predictable, transparent, and easy to integrate into standard R workflows.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;availability&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Availability&lt;/h2&gt;
&lt;p&gt;The package is available on CRAN and can be installed using:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;nycOpenData&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Development continues on GitHub, where new datasets and improvements are added regularly.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;acknowledgements&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Acknowledgements&lt;/h2&gt;
&lt;p&gt;This package was developed alongside teaching and applied research projects in reproducible data science, with inspiration from open-source contributors across the R community and the NYC Open Data program.&lt;/p&gt;
&lt;p&gt;Useful links&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CRAN package: &lt;a href=&#34;https://CRAN.R-project.org/package=nycOpenData&#34; class=&#34;uri&#34;&gt;https://CRAN.R-project.org/package=nycOpenData&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;pkgdown site: &lt;a href=&#34;https://martinezc1.github.io/nycOpenData/&#34; class=&#34;uri&#34;&gt;https://martinezc1.github.io/nycOpenData/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;GitHub repository: &lt;a href=&#34;https://github.com/martinezc1/nycOpenData&#34; class=&#34;uri&#34;&gt;https://github.com/martinezc1/nycOpenData&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;NYC Open Data portal: &lt;a href=&#34;https://opendata.cityofnewyork.us/&#34; class=&#34;uri&#34;&gt;https://opendata.cityofnewyork.us/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As always, feedback, bug reports, and dataset requests are very welcome.&lt;/p&gt;
&lt;p&gt;Thanks for reading!&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>AssociationExplorer: A user-friendly shiny application for exploring associations and visual patterns</title>
      <link>https://statsandr.com/blog/associationexplorer-a-user-friendly-shiny-application-for-exploring-associations-and-visual-patterns/</link>
      <pubDate>Tue, 16 Dec 2025 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/associationexplorer-a-user-friendly-shiny-application-for-exploring-associations-and-visual-patterns/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;images/associationexplorer-a-user-friendly-shiny-application-for-exploring-associations-and-visual-patterns.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;I am pleased to announce the publication of our paper “AssociationExplorer: A user-friendly Shiny application for exploring associations and visual patterns” in the journal &lt;em&gt;SoftwareX&lt;/em&gt;, together with the official release of the AssociationExplorer2 R package on CRAN.&lt;/p&gt;
&lt;p&gt;Both the paper and the software are part of an open-science effort aimed at making exploratory data analysis more accessible to non-technical users.&lt;/p&gt;
&lt;div id=&#34;why-associationexplorer&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Why AssociationExplorer?&lt;/h2&gt;
&lt;p&gt;Exploring multivariate datasets is now central in social sciences, data journalism, and education. However, identifying and interpreting associations between variables often requires programming skills and a solid background in statistics, which can represent a substantial barrier for many users.&lt;/p&gt;
&lt;p&gt;AssociationExplorer was designed to lower this barrier by providing an interactive, visual, and statistically grounded tool for exploring associations between quantitative and qualitative variables, without requiring users to write any code.&lt;/p&gt;
&lt;p&gt;The application is primarily intended for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;journalists and data journalism practitioners,&lt;/li&gt;
&lt;li&gt;teachers and students,&lt;/li&gt;
&lt;li&gt;researchers in the exploratory phase of an analysis,&lt;/li&gt;
&lt;li&gt;engaged citizens interested in understanding public or survey data.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;what-does-the-app-do&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What does the app do?&lt;/h2&gt;
&lt;p&gt;AssociationExplorer follows a simple and guided workflow:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Import data (CSV or Excel files)&lt;/li&gt;
&lt;li&gt;Interactively select variables of interest&lt;/li&gt;
&lt;li&gt;Automatically compute association measures adapted to variable types:
&lt;ul&gt;
&lt;li&gt;Pearson’s &lt;span class=&#34;math inline&#34;&gt;\(r\)&lt;/span&gt; correlation for numeric–numeric pairs,&lt;/li&gt;
&lt;li&gt;Cramer’s V for categorical–categorical pairs,&lt;/li&gt;
&lt;li&gt;the correlation ratio &lt;span class=&#34;math inline&#34;&gt;\(\eta\)&lt;/span&gt; for mixed numeric–categorical pairs&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Filter associations using user-defined thresholds&lt;/li&gt;
&lt;li&gt;Visualize results through:
&lt;ul&gt;
&lt;li&gt;an interactive correlation network,&lt;/li&gt;
&lt;li&gt;contextual bivariate visualizations (scatter plots, mean plots, and colored contingency tables)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This workflow is designed to support transparent, reactive, and interpretable exploratory data analysis.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;a-paper-published-in-softwarex&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;A paper published in &lt;em&gt;SoftwareX&lt;/em&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;em&gt;SoftwareX&lt;/em&gt; paper provides a detailed description of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the motivation and intended audience of the tool,&lt;/li&gt;
&lt;li&gt;the software architecture,&lt;/li&gt;
&lt;li&gt;the methodological choices underlying the association measures,&lt;/li&gt;
&lt;li&gt;an illustrative case study based on the European Social Survey,&lt;/li&gt;
&lt;li&gt;and perspectives for future development.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Link to the paper: &lt;a href=&#34;https://doi.org/10.1016/j.softx.2025.102483&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1016/j.softx.2025.102483&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In line with the journal’s standards, the code, documentation, and example data are fully open and reproducible.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-r-package-is-also-on-cran&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The R package is also on CRAN&lt;/h2&gt;
&lt;p&gt;Alongside the paper, an R package is also available on CRAN, making installation and use straightforward:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;AssociationExplorer2&amp;quot;)
library(AssociationExplorer2)
run_associationexplorer()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The CRAN release ensures:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;standardized installation,&lt;/li&gt;
&lt;li&gt;better integration with existing R workflows,&lt;/li&gt;
&lt;li&gt;clearer versioning and dependency management.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;who-is-it-for-and-how-can-it-be-used&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Who is it for, and how can it be used?&lt;/h2&gt;
&lt;p&gt;AssociationExplorer is particularly useful for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;exploratory analysis prior to formal modeling,&lt;/li&gt;
&lt;li&gt;teaching concepts related to association and dependence,&lt;/li&gt;
&lt;li&gt;data storytelling and journalistic exploration,&lt;/li&gt;
&lt;li&gt;the analysis of survey data and public datasets.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The goal is not to replace confirmatory statistical analyses, but to provide a robust tool for understanding the structure of the data before modeling.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;acknowledgements&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Acknowledgements&lt;/h2&gt;
&lt;p&gt;This work was carried out in collaboration with Cédric Heuchenne, Arnaud Claes, and Antonin Descampe, whom I warmly thank.&lt;/p&gt;
&lt;p&gt;The project is supported by the Walloon Region and SPW Recherche within the ODALON research project.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;useful-links&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Useful links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;📄 &lt;em&gt;SoftwareX&lt;/em&gt; paper: &lt;a href=&#34;https://doi.org/10.1016/j.softx.2025.102483&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1016/j.softx.2025.102483&lt;/a&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;📦 CRAN package: &lt;a href=&#34;https://CRAN.R-project.org/package=AssociationExplorer2&#34; class=&#34;uri&#34;&gt;https://CRAN.R-project.org/package=AssociationExplorer2&lt;/a&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;💻 GitHub repository:
&lt;ul&gt;
&lt;li&gt;of the &lt;a href=&#34;https://github.com/AntoineSoetewey/AssociationExplorer&#34;&gt;paper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;of the &lt;a href=&#34;https://github.com/AntoineSoetewey/AssociationExplorer2&#34;&gt;R package&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As always, feedback, bug reports, and suggestions are very welcome.&lt;/p&gt;
&lt;p&gt;Thanks for reading!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;p&gt;Soetewey, A., Heuchenne, C., Claes, A. and Descampe, A. (2026). AssociationExplorer: A user-friendly shiny application for exploring associations and visual patterns. &lt;em&gt;SoftwareX, 33&lt;/em&gt;(102483). &lt;a href=&#34;https://doi.org/10.1016/j.softx.2025.102483&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1016/j.softx.2025.102483&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Soetewey, A., Heuchenne, C., Claes, A. and Descampe, A. (2025). AssociationExplorer2: A User-Friendly ‘shiny’ Application for Exploring Associations and Visual Patterns. R package version 0.1.4, &lt;a href=&#34;https://github.com/AntoineSoetewey/AssociationExplorer2&#34; class=&#34;uri&#34;&gt;https://github.com/AntoineSoetewey/AssociationExplorer2&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Nonparametric serial interval estimation</title>
      <link>https://statsandr.com/blog/nonparametric-serial-interval-estimation/</link>
      <pubDate>Mon, 18 Aug 2025 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/nonparametric-serial-interval-estimation/</guid>
      <description>


&lt;div id=&#34;motivation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Motivation&lt;/h2&gt;
&lt;p&gt;Epidemiological delays inform about the time between two well-defined events related to a disease. The serial interval (SI) of an infectious disease is defined as the time between symptom onset in a primary case (infector) and symptom onset in a secondary case (infectee). It is a widely used epidemiological delay quantity and plays a central role in mathematical/statistical models of disease transmission. There exists a tight link between the reproduction number (average number of secondary infections generated by an infected individual) and the serial interval. Therefore, getting accurate knowledge about the SI distribution is key to gain a clear understanding of transmission dynamics during outbreaks. Timings of symptom onset for infector-infectee pairs can be obtained from line list data and observations usually consist of calendar dates. From a mathematical perspective, it is more convenient to work with numbers than with calendar dates and the latter are typically transformed to integers for the sake of statistical analysis.&lt;/p&gt;
&lt;p&gt;The main challenge when working with SI data is censoring in the sense that exact symptom onset times are usually unobserved and only known to have occurred between two time points. If the time resolution of a reported timing of illness onset is a calendar day, for instance July 15, there is not enough information to determine the exact time of illness onset within that day. As such, symptom onset is assumed to have occurred between July 15 and July 16 and we say that serial interval data are interval-censored. The figure below illustrates the coarse structure of SI data that adds a layer of complexity to the estimation problem.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;images/SIcoarse.PNG&#34; style=&#34;width:100.0%&#34; alt=&#34;Source: Gressani O, Hens N. (2025). Nonparametric serial interval estimation with uniform mixtures. PLoS Comput Biol 21(8): e1013338.&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Source: Gressani O, Hens N. (2025). Nonparametric serial interval estimation with uniform mixtures. PLoS Comput Biol 21(8): e1013338.&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;A recent article by &lt;a href=&#34;https://doi.org/10.1371/journal.pcbi.1013338&#34;&gt;Gressani and Hens (2025)&lt;/a&gt; published in PLOS Computational Biology proposes a new estimator of the cumulative distribution function of the serial interval without making parametric assumptions regarding the underlying SI distribution. The estimator is based on mixtures of uniform distributions and only requires left and right bounds of serial interval windows of infector-infectee pairs as a main input (&lt;span class=&#34;math inline&#34;&gt;\(s_{iL}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(s_{iR}\)&lt;/span&gt; in the above figure). Point estimates of different serial interval features are available in closed-form and the bootstrap is used to compute confidence intervals. The nonparametric methodology is relatively simple and computationally fast and stable. Moreover, a user-friendly routine is available in the &lt;a href=&#34;https://github.com/oswaldogressani/EpiDelays&#34;&gt;EpiDelays package&lt;/a&gt; written in R. This post aims at giving users a simple first experience with this new nonparametric methodology for serial interval estimation. The package can be installed from GitHub (using devtools) as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;oswaldogressani/EpiDelays&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;simulated-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Simulated data&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;estimSI()&lt;/code&gt; routine of the EpiDelays package can be used to compute nonparametric estimates (point estimates with standard errors and confidence intervals) of different serial interval features (e.g. the mean, median, standard deviation). The routine is simple to use and requires only two inputs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;x&lt;/code&gt;: A data frame with &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; rows (corresponding to the number of transmission pairs for which illness onset data is available) and two columns containing the lower bound of the SI window &lt;span class=&#34;math inline&#34;&gt;\(s_{iL}\)&lt;/span&gt; (first column) and the upper bound of the SI window &lt;span class=&#34;math inline&#34;&gt;\(s_{iR}\)&lt;/span&gt; (second column).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;nboot&lt;/code&gt;: An integer for the bootstrap sample size (default is 2000) used to construct (&lt;span class=&#34;math inline&#34;&gt;\(90\%\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(95\%\)&lt;/span&gt;) confidence intervals (CIs).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We start by illustrating the use of &lt;code&gt;estimSI()&lt;/code&gt; on simulated data. The &lt;code&gt;simSI()&lt;/code&gt; routine can be used to simulate artificial serial interval data with SI windows having a width (coarseness) of at least two days. The underlying target SI distribution is assumed to have a Gaussian distribution with mean &lt;code&gt;muS&lt;/code&gt; and standard deviation &lt;code&gt;sdS&lt;/code&gt; that have to be specified by the user. The code below can be used to generate &lt;span class=&#34;math inline&#34;&gt;\(n=15\)&lt;/span&gt; SI windows from a Gaussian distribution with a mean of &lt;span class=&#34;math inline&#34;&gt;\(3\)&lt;/span&gt; days and standard deviation of &lt;span class=&#34;math inline&#34;&gt;\(2\)&lt;/span&gt; days. More details regarding the data generating mechanism can be found in the &lt;a href=&#34;https://doi.org/10.1371/journal.pcbi.1013338&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;set.seed(2025)
simdata &amp;lt;- simSI(muS = 3, sdS = 2, n = 15)
gt::gt(round(simdata, 2))&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;kwsipvprqq&#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;#kwsipvprqq table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#kwsipvprqq thead, #kwsipvprqq tbody, #kwsipvprqq tfoot, #kwsipvprqq tr, #kwsipvprqq td, #kwsipvprqq th {
  border-style: none;
}

#kwsipvprqq p {
  margin: 0;
  padding: 0;
}

#kwsipvprqq .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#kwsipvprqq .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;
}

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

#kwsipvprqq .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;
}

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

#kwsipvprqq .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;
}

#kwsipvprqq .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;
}

#kwsipvprqq .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;
}

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

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

#kwsipvprqq .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%;
}

#kwsipvprqq .gt_spanner_row {
  border-bottom-style: hidden;
}

#kwsipvprqq .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;
}

#kwsipvprqq .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;
}

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

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

#kwsipvprqq .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#kwsipvprqq .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;
}

#kwsipvprqq .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;
}

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

#kwsipvprqq .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#kwsipvprqq .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;
}

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

#kwsipvprqq .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;
}

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

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

#kwsipvprqq .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;
}

#kwsipvprqq .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;
}

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

#kwsipvprqq .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;
}

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

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

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

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

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

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

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

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

#kwsipvprqq .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#kwsipvprqq .gt_indent_5 {
  text-indent: 25px;
}

#kwsipvprqq .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#kwsipvprqq div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;s&#34;&gt;s&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;sl&#34;&gt;sl&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;sr&#34;&gt;sr&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;sw&#34;&gt;sw&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;s&#34; class=&#34;gt_row gt_right&#34;&gt;4.24&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;3.07&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;4&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;4.55&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;4&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;6&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;5.54&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;7&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;3.74&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;2.67&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;4&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;3.79&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;2.84&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;4&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;2.31&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;4&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;4.40&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;6&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;2.21&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;-0.51&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;-2&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;2.16&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;4.53&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;s&#34; class=&#34;gt_row gt_right&#34;&gt;5.13&lt;/td&gt;
&lt;td headers=&#34;sl&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;sr&#34; class=&#34;gt_row gt_right&#34;&gt;7&lt;/td&gt;
&lt;td headers=&#34;sw&#34; class=&#34;gt_row gt_right&#34;&gt;4&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The first column of the simulated dataset contains the true (unobserved) serial interval value generated from the chosen Gaussian distribution. The second and third columns contain the left and right bound of the SI window (&lt;code&gt;sl&lt;/code&gt; and &lt;code&gt;sr&lt;/code&gt;). Finally, the last column contains the width of the observed SI window, i.e. &lt;code&gt;sw=sr-sl&lt;/code&gt;. The underlying target SI distribution is specified to be Gaussian with a mean of &lt;span class=&#34;math inline&#34;&gt;\(3\)&lt;/span&gt; days and standard deviation of &lt;span class=&#34;math inline&#34;&gt;\(2\)&lt;/span&gt; days. The 5th, 25th, 75th and 95th quantiles of the latter distribution are:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round(qnorm(p = c(0.05, 0.25, 0.75, 0.95), mean = 3, sd = 2), 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.3  1.7  4.3  6.3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now create a data frame containing &lt;code&gt;sl&lt;/code&gt; and &lt;code&gt;sr&lt;/code&gt; and use the latter as an input in the &lt;code&gt;estimSI()&lt;/code&gt; routine. Nonparametric estimates of different SI features can be accessed with &lt;code&gt;$npestim$&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;xdf &amp;lt;- data.frame(sl = simdata$sl, sr = simdata$sr)
SIfit &amp;lt;- estimSI(x = xdf, nboot = 2000)
gt::gt(round(SIfit$npestim, 1),
  rownames_to_stub = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;aomvniacfb&#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;#aomvniacfb table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#aomvniacfb thead, #aomvniacfb tbody, #aomvniacfb tfoot, #aomvniacfb tr, #aomvniacfb td, #aomvniacfb th {
  border-style: none;
}

#aomvniacfb p {
  margin: 0;
  padding: 0;
}

#aomvniacfb .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#aomvniacfb .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;
}

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

#aomvniacfb .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;
}

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

#aomvniacfb .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;
}

#aomvniacfb .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;
}

#aomvniacfb .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;
}

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

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

#aomvniacfb .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%;
}

#aomvniacfb .gt_spanner_row {
  border-bottom-style: hidden;
}

#aomvniacfb .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;
}

#aomvniacfb .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;
}

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

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

#aomvniacfb .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#aomvniacfb .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;
}

#aomvniacfb .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;
}

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

#aomvniacfb .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#aomvniacfb .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;
}

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

#aomvniacfb .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;
}

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

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

#aomvniacfb .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;
}

#aomvniacfb .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;
}

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

#aomvniacfb .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;
}

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

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

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

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

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

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

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

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

#aomvniacfb .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#aomvniacfb .gt_indent_5 {
  text-indent: 25px;
}

#aomvniacfb .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#aomvniacfb div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;a::stub&#34;&gt;&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;mean&#34;&gt;mean&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;sd&#34;&gt;sd&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.05&#34;&gt;q0.05&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.25&#34;&gt;q0.25&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.5&#34;&gt;q0.5&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.75&#34;&gt;q0.75&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.95&#34;&gt;q0.95&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody class=&#34;gt_table_body&#34;&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_1&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;point&lt;/th&gt;
&lt;td headers=&#34;stub_1_1 mean&#34; class=&#34;gt_row gt_right&#34;&gt;3.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 sd&#34; class=&#34;gt_row gt_right&#34;&gt;1.7&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;0.3&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;2.5&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;3.5&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;4.6&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;6.0&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_2&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;se&lt;/th&gt;
&lt;td headers=&#34;stub_1_2 mean&#34; class=&#34;gt_row gt_right&#34;&gt;0.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 sd&#34; class=&#34;gt_row gt_right&#34;&gt;0.3&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;1.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;0.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;0.3&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;0.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;0.5&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_3&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;ci90l&lt;/th&gt;
&lt;td headers=&#34;stub_1_3 mean&#34; class=&#34;gt_row gt_right&#34;&gt;2.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 sd&#34; class=&#34;gt_row gt_right&#34;&gt;1.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;-1.3&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;1.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;2.9&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;3.9&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;5.0&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_4&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;ci90r&lt;/th&gt;
&lt;td headers=&#34;stub_1_4 mean&#34; class=&#34;gt_row gt_right&#34;&gt;4.0&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 sd&#34; class=&#34;gt_row gt_right&#34;&gt;2.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;2.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;3.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;4.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;5.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;6.6&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_5&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;ci95l&lt;/th&gt;
&lt;td headers=&#34;stub_1_5 mean&#34; class=&#34;gt_row gt_right&#34;&gt;2.7&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 sd&#34; class=&#34;gt_row gt_right&#34;&gt;1.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;-1.3&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;1.5&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;2.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;3.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;4.9&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_6&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;ci95r&lt;/th&gt;
&lt;td headers=&#34;stub_1_6 mean&#34; class=&#34;gt_row gt_right&#34;&gt;4.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 sd&#34; class=&#34;gt_row gt_right&#34;&gt;2.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;2.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;3.3&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;4.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;5.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;6.6&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The output shows point estimates (point), standard errors (se) and confidence intervals bounds (ci) for the serial interval mean, standard deviation (sd) and 5th, 25th, 50th, 75th and 95th quantiles denoted by q0.05, q0.25, etc. We can also plot the estimated cumulative distribution function (cdf) obtained with the nonparametric approach and compare it with the target Gaussian cdf. The quality of the fit will typically depend on the sample size &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; and on the degree of coarseness present in the data. Note that the nonparametric methodology naturally deals with negative SI values.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sl &amp;lt;- simdata$sl
sr &amp;lt;- simdata$sr
Fhat &amp;lt;- function(s) (1 / SIfit$n) * sum((s - sl) / (sr - sl) * (s &amp;gt;= sl &amp;amp; s &amp;lt;= sr) + (s &amp;gt; sr))
sf &amp;lt;- seq(-3, 8, length = 100)
plot(sf, sapply(sf, Fhat), type = &amp;quot;l&amp;quot;, lwd = 2, xlab = &amp;quot;Serial interval&amp;quot;, ylab = &amp;quot;cdf&amp;quot;)
grid()
lines(sf, pnorm(sf, mean = 3, sd = 2), col = &amp;quot;blue&amp;quot;, lwd = 2)
legend(&amp;quot;topleft&amp;quot;, c(&amp;quot;Estimated cdf of SI&amp;quot;, &amp;quot;Target cdf of SI&amp;quot;), col = c(&amp;quot;black&amp;quot;, &amp;quot;blue&amp;quot;), lwd = c(2, 2), bty = &amp;quot;n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/nonparametric-serial-interval-estimation/index_files/figure-html/comparecdfs-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;real-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Real data&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://www.nejm.org/doi/full/10.1056/NEJMoa0906089&#34;&gt;Lessler et al. (2009)&lt;/a&gt; share a dataset containing serial interval windows obtained from &lt;span class=&#34;math inline&#34;&gt;\(n=16\)&lt;/span&gt; infector-infectee pairs for Influenza A (2009 H1N1 influenza) at a New York City school. The SI windows are directly available from the supplementary appendix of the latter reference and are encoded in a data frame &lt;code&gt;xNY&lt;/code&gt;. Nonparametric estimates of serial interval features are then obtained with &lt;code&gt;estimSI()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;xNY &amp;lt;- data.frame(sl = c(1, 1, 1, 0, 0, 4, 2, 3, 0, 3, 0, 3, 4, 1, 3, 3), sr = c(3, 3, 3, 2, 2, 6, 4, 5, 2, 5, 2, 5, 6, 3, 5, 5))
set.seed(123)
SIfitNY &amp;lt;- estimSI(xNY, nboot = 2000)
gt::gt(round(SIfitNY$npestim, 1),
  rownames_to_stub = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;lkmlioxfax&#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;#lkmlioxfax table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#lkmlioxfax thead, #lkmlioxfax tbody, #lkmlioxfax tfoot, #lkmlioxfax tr, #lkmlioxfax td, #lkmlioxfax th {
  border-style: none;
}

#lkmlioxfax p {
  margin: 0;
  padding: 0;
}

#lkmlioxfax .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#lkmlioxfax .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;
}

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

#lkmlioxfax .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;
}

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

#lkmlioxfax .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;
}

#lkmlioxfax .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;
}

#lkmlioxfax .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;
}

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

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

#lkmlioxfax .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%;
}

#lkmlioxfax .gt_spanner_row {
  border-bottom-style: hidden;
}

#lkmlioxfax .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;
}

#lkmlioxfax .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;
}

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

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

#lkmlioxfax .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#lkmlioxfax .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;
}

#lkmlioxfax .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;
}

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

#lkmlioxfax .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#lkmlioxfax .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;
}

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

#lkmlioxfax .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;
}

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

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

#lkmlioxfax .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;
}

#lkmlioxfax .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;
}

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

#lkmlioxfax .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;
}

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

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

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

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

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

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

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

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

#lkmlioxfax .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#lkmlioxfax .gt_indent_5 {
  text-indent: 25px;
}

#lkmlioxfax .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#lkmlioxfax div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;a::stub&#34;&gt;&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;mean&#34;&gt;mean&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;sd&#34;&gt;sd&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.05&#34;&gt;q0.05&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.25&#34;&gt;q0.25&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.5&#34;&gt;q0.5&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.75&#34;&gt;q0.75&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;q0.95&#34;&gt;q0.95&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody class=&#34;gt_table_body&#34;&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_1&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;point&lt;/th&gt;
&lt;td headers=&#34;stub_1_1 mean&#34; class=&#34;gt_row gt_right&#34;&gt;2.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 sd&#34; class=&#34;gt_row gt_right&#34;&gt;1.5&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;0.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;1.5&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;2.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;4.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_1 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;5.2&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_2&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;se&lt;/th&gt;
&lt;td headers=&#34;stub_1_2 mean&#34; class=&#34;gt_row gt_right&#34;&gt;0.3&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 sd&#34; class=&#34;gt_row gt_right&#34;&gt;0.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;0.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;0.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;0.6&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;0.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_2 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;0.3&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_3&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;ci90l&lt;/th&gt;
&lt;td headers=&#34;stub_1_3 mean&#34; class=&#34;gt_row gt_right&#34;&gt;2.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 sd&#34; class=&#34;gt_row gt_right&#34;&gt;1.3&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;0.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;1.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;1.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;3.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_3 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;4.7&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_4&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;ci90r&lt;/th&gt;
&lt;td headers=&#34;stub_1_4 mean&#34; class=&#34;gt_row gt_right&#34;&gt;3.4&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 sd&#34; class=&#34;gt_row gt_right&#34;&gt;1.7&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;1.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;2.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;3.7&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;4.6&lt;/td&gt;
&lt;td headers=&#34;stub_1_4 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;5.6&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_5&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;ci95l&lt;/th&gt;
&lt;td headers=&#34;stub_1_5 mean&#34; class=&#34;gt_row gt_right&#34;&gt;2.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 sd&#34; class=&#34;gt_row gt_right&#34;&gt;1.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;0.2&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;1.0&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;1.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;3.0&lt;/td&gt;
&lt;td headers=&#34;stub_1_5 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;4.6&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th id=&#34;stub_1_6&#34; scope=&#34;row&#34; class=&#34;gt_row gt_left gt_stub&#34;&gt;ci95r&lt;/th&gt;
&lt;td headers=&#34;stub_1_6 mean&#34; class=&#34;gt_row gt_right&#34;&gt;3.5&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 sd&#34; class=&#34;gt_row gt_right&#34;&gt;1.7&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.05&#34; class=&#34;gt_row gt_right&#34;&gt;1.1&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.25&#34; class=&#34;gt_row gt_right&#34;&gt;2.5&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.5&#34; class=&#34;gt_row gt_right&#34;&gt;3.8&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.75&#34; class=&#34;gt_row gt_right&#34;&gt;4.7&lt;/td&gt;
&lt;td headers=&#34;stub_1_6 q0.95&#34; class=&#34;gt_row gt_right&#34;&gt;5.7&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Interested readers can find more real data examples in &lt;a href=&#34;https://doi.org/10.1371/journal.pcbi.1013338&#34;&gt;Gressani and Hens (2025)&lt;/a&gt; and learn about the strengths and limitations of this new nonparametric methodology for serial interval estimation.&lt;/p&gt;
&lt;div id=&#34;references&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;p&gt;Gressani, O. and Hens, N. (2025). Nonparametric serial interval estimation with uniform mixtures.
&lt;em&gt;PLoS Computational Biology&lt;/em&gt; &lt;strong&gt;21&lt;/strong&gt;(8):e101338. &lt;a href=&#34;https://doi.org/10.1371/journal.pcbi.1013338&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1371/journal.pcbi.1013338&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Gressani; O. (2025). EpiDelays: A Software for Estimation of Epidemiological Delays (version 0.0.1). &lt;a href=&#34;https://github.com/oswaldogressani/EpiDelays&#34; class=&#34;uri&#34;&gt;https://github.com/oswaldogressani/EpiDelays&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Lessler, J., Reich, N. G., Cummings, D. A., and the New York City Department of Health and Mental Hygiene Swine Influenza Investigation Team. (2009). Outbreak of 2009 pandemic influenza A (H1N1) at a New York City school. &lt;em&gt;New England Journal of Medicine&lt;/em&gt; &lt;strong&gt;361&lt;/strong&gt;(27), 2628-2636. &lt;a href=&#34;https://www.nejm.org/doi/full/10.1056/NEJMoa0906089&#34; class=&#34;uri&#34;&gt;https://www.nejm.org/doi/full/10.1056/NEJMoa0906089&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>EpiLPS for estimation of incubation times</title>
      <link>https://statsandr.com/blog/epilps-for-estimation-of-incubation-times/</link>
      <pubDate>Thu, 01 Aug 2024 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/epilps-for-estimation-of-incubation-times/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#motivation&#34; id=&#34;toc-motivation&#34;&gt;Motivation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coarse-data&#34; id=&#34;toc-coarse-data&#34;&gt;Coarse data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#simulated-example&#34; id=&#34;toc-simulated-example&#34;&gt;Simulated example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#real-data-example&#34; id=&#34;toc-real-data-example&#34;&gt;Real data example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;div id=&#34;motivation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Motivation&lt;/h1&gt;
&lt;p&gt;A group of researchers from the Data Science Institute (DSI) at Hasselt University developed a new statistical model to estimate the incubation period of a pathogenic organism based on coarse data. The incubation period of an infectious disease (defined as the time elapsed between infection and the manifestation of first symptoms) is of great importance as it permits to shed light on the epidemic potential of a disease and to optimize the length of quarantine periods to freeze transmission. The article &lt;a href=&#34;https://doi.org/10.1093/aje/kwae192&#34;&gt;(Gressani et al. 2024)&lt;/a&gt; was recently published in the &lt;em&gt;American Journal of Epidemiology&lt;/em&gt; with practical implementation of the methodology accessible through the &lt;a href=&#34;https://statsandr.com/blog/paper-epilps-a-fast-and-flexible-bayesian-tool-for-estimation-of-the-time-varying-reproduction-number/&#34;&gt;EpiLPS package&lt;/a&gt; &lt;a href=&#34;https://doi.org/10.1371/journal.pcbi.1010618&#34;&gt;(Gressani et al. 2022)&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coarse-data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Coarse data&lt;/h1&gt;
&lt;p&gt;What makes estimation of incubation times so challenging in the first place? The devil lies in the data. True infection times are stealthy and rarely observed. In information-theoretic jargon this phenomenon is called “imperfect information’’ but statisticians prefer to call it censoring. To be more precise, infection times are interval censored, i.e. one part of the collected data contains exposure intervals &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{E}=[t^{E_L},t^{E_R}]\)&lt;/span&gt; reported by individuals that are part of the study, where &lt;span class=&#34;math inline&#34;&gt;\(t^{E_L}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(t^{E_R}\)&lt;/span&gt; stand for the left and right bound, respectively, of the exposure window. The other part of the data contains symptom onset times &lt;span class=&#34;math inline&#34;&gt;\(t^{\mathcal{S}}\)&lt;/span&gt;. This is a more easily accessible piece of information -people tend to remember the day when first symptoms appeared- and so the timing of symptom onset is assumed to be exactly observed. Subtracting the exposure bounds from the symptom onset time, one obtains the incubation interval &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{I}=[t^{\mathcal{I}_L}, t^{\mathcal{I}_R}]\)&lt;/span&gt; with lower bound &lt;span class=&#34;math inline&#34;&gt;\(t^{\mathcal{I}_L}=t^{\mathcal{S}}-t^{E_R}\)&lt;/span&gt; and upper bound &lt;span class=&#34;math inline&#34;&gt;\(t^{\mathcal{I}_R}=t^{\mathcal{S}}-t^{E_L}\)&lt;/span&gt;, characterizing the coarse data structure which will be the main model input.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;simulated-example&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Simulated example&lt;/h1&gt;
&lt;p&gt;In EpiLPS, the &lt;code&gt;estimIncub()&lt;/code&gt; routine is designed to compute an estimate of the incubation density based on the methodology of &lt;a href=&#34;https://doi.org/10.1093/aje/kwae192&#34;&gt;Gressani et al. (2024)&lt;/a&gt;. Giving a detailed account of the methodology would be out of scope for this blog and the reader is redirected to the article for technicalities. In a nutshell, it is a Bayesian approach making use of (penalized) B-splines, Laplace approximations and Markov chain Monte Carlo (MCMC) methods to derive a semi-parametric estimate of the incubation density. An attractive feature of the &lt;code&gt;estimIncub()&lt;/code&gt; routine for the end-user is the minimalistic input it requires to work, namely:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;x&lt;/code&gt;: A data frame containing the lower and upper bound of the incubation interval.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;K&lt;/code&gt;: An integer specifying the number of B-splines to smooth the incubation density.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;niter&lt;/code&gt;: The number of MCMC samples required.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In practice, only the data frame &lt;code&gt;x&lt;/code&gt; is required as the remaining inputs are assigned default values. Computationally, the routine requires a small amount of resources as costly subroutines are coded in C++ and integrated in R via the Rcpp package. The structure of &lt;code&gt;x&lt;/code&gt; is quite simple. It should be a data frame with two columns containing the left bound &lt;span class=&#34;math inline&#34;&gt;\(t^{\mathcal{I}_L}\)&lt;/span&gt; of the incubation interval (in the first column) and the right bound &lt;span class=&#34;math inline&#34;&gt;\(t^{\mathcal{I}_R}\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Let’s start with a simple example where &lt;code&gt;x&lt;/code&gt; is simulated based on a data generating mechanism assuming a known incubation distribution. This can be achieved with the &lt;code&gt;incubsim()&lt;/code&gt; routine in EpiLPS. We choose &lt;code&gt;x&lt;/code&gt; to be generated according to a Lognormal incubation distribution with a mean of 5.5 days and a standard deviation of 2.1 days following &lt;a href=&#34;https://doi.org/10.1126/science.abb6936&#34;&gt;Ferretti et al. (2020)&lt;/a&gt;. Simulation of &lt;span class=&#34;math inline&#34;&gt;\(n=40\)&lt;/span&gt; observations with an average exposure window of 2 days is implemented as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;set.seed(2024)
simdat &amp;lt;- incubsim(incubdist = &amp;quot;LogNormal&amp;quot;, n = 40, coarseness = 2)
gt(head(simdat$Dobsincub, 5))&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;kocanygkly&#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;#kocanygkly table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#kocanygkly thead, #kocanygkly tbody, #kocanygkly tfoot, #kocanygkly tr, #kocanygkly td, #kocanygkly th {
  border-style: none;
}

#kocanygkly p {
  margin: 0;
  padding: 0;
}

#kocanygkly .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#kocanygkly .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;
}

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

#kocanygkly .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;
}

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

#kocanygkly .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;
}

#kocanygkly .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;
}

#kocanygkly .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;
}

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

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

#kocanygkly .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%;
}

#kocanygkly .gt_spanner_row {
  border-bottom-style: hidden;
}

#kocanygkly .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;
}

#kocanygkly .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;
}

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

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

#kocanygkly .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#kocanygkly .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;
}

#kocanygkly .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;
}

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

#kocanygkly .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#kocanygkly .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;
}

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

#kocanygkly .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;
}

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

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

#kocanygkly .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;
}

#kocanygkly .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;
}

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

#kocanygkly .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;
}

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

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

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

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

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

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

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

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

#kocanygkly .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#kocanygkly .gt_indent_5 {
  text-indent: 25px;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;tL&#34;&gt;tL&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;tR&#34;&gt;tR&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;tL&#34; class=&#34;gt_row gt_right&#34;&gt;3.724500&lt;/td&gt;
&lt;td headers=&#34;tR&#34; class=&#34;gt_row gt_right&#34;&gt;5.510304&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;tL&#34; class=&#34;gt_row gt_right&#34;&gt;4.381377&lt;/td&gt;
&lt;td headers=&#34;tR&#34; class=&#34;gt_row gt_right&#34;&gt;6.654224&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;tL&#34; class=&#34;gt_row gt_right&#34;&gt;4.588020&lt;/td&gt;
&lt;td headers=&#34;tR&#34; class=&#34;gt_row gt_right&#34;&gt;5.483614&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;tL&#34; class=&#34;gt_row gt_right&#34;&gt;3.847835&lt;/td&gt;
&lt;td headers=&#34;tR&#34; class=&#34;gt_row gt_right&#34;&gt;6.003948&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;tL&#34; class=&#34;gt_row gt_right&#34;&gt;3.522282&lt;/td&gt;
&lt;td headers=&#34;tR&#34; class=&#34;gt_row gt_right&#34;&gt;5.033487&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;By typing &lt;code&gt;simdat$Dobsincub&lt;/code&gt;, the user has access to the generated incubation intervals (expressed in days), corresponding here to a data frame with two columns and &lt;span class=&#34;math inline&#34;&gt;\(n=40\)&lt;/span&gt; rows. This is the data frame that is injected in the &lt;code&gt;estimIncub()&lt;/code&gt; routine:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fit &amp;lt;- estimIncub(x = simdat$Dobsincub, verbose = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ----------------------------------------------------------------
## Time elapsed: 1.339 seconds.
## Fitted density is Log-Normal with meanlog=1.617 and sdlog=0.317.
## Mean incubation period (days): 5.298 with 95% CI: 5.086-5.615.
## 95th percentile (days): 8.484 with 95% CI: 8.121-9.089.
## ----------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output in the R console can easily be interpreted. It tells us that the model chooses a Lognormal density fit for the incubation period with a mean of 5.3 days (95% CI: 5.0-5.6 days). More detailed summary statistics are accessible by typing &lt;code&gt;fit$stats&lt;/code&gt;, such as the posterior standard deviation and additional percentiles. What happens under the hood? Basically, the model computes a semi-parametric fit to the data and compares it with classic parametric fits (Lognormal, Weibull and Gamma) used for incubation modeling. The candidate with the lowest Bayesian information criterion (BIC) wins the game and is finally selected (here the Lognormal distribution). The incubation windows and the fitted incubation density can be obtained by typing:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grid.arrange(plot(fit, typ = &amp;quot;incubwin&amp;quot;), plot(fit, type = &amp;quot;pdf&amp;quot;), nrow = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/epilps-for-estimation-of-incubation-times/index_files/figure-html/estimincubation-2-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;real-data-example&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Real data example&lt;/h1&gt;
&lt;p&gt;The flexible Bayesian methodology is illustrated on SARS-CoV-2 symptom onset and exposure window data extracted from cases in Vietnam. The dataset was analyzed in &lt;a href=&#34;https://doi.org/10.1371/journal.pone.0243889&#34;&gt;Bui et al. (2020)&lt;/a&gt; and is publicly available on the GitHub repository provided in the article (&lt;a href=&#34;https://github.com/longbui/Covid19IncubVN&#34; class=&#34;uri&#34;&gt;https://github.com/longbui/Covid19IncubVN&lt;/a&gt;; last accessed July 17, 2024). The dataset contains information about &lt;span class=&#34;math inline&#34;&gt;\(n=19\)&lt;/span&gt; cases identified from January 23, 2020 to April 13, 2020. After continuity corrections (required to change calendar dates into continuous time points), the left and right incubation bounds are given by:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Left incubation bound
tL &amp;lt;- c(0.504, 2.983, 5.343, 6.969, 6.990, 2.570, 6.870, 1.263, 0.693, 1.869, 1.151, 2.748, 1.209, 1.161, 4.982, 4.017, 2.170, 9.805, 1.659)

# Right incubation bound
tR &amp;lt;- c(1.491, 7.762, 11.777, 12.821, 11.359, 8.551, 24.954, 4.144, 6.408, 7.083, 4.191, 10.326, 9.942, 7.254, 12.690, 10.825, 14.478, 16.592, 18.649)

# Data set
dataVietnam &amp;lt;- data.frame(tL = tL, tR = tR)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;estimIncub()&lt;/code&gt; routine provides a Weibull fit with a mean incubation period of 6.7 days (95% CI: 5.8-7.4 days) and the standard deviation (extracted by typing &lt;code&gt;incubfit$stats&lt;/code&gt;) is 3.3 days (95% CI: 3.0-3.8 days). A figure of the incubation windows and the fitted Weibull density (with 95% credible interval) is also provided.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;set.seed(2024)
incubfit &amp;lt;- EpiLPS::estimIncub(x = dataVietnam, verbose = TRUE, tmax = 25)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ----------------------------------------------------------------
## Time elapsed: 1.13 seconds.
## Fitted density is Weibull with shape=2.142 and scale=7.521.
## Mean incubation period (days): 6.661 with 95% CI: 5.753-7.375.
## 95th percentile (days): 12.552 with 95% CI: 11.931-14.087.
## ----------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grid.arrange(plot(incubfit, typ = &amp;quot;incubwin&amp;quot;), plot(incubfit, type = &amp;quot;pdf&amp;quot;), nrow = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/epilps-for-estimation-of-incubation-times/index_files/figure-html/RealData-3-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;p&gt;Gressani, O., Torneri, A., Hens, N. and Faes, C. (2024). Flexible Bayesian estimation of incubation times. &lt;em&gt;American Journal of Epidemiology&lt;/em&gt; (Accepted manuscript). &lt;a href=&#34;https://doi.org/10.1093/aje/kwae192&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1093/aje/kwae192&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Gressani, O., Wallinga, J., Althaus, C. L., Hens, N. and Faes, C.
(2022). EpiLPS: A fast and flexible Bayesian tool for estimation of the
time-varying reproduction number. &lt;em&gt;PLoS Comput Biol&lt;/em&gt; &lt;strong&gt;18&lt;/strong&gt;(10):
e1010618. &lt;a href=&#34;https://doi.org/10.1371/journal.pcbi.1010618&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1371/journal.pcbi.1010618&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Eddelbuettel, D. and Francois, R. (2011). Rcpp: Seamless R and C++ Integration. &lt;em&gt;Journal of Statistical Software&lt;/em&gt;, &lt;strong&gt;40&lt;/strong&gt;(8), 1–18. &lt;a href=&#34;https://doi.org/10.18637/jss.v040.i08&#34; class=&#34;uri&#34;&gt;https://doi.org/10.18637/jss.v040.i08&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Ferretti, L. et al. (2020). Quantifying SARS-CoV-2 transmission suggests epidemic control with
digital contact tracing. &lt;em&gt;Science&lt;/em&gt; &lt;strong&gt;368&lt;/strong&gt;, eabb6936. &lt;a href=&#34;https://doi.org/10.1126/science.abb6936&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1126/science.abb6936&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Bui LV, Nguyen HT, Levine H, Nguyen HN, Nguyen T-A, Nguyen TP, et al. (2020) Estimation of the incubation period of COVID-19 in Vietnam. &lt;em&gt;PLoS ONE&lt;/em&gt; &lt;strong&gt;15&lt;/strong&gt;(12): e0243889. &lt;a href=&#34;https://doi.org/10.1371/journal.pone.0243889&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1371/journal.pone.0243889&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Binary logistic regression in R</title>
      <link>https://statsandr.com/blog/binary-logistic-regression-in-r/</link>
      <pubDate>Tue, 30 Jan 2024 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/binary-logistic-regression-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#linear-versus-logistic-regression&#34; id=&#34;toc-linear-versus-logistic-regression&#34;&gt;Linear versus logistic regression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#univariable-versus-multivariable-logistic-regression&#34; id=&#34;toc-univariable-versus-multivariable-logistic-regression&#34;&gt;Univariable versus multivariable logistic regression&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#binary-logistic-regression-in-r&#34; id=&#34;toc-binary-logistic-regression-in-r&#34;&gt;Binary logistic regression in R&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#univariable-binary-logistic-regression&#34; id=&#34;toc-univariable-binary-logistic-regression&#34;&gt;Univariable binary logistic regression&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#quantitative-independent-variable&#34; id=&#34;toc-quantitative-independent-variable&#34;&gt;Quantitative independent variable&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#qualitative-independent-variable&#34; id=&#34;toc-qualitative-independent-variable&#34;&gt;Qualitative independent variable&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#multivariable-binary-logistic-regression&#34; id=&#34;toc-multivariable-binary-logistic-regression&#34;&gt;Multivariable binary logistic regression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interaction&#34; id=&#34;toc-interaction&#34;&gt;Interaction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#model-selection&#34; id=&#34;toc-model-selection&#34;&gt;Model selection&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#quality-of-a-model&#34; id=&#34;toc-quality-of-a-model&#34;&gt;Quality of a model&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#validity-of-the-predictions&#34; id=&#34;toc-validity-of-the-predictions&#34;&gt;Validity of the predictions&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#accuracy&#34; id=&#34;toc-accuracy&#34;&gt;Accuracy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sensitivity-and-specificity&#34; id=&#34;toc-sensitivity-and-specificity&#34;&gt;Sensitivity and specificity&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#auc-and-roc-curve&#34; id=&#34;toc-auc-and-roc-curve&#34;&gt;AUC and ROC curve&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#reporting-results&#34; id=&#34;toc-reporting-results&#34;&gt;Reporting results&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#gtsummary-package&#34; id=&#34;toc-gtsummary-package&#34;&gt;{gtsummary} package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#finalfit-package&#34; id=&#34;toc-finalfit-package&#34;&gt;{finalfit} package&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conditions-of-application&#34; id=&#34;toc-conditions-of-application&#34;&gt;Conditions of application&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;images/binary-logistic-regression-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Regression is a common tool in statistics to test and quantify relationships between variables.&lt;/p&gt;
&lt;p&gt;The two most common regressions are linear and logistic regressions. A &lt;strong&gt;linear&lt;/strong&gt; regression is used when the dependent variable is &lt;strong&gt;quantitative&lt;/strong&gt;, whereas a &lt;strong&gt;logistic&lt;/strong&gt; regression is used when the dependent variable is &lt;strong&gt;qualitative&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Both linear and logistic regressions are divided into different types. Before detailing them, let’s first recap of which type a variable can be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A quantitative variable measures a quantity, the values it can take are numbers. It is divided into:
&lt;ul&gt;
&lt;li&gt;discrete: the values it can take are countable and have a finite number of possibilities (the values are often integers, for example the number of children), and&lt;/li&gt;
&lt;li&gt;continuous: the values it can take are not countable and have an infinite number of possibilities (the values are usually with decimals, or at least decimals are technically possible, for example the weight).&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;A qualitative variable (also known as categorical) is not numerical and its values fit into categories. It is also divided into two types:
&lt;ul&gt;
&lt;li&gt;nominal: no ordering is possible or implied in the categories (for example the sex), and&lt;/li&gt;
&lt;li&gt;ordinal: an order is implied in the categories (for example the health status, such as poor/reasonable/good).&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A &lt;strong&gt;binary&lt;/strong&gt; variable, also known as dichotomous, is a special case of qualitative nominal variable when there are &lt;strong&gt;only two categories&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;See more details and examples about &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;variable types&lt;/a&gt; if needed.&lt;/p&gt;
&lt;p&gt;Now that the types of a variable is clear, let’s summarize the different types of regression:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Linear regression:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Simple&lt;/strong&gt; linear regression is used when the goal is to estimate the relationship between a quantitative continuous dependent variable (also often called outcome or response variable) and &lt;strong&gt;only one&lt;/strong&gt; independent variable (also often called explanatory variable, covariate or predictor) of any type.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple&lt;/strong&gt; linear regression is used when the goal is to estimate the relationship between a quantitative continuous dependent variable and &lt;strong&gt;two or more&lt;/strong&gt; independent variables (again, of any type).&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Logistic regression:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Binary&lt;/strong&gt; logistic regression is used when the goal is to estimate the relationship between a &lt;strong&gt;binary dependent variable&lt;/strong&gt; (= two outcomes), and one or more independent variables (of any type).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multinomial&lt;/strong&gt; logistic regression is used when the goal is to estimate the relationship between a &lt;strong&gt;nominal dependent variable&lt;/strong&gt; with three or more &lt;em&gt;unordered&lt;/em&gt; outcomes, and one or more independent variables (of any type).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ordinal&lt;/strong&gt; logistic regression is used when the goal is to estimate the relationship between an &lt;strong&gt;ordinal dependent variable&lt;/strong&gt; with three or more &lt;em&gt;ordered&lt;/em&gt; outcomes, and one or more independent variables (of any type).&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that there exists another type of regression; the Poisson regression. This type of regression is used when the goal is to estimate the relationship between a dependent variable which is in the form of count data (number of occurrences of an event of interest over a given period of time or space, e.g., &lt;span class=&#34;math inline&#34;&gt;\(0, 1, 2, \ldots\)&lt;/span&gt;), and one or more independent variables.&lt;/p&gt;
&lt;p&gt;Logistic regressions and poisson regressions are both part of a broader type of model called &lt;strong&gt;generalized linear models&lt;/strong&gt; (abbreviated as &lt;strong&gt;GLM&lt;/strong&gt;). The name “generalized linear models” comes from the fact that these models allow to “generalize” the classic linear model. Indeed, it can be used in many situations, for example when analyzing a dependent variable which is not necessarily quantitative continuous or when residuals are not normally distributed (which are prerequisites for a linear model).&lt;/p&gt;
&lt;p&gt;Linear regression and its application in R have already been presented in this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;post&lt;/a&gt;. It is now time to present the logistic regression.&lt;/p&gt;
&lt;p&gt;Binary logistic regression being the most common and the easiest one to interpret among the different types of logistic regression, this post will focus only on the binary logistic regression. Other types of regression (multinomial &amp;amp; ordinal logistic regressions, as well as Poisson regressions are left for future posts).&lt;/p&gt;
&lt;p&gt;In this post, we will first explain when a logistic regression is more appropriate than a linear regression. We will then show how to perform a binary logistic regression in R, and how to interpret and report results. We will also present some plots in order to visualize results. Finally, we will cover the topics of model selection, quality of fit and underlying assumptions of a binary logistic regression. We will try to keep this tutorial as applied as possible by focusing on the applications in R and the interpretations. Mathematical details will be as concise as possible.&lt;/p&gt;
&lt;div id=&#34;linear-versus-logistic-regression&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Linear versus logistic regression&lt;/h2&gt;
&lt;p&gt;We know that a linear regression is a convenient way to estimate the relationship between a quantitative continuous dependent variable, and one or more independent variables (of any type).&lt;/p&gt;
&lt;p&gt;For instance, suppose we would like to estimate the relationship between two quantitative variables, &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt;. Using the ordinary least squares method (the most common estimator used in linear regression), we obtain the following regression line:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now suppose we are interested in estimating the impact of age on whether or not a patient has a certain disease. Age is considered as a quantitative continuous variable, while having the disease is binary (a patient is either ill or healthy).&lt;/p&gt;
&lt;p&gt;Visually, we could have something like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If we fit a regression line (using the ordinary least square method) to the points, we obtain the following plot:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We see that the regression line goes below 0 and above 1 with respect to the &lt;span class=&#34;math inline&#34;&gt;\(y\)&lt;/span&gt;-axis. Since the dependent variable &lt;code&gt;disease&lt;/code&gt; cannot take values below 0 (= healthy) nor above 1 (= ill), it is obvious that a linear regression is not appropriate for these data!&lt;/p&gt;
&lt;p&gt;In addition to this limitation, the assumptions of normality and homoscedasticity, which are required in linear regression, are clearly not appropriate with these data since the dependent variable is binary and follows a Binomial distribution! R will not stop you from performing a linear regression on binary data, but this will produce a model of little interest.&lt;/p&gt;
&lt;p&gt;This is where a logistic regression becomes handy as it takes into consideration these limitations.&lt;/p&gt;
&lt;p&gt;Applied to our example, here is how the points are fitted using a binary logistic regression:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It is clear that this model is more appropriate.&lt;/p&gt;
&lt;p&gt;The curve (known as a sigmoid) is obtained via a transformation of the predicted values. There are several possible choices for the link function, which aim is to constrain predicted values to be within the range of observed values.&lt;/p&gt;
&lt;p&gt;The most widely used in practice is the logit function, which relates the probability of occurrence of an event (bounded between 0 and 1) to the linear combination of independent variables. The logit function also turns out to be the canonical link function for a Bernoulli or Binomial distribution. This transformation ensures that no matter in which range the &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; values are located, &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; will only take numbers between 0 and 1.&lt;/p&gt;
&lt;p&gt;One could say that the fitted values (= represented by the blue curve) taking values between 0 and 1 also does not seem to make sense since a patient can only be healthy or ill (and thus the dependent variable can only take the value 0 or 1, respectively). However, in a binary logistic regression it is not the outcome no disease/disease that is directly modeled, but the &lt;em&gt;likelihood&lt;/em&gt; that a patient has the disease or not given his or her characteristics. This likelihood will be framed in terms of a &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/&#34;&gt;probability&lt;/a&gt; to observe or not the disease in a patient, which is indeed included between 0 and 1, or 0% and 100%.&lt;/p&gt;
&lt;p&gt;More generally, with a logistic regression we would like to &lt;strong&gt;model how the probability of success varies with the independent variables&lt;/strong&gt; and determine whether or not these changes are statistically significant. We are actually going to model the logarithm of the odds, and the logistic regression model will be written as follows:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
\log(odds(success)) &amp;amp;= logit(\pi) \\
&amp;amp;= \log\left(\frac{\pi}{1 - \pi}\right) \\
&amp;amp;= \beta_0 + \beta_1 X_1 + \cdots + \beta_p X_p
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(\pi\)&lt;/span&gt; &lt;span class=&#34;math inline&#34;&gt;\((0 \le \pi \le 1)\)&lt;/span&gt; is the probability of an event happening (success) and denoted &lt;span class=&#34;math inline&#34;&gt;\(\pi = P(success)\)&lt;/span&gt;. We find the values of &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_0\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\ldots\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_p\)&lt;/span&gt;, which are used as estimates for &lt;span class=&#34;math inline&#34;&gt;\(\beta_0\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\ldots\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\beta_p\)&lt;/span&gt;, using the maximum likelihood method. This method is one of several methods used in statistics to estimate parameters of a mathematical model. The goal of the estimator is to estimate the parameters &lt;span class=&#34;math inline&#34;&gt;\(\beta_0\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\ldots\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\beta_p\)&lt;/span&gt; which maximize the log likelihood function. Different algorithms have been established over the years for this non-linear optimization, but this is beyond the scope of the post.&lt;/p&gt;
&lt;p&gt;Logistic regressions are very common in the medical field, for example to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;estimate the risk factors associated with a disease or a harmful condition,&lt;/li&gt;
&lt;li&gt;predict the risk of developing a disease based on a patient’s characteristics, or&lt;/li&gt;
&lt;li&gt;determine the most important biological factors associated with a specific disease or condition.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However, logistic regressions are used in many other domains, for instance in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;banking sector: estimate a debtor’s creditworthiness based on his or her profile (income, assets, liabilities, etc.),&lt;/li&gt;
&lt;li&gt;marketing: estimate a customer’s propensity to buy a product or service based on his or her profile (age, sex, salary, previous purchases, etc.),&lt;/li&gt;
&lt;li&gt;sports: estimate the probability of a player winning against another player as a function of the characteristics of the two opponents,&lt;/li&gt;
&lt;li&gt;politics: answer the question “Would a citizen vote for our political party at the next elections?”&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;univariable-versus-multivariable-logistic-regression&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Univariable versus multivariable logistic regression&lt;/h2&gt;
&lt;p&gt;Now that it is more clear when a binary logistic regression should be used, we show how to perform one in R. We start by presenting univariable binary logistic regressions, and then multivariable binary logistic regressions.&lt;/p&gt;
&lt;p&gt;Remember that in both cases, the dependent variable must be a qualitative variable with two outcomes (hence the name &lt;em&gt;binary&lt;/em&gt; logistic regression). The difference between a univariable and multivariable binary logistic regression lies in the fact that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;for a &lt;strong&gt;univariable&lt;/strong&gt; binary logistic regression, there is only &lt;strong&gt;one independent variable&lt;/strong&gt;, while&lt;/li&gt;
&lt;li&gt;for a &lt;strong&gt;multivariable&lt;/strong&gt; binary logistic regression, there are &lt;strong&gt;two ore more independent variables&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is true that the term “univariable” may be confusing here because there are two variables in the model (i.e., one dependent variable and one independent variable). However, it is called univariable binary logistic regression to indicate that only one independent variable is considered in the model, as opposed to multivariable binary logistic regression where several independent variables are considered in the model.&lt;/p&gt;
&lt;p&gt;To draw a parallel with linear regression:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a univariable binary logistic regression is the equivalent of a simple linear regression, whereas&lt;/li&gt;
&lt;li&gt;a multivariable binary logistic regression is the equivalent of a multiple linear regression&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;when the dependent variable is binary instead of quantitative continuous. This is the reason a univariable binary logistic regression is sometimes called a simple binary logistic regression and a multivariable binary logistic regression sometimes called a multiple binary logistic regression.&lt;/p&gt;
&lt;p&gt;The terms univaria&lt;em&gt;ble&lt;/em&gt;/multivaria&lt;em&gt;ble&lt;/em&gt; should not be confused with univaria&lt;em&gt;te&lt;/em&gt;/multivaria&lt;em&gt;te&lt;/em&gt;. The number of dependent variables characterizes the model as univariate or multivariate; univariate refers to a model with only one dependent variable, while multivariate refers to a model that simultaneously predicts more than one dependent variable. Usually, the intent is to differentiate models based on the number of independent variables. This distinction is made thanks to the terms univariable and multivariable. Multivariable refers to a model relating multiple predictor variables to a dependent variable, whereas univariable refers to a model relating one single independent variable to a dependent variable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;For these illustrations, we use the “Heart Disease” dataset, available from the &lt;code&gt;{kmed}&lt;/code&gt; R package. This data frame consists of 14 variables, of which only 5 of them are kept for this post:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;age&lt;/code&gt;: age in years&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sex&lt;/code&gt;: sex (FALSE = female, TRUE = male)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cp&lt;/code&gt;: chest pain type (1 = typical angina, 2 = atypical angina, 3 = non-anginal pain, 4 = asymptomatic)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;thalach&lt;/code&gt;: maximum heart rate achieved&lt;/li&gt;
&lt;li&gt;&lt;code&gt;class&lt;/code&gt;: diagnosis of heart disease (divided into 4 classes)&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# import and rename dataset
library(kmed)
dat &amp;lt;- heart

# select variables
library(dplyr)
dat &amp;lt;- dat |&amp;gt;
  select(
    age,
    sex,
    cp,
    thalach,
    class
  )

# print dataset&amp;#39;s structure
str(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;#39;data.frame&amp;#39;:	297 obs. of  5 variables:
##  $ age    : num  63 67 67 37 41 56 62 57 63 53 ...
##  $ sex    : logi  TRUE TRUE TRUE TRUE FALSE TRUE ...
##  $ cp     : Factor w/ 4 levels &amp;quot;1&amp;quot;,&amp;quot;2&amp;quot;,&amp;quot;3&amp;quot;,&amp;quot;4&amp;quot;: 1 4 4 3 2 2 4 4 4 4 ...
##  $ thalach: num  150 108 129 187 172 178 160 163 147 155 ...
##  $ class  : int  0 2 1 0 0 0 3 0 2 1 ...
##  - attr(*, &amp;quot;na.action&amp;quot;)= &amp;#39;omit&amp;#39; Named int [1:6] 88 167 193 267 288 303
##   ..- attr(*, &amp;quot;names&amp;quot;)= chr [1:6] &amp;quot;88&amp;quot; &amp;quot;167&amp;quot; &amp;quot;193&amp;quot; &amp;quot;267&amp;quot; ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the pipe operator &lt;code&gt;|&amp;gt;&lt;/code&gt; and the &lt;code&gt;{dplyr}&lt;/code&gt; package is used to select variables. See &lt;a href=&#34;https://statsandr.com/blog/introduction-to-data-manipulation-in-r-with-dplyr/&#34;&gt;more data manipulation techniques&lt;/a&gt; using this package if you are interested.&lt;/p&gt;
&lt;p&gt;For greater readability, we rename the variables &lt;code&gt;cp&lt;/code&gt;, &lt;code&gt;thalach&lt;/code&gt; and &lt;code&gt;class&lt;/code&gt; with more informative names:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# rename variables
dat &amp;lt;- dat |&amp;gt;
  rename(
    chest_pain = cp,
    max_heartrate = thalach,
    heart_disease = class
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We transform the variables &lt;code&gt;sex&lt;/code&gt; and &lt;code&gt;chest_pain&lt;/code&gt; into &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factor&lt;/a&gt; and set the labels accordingly:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# recode sex
dat$sex &amp;lt;- factor(dat$sex,
  levels = c(FALSE, TRUE),
  labels = c(&amp;quot;female&amp;quot;, &amp;quot;male&amp;quot;)
)

# recode chest_pain
dat$chest_pain &amp;lt;- factor(dat$chest_pain,
  levels = 1:4,
  labels = c(&amp;quot;typical angina&amp;quot;, &amp;quot;atypical angina&amp;quot;, &amp;quot;non-anginal pain&amp;quot;, &amp;quot;asymptomatic&amp;quot;)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For a binary logistic regression in R, it is recommended that all the qualitative variables are transformed into factors.&lt;/p&gt;
&lt;p&gt;In our case, &lt;code&gt;heart_disease&lt;/code&gt; (our dependent variable) is currently encoded as &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#integer&#34;&gt;integer&lt;/a&gt; with values ranging from 0 to 4. Therefore, we first classify it into 2 classes by setting 0 for 0 values and 1 for non-0 values, using the &lt;code&gt;ifelse()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# recode heart_disease into 2 classes
dat$heart_disease &amp;lt;- ifelse(dat$heart_disease == 0,
  0,
  1
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then transform it into a factor and set the labels accordingly using the &lt;code&gt;factor()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# set labels for heart_disease
dat$heart_disease &amp;lt;- factor(dat$heart_disease,
  levels = c(0, 1),
  labels = c(&amp;quot;no disease&amp;quot;, &amp;quot;disease&amp;quot;)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Keep in mind the order of the levels for your dependent variable, as it will have an impact on the interpretations. In R, the first level given by &lt;code&gt;levels()&lt;/code&gt; is always taken as the reference level.&lt;/p&gt;
&lt;p&gt;In our case, the first level is the absence of the disease and the second level is the presence of the disease:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(dat$heart_disease)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;no disease&amp;quot; &amp;quot;disease&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This means that when we will build the models, we will estimate the impact of the independent variable(s) on the &lt;strong&gt;presence&lt;/strong&gt; of the disease (and not the absence!).&lt;/p&gt;
&lt;p&gt;This is the reason that, for dependent variables of the type no/yes, false/true, absence/presence of a condition, etc. it is recommended to set the level no, false, absence of the condition, etc. as the reference level. It is indeed usually easier to interpret the impact of an independent variable on the presence of a condition/disease than the opposite.&lt;/p&gt;
&lt;p&gt;If you want to switch the reference level, this can be done with the &lt;code&gt;relevel()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;Here is a preview of the final data frame and some basic &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# print first 6 observations
head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   age    sex       chest_pain max_heartrate heart_disease
## 1  63   male   typical angina           150    no disease
## 2  67   male     asymptomatic           108       disease
## 3  67   male     asymptomatic           129       disease
## 4  37   male non-anginal pain           187    no disease
## 5  41 female  atypical angina           172    no disease
## 6  56   male  atypical angina           178    no disease&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# basic descriptive statistics
summary(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       age            sex                 chest_pain  max_heartrate  
##  Min.   :29.00   female: 96   typical angina  : 23   Min.   : 71.0  
##  1st Qu.:48.00   male  :201   atypical angina : 49   1st Qu.:133.0  
##  Median :56.00                non-anginal pain: 83   Median :153.0  
##  Mean   :54.54                asymptomatic    :142   Mean   :149.6  
##  3rd Qu.:61.00                                       3rd Qu.:166.0  
##  Max.   :77.00                                       Max.   :202.0  
##     heart_disease
##  no disease:160  
##  disease   :137  
##                  
##                  
##                  
## &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The data frame is now ready to be analyzed further through univariable and multivariable binary logistic regressions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;binary-logistic-regression-in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Binary logistic regression in R&lt;/h1&gt;
&lt;div id=&#34;univariable-binary-logistic-regression&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Univariable binary logistic regression&lt;/h2&gt;
&lt;p&gt;As mentioned above, we start with a univariable binary logistic regression, that is, a binary logistic regression with only one independent variable.&lt;/p&gt;
&lt;p&gt;In R, a binary logistic regression can be done with the &lt;code&gt;glm()&lt;/code&gt; function and the &lt;code&gt;family = &#34;binomial&#34;&lt;/code&gt; argument. Similar to linear regression, the formula used inside the function must be written as &lt;code&gt;dependent variable ~ independent variable&lt;/code&gt; (in this order!).&lt;/p&gt;
&lt;p&gt;While the dependent variable must be categorical with two levels, the independent variable can be of any type. However, interpretations differ depending on whether the independent variable is qualitative or quantitative.&lt;/p&gt;
&lt;p&gt;For completeness, we illustrate this type of regression with both a quantitative and a qualitative independent variable, starting with a quantitative independent variable.&lt;/p&gt;
&lt;div id=&#34;quantitative-independent-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Quantitative independent variable&lt;/h3&gt;
&lt;p&gt;Suppose we want to estimate the impact of a patient’s age on the presence of heart disease. In this case, &lt;code&gt;age&lt;/code&gt; is our independent variable and &lt;code&gt;heart_disease&lt;/code&gt; is our dependent variable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save model
m1 &amp;lt;- glm(heart_disease ~ age,
  data = dat,
  family = &amp;quot;binomial&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Results of the model is saved under the object &lt;code&gt;m1&lt;/code&gt;. Again, similar to linear regression, results can be accessed thanks to the &lt;code&gt;summary()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# print results
summary(m1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## glm(formula = heart_disease ~ age, family = &amp;quot;binomial&amp;quot;, data = dat)
## 
## Coefficients:
##             Estimate Std. Error z value Pr(&amp;gt;|z|)    
## (Intercept) -3.05122    0.76862  -3.970  7.2e-05 ***
## age          0.05291    0.01382   3.829 0.000128 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 409.95  on 296  degrees of freedom
## Residual deviance: 394.25  on 295  degrees of freedom
## AIC: 398.25
## 
## Number of Fisher Scoring iterations: 4&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The most important results in this output are displayed in the table after &lt;code&gt;Coefficients&lt;/code&gt;. The bottom part of the output summarizes the distribution of the deviance residuals. In a nutshell, deviance residuals measure how well the observations fit the model. The closer the residual to 0, the better the fit of the observation.&lt;/p&gt;
&lt;p&gt;Within the &lt;code&gt;Coefficients&lt;/code&gt; table, we focus on the first and last columns (the other two columns correspond to the standard error and the test statistic, which are both used to compute the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the column &lt;code&gt;Estimate&lt;/code&gt; corresponds to the coefficients &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_0\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1\)&lt;/span&gt;, and&lt;/li&gt;
&lt;li&gt;the column &lt;code&gt;Pr(&amp;gt;|z|)&lt;/code&gt; corresponds to the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;R performs a &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis test&lt;/a&gt; for each coefficient, that is, &lt;span class=&#34;math inline&#34;&gt;\(H_0: \beta_j = 0\)&lt;/span&gt; versus &lt;span class=&#34;math inline&#34;&gt;\(H_1: \beta_j \neq 0\)&lt;/span&gt; for &lt;span class=&#34;math inline&#34;&gt;\(j = 0, 1\)&lt;/span&gt; via the Wald test, and print the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values in the last column. We can thus compare these &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values to the chosen significance level (usually &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;) to conclude whether or not each of the coefficient is significantly different from 0. The lower the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value, the more evidence that the coefficient is different from 0. This is similar to linear regression.&lt;/p&gt;
&lt;p&gt;Coefficients are slightly harder to interpret in logistic regression than in linear regression because the relationship between dependent and independent variables is not linear.&lt;/p&gt;
&lt;p&gt;Let’s first interpret the coefficient of age, &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1\)&lt;/span&gt;, which is the most important coefficient of the two.&lt;/p&gt;
&lt;p&gt;First, since the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value of the test on the coefficient for age is &amp;lt; 0.05, we conclude that it is significantly different from 0, which means that age is significantly associated with the presence of heart disease (at the 5% significance level). Note that if the test was not significant (i.e., the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(\ge \alpha\)&lt;/span&gt;), we would refrain from interpreting the coefficient since it means that, based on the data at hand, we are unable to conclude that age is associated with the presence of heart disease in the population.&lt;/p&gt;
&lt;p&gt;Second, remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;when &lt;span class=&#34;math inline&#34;&gt;\(\beta_1 = 0\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; are independent,&lt;/li&gt;
&lt;li&gt;when &lt;span class=&#34;math inline&#34;&gt;\(\beta_1 &amp;gt; 0\)&lt;/span&gt;, the probability that &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt; &lt;em&gt;increases&lt;/em&gt; with &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;, and&lt;/li&gt;
&lt;li&gt;when &lt;span class=&#34;math inline&#34;&gt;\(\beta_1 &amp;lt; 0\)&lt;/span&gt;, the probability that &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt; &lt;em&gt;decreases&lt;/em&gt; with &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In our context, we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;when &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1 = 0\)&lt;/span&gt;, the probability of developing a heart disease is &lt;em&gt;independent&lt;/em&gt; of the age,&lt;/li&gt;
&lt;li&gt;when &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1 &amp;gt; 0\)&lt;/span&gt;, the probability of developing a heart disease &lt;em&gt;increases&lt;/em&gt; with age, and&lt;/li&gt;
&lt;li&gt;when &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1 &amp;lt; 0\)&lt;/span&gt;, the probability of developing a heart disease &lt;em&gt;decreases&lt;/em&gt; with age.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here we have &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1 =\)&lt;/span&gt; 0.053 &lt;span class=&#34;math inline&#34;&gt;\(&amp;gt; 0\)&lt;/span&gt;, so we already know that the older the patient, the more likely he or she is to develop a heart disease. This makes sense.&lt;/p&gt;
&lt;p&gt;Now that we know the direction of the relationship, we would like to &lt;strong&gt;quantify&lt;/strong&gt; this relationship. This is easily done thanks to odds ratios (OR). OR are found by taking the exponential of the coefficients. In R, the exponential is done thanks to the &lt;code&gt;exp()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;OR can be interpreted as follows: the OR is the multiplicative change in the odds in favor of &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt; when &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; increases by 1 unit.&lt;/p&gt;
&lt;p&gt;Applied to our context, we compute the OR for the age by computing &lt;span class=&#34;math inline&#34;&gt;\(\exp(\hat{\beta}_1) =\)&lt;/span&gt; exp(0.053).&lt;/p&gt;
&lt;p&gt;Using R, this gives:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# OR for age
exp(coef(m1)[&amp;quot;age&amp;quot;])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      age 
## 1.054331&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on this result, we can say that an extra year of age increases the odds (that is, the chance) of developing a heart disease by a factor of 1.054.&lt;/p&gt;
&lt;p&gt;Therefore, the odds of developing a heart disease increases by (1.054 - 1) &lt;span class=&#34;math inline&#34;&gt;\(\times\)&lt;/span&gt; 100 = 5.4% when a patient becomes one year older.&lt;/p&gt;
&lt;p&gt;To sum up:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;when the coefficient &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1 = 0 \Rightarrow\)&lt;/span&gt; OR &lt;span class=&#34;math inline&#34;&gt;\(= \exp(\hat{\beta}_1) = 1 \Rightarrow P(Y = 1)\)&lt;/span&gt; is &lt;em&gt;independent&lt;/em&gt; of &lt;span class=&#34;math inline&#34;&gt;\(X \Rightarrow\)&lt;/span&gt; there is &lt;em&gt;no&lt;/em&gt; relationship between &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;when the coefficient &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1 &amp;gt; 0 \Rightarrow\)&lt;/span&gt; OR &lt;span class=&#34;math inline&#34;&gt;\(= \exp(\hat{\beta}_1) &amp;gt; 1 \Rightarrow P(Y = 1)\)&lt;/span&gt; &lt;em&gt;increases&lt;/em&gt; with &lt;span class=&#34;math inline&#34;&gt;\(X \Rightarrow\)&lt;/span&gt; there is a &lt;em&gt;positive&lt;/em&gt; relationship between &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt;, and&lt;/li&gt;
&lt;li&gt;when the coefficient &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1 &amp;lt; 0 \Rightarrow\)&lt;/span&gt; OR &lt;span class=&#34;math inline&#34;&gt;\(= \exp(\hat{\beta}_1) &amp;lt; 1 \Rightarrow P(Y = 1)\)&lt;/span&gt; &lt;em&gt;decreases&lt;/em&gt; with &lt;span class=&#34;math inline&#34;&gt;\(X \Rightarrow\)&lt;/span&gt; there is a &lt;em&gt;negative&lt;/em&gt; relationship between &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We now interpret the intercept &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_0\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;First, we look at the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value of the test on the intercept. This &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value being &amp;lt; 0.05, we conclude that the intercept is significantly different from 0 (at the 5% significance level).&lt;/p&gt;
&lt;p&gt;Second, similar to linear regression, in order to obtain an interpretation of the intercept, we need to find a situation in which the other coefficient, &lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt;, vanishes.&lt;/p&gt;
&lt;p&gt;In our case, it happens when a patient is 0 year old. We may or may not need to interpret results in a such a situation, and in many situations the interpretation does not make sense, so it is more a hypothetical interpretation. However, again for completeness we show how to interpret the intercept. Note that it is also possible to center the numeric variable so that the intercept has a more meaningful interpretation. This, however, goes beyond the scope of the post.&lt;/p&gt;
&lt;p&gt;For a patient aged 0 year, the odds of developing a heart disease is &lt;span class=&#34;math inline&#34;&gt;\(\exp(\hat{\beta}_0) =\)&lt;/span&gt; exp(-3.051) = 0.047. When interpreting an intercept, it often makes more sense to interpret it as the probability that &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt;, which can be computed as follows:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\frac{\exp(\hat{\beta}_0)}{1 + \exp(\hat{\beta}_0)}.\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In our case, it corresponds to the probability that a patient of age 0 develops a heart disease, which is equal to:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# prob(heart disease) for age = 0
exp(coef(m1)[1]) / (1 + exp(coef(m1)[1]))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## (Intercept) 
##  0.04516478&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This means that, if we trust our model, a newborn is expected to develops a heart disease with a probability of 4.52%.&lt;/p&gt;
&lt;p&gt;For your information, a confidence interval can be computed for any of the OR using the &lt;code&gt;confint()&lt;/code&gt; function. For example, a 95% confidence interval for the OR for age:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 95% CI for the OR for age
exp(confint(m1,
  parm = &amp;quot;age&amp;quot;
))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    2.5 %   97.5 % 
## 1.026699 1.083987&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember than when evaluating an OR, the null value is 1, not 0. An OR of 1 in this study would mean that there is no association between the age and the presence of heart disease. If the 95% confidence interval of the OR does not include 1, we conclude that there is a significant association between the age and the presence of heart disease. On the contrary, if it includes 1, we do not reject the hypothesis that there is no association between age and the presence of heart disease.&lt;/p&gt;
&lt;p&gt;In our case, the 95% CI does not include 1, so we conclude, at the 5% significance level, that there is a significant association between age and the presence of heart disease.&lt;/p&gt;
&lt;p&gt;You will notice that it is the same conclusion than with the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value. This is normal, it will always be the case:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;if the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.05, 1 will not be included in the 95% CI, and&lt;/li&gt;
&lt;li&gt;if the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(\ge\)&lt;/span&gt; 0.05, 1 will be included in the 95% CI.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This means that you can choose whether you draw your conclusion about the association between the two variables based on the 95% CI or the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value.&lt;/p&gt;
&lt;p&gt;Estimating the relationship between variables is the main reason for building models. Another goal is to predict the dependent variable based on newly observed values of the independent variable(s). This can be done with the &lt;code&gt;predict()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;Suppose we would like to predict the probability of developing a heart disease for a patient aged 30 years old:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# predict probability to develop heart disease
pred &amp;lt;- predict(m1,
  newdata = data.frame(age = c(30)),
  type = &amp;quot;response&amp;quot;
)

# print prediction
pred&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         1 
## 0.1878525&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is predicted that a 30-year-old patient has a 18.79% chance of developing a heart disease.&lt;/p&gt;
&lt;p&gt;Note that if you would like to construct a confidence interval for this prediction, it can be done by adding the &lt;code&gt;se = TRUE&lt;/code&gt; argument in the &lt;code&gt;predict()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# predict probability to develop heart disease
pred &amp;lt;- predict(m1,
  newdata = data.frame(age = c(30)),
  type = &amp;quot;response&amp;quot;,
  se = TRUE
)

# print prediction
pred$fit&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         1 
## 0.1878525&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 95% confidence interval for the prediction
lower &amp;lt;- pred$fit - (qnorm(0.975) * pred$se.fit)
upper &amp;lt;- pred$fit + (qnorm(0.975) * pred$se.fit)
c(lower, upper)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##          1          1 
## 0.07873357 0.29697138&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are a frequent reader of the blog, you are probably know that I like visualizations. The &lt;code&gt;plot_model()&lt;/code&gt; function available in the &lt;code&gt;{sjPlot}&lt;/code&gt; R package does a good job of visualizing results of the model:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(sjPlot)

# plot
plot_model(m1,
  type = &amp;quot;pred&amp;quot;,
  terms = &amp;quot;age&amp;quot;
) +
  labs(y = &amp;quot;Prob(heart disease)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-19-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For those of you who are familiar 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;, you will have noticed that the function accepts layers from the &lt;code&gt;{ggplot2}&lt;/code&gt; package. Note also that this function works with other types of model (such as linear models).&lt;/p&gt;
&lt;p&gt;The above plot shows the probability of developing a heart disease in function of age, and confirms results found above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We see that the probability of developing a heart disease increases with age (which was expected given that the OR for the coefficient of age is &amp;gt; 1),&lt;/li&gt;
&lt;li&gt;and we also see that the probability of developing a heart disease for a 30-year-old patient is slightly below 20%.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;qualitative-independent-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Qualitative independent variable&lt;/h3&gt;
&lt;p&gt;Suppose now that we are interested in estimating the relationship between the probability of developing a heart disease and the sex (which is a qualitative variable).&lt;/p&gt;
&lt;p&gt;Recall that when the independent variable was quantitative, &lt;span class=&#34;math inline&#34;&gt;\(\exp(\hat{\beta}_1)\)&lt;/span&gt; was the multiplicative change in the odds in favor of &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt; as &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; increases by 1 unit.&lt;/p&gt;
&lt;p&gt;With &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; being the sex, the only unit increase possible is from 0 to 1 (or from 1 to 2 if sex is encoded as a factor), so we can write an interpretation in terms of female/male:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\exp(\hat{\beta}_1)\)&lt;/span&gt; is the multiplicative change of the odds in favor of &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt; as a female becomes a male.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Again, keep in mind what is the order of the level for the variable sex. In our case, the level female comes before the level male:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# levels for sex
levels(dat$sex)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;female&amp;quot; &amp;quot;male&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So it is indeed the multiplicative change of the odds in favor of &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt; &lt;strong&gt;as a female becomes a male&lt;/strong&gt;. If the level male came before the level female in our dataset, it would have been the opposite.&lt;/p&gt;
&lt;p&gt;You will concede that it is rather strange to interpret odds as a female becomes a male, or vice versa. Therefore, it is better to say:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\exp(\hat{\beta}_1)\)&lt;/span&gt; is the multiplicative change of the odds in favor of &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt; for &lt;strong&gt;males versus females&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In our case, we obtain the following results:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save model
m2 &amp;lt;- glm(heart_disease ~ sex,
  data = dat,
  family = &amp;quot;binomial&amp;quot;
)

# print results
summary(m2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## glm(formula = heart_disease ~ sex, family = &amp;quot;binomial&amp;quot;, data = dat)
## 
## Coefficients:
##             Estimate Std. Error z value Pr(&amp;gt;|z|)    
## (Intercept)  -1.0438     0.2326  -4.488 7.18e-06 ***
## sexmale       1.2737     0.2725   4.674 2.95e-06 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 409.95  on 296  degrees of freedom
## Residual deviance: 386.12  on 295  degrees of freedom
## AIC: 390.12
## 
## Number of Fisher Scoring iterations: 4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# OR for sex
exp(coef(m2)[&amp;quot;sexmale&amp;quot;])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  sexmale 
## 3.573933&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which can be interpreted as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value of the test on the coefficient for sex is &amp;lt; 0.05, so we conclude that the sex is significantly associated with the presence of heart disease (at the 5% significance level).&lt;/li&gt;
&lt;li&gt;Moreover, when looking at the coefficient for sex, &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_1 =\)&lt;/span&gt; 1.274, we can say that:
&lt;ul&gt;
&lt;li&gt;For males, the odds of developing a heart disease is multiplied by a factor of exp(1.274) = 3.574 compared to females.&lt;/li&gt;
&lt;li&gt;In other words, the odds of developing a heart disease for males are 3.574 times the odds for females.&lt;/li&gt;
&lt;li&gt;This means that, the odds of developing a heart disease are (3.574 - 1) &lt;span class=&#34;math inline&#34;&gt;\(\times\)&lt;/span&gt; 100 = 257.4% higher for males than for females.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These results again make sense, as it known that men are more likely to have a heart disease than women.&lt;/p&gt;
&lt;p&gt;The interpretation of the intercept &lt;span class=&#34;math inline&#34;&gt;\(\hat{\beta}_0 =\)&lt;/span&gt; -1.044 is similar than in the previous section in the sense that it gives the probability of developing a heart disease when the other coefficient, &lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt;, is equal to 0.&lt;/p&gt;
&lt;p&gt;In our case, &lt;span class=&#34;math inline&#34;&gt;\(\beta_1 = 0\)&lt;/span&gt; simply means that the patient is a female. Therefore, the probability of developing a heart disease for a woman is:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# prob(disease) for sex = female
exp(coef(m2)[1]) / (1 + exp(coef(m2)[1]))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## (Intercept) 
##   0.2604167&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The avid reader will notice that a univariable binary logistic regression with a qualitative independent variable will lead to the same conclusion than 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;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;chisq.test(table(dat$heart_disease, dat$sex))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Pearson&amp;#39;s Chi-squared test with Yates&amp;#39; continuity correction
## 
## data:  table(dat$heart_disease, dat$sex)
## X-squared = 21.852, df = 1, p-value = 2.946e-06&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on this test, we reject the null hypothesis of independence between the two variables and we thus conclude that there is a significant association between the sex and the presence of heart disease (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001).&lt;/p&gt;
&lt;p&gt;The advantage of a univariable binary logistic regression over a Chi-square test of independence is that it not only tests whether or not there is a significant association between the two variables, but it also &lt;strong&gt;estimates the direction and strength of this relationship&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;As for a univariable logistic regression with a quantitative independent variable, predictions can also be made with the &lt;code&gt;predict()&lt;/code&gt; function. Suppose we would like to predict the probability of developing a heart disease for a male:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# predict probability to develop heart disease
pred &amp;lt;- predict(m2,
  newdata = data.frame(sex = c(&amp;quot;male&amp;quot;)),
  type = &amp;quot;response&amp;quot;
)

# print prediction
pred&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         1 
## 0.5572139&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on this model, it is predicted that a male patient has 55.72% chance of developing a heart disease.&lt;/p&gt;
&lt;p&gt;We can also visualize these results thanks to the &lt;code&gt;plot_model()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
plot_model(m2,
  type = &amp;quot;pred&amp;quot;,
  terms = &amp;quot;sex&amp;quot;
) +
  labs(y = &amp;quot;Prob(heart disease)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-25-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The points correspond to the predicted probabilities, and the bars correspond to their confidence intervals.&lt;/p&gt;
&lt;p&gt;The plot of the results in terms of probabilities confirms what was found above, that is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;women are less likely to develop a heart disease than men,&lt;/li&gt;
&lt;li&gt;the probability that a woman develops a heart disease is expected to be slightly above 25%, and&lt;/li&gt;
&lt;li&gt;the probability that a man develops a heart disease is expected to be around 55%.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;multivariable-binary-logistic-regression&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Multivariable binary logistic regression&lt;/h2&gt;
&lt;p&gt;The interpretation of the coefficients in multivariable logistic regression is similar to the interpretation in univariable regression, except that this time it estimates the multiplicative change in the odds in favor of &lt;span class=&#34;math inline&#34;&gt;\(Y = 1\)&lt;/span&gt; when &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; increases by 1 unit, &lt;strong&gt;while the other independent variables remain unchanged&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This is similar to multiple linear regression, where a coefficient gives the expected change of &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; for an increase of 1 unit of &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;, while keeping all other variables constant.&lt;/p&gt;
&lt;p&gt;The main advantages of using a multivariable logistic regression compared to a univariable logistic regression are to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;consider the simultaneous (rather than isolated) effect of independent variables,&lt;/li&gt;
&lt;li&gt;take into account potential confounding and/or interaction effects, and&lt;/li&gt;
&lt;li&gt;improve predictions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this illustration, suppose we would like to estimate the relationship between heart disease and all variables present in the data frame, that is, age, sex, chest pain type and maximum heart rate achieved:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save model
m3 &amp;lt;- glm(heart_disease ~ .,
  data = dat,
  family = &amp;quot;binomial&amp;quot;
)

# print results
summary(m3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## glm(formula = heart_disease ~ ., family = &amp;quot;binomial&amp;quot;, data = dat)
## 
## Coefficients:
##                             Estimate Std. Error z value Pr(&amp;gt;|z|)    
## (Intercept)                -0.060150   1.962091  -0.031 0.975544    
## age                         0.042814   0.019009   2.252 0.024302 *  
## sexmale                     1.686330   0.349352   4.827 1.39e-06 ***
## chest_painatypical angina  -0.120481   0.641396  -0.188 0.851000    
## chest_painnon-anginal pain -0.124331   0.571093  -0.218 0.827658    
## chest_painasymptomatic      1.963723   0.548877   3.578 0.000347 ***
## max_heartrate              -0.030326   0.007975  -3.802 0.000143 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 409.95  on 296  degrees of freedom
## Residual deviance: 275.26  on 290  degrees of freedom
## AIC: 289.26
## 
## Number of Fisher Scoring iterations: 5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the formula &lt;code&gt;heart_disease ~ .&lt;/code&gt; is a shortcut to include all variables present in the data frame in the model as independent variables, except &lt;code&gt;heart_disease&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Based on the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values displayed in the last column of the coefficients table, we conclude that, at the 5% significance level, age, sex and maximum heart rate achieved are all significantly associated with heart disease (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values &amp;lt; 0.05).&lt;/p&gt;
&lt;p&gt;For the variables &lt;code&gt;age&lt;/code&gt;, &lt;code&gt;sex&lt;/code&gt; and &lt;code&gt;max_heartrate&lt;/code&gt;, there is only one &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value (the result of the test on the nullity of the coefficient).&lt;/p&gt;
&lt;p&gt;For the variable &lt;code&gt;chest_pain&lt;/code&gt;, 3 &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values are displayed. This is normal: similar to linear regression when a categorical variable with more than two levels is included in the model, one test is performed for each comparison between the reference level and the other levels.&lt;/p&gt;
&lt;p&gt;In our case, the reference level for the variable &lt;code&gt;chest_pain&lt;/code&gt; is &lt;code&gt;typical angina&lt;/code&gt; as it comes first:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(dat$chest_pain)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;typical angina&amp;quot;   &amp;quot;atypical angina&amp;quot;  &amp;quot;non-anginal pain&amp;quot; &amp;quot;asymptomatic&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Therefore, a test is performed for the comparison between:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;typical angina&lt;/code&gt; and &lt;code&gt;atypical angina&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;typical angina&lt;/code&gt; and &lt;code&gt;non-anginal pain&lt;/code&gt;, and&lt;/li&gt;
&lt;li&gt;&lt;code&gt;typical angina&lt;/code&gt; and &lt;code&gt;asymptomatic&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;But here we are not interested in comparing levels of the variable chest pain, we would like to test the overall effect of chest pain on heart disease. For this, we are going to compare two models via a likelihood ratio test (LRT):&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;a model which includes all the variables of interest &lt;strong&gt;and&lt;/strong&gt; the variable &lt;code&gt;chest_pain&lt;/code&gt;, and&lt;/li&gt;
&lt;li&gt;the exact same model but which &lt;strong&gt;excludes&lt;/strong&gt; the variable &lt;code&gt;chest_pain&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first one is referred as the full or complete model, whereas the second one is referred as the reduced model.&lt;/p&gt;
&lt;p&gt;We compare these two models with the &lt;code&gt;anova()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save reduced model
m3_reduced &amp;lt;- glm(heart_disease ~ age + sex + max_heartrate,
  data = dat,
  family = &amp;quot;binomial&amp;quot;
)

# compare reduced with full model
anova(m3_reduced, m3,
  test = &amp;quot;LRT&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Analysis of Deviance Table
## 
## Model 1: heart_disease ~ age + sex + max_heartrate
## Model 2: heart_disease ~ age + sex + chest_pain + max_heartrate
##   Resid. Df Resid. Dev Df Deviance  Pr(&amp;gt;Chi)    
## 1       293     325.12                          
## 2       290     275.26  3    49.86 8.558e-11 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that the reduced model must come before the complete model in the &lt;code&gt;anova()&lt;/code&gt; function. The null hypothesis of this test is that the two models are equivalent.&lt;/p&gt;
&lt;p&gt;At the 5% significance level (see the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value at the right of the R output), we reject the null hypothesis and we conclude that the complete model is significantly better than the reduced model at explaining the presence of heart disease. This means that chest pain is significantly associated with heart disease (which was expected since the comparison between &lt;code&gt;typical angina&lt;/code&gt; and &lt;code&gt;asymptomatic&lt;/code&gt; was found to be significant).&lt;/p&gt;
&lt;p&gt;A comparison of two models via the LRT will be shown again later, when discussing about interactions.&lt;/p&gt;
&lt;p&gt;Now that we have shown that all four independent variables were significantly associated with the presence of heart disease, we can interpret the coefficients in order to know the direction of the relationships and most importantly, quantify the strength of these relationships.&lt;/p&gt;
&lt;p&gt;Like univariable binary logistic regression, it is easier to interpret these relationships through OR. But this time, we also print the 95% CI of the OR in addition to the OR (rounded to 3 decimals) so that we can easily see which ones are significantly different from 1:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# OR and 95% CI
round(exp(cbind(OR = coef(m3), confint(m3))), 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                               OR 2.5 % 97.5 %
## (Intercept)                0.942 0.020 44.353
## age                        1.044 1.006  1.084
## sexmale                    5.400 2.776 10.971
## chest_painatypical angina  0.886 0.252  3.191
## chest_painnon-anginal pain 0.883 0.293  2.814
## chest_painasymptomatic     7.126 2.509 22.030
## max_heartrate              0.970 0.955  0.985&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From the OR and their 95% CI computed above, we conclude that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Age: the odds of having a heart disease are multiplied by a factor of 1.04 for each one-unit increase in age, all else being equal.&lt;/li&gt;
&lt;li&gt;Sex: the odds of developing a heart disease for males are 5.4 times the odds for females, all else being equal.&lt;/li&gt;
&lt;li&gt;Chest pain: the odds of developing a heart disease for people suffering from chest pain of the type “asymptomatic” are 7.13 times the odds for people suffering from chest pain of the type “typical angina”, all else being equal. We refrain from interpreting the other comparisons as they are not significant at the 5% significance level (1 is included in their 95% CI).&lt;/li&gt;
&lt;li&gt;Maximum heart rate achieved: the odds of having a heart disease are multiplied by a factor of 0.97 for each one-unit increase in maximum heart rate achieved, all else being equal.&lt;/li&gt;
&lt;li&gt;Intercept: we also refrain from interpreting the intercept as it is not significantly different from 0 at the 5% significance level (1 is included in the 95% CI).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you are interested in printing only the OR for which the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value of the coefficient is &amp;lt; 0.05, here is the code:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;exp(coef(m3))[coef(summary(m3))[, &amp;quot;Pr(&amp;gt;|z|)&amp;quot;] &amp;lt; 0.05]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                    age                sexmale chest_painasymptomatic 
##              1.0437437              5.3996293              7.1258054 
##          max_heartrate 
##              0.9701289&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember that we can always write the interpretations in terms of the percentage increase/decrease in odds with the formula &lt;span class=&#34;math inline&#34;&gt;\((OR - 1) \times 100\)&lt;/span&gt;, where OR corresponds to the odds ratio.&lt;/p&gt;
&lt;p&gt;For instance, for the maximum heart rate achieved, the OR = 0.97, so the interpretation becomes: the odds of developing a heart disease increases by (0.97 &lt;span class=&#34;math inline&#34;&gt;\(- 1) \times 100 =\)&lt;/span&gt; -3% for each one-unit increase in maximum heart rate achieved, which is equivalent to say that the odds of developing a heart disease &lt;em&gt;decreases&lt;/em&gt; by 3% for each one-unit increase in maximum heart rate achieved.&lt;/p&gt;
&lt;p&gt;For illustrative purposes, suppose now that we would like to predict the probability that a new patient develops a heart disease. Suppose that this patient is a 32-year-old woman, suffering from chest pain of the type non-anginal and she achieved a maximum heart rate of 150. The probability that she develops a heart disease is:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create data frame of new patient
new_patient &amp;lt;- data.frame(
  age = 32,
  sex = &amp;quot;female&amp;quot;,
  chest_pain = &amp;quot;non-anginal pain&amp;quot;,
  max_heartrate = 150
)

# predict probability to develop heart disease
pred &amp;lt;- predict(m3,
  newdata = new_patient,
  type = &amp;quot;response&amp;quot;
)

# print prediction
pred&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##          1 
## 0.03345948&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we trust our model, the probability that this new patient will develop a heart disease is predicted to be 3.35%.&lt;/p&gt;
&lt;p&gt;We can also visualize the results thanks to the &lt;code&gt;plot_model()&lt;/code&gt; function, three effects at the same time:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;effect of age, sex and chest pain type on the predicted probability of developing a heart disease, and&lt;/li&gt;
&lt;li&gt;effect of maximum heart rate achieved, sex and chest pain type on the predicted probability of developing a heart disease.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 1. age, sex and chest pain on prob of disease
plot_model(m3,
  type = &amp;quot;pred&amp;quot;,
  terms = c(&amp;quot;age&amp;quot;, &amp;quot;chest_pain&amp;quot;, &amp;quot;sex&amp;quot;),
  ci.lvl = NA # remove confidence bands
) +
  labs(y = &amp;quot;Prob(heart disease)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-32-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 2. max heart rate, chest pain and sex on prob of disease
plot_model(m3,
  type = &amp;quot;pred&amp;quot;,
  terms = c(&amp;quot;max_heartrate&amp;quot;, &amp;quot;chest_pain&amp;quot;, &amp;quot;sex&amp;quot;),
  ci.lvl = NA # remove confidence bands
) +
  labs(y = &amp;quot;Prob(heart disease)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-32-2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For more clarity in the plots, confidence bands are removed thanks to &lt;code&gt;ci.lvl = NA&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;These plots confirm results obtained above, that is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;there is a &lt;em&gt;positive&lt;/em&gt; relationship between age and the presence of heart disease,&lt;/li&gt;
&lt;li&gt;there is a &lt;em&gt;negative&lt;/em&gt; relationship between maximum heart rate achieved and the presence of heart disease,&lt;/li&gt;
&lt;li&gt;the odds of developing a heart disease is higher for patients suffering from chest pain of the type asymptomatic and similar for the 3 other types of chest pain, and&lt;/li&gt;
&lt;li&gt;the odds of developing a heart disease is higher for males than for females.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;interaction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Interaction&lt;/h2&gt;
&lt;p&gt;In the previous sections, potential interaction effects were omitted.&lt;/p&gt;
&lt;p&gt;An interaction occurs when the relationship between an independent variable and the outcome variable depends on the value or the level taken by another independent variable. On the contrary, if the relationship between an independent variable and the dependent variable remains unchanged no matter the value taken by another independent variable, we cannot conclude that there is an interaction effect.&lt;/p&gt;
&lt;p&gt;In our case, there would be an interaction if for example the relationship between age and heart disease depends on the sex. There would be an interaction, for instance, if the relationship between age and heart disease was positive for females, and negative for males, or vice versa. Or if the relationship between age and heart disease was much stronger or much weaker for females than for males.&lt;/p&gt;
&lt;p&gt;Let’s see if there is an interaction between age and sex, and more importantly, whether or not this interaction is significant. For this, we need to build two models:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;one model containing only the main effects, so without the interaction, and&lt;/li&gt;
&lt;li&gt;one model containing the main effects &lt;strong&gt;and&lt;/strong&gt; the interaction.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save model without interaction
m4 &amp;lt;- glm(heart_disease ~ age + sex,
  data = dat,
  family = &amp;quot;binomial&amp;quot;
)

# save model with interaction
m4_inter &amp;lt;- glm(heart_disease ~ age * sex,
  data = dat,
  family = &amp;quot;binomial&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We first assess the interaction visually via the &lt;code&gt;plot_model()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
plot_model(m4_inter,
  type = &amp;quot;pred&amp;quot;,
  terms = c(&amp;quot;age&amp;quot;, &amp;quot;sex&amp;quot;),
  ci.lvl = NA # remove confidence bands
) +
  labs(y = &amp;quot;Prob(heart disease)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-34-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Since the two curves of the predicted probabilities are relatively similar and follow the same pattern, the relationship between age and the presence of heart disease does not seem to depend on the sex, indicating that there may indeed be no interaction. However, we would like to test it more formally via a statistical test.&lt;/p&gt;
&lt;p&gt;For this, we can compare the two models (the one without compared to the one with interaction) with a likelihood ratio test (LRT), using the &lt;code&gt;anova()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;anova(m4, m4_inter,
  test = &amp;quot;LRT&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Analysis of Deviance Table
## 
## Model 1: heart_disease ~ age + sex
## Model 2: heart_disease ~ age * sex
##   Resid. Df Resid. Dev Df Deviance Pr(&amp;gt;Chi)
## 1       294     364.43                     
## 2       293     364.23  1  0.20741   0.6488&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember that it is always the reduced model as the first argument in the &lt;code&gt;anova()&lt;/code&gt; function, and then the more complex model as the second argument.&lt;/p&gt;
&lt;p&gt;The test confirms what we supposed based on the plot: at the 5% significance level, we do not reject the null hypothesis that the two models are equivalent. Since the only difference between the two models is that an interaction term is added in the complete model, we do not reject the hypothesis that there is no interaction between the age and the sex (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.649).&lt;/p&gt;
&lt;p&gt;This conclusion could have also been obtained more simply with the &lt;code&gt;drop1()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;drop1(m4_inter,
  test = &amp;quot;LRT&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Single term deletions
## 
## Model:
## heart_disease ~ age * sex
##         Df Deviance    AIC     LRT Pr(&amp;gt;Chi)
## &amp;lt;none&amp;gt;       364.23 372.23                 
## age:sex  1   364.43 370.43 0.20741   0.6488&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, this gives the same &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value of 0.649.&lt;/p&gt;
&lt;p&gt;In practice, a non-significant interaction is removed from the model before interpreting its results. In our case, only the main effects of age and sex would remain in the model.&lt;/p&gt;
&lt;p&gt;This leads us to model selection, or which variables should be included in our final model. This is discussed in the next section.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;model-selection&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Model selection&lt;/h2&gt;
&lt;p&gt;In practice, we often have several models, corresponding to the different combinations of independent variables and their interactions. Finding the best model is not easy.&lt;/p&gt;
&lt;p&gt;In general, the best practice is to obtain a final model that is as parsimonious as possible, that is, with as few parameters as possible. A parsimonious model is easier to interpret and generalize, and also more powerful from a statistical point of view. On the other hand, it should not be too simple so that it still captures the variations or patterns in the data. In general, while more variables are often better than one, too many is often worse than a few.&lt;/p&gt;
&lt;p&gt;The two most common approaches to obtain a final model are the following:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Adjust the model by removing the main effects and their interactions which are not significant with respect to their &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values, obtained by testing the nullity of the corresponding coefficients using a statistical test such as the likelihood ratio test or the Wald test. If there are several main effects or interactions which are not significant, interactions must be removed before removing any main effect. Moreover, it is recommended to remove interactions and independent variables one by one (starting with the one with the highest &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value), as removing a variable or an interaction may make another variable or interaction that was initially non-significant significant.&lt;/li&gt;
&lt;li&gt;Adjust the model by using AIC (Akaike Information Criterion) or BIC (Bayesian Information Criterion). These procedures allow to select the best model (according to AIC or BIC) by finding an equilibrium between simplicity and complexity. These selection processes usually lead to a final model with as few parameters as possible, but which captures as much information in the data as possible. Note that only models with the same dependent variable can be compared using AIC or BIC. Models with different dependent variables cannot be compared using these criteria.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first method requires that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the underlying assumptions are valid,&lt;/li&gt;
&lt;li&gt;the sample size is sufficiently large, and&lt;/li&gt;
&lt;li&gt;the models are nested (i.e., the complete model includes at least all the variables included in the reduced model).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Moreover, the second method can be used with widely used criteria when selecting variables, and more importantly, in a completely autonomous way in R.&lt;/p&gt;
&lt;p&gt;For this reason, the second method is recommended and more often used in practice.&lt;/p&gt;
&lt;p&gt;This second method, referred as the stepwise selection, is divided into 3 types:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;backward selection: we start from the most complete model (containing all independent variables and usually also their interactions), and the interactions/main effects are deleted at each step until the model cannot be improved,&lt;/li&gt;
&lt;li&gt;forward selection: we start from the most basic model containing only the intercept, and the independent variables/interactions are added at each step until the model cannot be improved, or&lt;/li&gt;
&lt;li&gt;mixed selection: we apply both the backward &lt;strong&gt;and&lt;/strong&gt; forward selection to determine the best model according to the desired criterion.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We show how to select the best model according to AIC using the mixed stepwise selection, illustrated with all variables present in the data frame as independent variables and all possible second order interactions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save initial model
m5 &amp;lt;- glm(heart_disease ~ (age + sex + chest_pain + max_heartrate)^2,
  data = dat,
  family = &amp;quot;binomial&amp;quot;
)

# select best model according to AIC using mixed selection
m5_final &amp;lt;- step(m5,
  direction = &amp;quot;both&amp;quot;, # both = mixed selection
  trace = FALSE # do not display intermediate steps
)

# display results of final model
summary(m5_final)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## glm(formula = heart_disease ~ age + sex + chest_pain + max_heartrate + 
##     age:max_heartrate, family = &amp;quot;binomial&amp;quot;, data = dat)
## 
## Coefficients:
##                              Estimate Std. Error z value Pr(&amp;gt;|z|)    
## (Intercept)                19.4386591  8.1904201   2.373 0.017628 *  
## age                        -0.3050017  0.1414986  -2.156 0.031122 *  
## sexmale                     1.7055353  0.3507149   4.863 1.16e-06 ***
## chest_painatypical angina  -0.0086463  0.6547573  -0.013 0.989464    
## chest_painnon-anginal pain -0.0590333  0.5844000  -0.101 0.919538    
## chest_painasymptomatic      1.9724490  0.5649516   3.491 0.000481 ***
## max_heartrate              -0.1605658  0.0540933  -2.968 0.002994 ** 
## age:max_heartrate           0.0023314  0.0009433   2.471 0.013457 *  
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 409.95  on 296  degrees of freedom
## Residual deviance: 268.60  on 289  degrees of freedom
## AIC: 284.6
## 
## Number of Fisher Scoring iterations: 5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;According to the AIC (which is the default criterion when using the &lt;code&gt;step()&lt;/code&gt; function), the best model is the one including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;age&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sex&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;chest_pain&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;max_heartrate&lt;/code&gt;, and&lt;/li&gt;
&lt;li&gt;the interaction between &lt;code&gt;age&lt;/code&gt; and &lt;code&gt;max_heartrate&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For your information, you can also easily compare models manually using AIC or the pseudo-&lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; with the &lt;code&gt;tab_model()&lt;/code&gt; function, also available in the &lt;code&gt;{sjPlot}&lt;/code&gt; R package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab_model(m3, m4, m5_final,
  show.ci = FALSE, # remove CI
  show.aic = TRUE, # display AIC
  p.style = &amp;quot;numeric_stars&amp;quot; # display p-values and stars
)&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;border-collapse:collapse; border:none;&#34;&gt;
&lt;tr&gt;
&lt;th style=&#34;border-top: double; text-align:center; font-style:normal; font-weight:bold; padding:0.2cm;  text-align:left; &#34;&gt;
 
&lt;/th&gt;
&lt;th colspan=&#34;2&#34; style=&#34;border-top: double; text-align:center; font-style:normal; font-weight:bold; padding:0.2cm; &#34;&gt;
heart disease
&lt;/th&gt;
&lt;th colspan=&#34;2&#34; style=&#34;border-top: double; text-align:center; font-style:normal; font-weight:bold; padding:0.2cm; &#34;&gt;
heart disease
&lt;/th&gt;
&lt;th colspan=&#34;2&#34; style=&#34;border-top: double; text-align:center; font-style:normal; font-weight:bold; padding:0.2cm; &#34;&gt;
heart disease
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; text-align:center; border-bottom:1px solid; font-style:italic; font-weight:normal;  text-align:left; &#34;&gt;
Predictors
&lt;/td&gt;
&lt;td style=&#34; text-align:center; border-bottom:1px solid; font-style:italic; font-weight:normal;  &#34;&gt;
Odds Ratios
&lt;/td&gt;
&lt;td style=&#34; text-align:center; border-bottom:1px solid; font-style:italic; font-weight:normal;  &#34;&gt;
p
&lt;/td&gt;
&lt;td style=&#34; text-align:center; border-bottom:1px solid; font-style:italic; font-weight:normal;  &#34;&gt;
Odds Ratios
&lt;/td&gt;
&lt;td style=&#34; text-align:center; border-bottom:1px solid; font-style:italic; font-weight:normal;  &#34;&gt;
p
&lt;/td&gt;
&lt;td style=&#34; text-align:center; border-bottom:1px solid; font-style:italic; font-weight:normal;  &#34;&gt;
Odds Ratios
&lt;/td&gt;
&lt;td style=&#34; text-align:center; border-bottom:1px solid; font-style:italic; font-weight:normal;  col7&#34;&gt;
p
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; &#34;&gt;
(Intercept)
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.94 &lt;sup&gt;&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.976
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.01 &lt;sup&gt;***&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;strong&gt;&amp;lt;0.001&lt;/strong&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
276759408.51 &lt;sup&gt;*&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  col7&#34;&gt;
&lt;strong&gt;0.018&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; &#34;&gt;
age
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
1.04 &lt;sup&gt;*&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;strong&gt;0.024&lt;/strong&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
1.07 &lt;sup&gt;***&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;strong&gt;&amp;lt;0.001&lt;/strong&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.74 &lt;sup&gt;*&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  col7&#34;&gt;
&lt;strong&gt;0.031&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; &#34;&gt;
sex [male]
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
5.40 &lt;sup&gt;***&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;strong&gt;&amp;lt;0.001&lt;/strong&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
4.47 &lt;sup&gt;***&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;strong&gt;&amp;lt;0.001&lt;/strong&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
5.50 &lt;sup&gt;***&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  col7&#34;&gt;
&lt;strong&gt;&amp;lt;0.001&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; &#34;&gt;
chest pain [atypical&lt;br&gt;angina]
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.89 &lt;sup&gt;&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.851
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.99 &lt;sup&gt;&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  col7&#34;&gt;
0.989
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; &#34;&gt;
chest pain [non-anginal&lt;br&gt;pain]
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.88 &lt;sup&gt;&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.828
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.94 &lt;sup&gt;&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  col7&#34;&gt;
0.920
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; &#34;&gt;
chest pain [asymptomatic]
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
7.13 &lt;sup&gt;***&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;strong&gt;&amp;lt;0.001&lt;/strong&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
7.19 &lt;sup&gt;***&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  col7&#34;&gt;
&lt;strong&gt;&amp;lt;0.001&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; &#34;&gt;
max heartrate
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.97 &lt;sup&gt;***&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;strong&gt;&amp;lt;0.001&lt;/strong&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
0.85 &lt;sup&gt;**&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  col7&#34;&gt;
&lt;strong&gt;0.003&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; &#34;&gt;
age × max heartrate
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  &#34;&gt;
1.00 &lt;sup&gt;*&lt;/sup&gt;
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:center;  col7&#34;&gt;
&lt;strong&gt;0.013&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; padding-top:0.1cm; padding-bottom:0.1cm; border-top:1px solid;&#34;&gt;
Observations
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left; border-top:1px solid;&#34; colspan=&#34;2&#34;&gt;
297
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left; border-top:1px solid;&#34; colspan=&#34;2&#34;&gt;
297
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left; border-top:1px solid;&#34; colspan=&#34;2&#34;&gt;
297
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; padding-top:0.1cm; padding-bottom:0.1cm;&#34;&gt;
R&lt;sup&gt;2&lt;/sup&gt; Tjur
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left;&#34; colspan=&#34;2&#34;&gt;
0.393
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left;&#34; colspan=&#34;2&#34;&gt;
0.142
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left;&#34; colspan=&#34;2&#34;&gt;
0.409
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; text-align:left; padding-top:0.1cm; padding-bottom:0.1cm;&#34;&gt;
AIC
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left;&#34; colspan=&#34;2&#34;&gt;
289.263
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left;&#34; colspan=&#34;2&#34;&gt;
370.435
&lt;/td&gt;
&lt;td style=&#34; padding:0.2cm; text-align:left; vertical-align:top; padding-top:0.1cm; padding-bottom:0.1cm; text-align:left;&#34; colspan=&#34;2&#34;&gt;
284.599
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&#34;7&#34; style=&#34;font-style:italic; border-top:double black; text-align:right;&#34;&gt;
* p&amp;lt;0.05   ** p&amp;lt;0.01   *** p&amp;lt;0.001
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Pseudo-&lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; is a generalization of the coefficient of determination &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; often used in linear regression to judge the quality of a model. Like the &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; in linear regression, the pseudo-&lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; varies from 0 to 1, and can be interpreted as the percentage of the null deviance explained by the independent variable(s). The higher the pseudo-&lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; and the lower the AIC, the better the model.&lt;/p&gt;
&lt;p&gt;Note that there are several pseudo-&lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt;, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Likelihood ratio &lt;span class=&#34;math inline&#34;&gt;\(R^2_{L}\)&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;Cox and Snell &lt;span class=&#34;math inline&#34;&gt;\(R^2_{CS}\)&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;Nagelkerke &lt;span class=&#34;math inline&#34;&gt;\(R^2_{N}\)&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;McFadden &lt;span class=&#34;math inline&#34;&gt;\(R^2_{McF}\)&lt;/span&gt;, and&lt;/li&gt;
&lt;li&gt;Tjur &lt;span class=&#34;math inline&#34;&gt;\(R^2_{T}\)&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;tab_model()&lt;/code&gt; function gives the Tjur &lt;span class=&#34;math inline&#34;&gt;\(R^2_{T}\)&lt;/span&gt; by default.&lt;/p&gt;
&lt;p&gt;Based on the AIC and the Tjur &lt;span class=&#34;math inline&#34;&gt;\(R^2_{T}\)&lt;/span&gt;, the last model is considered as the best one among the 3 considered.&lt;/p&gt;
&lt;p&gt;Note that, even though a model is deemed the best one among the ones you have considered (based on one or several criteria), it does not necessarily mean that it fits the data well. There are several methods to check the quality of a model and to check if it is appropriate for the data at hand. This is the topic of the next section.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;quality-of-a-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Quality of a model&lt;/h2&gt;
&lt;p&gt;Usually, the goal of building a model is to be able to predict, as precisely as possible, the response variable for new data.&lt;/p&gt;
&lt;p&gt;In the next sections, we present some measures to judge the quality of a model, starting with the easiest and most intuitive one, followed by two widely used in the medical domain, and finally two other metrics common in the field of machine learning.&lt;/p&gt;
&lt;div id=&#34;validity-of-the-predictions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Validity of the predictions&lt;/h3&gt;
&lt;div id=&#34;accuracy&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Accuracy&lt;/h4&gt;
&lt;p&gt;A good way to judge the accuracy of a model is to monitor its performance on new data and count how often it predicts the correct outcome.&lt;/p&gt;
&lt;p&gt;Unfortunately, when we have access to new data, we often do not know the real outcome and we cannot therefore check if the model does a good job in predicting the outcome. The trick is to:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;train the model on the initial data frame,&lt;/li&gt;
&lt;li&gt;test the model on the exact same data (just like if it was a complete different data frame for which we do not know the outcome), and then&lt;/li&gt;
&lt;li&gt;compare the predictions made by the model to the real outcomes.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To illustrate this process, we take the model built in the previous section and test it on the initial data frame.&lt;/p&gt;
&lt;p&gt;Moreover, suppose that if the probability for the patient to develop a heart disease is below 50%, we consider that the predicted outcome is the absence of the disease, otherwise the predicted outcome is the presence of the disease.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create a vector of predicted probabilities
preds &amp;lt;- predict(m5_final,
  newdata = select(dat, -heart_disease), # remove real outcomes
  type = &amp;quot;response&amp;quot;
)

# if probability &amp;lt; threshold, patient is considered not to have the disease
preds_outcome &amp;lt;- ifelse(preds &amp;lt; 0.5,
  0,
  1
)

# transform predictions into factor and set labels
preds_outcome &amp;lt;- factor(preds_outcome,
  levels = c(0, 1),
  labels = c(&amp;quot;no disease&amp;quot;, &amp;quot;disease&amp;quot;)
)

# compare observed vs. predicted outcome
tab &amp;lt;- table(dat$heart_disease, preds_outcome,
  dnn = c(&amp;quot;observed&amp;quot;, &amp;quot;predicted&amp;quot;)
)

# print results
tab&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             predicted
## observed     no disease disease
##   no disease        132      28
##   disease            33     104&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From the contingency table of the predicted and observed outcomes, we see that the model:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;correctly predicted the absence of the disease for 132 patients,&lt;/li&gt;
&lt;li&gt;incorrectly predicted the presence of the disease for 28 patients,&lt;/li&gt;
&lt;li&gt;incorrectly predicted the absence of the disease for 33 patients, and&lt;/li&gt;
&lt;li&gt;correctly predicted the presence of the disease for 104 patients.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The percentage of correct predictions, referred as the accuracy, is the sum of the correct predictions divided by the total number of predictions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;accuracy &amp;lt;- sum(diag(tab)) / sum(tab)
accuracy&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.7946128&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This model has an accuracy of 79.5%.&lt;/p&gt;
&lt;p&gt;Although accuracy is the most intuitive and easiest way to measure a model’s predictive performance, it has some drawbacks, notably because we have to choose an &lt;em&gt;arbitrary&lt;/em&gt; threshold beyond which we classify a new observation as 1 or 0. A more detailed discussion about this can be found on Frank Harrell’s &lt;a href=&#34;https://hbiostat.org/blog/post/classification/index.html&#34; target=&#34;_blank&#34;&gt;blog&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this illustration, we chose 50% as the threshold beyond which a patient was considered as having the disease. Nonetheless, we could have chosen another threshold and the results would have been different!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sensitivity-and-specificity&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Sensitivity and specificity&lt;/h4&gt;
&lt;p&gt;If you work in the medical field, or if your research is related to medical sciences, you have probably already heard about sensitivity and specificity.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;sensitivity&lt;/strong&gt; of a classifier, also referred as the recall, measures the ability of a classifier to detect the condition when the condition is present. In our case, it is the percentage of diseased people who are correctly identified as having the disease. Formally, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[ Sensitivity = \frac{\text{True positives}}{\text{True positives} + \text{False negatives}},\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where true positives are people correctly diagnosed as ill and false negatives are people incorrectly diagnosed as healthy.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;specificity&lt;/strong&gt; of a classifier measures the ability of a classifier to correctly exclude the condition when the condition is absent. In our case, it is the percentage of healthy people who are correctly identified as not having the disease. Formally, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[Specificity = \frac{\text{True negatives}}{\text{True negatives} + \text{False positives}},\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where true negatives are people correctly diagnosed as healthy and false positives are people incorrectly diagnosed as ill.&lt;/p&gt;
&lt;p&gt;In R, sensitivity and specificity can be computed as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sensitivity
sensitivity &amp;lt;- tab[2, 2] / (tab[2, 2] + tab[2, 1])
sensitivity&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.7591241&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specificity
specificity &amp;lt;- tab[1, 1] / (tab[1, 1] + tab[1, 2])
specificity&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.825&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With our model, we obtain:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sensitivity = 75.9%, and&lt;/li&gt;
&lt;li&gt;specificity = 82.5%.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The closer the sensitivity and the specificity are to 100%, the better the model.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;auc-and-roc-curve&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;AUC and ROC curve&lt;/h3&gt;
&lt;p&gt;We have already seen that the better the quality of the model, the better the predictions.&lt;/p&gt;
&lt;p&gt;Another common and less arbitrary way to judge the quality of a model is by computing the AUC (Area Under the Curve) and plotting the ROC (Receiver Operating Characteristic) curve.&lt;/p&gt;
&lt;p&gt;This can be achieved easily thanks to the &lt;code&gt;{pROC}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(pROC)

# save roc object
res &amp;lt;- roc(heart_disease ~ fitted(m5_final),
  data = dat
)

# plot ROC curve
ggroc(res, legacy.axes = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-42-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# print AUC
res$auc&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Area under the curve: 0.87&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As the &lt;code&gt;ggroc()&lt;/code&gt; function works with layers from the &lt;code&gt;{ggplot2}&lt;/code&gt; package, we can print the AUC directly in the title of the plot of the ROC curve:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot ROC curve with AUC in title
ggroc(res, legacy.axes = TRUE) +
  labs(title = paste0(&amp;quot;AUC = &amp;quot;, round(res$auc, 2)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-43-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;These two quality metrics can be interpreted as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;in the plot, the closer the ROC curve is to the upper left-hand corner, the better the model, and&lt;/li&gt;
&lt;li&gt;the closer the AUC is to 1, the better the model.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Based on the ROC curve and the AUC, we can say that this model is good to very good. This means that the model is appropriate for these data, and that it can be useful to predict whether or not a patient will develop a heart disease!&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;reporting-results&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Reporting results&lt;/h2&gt;
&lt;p&gt;As we have seen before, odds ratios are useful when reporting results of binary logistic regressions.&lt;/p&gt;
&lt;p&gt;Computing these odds ratios together with the confidence intervals is not particularly difficult. However, presenting them in a table for a publication or a report can quickly become time consuming, in particular if you have many models and many independent variables.&lt;/p&gt;
&lt;p&gt;Luckily, there are two packages which saved me a lot of time and which I use almost every time I need to report results of a logistic regression.&lt;/p&gt;
&lt;p&gt;The first package, called &lt;code&gt;{gtsummary}&lt;/code&gt; is useful to report results of one regression at a time. The second one is the &lt;code&gt;{finalfit}&lt;/code&gt; package.&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; This packages is more appropriate if you need to report results of several regressions at a time.&lt;/p&gt;
&lt;div id=&#34;gtsummary-package&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;{gtsummary} package&lt;/h3&gt;
&lt;p&gt;Here is an example with one of the models built previously:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(gtsummary)

# print table of results
tbl_regression(m5_final, exponentiate = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;hsdigyayxw&#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;#hsdigyayxw table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#hsdigyayxw thead, #hsdigyayxw tbody, #hsdigyayxw tfoot, #hsdigyayxw tr, #hsdigyayxw td, #hsdigyayxw th {
  border-style: none;
}

#hsdigyayxw p {
  margin: 0;
  padding: 0;
}

#hsdigyayxw .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#hsdigyayxw .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;
}

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

#hsdigyayxw .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;
}

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

#hsdigyayxw .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;
}

#hsdigyayxw .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;
}

#hsdigyayxw .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;
}

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

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

#hsdigyayxw .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%;
}

#hsdigyayxw .gt_spanner_row {
  border-bottom-style: hidden;
}

#hsdigyayxw .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;
}

#hsdigyayxw .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;
}

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

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

#hsdigyayxw .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#hsdigyayxw .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;
}

#hsdigyayxw .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;
}

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

#hsdigyayxw .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#hsdigyayxw .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;
}

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

#hsdigyayxw .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;
}

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

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

#hsdigyayxw .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;
}

#hsdigyayxw .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;
}

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

#hsdigyayxw .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;
}

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

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

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

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

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

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

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

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

#hsdigyayxw .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#hsdigyayxw .gt_indent_5 {
  text-indent: 25px;
}

#hsdigyayxw .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#hsdigyayxw div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;label&#34;&gt;&lt;span class=&#39;gt_from_md&#39;&gt;&lt;strong&gt;Characteristic&lt;/strong&gt;&lt;/span&gt;&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;estimate&#34;&gt;&lt;span class=&#39;gt_from_md&#39;&gt;&lt;strong&gt;OR&lt;/strong&gt;&lt;/span&gt;&lt;span class=&#34;gt_footnote_marks&#34; style=&#34;white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/span&gt;&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;conf.low&#34;&gt;&lt;span class=&#39;gt_from_md&#39;&gt;&lt;strong&gt;95% CI&lt;/strong&gt;&lt;/span&gt;&lt;span class=&#34;gt_footnote_marks&#34; style=&#34;white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/span&gt;&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.value&#34;&gt;&lt;span class=&#39;gt_from_md&#39;&gt;&lt;strong&gt;p-value&lt;/strong&gt;&lt;/span&gt;&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;label&#34; class=&#34;gt_row gt_left&#34;&gt;age&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;0.74&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;0.55, 0.96&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;0.031&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;sex&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;    female&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;—&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;—&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;    male&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;5.50&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;2.82, 11.2&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;0.001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;chest_pain&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;    typical angina&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;—&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;—&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;    atypical angina&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;0.99&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;0.27, 3.65&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;&gt;0.9&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;    non-anginal pain&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;0.94&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;0.30, 3.07&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;&gt;0.9&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;    asymptomatic&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;7.19&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;2.44, 22.8&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;&lt;0.001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;max_heartrate&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;0.85&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;0.76, 0.94&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;0.003&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;label&#34; class=&#34;gt_row gt_left&#34;&gt;age * max_heartrate&lt;/td&gt;
&lt;td headers=&#34;estimate&#34; class=&#34;gt_row gt_center&#34;&gt;1.00&lt;/td&gt;
&lt;td headers=&#34;conf.low&#34; class=&#34;gt_row gt_center&#34;&gt;1.00, 1.00&lt;/td&gt;
&lt;td headers=&#34;p.value&#34; class=&#34;gt_row gt_center&#34;&gt;0.013&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  &lt;tfoot class=&#34;gt_footnotes&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;gt_footnote&#34; colspan=&#34;4&#34;&gt;&lt;span class=&#34;gt_footnote_marks&#34; style=&#34;white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/span&gt; &lt;span class=&#39;gt_from_md&#39;&gt;OR = Odds Ratio, CI = Confidence Interval&lt;/span&gt;&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;p&gt;What I like with this package is its ease of use, and the fact that all results are nicely formatted in a table. This is a very good starting point when I need to create a table for a publication or a report, for one regression at a time.&lt;/p&gt;
&lt;p&gt;The second package becomes interesting when you need to report results for several models at once.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;finalfit-package&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;{finalfit} package&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;{finalfit}&lt;/code&gt; package allows to report odds ratios, their confidence intervals and the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values in a very efficient way. Moreover, it is quite easy to do so for many regressions at the same time.&lt;/p&gt;
&lt;p&gt;Let me present the package by reporting results of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;all univariable binary logistic regressions that are possible with the variables available in the data frame,&lt;/li&gt;
&lt;li&gt;a multivariable binary logistic regression that includes all variables available in the data frame, and&lt;/li&gt;
&lt;li&gt;a multivariable binary logistic regression that includes only some of the variables present in the data frame.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We start with all the possible univariable binary logistic regressions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load packages
library(tidyverse)
library(gt)
library(finalfit)

# set dependent and independent variables
dependent &amp;lt;- &amp;quot;heart_disease&amp;quot;
independent &amp;lt;- c(&amp;quot;age&amp;quot;, &amp;quot;sex&amp;quot;, &amp;quot;chest_pain&amp;quot;, &amp;quot;max_heartrate&amp;quot;)

# save results of univariable logistic regressions
glmuni &amp;lt;- dat |&amp;gt;
  glmuni(dependent, independent) |&amp;gt;
  fit2df(
    explanatory_name = &amp;quot;Variables&amp;quot;,
    estimate_name = &amp;quot;Crude OR&amp;quot;,
    estimate_suffix = &amp;quot; (95% CI)&amp;quot;
  )

# print results
glmuni |&amp;gt;
  gt()&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;ewvlblrgtf&#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;#ewvlblrgtf table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#ewvlblrgtf thead, #ewvlblrgtf tbody, #ewvlblrgtf tfoot, #ewvlblrgtf tr, #ewvlblrgtf td, #ewvlblrgtf th {
  border-style: none;
}

#ewvlblrgtf p {
  margin: 0;
  padding: 0;
}

#ewvlblrgtf .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#ewvlblrgtf .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;
}

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

#ewvlblrgtf .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;
}

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

#ewvlblrgtf .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;
}

#ewvlblrgtf .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;
}

#ewvlblrgtf .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;
}

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

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

#ewvlblrgtf .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%;
}

#ewvlblrgtf .gt_spanner_row {
  border-bottom-style: hidden;
}

#ewvlblrgtf .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;
}

#ewvlblrgtf .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;
}

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

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

#ewvlblrgtf .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#ewvlblrgtf .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;
}

#ewvlblrgtf .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;
}

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

#ewvlblrgtf .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#ewvlblrgtf .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;
}

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

#ewvlblrgtf .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;
}

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

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

#ewvlblrgtf .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;
}

#ewvlblrgtf .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;
}

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

#ewvlblrgtf .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;
}

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

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

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

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

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

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

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

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

#ewvlblrgtf .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#ewvlblrgtf .gt_indent_5 {
  text-indent: 25px;
}

#ewvlblrgtf .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#ewvlblrgtf div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;Variables&#34;&gt;Variables&lt;/th&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;Crude-OR-(95%-CI)&#34;&gt;Crude OR (95% CI)&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;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;age&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;1.05 (1.03-1.08, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;sexmale&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;3.57 (2.12-6.18, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painatypical angina&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.51 (0.16-1.66, p=0.255)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painnon-anginal pain&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.63 (0.23-1.86, p=0.384)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painasymptomatic&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;6.04 (2.39-16.76, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;max_heartrate&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.96 (0.94-0.97, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;A few remarks regarding this code:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;glmuni()&lt;/code&gt; is used because we want to run univariable GLM.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;explanatory_name = &#34;Variables&#34;&lt;/code&gt; is used to rename the first column (by default it is “explanatory”).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;estimate_name = &#34;Crude OR&#34;&lt;/code&gt; is used to rename the second column and inform the reader that we are in the univariable case. In the univariable case, OR are often called crude OR because they are not adjusted for the effects of the other independent variables.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;estimate_suffix = &#34; (95% CI)&#34;&lt;/code&gt; is used to specify that it is the 95% confidence intervals which are inside the parentheses.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;gt()&lt;/code&gt; layer at the end of the code is not compulsory. It is just to make the output appears in a nice table instead of the usual format of R outputs. See more information about the &lt;code&gt;{gt}&lt;/code&gt; package in its &lt;a href=&#34;https://gt.rstudio.com/&#34; target=&#34;_blank&#34;&gt;documentation&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is how to report results of a multivariable binary logistic regression which includes all variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save results of full model
glmmulti_full &amp;lt;- dat |&amp;gt;
  glmmulti(dependent, independent) |&amp;gt;
  fit2df(
    explanatory_name = &amp;quot;Variables&amp;quot;,
    estimate_name = &amp;quot;Adjusted OR - full model&amp;quot;,
  )

# print results
glmmulti_full |&amp;gt;
  gt()&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;vtrqkpqzfa&#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;#vtrqkpqzfa table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#vtrqkpqzfa thead, #vtrqkpqzfa tbody, #vtrqkpqzfa tfoot, #vtrqkpqzfa tr, #vtrqkpqzfa td, #vtrqkpqzfa th {
  border-style: none;
}

#vtrqkpqzfa p {
  margin: 0;
  padding: 0;
}

#vtrqkpqzfa .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#vtrqkpqzfa .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;
}

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

#vtrqkpqzfa .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;
}

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

#vtrqkpqzfa .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;
}

#vtrqkpqzfa .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;
}

#vtrqkpqzfa .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;
}

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

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

#vtrqkpqzfa .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%;
}

#vtrqkpqzfa .gt_spanner_row {
  border-bottom-style: hidden;
}

#vtrqkpqzfa .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;
}

#vtrqkpqzfa .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;
}

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

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

#vtrqkpqzfa .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#vtrqkpqzfa .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;
}

#vtrqkpqzfa .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;
}

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

#vtrqkpqzfa .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#vtrqkpqzfa .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;
}

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

#vtrqkpqzfa .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;
}

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

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

#vtrqkpqzfa .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;
}

#vtrqkpqzfa .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;
}

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

#vtrqkpqzfa .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;
}

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

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

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

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

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

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

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

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

#vtrqkpqzfa .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#vtrqkpqzfa .gt_indent_5 {
  text-indent: 25px;
}

#vtrqkpqzfa .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#vtrqkpqzfa div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;Variables&#34;&gt;Variables&lt;/th&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;Adjusted-OR---full-model&#34;&gt;Adjusted OR - full model&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;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;age&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;1.04 (1.01-1.08, p=0.024)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;sexmale&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;5.40 (2.78-10.97, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painatypical angina&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;0.89 (0.25-3.19, p=0.851)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painnon-anginal pain&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;0.88 (0.29-2.81, p=0.828)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painasymptomatic&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;7.13 (2.51-22.03, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;max_heartrate&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;0.97 (0.95-0.99, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;A few remarks regarding this code:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;glmmulti()&lt;/code&gt; is used because we want to run multivariable GLM.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;estimate_name = &#34;Adjusted OR - full model&#34;&lt;/code&gt; is used to remind the reader that we are in the multivariable case with all variables included. In the multivariable case, OR are often called adjusted OR because they are adjusted for the effects of the other independent variables.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is how to report results of a multivariable binary logistic regression which includes only a selection of variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select the variables to be included in the final model
independent_final &amp;lt;- c(&amp;quot;age&amp;quot;, &amp;quot;sex&amp;quot;, &amp;quot;chest_pain&amp;quot;)

# save results of final model
glmmulti_final &amp;lt;- dat |&amp;gt;
  glmmulti(dependent, independent_final) |&amp;gt;
  fit2df(
    explanatory_name = &amp;quot;Variables&amp;quot;,
    estimate_name = &amp;quot;Adjusted OR - final model&amp;quot;,
    estimate_suffix = &amp;quot; (95% CI)&amp;quot;
  )

# print results
glmmulti_final |&amp;gt;
  gt()&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;klgxvctcfp&#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;#klgxvctcfp table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#klgxvctcfp thead, #klgxvctcfp tbody, #klgxvctcfp tfoot, #klgxvctcfp tr, #klgxvctcfp td, #klgxvctcfp th {
  border-style: none;
}

#klgxvctcfp p {
  margin: 0;
  padding: 0;
}

#klgxvctcfp .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#klgxvctcfp .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;
}

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

#klgxvctcfp .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;
}

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

#klgxvctcfp .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;
}

#klgxvctcfp .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;
}

#klgxvctcfp .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;
}

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

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

#klgxvctcfp .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%;
}

#klgxvctcfp .gt_spanner_row {
  border-bottom-style: hidden;
}

#klgxvctcfp .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;
}

#klgxvctcfp .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;
}

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

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

#klgxvctcfp .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#klgxvctcfp .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;
}

#klgxvctcfp .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;
}

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

#klgxvctcfp .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#klgxvctcfp .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;
}

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

#klgxvctcfp .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;
}

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

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

#klgxvctcfp .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;
}

#klgxvctcfp .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;
}

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

#klgxvctcfp .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;
}

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

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

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

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

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

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

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

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

#klgxvctcfp .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#klgxvctcfp .gt_indent_5 {
  text-indent: 25px;
}

#klgxvctcfp .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#klgxvctcfp div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;Variables&#34;&gt;Variables&lt;/th&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;Adjusted-OR---final-model-(95%-CI)&#34;&gt;Adjusted OR - final model (95% CI)&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;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;age&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;1.07 (1.03-1.11, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;sexmale&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;5.52 (2.88-11.07, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painatypical angina&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.82 (0.24-2.82, p=0.743)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painnon-anginal pain&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.93 (0.32-2.90, p=0.903)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_painasymptomatic&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;9.48 (3.47-28.53, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Note that you have to manually select the variables (the package will not choose for you unfortunately). The selection could be done preliminary thanks to a stepwise procedure for example.&lt;/p&gt;
&lt;p&gt;Now the most interesting part of this package:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;we can combine all these results together,&lt;/li&gt;
&lt;li&gt;in addition to some descriptive statistics for each level of the dependent variable!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are all results combined together and displayed in a table:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save descriptive statistics
summary &amp;lt;- dat |&amp;gt;
  summary_factorlist(dependent, independent, fit_id = TRUE)

# save results of regressions
output &amp;lt;- summary |&amp;gt;
  finalfit_merge(glmuni) |&amp;gt;
  finalfit_merge(glmmulti_full) |&amp;gt;
  finalfit_merge(glmmulti_final)

# print all results
output |&amp;gt;
  dplyr::select(-fit_id, -index) |&amp;gt;
  dplyr::rename(
    Variables = label,
    &amp;quot; &amp;quot; = levels
  ) |&amp;gt;
  gt()&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;szrjblstrk&#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;#szrjblstrk table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#szrjblstrk thead, #szrjblstrk tbody, #szrjblstrk tfoot, #szrjblstrk tr, #szrjblstrk td, #szrjblstrk th {
  border-style: none;
}

#szrjblstrk p {
  margin: 0;
  padding: 0;
}

#szrjblstrk .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#szrjblstrk .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;
}

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

#szrjblstrk .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;
}

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

#szrjblstrk .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;
}

#szrjblstrk .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;
}

#szrjblstrk .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;
}

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

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

#szrjblstrk .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%;
}

#szrjblstrk .gt_spanner_row {
  border-bottom-style: hidden;
}

#szrjblstrk .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;
}

#szrjblstrk .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;
}

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

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

#szrjblstrk .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#szrjblstrk .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;
}

#szrjblstrk .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;
}

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

#szrjblstrk .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#szrjblstrk .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;
}

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

#szrjblstrk .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;
}

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

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

#szrjblstrk .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;
}

#szrjblstrk .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;
}

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

#szrjblstrk .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;
}

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

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

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

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

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

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

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

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

#szrjblstrk .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#szrjblstrk .gt_indent_5 {
  text-indent: 25px;
}

#szrjblstrk .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#szrjblstrk div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;Variables&#34;&gt;Variables&lt;/th&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;a-&#34;&gt; &lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;no-disease&#34;&gt;no disease&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;disease&#34;&gt;disease&lt;/th&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;Crude-OR-(95%-CI)&#34;&gt;Crude OR (95% CI)&lt;/th&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;Adjusted-OR---full-model&#34;&gt;Adjusted OR - full model&lt;/th&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;Adjusted-OR---final-model-(95%-CI)&#34;&gt;Adjusted OR - final model (95% CI)&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;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;age&lt;/td&gt;
&lt;td headers=&#34; &#34; class=&#34;gt_row gt_left&#34;&gt;Mean (SD)&lt;/td&gt;
&lt;td headers=&#34;no disease&#34; class=&#34;gt_row gt_right&#34;&gt;52.6 (9.6)&lt;/td&gt;
&lt;td headers=&#34;disease&#34; class=&#34;gt_row gt_right&#34;&gt;56.8 (7.9)&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;1.05 (1.03-1.08, p&amp;lt;0.001)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;1.04 (1.01-1.08, p=0.024)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;1.07 (1.03-1.11, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;sex&lt;/td&gt;
&lt;td headers=&#34; &#34; class=&#34;gt_row gt_left&#34;&gt;female&lt;/td&gt;
&lt;td headers=&#34;no disease&#34; class=&#34;gt_row gt_right&#34;&gt;71 (44.4)&lt;/td&gt;
&lt;td headers=&#34;disease&#34; class=&#34;gt_row gt_right&#34;&gt;25 (18.2)&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;-&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;-&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;-&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;&lt;/td&gt;
&lt;td headers=&#34; &#34; class=&#34;gt_row gt_left&#34;&gt;male&lt;/td&gt;
&lt;td headers=&#34;no disease&#34; class=&#34;gt_row gt_right&#34;&gt;89 (55.6)&lt;/td&gt;
&lt;td headers=&#34;disease&#34; class=&#34;gt_row gt_right&#34;&gt;112 (81.8)&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;3.57 (2.12-6.18, p&amp;lt;0.001)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;5.40 (2.78-10.97, p&amp;lt;0.001)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;5.52 (2.88-11.07, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;chest_pain&lt;/td&gt;
&lt;td headers=&#34; &#34; class=&#34;gt_row gt_left&#34;&gt;typical angina&lt;/td&gt;
&lt;td headers=&#34;no disease&#34; class=&#34;gt_row gt_right&#34;&gt;16 (10.0)&lt;/td&gt;
&lt;td headers=&#34;disease&#34; class=&#34;gt_row gt_right&#34;&gt;7 (5.1)&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;-&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;-&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;-&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;&lt;/td&gt;
&lt;td headers=&#34; &#34; class=&#34;gt_row gt_left&#34;&gt;atypical angina&lt;/td&gt;
&lt;td headers=&#34;no disease&#34; class=&#34;gt_row gt_right&#34;&gt;40 (25.0)&lt;/td&gt;
&lt;td headers=&#34;disease&#34; class=&#34;gt_row gt_right&#34;&gt;9 (6.6)&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.51 (0.16-1.66, p=0.255)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;0.89 (0.25-3.19, p=0.851)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.82 (0.24-2.82, p=0.743)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;&lt;/td&gt;
&lt;td headers=&#34; &#34; class=&#34;gt_row gt_left&#34;&gt;non-anginal pain&lt;/td&gt;
&lt;td headers=&#34;no disease&#34; class=&#34;gt_row gt_right&#34;&gt;65 (40.6)&lt;/td&gt;
&lt;td headers=&#34;disease&#34; class=&#34;gt_row gt_right&#34;&gt;18 (13.1)&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.63 (0.23-1.86, p=0.384)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;0.88 (0.29-2.81, p=0.828)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.93 (0.32-2.90, p=0.903)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;&lt;/td&gt;
&lt;td headers=&#34; &#34; class=&#34;gt_row gt_left&#34;&gt;asymptomatic&lt;/td&gt;
&lt;td headers=&#34;no disease&#34; class=&#34;gt_row gt_right&#34;&gt;39 (24.4)&lt;/td&gt;
&lt;td headers=&#34;disease&#34; class=&#34;gt_row gt_right&#34;&gt;103 (75.2)&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;6.04 (2.39-16.76, p&amp;lt;0.001)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;7.13 (2.51-22.03, p&amp;lt;0.001)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;9.48 (3.47-28.53, p&amp;lt;0.001)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Variables&#34; class=&#34;gt_row gt_left&#34;&gt;max_heartrate&lt;/td&gt;
&lt;td headers=&#34; &#34; class=&#34;gt_row gt_left&#34;&gt;Mean (SD)&lt;/td&gt;
&lt;td headers=&#34;no disease&#34; class=&#34;gt_row gt_right&#34;&gt;158.6 (19.0)&lt;/td&gt;
&lt;td headers=&#34;disease&#34; class=&#34;gt_row gt_right&#34;&gt;139.1 (22.7)&lt;/td&gt;
&lt;td headers=&#34;Crude OR (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;0.96 (0.94-0.97, p&amp;lt;0.001)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - full model&#34; class=&#34;gt_row gt_left&#34;&gt;0.97 (0.95-0.99, p&amp;lt;0.001)&lt;/td&gt;
&lt;td headers=&#34;Adjusted OR - final model (95% CI)&#34; class=&#34;gt_row gt_left&#34;&gt;-&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;A few remarks regarding this code:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;summary_factorlist(dependent, independent, fit_id = TRUE)&lt;/code&gt; is used to compute the descriptive statistics by group of the dependent variable.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;finalfit_merge()&lt;/code&gt; is used to merge results together.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dplyr::select(-fit_id, -index)&lt;/code&gt; is used to remove unnecessary columns.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dplyr::rename(Variables = label, &#34; &#34; = levels)&lt;/code&gt; is used to renames some columns.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And finally, a few remarks regarding the resulting table:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The first column gives the name of the variables.&lt;/li&gt;
&lt;li&gt;The second column specifies:
&lt;ul&gt;
&lt;li&gt;for qualitative variables: the levels&lt;/li&gt;
&lt;li&gt;for quantitative variables: that it is the mean and the standard deviation (SD) which will be computed in the next two columns&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;The third and fourth columns give the descriptive statistics for each level of the dependent variable:
&lt;ul&gt;
&lt;li&gt;for qualitative variables: the number of cases, and in parentheses the frequencies by column&lt;/li&gt;
&lt;li&gt;for quantitative variables: the mean, and in parentheses the standard deviation&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;The last three columns give the OR, and in parentheses the 95% CI of the OR and the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value (for the univariable and the two multivariable models, respectively).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For your convenience, here is the full code so you can copy paste it easily in case you want to reproduce the process:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load packages
library(tidyverse)
library(gt)
library(finalfit)

# set variables
dependent &amp;lt;- &amp;quot;heart_disease&amp;quot;
independent &amp;lt;- c(&amp;quot;age&amp;quot;, &amp;quot;sex&amp;quot;, &amp;quot;chest_pain&amp;quot;, &amp;quot;max_heartrate&amp;quot;)
independent_final &amp;lt;- c(&amp;quot;age&amp;quot;, &amp;quot;sex&amp;quot;, &amp;quot;chest_pain&amp;quot;)

# save descriptive statistics
summary &amp;lt;- dat |&amp;gt;
  summary_factorlist(dependent, independent, fit_id = TRUE)

# save results of univariable logistic regressions
glmuni &amp;lt;- dat |&amp;gt;
  glmuni(dependent, independent) |&amp;gt;
  fit2df(
    explanatory_name = &amp;quot;Variables&amp;quot;,
    estimate_name = &amp;quot;Crude OR&amp;quot;,
    estimate_suffix = &amp;quot; (95% CI)&amp;quot;
  )

# save results of full model
glmmulti_full &amp;lt;- dat |&amp;gt;
  glmmulti(dependent, independent) |&amp;gt;
  fit2df(
    explanatory_name = &amp;quot;Variables&amp;quot;,
    estimate_name = &amp;quot;Adjusted OR - full model&amp;quot;,
  )

# save results of final model
glmmulti_final &amp;lt;- dat |&amp;gt;
  glmmulti(dependent, independent_final) |&amp;gt;
  fit2df(
    explanatory_name = &amp;quot;Variables&amp;quot;,
    estimate_name = &amp;quot;Adjusted OR - final model&amp;quot;,
    estimate_suffix = &amp;quot; (95% CI)&amp;quot;
  )

# save merged results
output &amp;lt;- summary |&amp;gt;
  finalfit_merge(glmuni) |&amp;gt;
  finalfit_merge(glmmulti_full) |&amp;gt;
  finalfit_merge(glmmulti_final)

# print all results
output |&amp;gt;
  dplyr::select(-fit_id, -index) |&amp;gt;
  dplyr::rename(
    Variables = label,
    &amp;quot; &amp;quot; = levels
  ) |&amp;gt;
  gt()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Last but not least, the &lt;code&gt;or_plot()&lt;/code&gt; function, also available from the &lt;code&gt;{finalfit}&lt;/code&gt; package, is useful to visualize all odds ratio and their 95% confidence intervals:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat |&amp;gt; or_plot(dependent, independent,
  table_text_size = 3.5 # reduce text size
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-50-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Here is how to read this plot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The squares represent the OR, and the whiskers their 95% CI.&lt;/li&gt;
&lt;li&gt;When the 95% CI crosses the vertical dashed line, it means that the OR is not significantly different from 1 (at the 5% significance level). In these cases, we cannot reject the hypothesis of no association with the dependent variable.&lt;/li&gt;
&lt;li&gt;When the 95% CI does not cross the vertical dashed line, it means that the OR is significantly different from 1. In these cases:
&lt;ul&gt;
&lt;li&gt;if the square is located to the right of the vertical dashed line, there is a positive relationship between the outcome and the independent variable (known as a risk factor), and&lt;/li&gt;
&lt;li&gt;if the square is located to the left of the vertical dashed line, there is a negative relationship between the outcome and the independent variable (known as a protective factor).&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The plot confirms what was obtained above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;age is a risk factor for heart disease,&lt;/li&gt;
&lt;li&gt;maximum heart rate achieved is a protective factor for heart disease, and&lt;/li&gt;
&lt;li&gt;being a male and suffering from asymptomatic chest pain are both risk factors of heart disease.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Be careful that sometimes the square is too big to see the whiskers of the 95% CI. This is the case for the variables &lt;code&gt;max_heartrate&lt;/code&gt; and &lt;code&gt;age&lt;/code&gt;. In these cases, it is better to check the significance of the OR thanks to their 95% CI or the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values printed in parentheses.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conditions-of-application&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Conditions of application&lt;/h2&gt;
&lt;p&gt;For results to be valid and interpretable, a binary logistic regression requires:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the dependent variable to be binary,&lt;/li&gt;
&lt;li&gt;independence of the observations: no repeated measurements or matched data, otherwise generalize linear mixed effect models (GLMM) should be used,&lt;/li&gt;
&lt;li&gt;linearity of continuous independent variables and the log-odds outcome: take age and heart disease as an example. If heart disease is more frequent or less frequent as age rises, the model will work well. However, if children and the elderly are at high risk of having a heart disease, but those in middle years are not, then the relationship is not linear, or not monotonic, meaning that the response does not only go in one direction,&lt;/li&gt;
&lt;li&gt;a sufficiently large sample size (for confidence intervals and hypothesis tests to be valid), and&lt;/li&gt;
&lt;li&gt;no multicollinearity: independent variables should not be highly correlated with each other, otherwise coefficients and OR can become unstable.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here is how to verify each of them:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;this is obvious; check if the dependent variable has indeed only two levels,&lt;/li&gt;
&lt;li&gt;this is often not tested formally, but verified through the design of the experiment,&lt;/li&gt;
&lt;li&gt;quantitative independent variables should have a linear relationship between their log-odds and their observed values. A visual check is sufficient, see below with age, maximum heart rate achieved and model &lt;code&gt;m3&lt;/code&gt; as example:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# linearity to the log-odds?
dat |&amp;gt;
  dplyr::select(age, max_heartrate) |&amp;gt;
  mutate(log_odds = predict(m3)) |&amp;gt;
  pivot_longer(-log_odds) |&amp;gt;
  ggplot(aes(log_odds, value)) +
  geom_point() +
  geom_smooth(method = &amp;quot;lm&amp;quot;) +
  facet_wrap(~name)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/index_files/figure-html/unnamed-chunk-51-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;4&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;in practice, it is recommended to have at least 10 times as many events as parameters in the model, and&lt;/li&gt;
&lt;li&gt;the variance inflation factors (VIF) is a well known measure of multicollinearity. It should be below 10 or 5, depending on the field of research. VIF can be computed with the &lt;code&gt;vif()&lt;/code&gt; function, available in the &lt;code&gt;{car}&lt;/code&gt; package:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(car)

# compute VIF for model m3
vif(m3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                   GVIF Df GVIF^(1/(2*Df))
## age           1.205246  1        1.097837
## sex           1.155071  1        1.074742
## chest_pain    1.113010  3        1.018005
## max_heartrate 1.143125  1        1.069170&lt;/code&gt;&lt;/pre&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;In this relatively long and detailed post, we covered several important points about binary logistic regression. First, when to use such models and what is the difference with linear models, how to implement it in R, and how to interpret and report results. We ended by discussing about model selection, how to judge the quality of fit of a logistic regression, and its underlying assumptions.&lt;/p&gt;
&lt;p&gt;I now hope that (univariable and multivariable) binary logistic regressions in R no longer hold any secrets for you.&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;Thanks to Claire from DellaData.fr for introducing me to this package.&lt;a href=&#34;#fnref1&#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>What is the probability that two persons have the same initials?</title>
      <link>https://statsandr.com/blog/what-is-the-probability-that-two-persons-have-the-same-initials/</link>
      <pubDate>Wed, 06 Dec 2023 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/what-is-the-probability-that-two-persons-have-the-same-initials/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-likely-is-it&#34; id=&#34;toc-how-likely-is-it&#34;&gt;How likely is it?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#for-our-team&#34; id=&#34;toc-for-our-team&#34;&gt;For our team&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#for-teams-of-different-sizes&#34; id=&#34;toc-for-teams-of-different-sizes&#34;&gt;For teams of different sizes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#verification&#34; id=&#34;toc-verification&#34;&gt;Verification&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#for-our-team-1&#34; id=&#34;toc-for-our-team-1&#34;&gt;For our team&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#for-teams-of-different-sizes-1&#34; id=&#34;toc-for-teams-of-different-sizes-1&#34;&gt;For teams of different sizes&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;images/what-is-the-probability-that-two-persons-have-the-same-initials.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Last week, I joined a team to work on a collaborative project. The team was already established for a few months, with several scientists working together on the project. For simplicity, they used to sign documents, mention colleagues in emails, etc. with their initials (the first letter of their first name followed by the first letter of their last name).&lt;/p&gt;
&lt;p&gt;A couple of days after joining the project, when I needed to sign my first document with my initials, we realized that another person in the team had the exact same initials than me.&lt;/p&gt;
&lt;p&gt;This was not really an issue, as we decided that I would write my initials backward, that is, “SA” instead of “AS”, and the other person would keep signing with “AS” as usual.&lt;/p&gt;
&lt;p&gt;It could have stopped here. However, the idea to write a post about this rather trivial anecdote came to me when the team leader claimed, in the middle of a meeting: “That’s very unfortunate that you two have the same initials! What are the chances of this happening to us?!”.&lt;/p&gt;
&lt;p&gt;We spent a couple of minutes trying to estimate this probability, which in the end were mostly based on our intuitions rather than on a formal calculation. This piqued my curiosity.&lt;/p&gt;
&lt;p&gt;Given that the project we are working on requires the use of simulations, I decided to focus on answering this question via simulations in R. That being said, as for most simulations, it is a good practice to verify these results. This is done using &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/&#34;&gt;probability theory&lt;/a&gt;. This comparison will allow to assess the truthfulness of results obtained through simulations.&lt;/p&gt;
&lt;p&gt;Furthermore, I thought that it would be a nice way to illustrate methods not often presented in my posts: for loops, replications and writing functions in R.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-likely-is-it&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How likely is it?&lt;/h1&gt;
&lt;p&gt;Before answering the question raised by the team leader, there are three things to note:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Although the team leader was curious to know the probability that &lt;em&gt;exactly two persons&lt;/em&gt; have the same initials, we are actually more interested in the probability that &lt;em&gt;at least two persons&lt;/em&gt; have the same initials (as the problem also occurs if more than two persons within a team have the same initials).&lt;/li&gt;
&lt;li&gt;The team consists of 8 people.&lt;/li&gt;
&lt;li&gt;We restrict ourselves to two-letters initials (the first letter being the first letter of the first name, the second letter being the first letter of the last name). This means that middle names are not taken into account, and only the first letter is considered for compound names.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In this post, we will show how to compute this probability:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;in our context, that is, for a team of 8 persons, and&lt;/li&gt;
&lt;li&gt;for completeness, for teams of all sizes from 2 to 100 persons.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As stated in the introduction, we will compute these probabilities first through simulations and then through probability theory.&lt;/p&gt;
&lt;div id=&#34;for-our-team&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;For our team&lt;/h2&gt;
&lt;p&gt;We start by creating a vector of size 8, corresponding to the initials of a team of 8 persons randomly sampled among all 26 letters of the Latin alphabet:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of persons
n_persons &amp;lt;- 8

# create vector of initials
initials &amp;lt;- replicate(
  n = n_persons, # number of replications
  paste0(sample(LETTERS, size = 1), sample(LETTERS, size = 1)) # sample letters
)

# display initials
initials&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;UJ&amp;quot; &amp;quot;MN&amp;quot; &amp;quot;XD&amp;quot; &amp;quot;CY&amp;quot; &amp;quot;BB&amp;quot; &amp;quot;ZB&amp;quot; &amp;quot;CU&amp;quot; &amp;quot;HQ&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# are there duplicates?
any(duplicated(initials))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As we can see, everyone has different initials in this simulated team of 8 persons, but this will not always be the case.&lt;/p&gt;
&lt;p&gt;To estimate, via simulations, how likely is that at least two persons have the same initials among the team, we need to replicate this vector of 8 sampled initials a large number of times (say 1,000 replications):&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;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of replications
reps &amp;lt;- 1000

# create and save replications
dat &amp;lt;- replicate(
  n = reps, # number of replications
  replicate(n_persons, paste0(sample(LETTERS, size = 1), sample(LETTERS, size = 1)))
)

# dimensions
dim(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]    8 1000&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# display first 4 simulated teams
dat[, 1:4]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3] [,4]
## [1,] &amp;quot;VA&amp;quot; &amp;quot;BU&amp;quot; &amp;quot;LU&amp;quot; &amp;quot;PT&amp;quot;
## [2,] &amp;quot;JG&amp;quot; &amp;quot;SM&amp;quot; &amp;quot;HM&amp;quot; &amp;quot;OL&amp;quot;
## [3,] &amp;quot;BY&amp;quot; &amp;quot;NA&amp;quot; &amp;quot;VJ&amp;quot; &amp;quot;OT&amp;quot;
## [4,] &amp;quot;RT&amp;quot; &amp;quot;CM&amp;quot; &amp;quot;WT&amp;quot; &amp;quot;YT&amp;quot;
## [5,] &amp;quot;PS&amp;quot; &amp;quot;CT&amp;quot; &amp;quot;NB&amp;quot; &amp;quot;QJ&amp;quot;
## [6,] &amp;quot;MG&amp;quot; &amp;quot;KR&amp;quot; &amp;quot;SV&amp;quot; &amp;quot;US&amp;quot;
## [7,] &amp;quot;PL&amp;quot; &amp;quot;SN&amp;quot; &amp;quot;PN&amp;quot; &amp;quot;XW&amp;quot;
## [8,] &amp;quot;NJ&amp;quot; &amp;quot;BR&amp;quot; &amp;quot;DD&amp;quot; &amp;quot;ZC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The result is a matrix of 8 rows and 1000 columns, where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;each rows corresponds to the sampled initials of a person, and&lt;/li&gt;
&lt;li&gt;each column corresponds to one simulated team of 8 people.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For better readability, we rename:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the row names as &lt;code&gt;M1&lt;/code&gt; to &lt;code&gt;M8&lt;/code&gt;, corresponding to persons 1 to 8, and&lt;/li&gt;
&lt;li&gt;the column names as &lt;code&gt;T1&lt;/code&gt; to &lt;code&gt;T1000&lt;/code&gt;, corresponding to teams 1 to 1000.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# rename rows
rownames(dat) &amp;lt;- paste0(&amp;quot;M&amp;quot;, 1:n_persons)

# rename columns
colnames(dat) &amp;lt;- paste0(&amp;quot;T&amp;quot;, 1:reps)

# display first 4 simulated teams
dat[, 1:4]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    T1   T2   T3   T4  
## M1 &amp;quot;VA&amp;quot; &amp;quot;BU&amp;quot; &amp;quot;LU&amp;quot; &amp;quot;PT&amp;quot;
## M2 &amp;quot;JG&amp;quot; &amp;quot;SM&amp;quot; &amp;quot;HM&amp;quot; &amp;quot;OL&amp;quot;
## M3 &amp;quot;BY&amp;quot; &amp;quot;NA&amp;quot; &amp;quot;VJ&amp;quot; &amp;quot;OT&amp;quot;
## M4 &amp;quot;RT&amp;quot; &amp;quot;CM&amp;quot; &amp;quot;WT&amp;quot; &amp;quot;YT&amp;quot;
## M5 &amp;quot;PS&amp;quot; &amp;quot;CT&amp;quot; &amp;quot;NB&amp;quot; &amp;quot;QJ&amp;quot;
## M6 &amp;quot;MG&amp;quot; &amp;quot;KR&amp;quot; &amp;quot;SV&amp;quot; &amp;quot;US&amp;quot;
## M7 &amp;quot;PL&amp;quot; &amp;quot;SN&amp;quot; &amp;quot;PN&amp;quot; &amp;quot;XW&amp;quot;
## M8 &amp;quot;NJ&amp;quot; &amp;quot;BR&amp;quot; &amp;quot;DD&amp;quot; &amp;quot;ZC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now need to compute, among the 1000 teams simulated, how many of them have at least two persons with the same initials:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# transform to data frame
dat &amp;lt;- as.data.frame(dat)

# save which teams have duplicates
duplicates &amp;lt;- rep(NA, reps) # create empty vector
for (i in 1:reps) { # for loop over i from 1 to 1,000
  duplicates[i] &amp;lt;- any(duplicated(dat[, i])) # save results TRUE/FALSE in duplicates vector
}

# count how many teams have duplicates
sum(duplicates)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 41&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, for each column of our data frame &lt;code&gt;dat&lt;/code&gt; (from the first to the 1000th column), we ask whether there are duplicates or not. This is done repeatedly over all columns thanks to a for loop. For each column, the result is &lt;code&gt;TRUE&lt;/code&gt; if there are duplicates, otherwise it is &lt;code&gt;FALSE&lt;/code&gt;. The result of each iteration is saved in the &lt;code&gt;duplicates&lt;/code&gt; vector. As &lt;code&gt;TRUE = 1&lt;/code&gt; and &lt;code&gt;FALSE = 0&lt;/code&gt; in R, we can then count how many columns (and thus teams) have duplicates by summing the number of &lt;code&gt;TRUE&lt;/code&gt; in the &lt;code&gt;duplicates&lt;/code&gt; vector.&lt;/p&gt;
&lt;p&gt;As we can see from the output above, among the 1000 simulated teams, 41 of them have duplicates, that is, 41 of them have at least two persons with the same initials.&lt;/p&gt;
&lt;p&gt;Therefore, based on the simulations, we can expect the probability that at least two persons with the same initials in a team of 8 persons to be close to 4.1%.&lt;/p&gt;
&lt;p&gt;This is a good starting point. Notice, however, that I wrote close to 4.1% because this probability will vary each time it is computed via simulations.&lt;/p&gt;
&lt;p&gt;For instance, if we repeat the exact same process a second time:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create and save replications
dat &amp;lt;- replicate(
  n = reps, # number of replications
  replicate(n_persons, paste0(sample(LETTERS, size = 1), sample(LETTERS, size = 1)))
)

# transform to data frame
dat &amp;lt;- as.data.frame(dat)

# save which teams have duplicates
duplicates &amp;lt;- rep(NA, reps) # create empty vector
for (i in 1:reps) { # for loop over i from 1 to 1,000
  duplicates[i] &amp;lt;- any(duplicated(dat[, i])) # save results in the duplicates vector (as TRUE/FALSE)
}

# count how many teams have duplicates
sum(duplicates)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 44&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now find a probability of 4.4%. This is not an error, but it is due to randomness when sampling initials.&lt;/p&gt;
&lt;p&gt;Luckily, we can make the computation of this probability more robust thanks to replications. Intuitively, it works as follows. We repeat the same computation multiple times, giving us a range of possible probabilities. This allows us to assess the uncertainty of our result, and understand how the probability might vary due to taking different random samples of initials.&lt;/p&gt;
&lt;p&gt;So the goal is to compute our probability multiple times (say 100 times), and see its distribution.&lt;/p&gt;
&lt;p&gt;To repeat the same computation multiple times, it is best to write a function in order to avoid copy pasting the same code over and over. So we first write a function (called &lt;code&gt;initials&lt;/code&gt;) which computes the probability that at least two persons share the same initials among a team of &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; people:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;initials &amp;lt;- function(n_persons, reps = 1000) {
  # simulate data
  dat &amp;lt;- as.data.frame(replicate(
    reps,
    replicate(n_persons, paste0(sample(LETTERS, size = 1), sample(LETTERS, size = 1)))
  ))

  # save which teams have duplicates
  duplicates &amp;lt;- rep(NA, reps)
  for (i in 1:reps) {
    duplicates[i] &amp;lt;- any(duplicated(dat[, i]))
  }

  # proportion of teams with duplicates
  return(mean(duplicates))
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A function in R requires to include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the parameters inside &lt;code&gt;()&lt;/code&gt;, and&lt;/li&gt;
&lt;li&gt;the computation inside &lt;code&gt;{}&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can then use our function to compute the probability that at least two persons share the same initials among a team of 8 people. And we combine it with the &lt;code&gt;replicate()&lt;/code&gt; function to compute this probability 100 times.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# compute and save probabilities
probs &amp;lt;- replicate(100, initials(n_persons = 8))

# display probabilities
probs&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   [1] 0.032 0.037 0.040 0.043 0.033 0.042 0.039 0.047 0.045 0.038 0.052 0.042
##  [13] 0.042 0.040 0.023 0.044 0.041 0.039 0.036 0.048 0.041 0.037 0.027 0.030
##  [25] 0.052 0.038 0.043 0.035 0.038 0.045 0.047 0.044 0.030 0.036 0.036 0.048
##  [37] 0.038 0.045 0.044 0.034 0.031 0.043 0.045 0.034 0.049 0.047 0.051 0.036
##  [49] 0.051 0.040 0.043 0.044 0.038 0.049 0.043 0.050 0.035 0.043 0.048 0.038
##  [61] 0.041 0.044 0.039 0.045 0.033 0.057 0.036 0.043 0.041 0.041 0.041 0.041
##  [73] 0.038 0.044 0.031 0.034 0.049 0.041 0.040 0.034 0.032 0.036 0.049 0.047
##  [85] 0.048 0.038 0.038 0.037 0.036 0.037 0.043 0.040 0.026 0.049 0.046 0.044
##  [97] 0.048 0.038 0.026 0.029&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we visualize the distribution of these 100 probabilities thanks to a histogram and a boxplot (with the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;{ggplot2} package&lt;/a&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# visualize distribution of the computed probabilities
# build and save plots
library(ggplot2)

p1 &amp;lt;- ggplot(mapping = aes(x = probs)) +
  geom_histogram(color = &amp;quot;black&amp;quot;, fill = &amp;quot;steelblue&amp;quot;, bins = 8) +
  labs(
    x = &amp;quot;Probabilities&amp;quot;,
    y = &amp;quot;Frequencies&amp;quot;
  ) +
  scale_x_continuous(labels = scales::percent) # format x-axis in %

p2 &amp;lt;- ggplot(mapping = aes(x = probs)) +
  geom_boxplot(color = &amp;quot;black&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  labs(x = &amp;quot;Probabilities&amp;quot;) +
  theme(
    axis.text.y = element_blank(),
    axis.ticks.y = element_blank()
  ) +
  scale_x_continuous(labels = scales::percent) # format x-axis in %

# combine plots
library(patchwork)

p1 + p2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-the-probability-that-two-persons-have-the-same-initials/index_files/figure-html/unnamed-chunk-8-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;These two plots show that the probability that at least two persons share the same initials among a team of 8 people is most likely between 3.5% and 4.5%.&lt;/p&gt;
&lt;p&gt;For the record, during the meeting at the root of all this thinking, most of us thought that it was much less likely. Indeed, I believe we were tempted to compute the probability that someone who joins the team has “AS” as initials. This is indeed much less likely, as the probability is only &lt;span class=&#34;math inline&#34;&gt;\(\frac{1}{26} \times \frac{1}{26} \simeq 0.15\%\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;However, this does not take into account the fact:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;that the newcomer can have the same initials as any other person, and&lt;/li&gt;
&lt;li&gt;that it is not only the newcomer who can have the same initials as another person (2 people already working in the team when the newcomer arrives could have the same initials as well).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you are puzzled by this finding, I recommend reading about the &lt;a href=&#34;https://en.wikipedia.org/wiki/Birthday_problem&#34; target=&#34;_blank&#34;&gt;birthday’s paradox&lt;/a&gt;. The birthday’s paradox states that the probability of two people sharing the same birthday becomes surprisingly high with a relatively small group of individuals. In practice, in a group of just 23 people, there is a greater than 50% chance that at least two individuals share the same birthday, illustrating our counterintuitive intuitions about the likelihood of such coincidences. This phenomenon arises due to the multitude of possible birthday pairs within the group, similar to the multitude of possible pairs if initials within a team.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;for-teams-of-different-sizes&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;For teams of different sizes&lt;/h2&gt;
&lt;p&gt;We are now interested in computing this probability not just for a team of 8 persons, but for teams of different sizes. We can do this with the help of our function defined earlier.&lt;/p&gt;
&lt;p&gt;For the illustration, let’s compute the probability that at least two persons have the same initials, for teams of 2 and up to 100 persons:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# set lower and upper bounds of number of persons
min_persons &amp;lt;- 2
max_persons &amp;lt;- 100

# create empty vector of probabilities
probs &amp;lt;- rep(NA, length(min_persons:max_persons))

# compute and save probabilities for teams of size 2 to 100
for (i in min_persons:max_persons) {
  probs[i] &amp;lt;- initials(n_persons = i)
}

# display probabilities
probs&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   [1]    NA 0.001 0.005 0.013 0.012 0.019 0.036 0.040 0.047 0.057 0.074 0.083
##  [13] 0.103 0.128 0.158 0.166 0.178 0.215 0.232 0.260 0.275 0.296 0.300 0.329
##  [25] 0.357 0.392 0.405 0.405 0.439 0.478 0.495 0.536 0.535 0.563 0.578 0.599
##  [37] 0.653 0.656 0.686 0.693 0.715 0.711 0.767 0.760 0.786 0.784 0.814 0.817
##  [49] 0.825 0.826 0.842 0.845 0.867 0.893 0.901 0.920 0.919 0.911 0.917 0.942
##  [61] 0.950 0.951 0.946 0.947 0.969 0.959 0.965 0.964 0.977 0.984 0.977 0.977
##  [73] 0.985 0.978 0.986 0.981 0.989 0.991 0.989 0.988 0.992 0.993 0.994 0.996
##  [85] 0.997 0.995 0.994 0.999 0.999 0.999 1.000 0.999 0.997 1.000 0.999 0.999
##  [97] 0.999 1.000 1.000 0.999&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are left with storing these probabilities together with the number of persons in the team in a data frame:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create data frame with saved probabilities and number of persons
dat_plot_sim &amp;lt;- data.frame(
  n_persons = (min_persons - 1):max_persons,
  prob = probs
)

# display first 6 rows
head(dat_plot_sim)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   n_persons  prob
## 1         1    NA
## 2         2 0.001
## 3         3 0.005
## 4         4 0.013
## 5         5 0.012
## 6         6 0.019&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Of course, two people having the same initials in a team of 1 (if we can call this a team…) is impossible.&lt;/p&gt;
&lt;p&gt;An event which is impossible has a probability equal to 0. We thus impute this probability in our data frame, in the first row:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# set proba = 0 when n_person = 1
dat_plot_sim[1, 2] &amp;lt;- 0

# display first 6 rows
head(dat_plot_sim)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   n_persons  prob
## 1         1 0.000
## 2         2 0.001
## 3         3 0.005
## 4         4 0.013
## 5         5 0.012
## 6         6 0.019&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we visualize these probabilities in function of the number of persons in the team:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# visualize probabilities
ggplot(dat_plot_sim) +
  aes(x = n_persons, y = probs) +
  geom_line(linewidth = 1) +
  labs(
    x = &amp;quot;# of persons in the team&amp;quot;,
    y = &amp;quot;Probability&amp;quot;,
    title = &amp;quot;What is the probability that at least 2 persons have the same initials?&amp;quot;
  ) +
  scale_y_continuous(labels = scales::percent) # format y-axis in %&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-the-probability-that-two-persons-have-the-same-initials/index_files/figure-html/unnamed-chunk-12-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the plot above, we see that the probability that at least two persons have the same initials reaches 50% when the team exceeds around 30 people.&lt;/p&gt;
&lt;p&gt;Moreover, notice that this probability becomes close to 100% when the team reaches around 75 people.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;verification&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Verification&lt;/h1&gt;
&lt;p&gt;For the sake of completeness, we now compare results obtained through simulations with results obtained from probability theory.&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;We first define the function that will be used to compare results found above:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# define function
have_same &amp;lt;- function(s, n) {
  sample_space &amp;lt;- s
  probability &amp;lt;- 1
  for (i in 0:(n - 1)) {
    probability &amp;lt;- probability * (sample_space - i) / sample_space
  }
  1 - probability
}&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;for-our-team-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;For our team&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of possible two-letter initials
n_initials &amp;lt;- 26^2

# apply function
have_same(n_initials, n_persons)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.0407218&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The probability that at least two persons have the same initials in a team of 8 is 4.07%. This is close to the probability found with simulations, and within the range of 3.5%–4.5%.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;for-teams-of-different-sizes-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;For teams of different sizes&lt;/h2&gt;
&lt;p&gt;We now compute the probability for teams between 1 and 100 persons:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# compute and save probabilities for teams between 1 and 100 persons
probs &amp;lt;- vector(length = max_persons)
for (i in 1:max_persons) {
  probs[i] &amp;lt;- have_same(n_initials, i)
}

# create data frame with saved probabilities and number of persons
dat_plot_theory &amp;lt;- data.frame(
  n_persons = (min_persons - 1):max_persons,
  prob = probs
)

# display first 6 rows
head(dat_plot_theory)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   n_persons        prob
## 1         1 0.000000000
## 2         2 0.001479290
## 3         3 0.004433493
## 4         4 0.008851688
## 5         5 0.014716471
## 6         6 0.022004071&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we visualize these probabilities in function of the number of persons in the team:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# visualize probabilities
ggplot(dat_plot_theory) +
  aes(x = n_persons, y = probs) +
  geom_line(linewidth = 1) +
  labs(
    x = &amp;quot;# of persons in the team&amp;quot;,
    y = &amp;quot;Probability&amp;quot;,
    title = &amp;quot;What is the probability that at least 2 persons have the same initials?&amp;quot;
  ) +
  scale_y_continuous(labels = scales::percent) # format y-axis in %&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-the-probability-that-two-persons-have-the-same-initials/index_files/figure-html/unnamed-chunk-16-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For an easier comparison, we plot probabilities found thanks to simulations and thanks to probability theory on the same plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# combine the two data frames into one and add the method as variable
dat_plot_sim$Method &amp;lt;- &amp;quot;Simulations&amp;quot;
dat_plot_theory$Method &amp;lt;- &amp;quot;Theory&amp;quot;
dat_plot_all &amp;lt;- rbind(dat_plot_sim, dat_plot_theory)

# visualize probabilities on same plot
ggplot(dat_plot_all) +
  aes(x = n_persons, y = prob, color = Method) +
  geom_line(linewidth = 1) +
  labs(
    x = &amp;quot;# of persons in the team&amp;quot;,
    y = &amp;quot;Probability&amp;quot;,
    title = &amp;quot;What is the probability that at least 2 persons have the same initials?&amp;quot;
  ) +
  scale_y_continuous(labels = scales::percent) # format y-axis in %&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-the-probability-that-two-persons-have-the-same-initials/index_files/figure-html/unnamed-chunk-17-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The plot above shows that results using probability theory are relatively similar to results obtained through simulations, indicating that the simulations are trustworthy.&lt;/p&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;The initial question, raised during a meeting, was “What is the probability that, among our team consisting of 8 persons, two have the same initials?”.&lt;/p&gt;
&lt;p&gt;In this post, we first showed how to compute this probability through simulations in R. Secondly, we verified the veracity of the simulations thanks to probability theory. Furthermore, we illustrated how for loops, replications and writing a function can be used in R to answer a probability problem.&lt;/p&gt;
&lt;p&gt;As a side note, it is important to keep in mind that in this post, we assumed the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;All letters of the alphabet had the same probability of occurring, meaning that all pairs of initials were equally probable. This is probably not the case in reality, as a first and last name starting both with X is not as probable as a first and last name starting respectively with M and K. This bias could be limited by specifying different weights when sampling initials.&lt;/li&gt;
&lt;li&gt;We restricted ourselves to two-letters initials. Therefore, for compound first or last names, only the first letter is considered. Middle names are also not taken into account.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Last but not least, note that you will find slightly different results than mine, even if you use the exact same code. This is due to randomness. To replicate results as shown in this post, use &lt;code&gt;set.seed(6)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&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 can always use a larger number of replications, but in our case the final result is similar with more replications, and the aim of the post is more to show the development than the final answer.&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;I thank Richard for writing the first version of the code used for the verifications.&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>Introduction to data manipulation in R with {dplyr}</title>
      <link>https://statsandr.com/blog/introduction-to-data-manipulation-in-r-with-dplyr/</link>
      <pubDate>Mon, 27 Nov 2023 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/introduction-to-data-manipulation-in-r-with-dplyr/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#dplyr-package&#34; id=&#34;toc-dplyr-package&#34;&gt;{dplyr} package&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#filter-observations&#34; id=&#34;toc-filter-observations&#34;&gt;Filter observations&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#the-pipe-operator&#34; id=&#34;toc-the-pipe-operator&#34;&gt;The pipe operator&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#extract-observations&#34; id=&#34;toc-extract-observations&#34;&gt;Extract observations&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#based-on-their-positions&#34; id=&#34;toc-based-on-their-positions&#34;&gt;Based on their positions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#based-on-their-values&#34; id=&#34;toc-based-on-their-values&#34;&gt;Based on their values&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sample-observations&#34; id=&#34;toc-sample-observations&#34;&gt;Sample observations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sort-observations&#34; id=&#34;toc-sort-observations&#34;&gt;Sort observations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#select-variables&#34; id=&#34;toc-select-variables&#34;&gt;Select variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#rename-variables&#34; id=&#34;toc-rename-variables&#34;&gt;Rename variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#create-or-modify-variables&#34; id=&#34;toc-create-or-modify-variables&#34;&gt;Create or modify variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#summarize-observations&#34; id=&#34;toc-summarize-observations&#34;&gt;Summarize observations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#identify-distinct-values&#34; id=&#34;toc-identify-distinct-values&#34;&gt;Identify distinct values&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#connected-operations&#34; id=&#34;toc-connected-operations&#34;&gt;Connected operations&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#group-by&#34; id=&#34;toc-group-by&#34;&gt;Group by&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#number-of-observations&#34; id=&#34;toc-number-of-observations&#34;&gt;Number of observations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#number-of-distinct-values&#34; id=&#34;toc-number-of-distinct-values&#34;&gt;Number of distinct values&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#first-last-or-nth-value&#34; id=&#34;toc-first-last-or-nth-value&#34;&gt;First, last or nth value&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#if-else&#34; id=&#34;toc-if-else&#34;&gt;If else&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#case-when&#34; id=&#34;toc-case-when&#34;&gt;Case when&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion-and-other-resources&#34; id=&#34;toc-conclusion-and-other-resources&#34;&gt;Conclusion and other resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/introduction-to-data-manipulation-in-r-with-dplyr.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In a previous post, we showed how to &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;manipulate data in R&lt;/a&gt;. In particular, we illustrated how to create and manipulate vectors, factors, lists and data frames. This served as an introduction to R and was aimed at beginners. Moreover, as long as it was possible, all manipulations were made in base R, that is, without having to load any package.&lt;/p&gt;
&lt;p&gt;In this post, we would like to show again how to manipulate data in R, but this time using the &lt;code&gt;{dplyr}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;{dplyr}&lt;/code&gt; package, developed by Hadley Wickham and colleagues at Posit, provides a complete set of functions that help you solve the most common data manipulation challenges such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;filtering observations based on their values&lt;/li&gt;
&lt;li&gt;extracting observations based on their values or positions&lt;/li&gt;
&lt;li&gt;sampling observations based on a specific number or fraction of rows&lt;/li&gt;
&lt;li&gt;sorting observations based on one or several variables&lt;/li&gt;
&lt;li&gt;selecting variables based on their names or positions&lt;/li&gt;
&lt;li&gt;renaming variables&lt;/li&gt;
&lt;li&gt;adding new variables based on existing ones&lt;/li&gt;
&lt;li&gt;summarizing observations or variables to a single descriptive measure&lt;/li&gt;
&lt;li&gt;performing any operation by group&lt;/li&gt;
&lt;li&gt;categorizing observations into two or more groups&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;More information about the package can be found at &lt;a href=&#34;https://dplyr.tidyverse.org/&#34; target=&#34;_blank&#34;&gt;dplyr.tidyverse.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this post, we will present the most common functions for data manipulation and data management using the &lt;code&gt;{dplyr}&lt;/code&gt; package (illustrated on a data frame). This is however not an exhaustive list! It is likely that you will need other functions that the ones presented here. For the interested readers, see the end of this post for further resources.&lt;/p&gt;
&lt;p&gt;A question I am often asked is whether it is best to first learn data manipulation with base R and &lt;em&gt;then&lt;/em&gt; with &lt;code&gt;{dplyr}&lt;/code&gt;, or directly learn &lt;code&gt;{dplyr}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Everyone may not agree, but here is what I tend to answer. The interest in terms of efficiency and clarity/readability of the code that &lt;code&gt;{dplyr}&lt;/code&gt; brings is obvious. So even when I give a &lt;a href=&#34;https://datanalyze.be/trainings/&#34;&gt;training&lt;/a&gt; targeted to statisticians, I present the &lt;code&gt;{dplyr}&lt;/code&gt; package. However, I still do believe that learning data manipulation with base R is important for two reasons:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Everyone will, at some point, be confronted with code written in base R (either from collaboration with other R users, or from code found in textbooks or online).&lt;/li&gt;
&lt;li&gt;Through the feedback I receive from my students, I notice that &lt;code&gt;{dplyr}&lt;/code&gt; is relatively easy to learn when you are familiar with base R (which is quite rewarding for those who struggled at the beginning).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For these reasons, I tend to teach data manipulation with base R first and then slowly switch to &lt;code&gt;{dplyr}&lt;/code&gt; (up to the point that for some advanced training courses, I hardly use base R at all by the end of the course). As a side note, this is the approach I follow for data visualization in R as well: I teach first how to plot data with base R, then I gradually teach them &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;how to use &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With this approach, some students may have the impression that they wasted their time learning base R. At least, some may have this impression during the training. However, as soon as the training is done and they have to learn R by themselves or work on real projects, they are grateful of having learned both.&lt;/p&gt;
&lt;p&gt;I am curious to hear from other teachers regarding their approach, so feel free to share your opinion.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;To present the different functions, we will use the data frame &lt;code&gt;penguins&lt;/code&gt;, available within the &lt;code&gt;{palmerpenguins}&lt;/code&gt; package &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-palmerpenguins2020horst&#34;&gt;Horst et al. 2020&lt;/a&gt;)&lt;/span&gt;. Data are available by &lt;a href=&#34;https://creativecommons.org/public-domain/cc0/&#34; target=&#34;_blank&#34;&gt;CC-0&lt;/a&gt; license and can be downloaded from CRAN:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;palmerpenguins&amp;quot;)
library(palmerpenguins)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Before going further, we rename the data frame as &lt;code&gt;dat&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- penguins&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I like to call data frames I am working on with a generic name such as &lt;code&gt;dat&lt;/code&gt; for two reasons:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Every time I need to write the name of the data frame, it is usually shorter to write &lt;code&gt;dat&lt;/code&gt; than to write the name of the data frame (which is in this case &lt;code&gt;penguins&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;If I need to do similar analyses or plots on different data frames, the code I wrote in the past can be reused with only a few modifications. With this very simple trick, most of the time I only have to edit the names of the variables, but the name of the data frame does not need to be changed (which saves me a lot of time).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The data frame contains data for 344 penguins and 8 variables describing the species, the island, some measurements of the size of the bill, flipper and body mass, the sex and the study year. More information about the data frame can be found by running &lt;code&gt;?penguins&lt;/code&gt; (after loading the &lt;code&gt;{palmerpenguins}&lt;/code&gt; package).&lt;/p&gt;
&lt;p&gt;For this post, we will focus only on the variables &lt;code&gt;species&lt;/code&gt;, &lt;code&gt;body_mass_g&lt;/code&gt;, &lt;code&gt;sex&lt;/code&gt; and &lt;code&gt;year&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Before proceeding with the different data manipulation techniques, let’s first inspect the data by displaying its structure, the first 6 rows and a summary of it:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(dat) # structure of the data&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## tibble [344 × 4] (S3: tbl_df/tbl/data.frame)
##  $ species    : Factor w/ 3 levels &amp;quot;Adelie&amp;quot;,&amp;quot;Chinstrap&amp;quot;,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ body_mass_g: int [1:344] 3750 3800 3250 NA 3450 3650 3625 4675 3475 4250 ...
##  $ sex        : Factor w/ 2 levels &amp;quot;female&amp;quot;,&amp;quot;male&amp;quot;: 2 1 1 NA 1 2 1 2 NA NA ...
##  $ year       : int [1:344] 2007 2007 2007 2007 2007 2007 2007 2007 2007 2007 ...&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(dat) # display first 6 rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 × 4
##   species body_mass_g sex     year
##   &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 Adelie         3750 male    2007
## 2 Adelie         3800 female  2007
## 3 Adelie         3250 female  2007
## 4 Adelie           NA &amp;lt;NA&amp;gt;    2007
## 5 Adelie         3450 female  2007
## 6 Adelie         3650 male    2007&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(dat) # summary&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       species     body_mass_g       sex           year     
##  Adelie   :152   Min.   :2700   female:165   Min.   :2007  
##  Chinstrap: 68   1st Qu.:3550   male  :168   1st Qu.:2007  
##  Gentoo   :124   Median :4050   NA&amp;#39;s  : 11   Median :2008  
##                  Mean   :4202                Mean   :2008  
##                  3rd Qu.:4750                3rd Qu.:2009  
##                  Max.   :6300                Max.   :2009  
##                  NA&amp;#39;s   :2&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;dplyr-package&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;{dplyr} package&lt;/h1&gt;
&lt;p&gt;Without further ado, let’s illustrate the different functions for data manipulation available in the &lt;code&gt;{dplyr}&lt;/code&gt; package in the following sections.&lt;/p&gt;
&lt;p&gt;As for any package, we first need to install and load it before using it:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;dplyr&amp;quot;)
library(dplyr)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that all functions presented below requires tidy data, which means that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;each variable is in its own column,&lt;/li&gt;
&lt;li&gt;each observation, or case, is in its own row, and&lt;/li&gt;
&lt;li&gt;each value is in its own cell.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;images/tidy-data.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Rules of a tidy data frame: variables are columns, observations are rows, and values are cells. Source: R for Data Science (2e) by H. Wickham, M. Çetinkaya-Rundel and G. Grolemund.&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Rules of a tidy data frame: variables are columns, observations are rows, and values are cells. Source: R for Data Science (2e) by H. Wickham, M. Çetinkaya-Rundel and G. Grolemund.&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;filter-observations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Filter observations&lt;/h2&gt;
&lt;p&gt;Filtering observations based on their values can be done with the &lt;code&gt;filter()&lt;/code&gt; function. This function works on both &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative&lt;/a&gt; variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# filter observations based on a quantitative variable
filter(dat, body_mass_g &amp;gt; 4000)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 172 × 4
##    species body_mass_g sex    year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt; &amp;lt;int&amp;gt;
##  1 Adelie         4675 male   2007
##  2 Adelie         4250 &amp;lt;NA&amp;gt;   2007
##  3 Adelie         4400 male   2007
##  4 Adelie         4500 male   2007
##  5 Adelie         4200 male   2007
##  6 Adelie         4150 male   2007
##  7 Adelie         4650 male   2007
##  8 Adelie         4400 male   2007
##  9 Adelie         4600 male   2007
## 10 Adelie         4150 male   2007
## # ℹ 162 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# filter observations based on a qualitative variable
filter(dat, sex == &amp;quot;female&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 165 × 4
##    species body_mass_g sex     year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Adelie         3800 female  2007
##  2 Adelie         3250 female  2007
##  3 Adelie         3450 female  2007
##  4 Adelie         3625 female  2007
##  5 Adelie         3200 female  2007
##  6 Adelie         3700 female  2007
##  7 Adelie         3450 female  2007
##  8 Adelie         3325 female  2007
##  9 Adelie         3400 female  2007
## 10 Adelie         3800 female  2007
## # ℹ 155 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can combine several conditions with &lt;code&gt;&amp;amp;&lt;/code&gt; (if the conditions must be cumulative) or &lt;code&gt;|&lt;/code&gt; (if the conditions are alternatives), for instance:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# filter observations based on 2 cumulative conditions
filter(dat, body_mass_g &amp;gt; 4000 &amp;amp; sex == &amp;quot;female&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 58 × 4
##    species body_mass_g sex     year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Gentoo         4500 female  2007
##  2 Gentoo         4450 female  2007
##  3 Gentoo         4550 female  2007
##  4 Gentoo         4800 female  2007
##  5 Gentoo         4400 female  2007
##  6 Gentoo         4650 female  2007
##  7 Gentoo         4650 female  2007
##  8 Gentoo         4200 female  2007
##  9 Gentoo         4150 female  2007
## 10 Gentoo         4800 female  2007
## # ℹ 48 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that variable names do &lt;em&gt;not&lt;/em&gt; have to be written inside single nor double quotation marks (&lt;code&gt;&#39;&#39;&lt;/code&gt; or &lt;code&gt;&#34;&#34;&lt;/code&gt;). This is the case for all functions presented below.&lt;/p&gt;
&lt;div id=&#34;the-pipe-operator&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;The pipe operator&lt;/h3&gt;
&lt;p&gt;As you can see from the code above, the &lt;code&gt;filter()&lt;/code&gt; functions requires the name of the data frame as first argument, then the condition (with the usual logical operators &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;%in%&lt;/code&gt;, etc.) as second argument.&lt;/p&gt;
&lt;p&gt;Specifying the name of the data frame as first argument is required for all functions presented in this list. However, there is a workaround to specifying the data frame’s name inside the functions: the pipe operator (&lt;code&gt;|&amp;gt;&lt;/code&gt; or &lt;code&gt;%&amp;gt;%&lt;/code&gt;).&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;/p&gt;
&lt;p&gt;The pipe operator allows to perform a sequence of several operations, that is, chain a sequence of calculations together. It is particularly useful when you are performing several operations on a data frame, and you do not want to save the output at each intermediate step. We will see below how to use the pipe operator with several operations, but for now I would like to introduce it with only one operation at a time.&lt;/p&gt;
&lt;p&gt;As you can see with the &lt;code&gt;filter()&lt;/code&gt; function, the pipe operator is not compulsory. However, I recommend it so much (even to beginners) for its easy of use, convenience, code readability and popularity that from now on functions available in &lt;code&gt;{dplyr}&lt;/code&gt; will be presented together with the pipe operator.&lt;/p&gt;
&lt;p&gt;So with the pipe operator, the code above becomes:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# filter observations based on a quantitative variable
dat |&amp;gt;
  filter(body_mass_g &amp;gt; 4000)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 172 × 4
##    species body_mass_g sex    year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt; &amp;lt;int&amp;gt;
##  1 Adelie         4675 male   2007
##  2 Adelie         4250 &amp;lt;NA&amp;gt;   2007
##  3 Adelie         4400 male   2007
##  4 Adelie         4500 male   2007
##  5 Adelie         4200 male   2007
##  6 Adelie         4150 male   2007
##  7 Adelie         4650 male   2007
##  8 Adelie         4400 male   2007
##  9 Adelie         4600 male   2007
## 10 Adelie         4150 male   2007
## # ℹ 162 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# filter observations based on a qualitative variable
dat |&amp;gt;
  filter(sex == &amp;quot;female&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 165 × 4
##    species body_mass_g sex     year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Adelie         3800 female  2007
##  2 Adelie         3250 female  2007
##  3 Adelie         3450 female  2007
##  4 Adelie         3625 female  2007
##  5 Adelie         3200 female  2007
##  6 Adelie         3700 female  2007
##  7 Adelie         3450 female  2007
##  8 Adelie         3325 female  2007
##  9 Adelie         3400 female  2007
## 10 Adelie         3800 female  2007
## # ℹ 155 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# filter observations based on 2 cumulative conditions
dat |&amp;gt;
  filter(body_mass_g &amp;gt; 4000 &amp;amp; sex == &amp;quot;female&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 58 × 4
##    species body_mass_g sex     year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Gentoo         4500 female  2007
##  2 Gentoo         4450 female  2007
##  3 Gentoo         4550 female  2007
##  4 Gentoo         4800 female  2007
##  5 Gentoo         4400 female  2007
##  6 Gentoo         4650 female  2007
##  7 Gentoo         4650 female  2007
##  8 Gentoo         4200 female  2007
##  9 Gentoo         4150 female  2007
## 10 Gentoo         4800 female  2007
## # ℹ 48 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The pipe operator simply takes the results of one operation into the next operation below it, making the code extremely easy to write and read.&lt;/p&gt;
&lt;p&gt;This way, instead of specifying the data frame’s name as first argument in the &lt;code&gt;filter()&lt;/code&gt; function (or any other function within the &lt;code&gt;{dplyr}&lt;/code&gt; package), we simply specify the data frame’s name and then the desired function, combined together thanks to the pipe operator.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-observations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract observations&lt;/h2&gt;
&lt;p&gt;It is possible to extract observations based on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;their positions, or&lt;/li&gt;
&lt;li&gt;their values.&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;based-on-their-positions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Based on their positions&lt;/h3&gt;
&lt;p&gt;Extracting observations based on their positions can be done with the &lt;code&gt;slice()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract rows 2, 5 and 37
dat |&amp;gt;
  slice(c(2, 5, 37))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 4
##   species body_mass_g sex     year
##   &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 Adelie         3800 female  2007
## 2 Adelie         3450 female  2007
## 3 Adelie         3950 male    2007&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Moreover, extracting the first or last rows can be done with &lt;code&gt;slice_head()&lt;/code&gt; and &lt;code&gt;slice_tail()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract first 3 rows
dat |&amp;gt;
  slice_head(n = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 4
##   species body_mass_g sex     year
##   &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 Adelie         3750 male    2007
## 2 Adelie         3800 female  2007
## 3 Adelie         3250 female  2007&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract last 3 rows
dat |&amp;gt;
  slice_tail(n = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 4
##   species   body_mass_g sex     year
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 Chinstrap        3775 male    2009
## 2 Chinstrap        4100 male    2009
## 3 Chinstrap        3775 female  2009&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;based-on-their-values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Based on their values&lt;/h3&gt;
&lt;p&gt;To extract observations based on values of a variable, use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;slice_min()&lt;/code&gt; to select rows with the &lt;strong&gt;lowest&lt;/strong&gt; values (with a defined proportion), and&lt;/li&gt;
&lt;li&gt;&lt;code&gt;slice_max()&lt;/code&gt; to select rows with the &lt;strong&gt;highest&lt;/strong&gt; values (with a defined proportion).&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract observations with 25% lowest body mass
dat |&amp;gt;
  slice_min(body_mass_g, prop = 0.25)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 89 × 4
##    species   body_mass_g sex     year
##    &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Chinstrap        2700 female  2008
##  2 Adelie           2850 female  2008
##  3 Adelie           2850 female  2008
##  4 Adelie           2900 female  2008
##  5 Adelie           2900 female  2008
##  6 Adelie           2900 female  2009
##  7 Chinstrap        2900 female  2007
##  8 Adelie           2925 female  2009
##  9 Adelie           2975 &amp;lt;NA&amp;gt;    2007
## 10 Adelie           3000 female  2007
## # ℹ 79 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract observations with 25% highest body mass
dat |&amp;gt;
  slice_max(body_mass_g, prop = 0.25)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 90 × 4
##    species body_mass_g sex    year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt; &amp;lt;int&amp;gt;
##  1 Gentoo         6300 male   2007
##  2 Gentoo         6050 male   2007
##  3 Gentoo         6000 male   2008
##  4 Gentoo         6000 male   2009
##  5 Gentoo         5950 male   2008
##  6 Gentoo         5950 male   2009
##  7 Gentoo         5850 male   2007
##  8 Gentoo         5850 male   2007
##  9 Gentoo         5850 male   2009
## 10 Gentoo         5800 male   2008
## # ℹ 80 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;sample-observations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sample observations&lt;/h2&gt;
&lt;p&gt;Sampling observations can be done in two ways:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Random sample of a &lt;strong&gt;number&lt;/strong&gt; of rows with &lt;code&gt;sample_n()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Random sample of a &lt;strong&gt;fraction&lt;/strong&gt; of rows with &lt;code&gt;sample_frac()&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 3 rows
dat |&amp;gt;
  sample_n(size = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 4
##   species   body_mass_g sex     year
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 Adelie           3450 female  2007
## 2 Chinstrap        3675 female  2009
## 3 Gentoo           4500 female  2007&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of half of the rows
dat |&amp;gt;
  sample_frac(size = 1 / 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 172 × 4
##    species   body_mass_g sex     year
##    &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Adelie           4150 male    2008
##  2 Gentoo           5800 male    2008
##  3 Adelie           3650 male    2009
##  4 Adelie           3500 male    2009
##  5 Adelie           3450 female  2007
##  6 Adelie           4300 male    2009
##  7 Chinstrap        3400 female  2008
##  8 Adelie           3950 male    2007
##  9 Chinstrap        3325 female  2009
## 10 Adelie           3950 male    2008
## # ℹ 162 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that, as with the &lt;code&gt;sample()&lt;/code&gt; function within base R, &lt;code&gt;size&lt;/code&gt; can be greater than the size of the data frame. In this case, some rows will be duplicated, and you will need to specify the argument &lt;code&gt;replace = TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Alternatively, it is possible to obtain a random sample of a number of rows or fraction or rows with &lt;code&gt;slice_sample()&lt;/code&gt;. For this, use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the argument &lt;code&gt;n&lt;/code&gt; to select a number of rows, or&lt;/li&gt;
&lt;li&gt;the argument &lt;code&gt;prop&lt;/code&gt; to select a fraction of rows.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 3 rows
dat |&amp;gt;
  slice_sample(n = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 4
##   species body_mass_g sex     year
##   &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 Adelie         3200 female  2007
## 2 Adelie         3800 female  2007
## 3 Gentoo         4800 female  2007&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of half of the rows
dat |&amp;gt;
  slice_sample(prop = 1 / 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 172 × 4
##    species body_mass_g sex     year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Adelie         3900 male    2009
##  2 Adelie         3275 female  2009
##  3 Gentoo         5050 male    2008
##  4 Gentoo         4700 female  2009
##  5 Gentoo         4600 female  2008
##  6 Gentoo         4875 &amp;lt;NA&amp;gt;    2009
##  7 Adelie         3700 &amp;lt;NA&amp;gt;    2007
##  8 Gentoo         3950 female  2008
##  9 Gentoo         4550 female  2007
## 10 Adelie         3500 female  2008
## # ℹ 162 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;sort-observations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sort observations&lt;/h2&gt;
&lt;p&gt;Sorting observations can be done with the &lt;code&gt;arrange()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sort observations based on body mass (ascending order)
dat |&amp;gt;
  arrange(body_mass_g)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 4
##    species   body_mass_g sex     year
##    &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Chinstrap        2700 female  2008
##  2 Adelie           2850 female  2008
##  3 Adelie           2850 female  2008
##  4 Adelie           2900 female  2008
##  5 Adelie           2900 female  2008
##  6 Adelie           2900 female  2009
##  7 Chinstrap        2900 female  2007
##  8 Adelie           2925 female  2009
##  9 Adelie           2975 &amp;lt;NA&amp;gt;    2007
## 10 Adelie           3000 female  2007
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default, &lt;code&gt;arrange()&lt;/code&gt; uses the &lt;strong&gt;ascending&lt;/strong&gt; order. To sort in &lt;strong&gt;descending&lt;/strong&gt; order, use &lt;code&gt;desc()&lt;/code&gt; inside &lt;code&gt;arrange()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sort observations based on body mass (descending order)
dat |&amp;gt;
  arrange(desc(body_mass_g))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 4
##    species body_mass_g sex    year
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt; &amp;lt;int&amp;gt;
##  1 Gentoo         6300 male   2007
##  2 Gentoo         6050 male   2007
##  3 Gentoo         6000 male   2008
##  4 Gentoo         6000 male   2009
##  5 Gentoo         5950 male   2008
##  6 Gentoo         5950 male   2009
##  7 Gentoo         5850 male   2007
##  8 Gentoo         5850 male   2007
##  9 Gentoo         5850 male   2009
## 10 Gentoo         5800 male   2008
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As with &lt;code&gt;filter()&lt;/code&gt;, &lt;code&gt;arrange()&lt;/code&gt; can be used for several variables and works both on quantitative and qualitative variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sort observations based on two variables
dat |&amp;gt;
  arrange(sex, body_mass_g)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 4
##    species   body_mass_g sex     year
##    &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
##  1 Chinstrap        2700 female  2008
##  2 Adelie           2850 female  2008
##  3 Adelie           2850 female  2008
##  4 Adelie           2900 female  2008
##  5 Adelie           2900 female  2008
##  6 Adelie           2900 female  2009
##  7 Chinstrap        2900 female  2007
##  8 Adelie           2925 female  2009
##  9 Adelie           3000 female  2007
## 10 Adelie           3000 female  2009
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The code above sorts the observations first based on the sex (in alphabetical order) and then based on the body mass (in ascending order, so from lowest to highest).&lt;/p&gt;
&lt;p&gt;Note that if the qualitative variable is defined as an ordered &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factor&lt;/a&gt;, the sorting is based on level order, not alphabetical order!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;select-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Select variables&lt;/h2&gt;
&lt;p&gt;Selecting variables can be done with the &lt;code&gt;select()&lt;/code&gt; function, based on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the position of the variable(s), or&lt;/li&gt;
&lt;li&gt;the name(s) of the variable(s).&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select variables by their positions
dat |&amp;gt;
  select(c(2, 4))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 2
##    body_mass_g  year
##          &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
##  1        3750  2007
##  2        3800  2007
##  3        3250  2007
##  4          NA  2007
##  5        3450  2007
##  6        3650  2007
##  7        3625  2007
##  8        4675  2007
##  9        3475  2007
## 10        4250  2007
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select variables by their names
dat |&amp;gt;
  select(body_mass_g, year)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 2
##    body_mass_g  year
##          &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
##  1        3750  2007
##  2        3800  2007
##  3        3250  2007
##  4          NA  2007
##  5        3450  2007
##  6        3650  2007
##  7        3625  2007
##  8        4675  2007
##  9        3475  2007
## 10        4250  2007
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that it is also possible to remove variables. For this, use the &lt;code&gt;-&lt;/code&gt; sign in front of their positions or names:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# remove variables by their positions
dat |&amp;gt;
  select(-c(2, 4))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 2
##    species sex   
##    &amp;lt;fct&amp;gt;   &amp;lt;fct&amp;gt; 
##  1 Adelie  male  
##  2 Adelie  female
##  3 Adelie  female
##  4 Adelie  &amp;lt;NA&amp;gt;  
##  5 Adelie  female
##  6 Adelie  male  
##  7 Adelie  female
##  8 Adelie  male  
##  9 Adelie  &amp;lt;NA&amp;gt;  
## 10 Adelie  &amp;lt;NA&amp;gt;  
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# remove variables by their names
dat |&amp;gt;
  select(-c(body_mass_g, year))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 2
##    species sex   
##    &amp;lt;fct&amp;gt;   &amp;lt;fct&amp;gt; 
##  1 Adelie  male  
##  2 Adelie  female
##  3 Adelie  female
##  4 Adelie  &amp;lt;NA&amp;gt;  
##  5 Adelie  female
##  6 Adelie  male  
##  7 Adelie  female
##  8 Adelie  male  
##  9 Adelie  &amp;lt;NA&amp;gt;  
## 10 Adelie  &amp;lt;NA&amp;gt;  
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is also possible to select variables with a sequence of names:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select all variables from species to sex
dat |&amp;gt;
  select(species:sex)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 3
##    species body_mass_g sex   
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt; 
##  1 Adelie         3750 male  
##  2 Adelie         3800 female
##  3 Adelie         3250 female
##  4 Adelie           NA &amp;lt;NA&amp;gt;  
##  5 Adelie         3450 female
##  6 Adelie         3650 male  
##  7 Adelie         3625 female
##  8 Adelie         4675 male  
##  9 Adelie         3475 &amp;lt;NA&amp;gt;  
## 10 Adelie         4250 &amp;lt;NA&amp;gt;  
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Last but not least, &lt;code&gt;select()&lt;/code&gt; can also be used as an easy way to rearrange columns in the desired order:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# put sex as first column, then all the others
dat |&amp;gt;
  select(sex, species:year)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 4
##    sex    species body_mass_g  year
##    &amp;lt;fct&amp;gt;  &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
##  1 male   Adelie         3750  2007
##  2 female Adelie         3800  2007
##  3 female Adelie         3250  2007
##  4 &amp;lt;NA&amp;gt;   Adelie           NA  2007
##  5 female Adelie         3450  2007
##  6 male   Adelie         3650  2007
##  7 female Adelie         3625  2007
##  8 male   Adelie         4675  2007
##  9 &amp;lt;NA&amp;gt;   Adelie         3475  2007
## 10 &amp;lt;NA&amp;gt;   Adelie         4250  2007
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rename-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Rename variables&lt;/h2&gt;
&lt;p&gt;To rename variables, use the &lt;code&gt;rename()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# rename variables
dat |&amp;gt;
  rename(
    body_mass = body_mass_g, # rename body_mass_g into body_mass
    study_year = year # rename year into study_year
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 4
##    species body_mass sex    study_year
##    &amp;lt;fct&amp;gt;       &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;       &amp;lt;int&amp;gt;
##  1 Adelie       3750 male         2007
##  2 Adelie       3800 female       2007
##  3 Adelie       3250 female       2007
##  4 Adelie         NA &amp;lt;NA&amp;gt;         2007
##  5 Adelie       3450 female       2007
##  6 Adelie       3650 male         2007
##  7 Adelie       3625 female       2007
##  8 Adelie       4675 male         2007
##  9 Adelie       3475 &amp;lt;NA&amp;gt;         2007
## 10 Adelie       4250 &amp;lt;NA&amp;gt;         2007
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This might not be intuitive (at least it was not for me at the time of learning this package), so bear in mind that you always need to write first the new name and then the old name (separated with the &lt;code&gt;=&lt;/code&gt; sign).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;create-or-modify-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create or modify variables&lt;/h2&gt;
&lt;p&gt;You can create or modify certain variables of the data frame with &lt;code&gt;mutate()&lt;/code&gt;, based on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;another variable, or&lt;/li&gt;
&lt;li&gt;a vector of your choice.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create a new variable based on an existing one
dat |&amp;gt;
  mutate(
    body_mass_kg = body_mass_g / 1000
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 5
##    species body_mass_g sex     year body_mass_kg
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;        &amp;lt;dbl&amp;gt;
##  1 Adelie         3750 male    2007         3.75
##  2 Adelie         3800 female  2007         3.8 
##  3 Adelie         3250 female  2007         3.25
##  4 Adelie           NA &amp;lt;NA&amp;gt;    2007        NA   
##  5 Adelie         3450 female  2007         3.45
##  6 Adelie         3650 male    2007         3.65
##  7 Adelie         3625 female  2007         3.62
##  8 Adelie         4675 male    2007         4.68
##  9 Adelie         3475 &amp;lt;NA&amp;gt;    2007         3.48
## 10 Adelie         4250 &amp;lt;NA&amp;gt;    2007         4.25
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create a new variable from a vector of your choice
dat |&amp;gt;
  mutate(
    ID = 1:nrow(dat)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 5
##    species body_mass_g sex     year    ID
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
##  1 Adelie         3750 male    2007     1
##  2 Adelie         3800 female  2007     2
##  3 Adelie         3250 female  2007     3
##  4 Adelie           NA &amp;lt;NA&amp;gt;    2007     4
##  5 Adelie         3450 female  2007     5
##  6 Adelie         3650 male    2007     6
##  7 Adelie         3625 female  2007     7
##  8 Adelie         4675 male    2007     8
##  9 Adelie         3475 &amp;lt;NA&amp;gt;    2007     9
## 10 Adelie         4250 &amp;lt;NA&amp;gt;    2007    10
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that if you create a variable with a name which already exists in the data frame, the old variable will be erased and replaced by the new one.&lt;/p&gt;
&lt;p&gt;Like &lt;code&gt;rename()&lt;/code&gt;, &lt;code&gt;mutate()&lt;/code&gt; requires the argument to be written as &lt;code&gt;name = expression&lt;/code&gt;, where &lt;code&gt;name&lt;/code&gt; is name of the column created or modified and &lt;code&gt;expression&lt;/code&gt; is the formula for calculating the values.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summarize-observations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summarize observations&lt;/h2&gt;
&lt;p&gt;Often, you will want to summarize the data with some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt;. This can be done with the &lt;code&gt;summarize()&lt;/code&gt; function, in addition to most functions used for descriptive statistics (&lt;code&gt;mean()&lt;/code&gt;, &lt;code&gt;median()&lt;/code&gt;, &lt;code&gt;min()&lt;/code&gt;, &lt;code&gt;max()&lt;/code&gt;, &lt;code&gt;sd()&lt;/code&gt;, &lt;code&gt;var()&lt;/code&gt;, etc.):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# compute mean and sd of body mass
dat |&amp;gt;
  summarize(
    body_mass_mean = mean(body_mass_g, na.rm = TRUE),
    body_mass_sd = sd(body_mass_g, na.rm = TRUE)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 2
##   body_mass_mean body_mass_sd
##            &amp;lt;dbl&amp;gt;        &amp;lt;dbl&amp;gt;
## 1          4202.         802.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;na.rm = TRUE&lt;/code&gt; argument is used to omit missing values in the computation of the summary statistics.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;summarize()&lt;/code&gt; and &lt;code&gt;summarise()&lt;/code&gt; give the exact same results.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;identify-distinct-values&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Identify distinct values&lt;/h2&gt;
&lt;p&gt;Identifying distinct values of a variable can be done with &lt;code&gt;distinct()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# find the distinct species
dat |&amp;gt;
  distinct(species)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 1
##   species  
##   &amp;lt;fct&amp;gt;    
## 1 Adelie   
## 2 Gentoo   
## 3 Chinstrap&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Identifying distinct values is mostly done on qualitative or quantitative discrete variables, but it can be done on any type of variable and with several variables at the same time. If more than one variables is specified, it returns all the combinations of values of the variables.&lt;/p&gt;
&lt;p&gt;For instance, with species and study year:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# combination of distinct species and year
dat |&amp;gt;
  distinct(species, year)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 9 × 2
##   species    year
##   &amp;lt;fct&amp;gt;     &amp;lt;int&amp;gt;
## 1 Adelie     2007
## 2 Adelie     2008
## 3 Adelie     2009
## 4 Gentoo     2007
## 5 Gentoo     2008
## 6 Gentoo     2009
## 7 Chinstrap  2007
## 8 Chinstrap  2008
## 9 Chinstrap  2009&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;connected-operations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Connected operations&lt;/h2&gt;
&lt;p&gt;Another advantage of using the &lt;code&gt;{dplyr}&lt;/code&gt; package is that several operations can be connected all at once, with great readability of the code. This can easily be done with the pipe operator (&lt;code&gt;|&amp;gt;&lt;/code&gt; or &lt;code&gt;%&amp;gt;%&lt;/code&gt;) introduced earlier.&lt;/p&gt;
&lt;p&gt;Until now, we have always seen the same structure: we call a data frame, and then we apply an operation on that data frame. From now on, we will see how to combine more operations into one single chain of operations.&lt;/p&gt;
&lt;div id=&#34;group-by&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Group by&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;group_by()&lt;/code&gt; allows to modify the way the basic functions are performed. Instead of covering all the rows of the data frame, the operations will cover each of the groups of rows defined by the grouping command. In this way, aggregation operations, using &lt;code&gt;summarize()&lt;/code&gt;, will produce statistics for each group rather than for all observations.&lt;/p&gt;
&lt;p&gt;For example, we might be interested in computing some descriptive statistics of a quantitative variable, for each level of a qualitative variable (so by group).&lt;/p&gt;
&lt;p&gt;In our case, suppose we would like to compute the mean and standard deviation of the body mass, but this time separately for each species:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# compute mean and sd of body mass by species
dat |&amp;gt;
  group_by(species) |&amp;gt; # group by species
  summarize(
    mean = mean(body_mass_g, na.rm = TRUE), # compute mean
    sd = sd(body_mass_g, na.rm = TRUE) # compute sd
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 3
##   species    mean    sd
##   &amp;lt;fct&amp;gt;     &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1 Adelie    3701.  459.
## 2 Chinstrap 3733.  384.
## 3 Gentoo    5076.  504.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Applied to the example above, here is how the pipe operator works:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The first operation (&lt;code&gt;group_by()&lt;/code&gt;) groups observations by species.&lt;/li&gt;
&lt;li&gt;Then the output of the first operation is used as the input for the second operation (&lt;code&gt;summarize()&lt;/code&gt;): mean and standard deviation are computed on body mass.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As a result, we have the mean and standard deviation of body mass by group. As you can imagine, all previous operations can be connected to match your needs.&lt;/p&gt;
&lt;p&gt;Also note that &lt;code&gt;group_by()&lt;/code&gt; can be used for several grouping variables at the same time:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# compute mean and sd of body mass by species and sex
dat |&amp;gt;
  group_by(species, sex) |&amp;gt; # group by species and sex
  summarize(
    mean = mean(body_mass_g, na.rm = TRUE), # compute mean
    sd = sd(body_mass_g, na.rm = TRUE) # compute sd
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 × 4
## # Groups:   species [3]
##   species   sex     mean    sd
##   &amp;lt;fct&amp;gt;     &amp;lt;fct&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1 Adelie    female 3369.  269.
## 2 Adelie    male   4043.  347.
## 3 Adelie    &amp;lt;NA&amp;gt;   3540   477.
## 4 Chinstrap female 3527.  285.
## 5 Chinstrap male   3939.  362.
## 6 Gentoo    female 4680.  282.
## 7 Gentoo    male   5485.  313.
## 8 Gentoo    &amp;lt;NA&amp;gt;   4588.  338.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Note that, as for all connected operations, the name of the data frame needs to be specified only in the first operation.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;number-of-observations&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Number of observations&lt;/h3&gt;
&lt;p&gt;Some operations can only be performed inside other operations.&lt;/p&gt;
&lt;p&gt;This is the case with the number of observations &lt;code&gt;n()&lt;/code&gt;, which can only be used inside &lt;code&gt;summarize()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of observations
dat |&amp;gt;
  summarize(n_obs = n())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 1
##   n_obs
##   &amp;lt;int&amp;gt;
## 1   344&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To refer with the previous connected operation &lt;code&gt;group_by()&lt;/code&gt;, we can compute the number of observations by group using the two operations &lt;code&gt;n()&lt;/code&gt; and &lt;code&gt;group_by()&lt;/code&gt; separated by the pipe operator:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of observations by species
dat |&amp;gt;
  group_by(species) |&amp;gt;
  summarize(n_obs = n())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 2
##   species   n_obs
##   &amp;lt;fct&amp;gt;     &amp;lt;int&amp;gt;
## 1 Adelie      152
## 2 Chinstrap    68
## 3 Gentoo      124&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that &lt;code&gt;n()&lt;/code&gt; accepts no parameters and is therefore always written with empty parentheses.&lt;/p&gt;
&lt;p&gt;Moreover, note also that the &lt;code&gt;count()&lt;/code&gt; function is equivalent to &lt;code&gt;summarize(n = n())&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of observations
dat |&amp;gt;
  count()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 1
##       n
##   &amp;lt;int&amp;gt;
## 1   344&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of observations by species
dat |&amp;gt;
  count(species)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 2
##   species       n
##   &amp;lt;fct&amp;gt;     &amp;lt;int&amp;gt;
## 1 Adelie      152
## 2 Chinstrap    68
## 3 Gentoo      124&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;number-of-distinct-values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Number of distinct values&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;n_distinct()&lt;/code&gt;, which can also be used only inside &lt;code&gt;summarize()&lt;/code&gt;, computes the number of different values/levels of a variable or combination of variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of distinct species
dat |&amp;gt;
  summarize(n_species = n_distinct(species))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 1
##   n_species
##       &amp;lt;int&amp;gt;
## 1         3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of distinct species and year of study
dat |&amp;gt;
  summarize(n_species_year = n_distinct(species, year))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 1
##   n_species_year
##            &amp;lt;int&amp;gt;
## 1              9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that you do not have to specify a name for the output. In that case, the name of the operation will be used. For example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of distinct species
dat |&amp;gt;
  summarize(n_distinct(species))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 1
##   `n_distinct(species)`
##                   &amp;lt;int&amp;gt;
## 1                     3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;first-last-or-nth-value&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;First, last or nth value&lt;/h3&gt;
&lt;p&gt;Also only available inside &lt;code&gt;summarize()&lt;/code&gt;, the first, last or nth value can be found with the following commands:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# first value of the variable sex
dat |&amp;gt;
  summarize(first(sex))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 1
##   `first(sex)`
##   &amp;lt;fct&amp;gt;       
## 1 male&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# last value of the variable sex
dat |&amp;gt;
  summarize(last(sex))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 1
##   `last(sex)`
##   &amp;lt;fct&amp;gt;      
## 1 female&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 37th value of the variable sex
dat |&amp;gt;
  summarize(nth(sex, n = 37))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 × 1
##   `nth(sex, n = 37)`
##   &amp;lt;fct&amp;gt;             
## 1 male&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Several interesting arguments exist within this function to deal with missing values. For the interested reader, see more information in the documentation of the function (run &lt;code&gt;?nth()&lt;/code&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;if-else&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;If else&lt;/h3&gt;
&lt;p&gt;A very common data transformation is the well known “if else” technique. This technique is usually used to create, from an existing variable, another variable which can take &lt;strong&gt;two levels&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Suppose that we want to create a new variable called &lt;code&gt;body_mass_cat&lt;/code&gt;, which takes the value “High” when &lt;code&gt;body_mass_g&lt;/code&gt; is equal or greater than a certain threshold, “Low” otherwise. This transformation can be performed with the combination of &lt;code&gt;mutate()&lt;/code&gt; and &lt;code&gt;if_else()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# if else
dat |&amp;gt;
  mutate(
    body_mass_cat = if_else(body_mass_g &amp;gt;= 4000, # condition
      &amp;quot;High&amp;quot;, # output if condition is true
      &amp;quot;Low&amp;quot; # output if condition is false
    )
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 5
##    species body_mass_g sex     year body_mass_cat
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;        
##  1 Adelie         3750 male    2007 Low          
##  2 Adelie         3800 female  2007 Low          
##  3 Adelie         3250 female  2007 Low          
##  4 Adelie           NA &amp;lt;NA&amp;gt;    2007 &amp;lt;NA&amp;gt;         
##  5 Adelie         3450 female  2007 Low          
##  6 Adelie         3650 male    2007 Low          
##  7 Adelie         3625 female  2007 Low          
##  8 Adelie         4675 male    2007 High         
##  9 Adelie         3475 &amp;lt;NA&amp;gt;    2007 Low          
## 10 Adelie         4250 &amp;lt;NA&amp;gt;    2007 High         
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;if_else()&lt;/code&gt; function works with 3 arguments:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The condition (in our case: &lt;code&gt;body_mass_g &amp;gt;= 4000&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The output value when the condition is true (&lt;code&gt;High&lt;/code&gt; in our case).&lt;/li&gt;
&lt;li&gt;The output value when the conditions is false (&lt;code&gt;Low&lt;/code&gt; in our case).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As you can see from the table above, when body mass is missing, &lt;code&gt;if_else()&lt;/code&gt; also returns a missing value, which is often a good thing to prevent observations being classified erroneously.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-when&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case when&lt;/h3&gt;
&lt;p&gt;If you want to categorize a variable into &lt;strong&gt;more than two levels&lt;/strong&gt;, an if else is not the most appropriate tool. In these cases, a “case when” is more appropriate.&lt;/p&gt;
&lt;p&gt;For your information, when I learned R, I used to write nested if else functions, that is, a secondary if else inside a primary if else. Most of the time it worked (with very often a waste of time trying to debug my code), but it is very easy to make a mistake. And even if you managed to make it work, the code is not easy to read at all!&lt;/p&gt;
&lt;p&gt;So I highly recommend using this case when technique instead of several if else functions nested within each other.&lt;/p&gt;
&lt;p&gt;Suppose we want to classify body mass into 3 categories: low, medium and high. For this illustration, we arbitrarily decide that body mass is low when it is strictly lower than 3500, high when it is strictly higher than 4750 and medium otherwise.&lt;/p&gt;
&lt;p&gt;With nested if else functions, here is the code we would need to write:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# nested if else
dat |&amp;gt;
  mutate(
    body_mass_cat = if_else(body_mass_g &amp;lt; 3500, # first condition
      &amp;quot;Low&amp;quot;, # output if first condition is true
      if_else(body_mass_g &amp;gt; 4750, # second condition when first condition is false
        &amp;quot;High&amp;quot;, # output when second condition is true
        &amp;quot;Medium&amp;quot; # output when second condition is false
      )
    )
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 5
##    species body_mass_g sex     year body_mass_cat
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;        
##  1 Adelie         3750 male    2007 Medium       
##  2 Adelie         3800 female  2007 Medium       
##  3 Adelie         3250 female  2007 Low          
##  4 Adelie           NA &amp;lt;NA&amp;gt;    2007 &amp;lt;NA&amp;gt;         
##  5 Adelie         3450 female  2007 Low          
##  6 Adelie         3650 male    2007 Medium       
##  7 Adelie         3625 female  2007 Medium       
##  8 Adelie         4675 male    2007 Medium       
##  9 Adelie         3475 &amp;lt;NA&amp;gt;    2007 Low          
## 10 Adelie         4250 &amp;lt;NA&amp;gt;    2007 Medium       
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code works as follows:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;It evaluates the first condition &lt;code&gt;body_mass_g &amp;lt; 3500&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If it is true, &lt;code&gt;body_mass_cat&lt;/code&gt; is &lt;code&gt;Low&lt;/code&gt;. On the contrary, if it is false, it evaluates the second condition &lt;code&gt;body_mass_g &amp;gt; 4750&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If this second condition is true, &lt;code&gt;body_mass_cat&lt;/code&gt; is &lt;code&gt;High&lt;/code&gt;, otherwise it is &lt;code&gt;Medium&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As you can see from the results above, it works. However, you will concede that it is easy to make coding mistakes, and that the code is not easy to write nor to read.&lt;/p&gt;
&lt;p&gt;To improve this workflow, we now use the case when technique:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# case when, without a default option
dat |&amp;gt;
  mutate(
    body_mass_cat = case_when(
      body_mass_g &amp;lt; 3500 ~ &amp;quot;Low&amp;quot;,
      body_mass_g &amp;gt;= 3500 &amp;amp; body_mass_g &amp;lt;= 4750 ~ &amp;quot;Medium&amp;quot;,
      body_mass_g &amp;gt; 4750 ~ &amp;quot;High&amp;quot;
    )
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 5
##    species body_mass_g sex     year body_mass_cat
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;        
##  1 Adelie         3750 male    2007 Medium       
##  2 Adelie         3800 female  2007 Medium       
##  3 Adelie         3250 female  2007 Low          
##  4 Adelie           NA &amp;lt;NA&amp;gt;    2007 &amp;lt;NA&amp;gt;         
##  5 Adelie         3450 female  2007 Low          
##  6 Adelie         3650 male    2007 Medium       
##  7 Adelie         3625 female  2007 Medium       
##  8 Adelie         4675 male    2007 Medium       
##  9 Adelie         3475 &amp;lt;NA&amp;gt;    2007 Low          
## 10 Adelie         4250 &amp;lt;NA&amp;gt;    2007 Medium       
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This workflow is much simpler to code and read!&lt;/p&gt;
&lt;p&gt;If there are no missing values in the variable(s) used for the condition(s), it can even be simplified to:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# case when, with a default option
dat |&amp;gt;
  mutate(
    body_mass_cat = case_when(
      body_mass_g &amp;lt; 3500 ~ &amp;quot;Low&amp;quot;,
      body_mass_g &amp;gt; 4750 ~ &amp;quot;High&amp;quot;,
      .default = &amp;quot;Medium&amp;quot; # default output
    )
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 5
##    species body_mass_g sex     year body_mass_cat
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;        
##  1 Adelie         3750 male    2007 Medium       
##  2 Adelie         3800 female  2007 Medium       
##  3 Adelie         3250 female  2007 Low          
##  4 Adelie           NA &amp;lt;NA&amp;gt;    2007 Medium       
##  5 Adelie         3450 female  2007 Low          
##  6 Adelie         3650 male    2007 Medium       
##  7 Adelie         3625 female  2007 Medium       
##  8 Adelie         4675 male    2007 Medium       
##  9 Adelie         3475 &amp;lt;NA&amp;gt;    2007 Low          
## 10 Adelie         4250 &amp;lt;NA&amp;gt;    2007 Medium       
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, a default output can be specified with &lt;code&gt;.default&lt;/code&gt; for observations that do not match any of the conditions.&lt;/p&gt;
&lt;p&gt;However, be careful if there are missing values! Indeed, if there is at least one missing value (as in our case), the code above is not correct because observations with missing &lt;code&gt;body_mass_g&lt;/code&gt; will be misclassified as &lt;code&gt;Medium&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Therefore, if you really want to specify a default output, I recommend using the code below which keeps missing values as &lt;code&gt;NA&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# case when, with a default option and missing values
dat |&amp;gt;
  mutate(
    body_mass_cat = case_when(
      body_mass_g &amp;lt; 3500 ~ &amp;quot;Low&amp;quot;,
      body_mass_g &amp;gt; 4750 ~ &amp;quot;High&amp;quot;,
      is.na(body_mass_g) ~ NA, # keep missing values as NA
      .default = &amp;quot;Medium&amp;quot; # default output
    )
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 × 5
##    species body_mass_g sex     year body_mass_cat
##    &amp;lt;fct&amp;gt;         &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;        
##  1 Adelie         3750 male    2007 Medium       
##  2 Adelie         3800 female  2007 Medium       
##  3 Adelie         3250 female  2007 Low          
##  4 Adelie           NA &amp;lt;NA&amp;gt;    2007 &amp;lt;NA&amp;gt;         
##  5 Adelie         3450 female  2007 Low          
##  6 Adelie         3650 male    2007 Medium       
##  7 Adelie         3625 female  2007 Medium       
##  8 Adelie         4675 male    2007 Medium       
##  9 Adelie         3475 &amp;lt;NA&amp;gt;    2007 Low          
## 10 Adelie         4250 &amp;lt;NA&amp;gt;    2007 Medium       
## # ℹ 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I personally prefer to write all categories and not write a default option for improved code readability and robustness of my code, but it is more a personal opinion.&lt;/p&gt;
&lt;p&gt;In all cases, no matter if you used an if else or a case when, it is a good practice to check the variable you just created to make sure that you obtain the intended results.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion-and-other-resources&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion and other resources&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;This article introduced and illustrated the most common data manipulation and data management tools in R, using the &lt;code&gt;{dplyr}&lt;/code&gt; package. We also introduced the pipe operator, well known to users of modern R packages.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;{dplyr}&lt;/code&gt; package offers many more functions for data manipulation (in particular to merge data frames with the family of &lt;code&gt;join()&lt;/code&gt; functions). If you would like to learn more about this package, I recommend starting with the following resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://dplyr.tidyverse.org/&#34; target=&#34;_blank&#34;&gt;dplyr.tidyverse.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://r4ds.hadley.nz/data-transform.html&#34; target=&#34;_blank&#34;&gt;Chapter “Data transformation”&lt;/a&gt; in the book “R for Data Science”&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rstudio/cheatsheets/blob/main/data-transformation.pdf&#34; target=&#34;_blank&#34;&gt;Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://dplyr.tidyverse.org/articles/dplyr.html&#34; target=&#34;_blank&#34;&gt;Vignette&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;For those who are used to base R, a &lt;a href=&#34;https://cran.r-project.org/web/packages/dplyr/vignettes/base.html&#34; target=&#34;_blank&#34;&gt;vignette&lt;/a&gt; comparing &lt;code&gt;{dplyr}&lt;/code&gt; functions to their base R equivalents&lt;/li&gt;
&lt;/ul&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-palmerpenguins2020horst&#34; class=&#34;csl-entry&#34;&gt;
Horst, Allison Marie, Alison Presmanes Hill, and Kristen B Gorman. 2020. &lt;em&gt;Palmerpenguins: Palmer Archipelago (Antarctica) Penguin Data&lt;/em&gt;. &lt;a href=&#34;https://doi.org/10.5281/zenodo.3960218&#34;&gt;https://doi.org/10.5281/zenodo.3960218&lt;/a&gt;.
&lt;/div&gt;
&lt;/div&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;The keyboard shortcut for the pipe operator is &lt;code&gt;ctrl + shift + m&lt;/code&gt; (Windows) or &lt;code&gt;cmd + shift + m&lt;/code&gt; (Mac). It will print &lt;code&gt;%&amp;gt;%&lt;/code&gt;, unless you specified to use the native pipe operator &lt;code&gt;|&amp;gt;&lt;/code&gt; in the settings of RStudio.&lt;a href=&#34;#fnref1&#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>Scrape Yahoo search engine results with R</title>
      <link>https://statsandr.com/blog/scrape-yahoo-search-engine-results-with-r/</link>
      <pubDate>Thu, 24 Aug 2023 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/scrape-yahoo-search-engine-results-with-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scraping-yahoo-search-engine-results-with-r&#34; id=&#34;toc-scraping-yahoo-search-engine-results-with-r&#34;&gt;Scraping Yahoo search engine results with R&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;images/Scrape-Yahoo-search-engine-results-with-R-statsandr.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: This is a guest post by Manthan Koolwal, founder of Scrapingdog.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Web scraping is the process of extracting data from websites. It is usually done in an automated manner to obtain large amounts of data through various websites, without the need to gather data by hand.&lt;/p&gt;
&lt;p&gt;In a &lt;a href=&#34;https://statsandr.com/blog/web-scraping-in-r/&#34;&gt;previous post&lt;/a&gt;, we introduced this method and illustrated it with a Wikipedia page. Although there are a lot of &lt;a href=&#34;https://www.scrapingdog.com/blog/web-scraping-use-cases/&#34; target=&#34;_blank&#34;&gt;use cases of web scraping&lt;/a&gt;, in this blog post, we are restricting ourselves to scraping search results from Yahoo using R. Scraping search engine results can help you with SEO analysis, competitor analysis, keyword research, trend analysis, etc.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scraping-yahoo-search-engine-results-with-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Scraping Yahoo search engine results with R&lt;/h1&gt;
&lt;p&gt;After &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;installing R and RStudio&lt;/a&gt;, we first need to load the necessary packages by running the following commands:&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;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;rvest&amp;quot;)
# install.packages(&amp;quot;jsonlite&amp;quot;)
# install.packages(&amp;quot;purrr&amp;quot;)

library(rvest)
library(jsonlite)
library(purrr)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;{rvest}&lt;/code&gt; package is for web scraping, the &lt;code&gt;{jsonlite}&lt;/code&gt; package is for working with JSON data and the &lt;code&gt;{purrr}&lt;/code&gt; package is for working with functions and vectors.&lt;/p&gt;
&lt;p&gt;It is always better to decide in advance what exactly we are going to scrape. For this tutorial, we are going to scrape search results from this &lt;a href=&#34;https://search.yahoo.com/search?p=pizza&#34; target=&#34;_blank&#34;&gt;URL&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/Scrape-Yahoo-search-engine-results-with-R-statsandr_2.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We are going to scrape the following data points from this page:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Link&lt;/li&gt;
&lt;li&gt;Title&lt;/li&gt;
&lt;li&gt;Description&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this, we define the URL of the Yahoo search results page that we want to scrape. In this case, we are searching for the word “pizza”.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# URL of the Yahoo search results page
url &amp;lt;- &amp;quot;https://search.yahoo.com/search?p=pizza&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then use the &lt;code&gt;read_html()&lt;/code&gt; function from the &lt;code&gt;{rvest}&lt;/code&gt; package to read the HTML content of the provided URL:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Read the HTML content of the page
page &amp;lt;- read_html(url)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This creates an HTML document object that we can work with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(page)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## List of 2
##  $ node:&amp;lt;externalptr&amp;gt; 
##  $ doc :&amp;lt;externalptr&amp;gt; 
##  - attr(*, &amp;quot;class&amp;quot;)= chr [1:2] &amp;quot;xml_document&amp;quot; &amp;quot;xml_node&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here’s where we start the process of extracting the search results:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Extract search results
results &amp;lt;- page %&amp;gt;%
  html_nodes(&amp;quot;.algo-sr&amp;quot;) %&amp;gt;% # Selector for search result elements
  html_nodes(&amp;quot;a&amp;quot;) %&amp;gt;% # Select the &amp;lt;a&amp;gt; elements within the search results
  # Extract link, title, and description attributes
  map_df(~ data.frame(
    link = .x %&amp;gt;% html_attr(&amp;quot;href&amp;quot;),
    title = .x %&amp;gt;% html_text(),
    description = .x %&amp;gt;% html_attr(&amp;quot;title&amp;quot;),
    stringsAsFactors = FALSE
  ))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the code above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We use &lt;code&gt;%&amp;gt;%&lt;/code&gt; (pipe operator) to chain multiple operations together for clarity.&lt;/li&gt;
&lt;li&gt;First, we use &lt;code&gt;html_nodes(&#34;.algo-sr&#34;)&lt;/code&gt; to select the search result elements with the class &lt;code&gt;.algo-sr&lt;/code&gt;. These elements contain the links to the search results.&lt;/li&gt;
&lt;li&gt;Within each search result element, we further select the &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; elements using &lt;code&gt;html_nodes(&#34;a&#34;)&lt;/code&gt;. These &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; elements contain the link, title, and description information.&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;map_df()&lt;/code&gt;, we iterate through each &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element and extract the link, title, and description attributes.&lt;/li&gt;
&lt;li&gt;We create a data frame with these attributes for each search result.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Finally, we convert the results data frame into JSON format using the &lt;code&gt;toJSON()&lt;/code&gt; function from the &lt;code&gt;{jsonlite}&lt;/code&gt; package. The &lt;code&gt;pretty = TRUE&lt;/code&gt; argument adds indentation for better readability. We use &lt;code&gt;cat()&lt;/code&gt; to print the JSON-formatted results to the console.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Print the results in JSON format
cat(toJSON(results, pretty = TRUE))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIASPJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzEEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.yelp.com%2fsearch%3ffind_desc%3dpizza%26find_loc%3dBrussels%252C%2bR%25C3%25A9gion%2bde%2bBruxelles-Capitale/RK=2/RS=xW.v1O1REkKKLsO7DRIWoIGq4bA-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;yelp.comhttps://www.yelp.com › searchTop 10 Best pizza Near Brussels, Région de Bruxelles-Capitale&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIASfJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzIEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.yelp.com%2fsearch%3fcflt%3dpizza%26find_loc%3dBrussels%252C%2bR%25C3%25A9gion%2bde%2bBruxelles-Capitale/RK=2/RS=zynV6ypY6PoaPj4cg5yD9a1x.LU-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;yelp.comhttps://www.yelp.com › searchTHE BEST 10 PIZZA PLACES IN BRUSSELS, RÉGION DE ... - Yelp&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIASvJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzMEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.dominos.com%2fen/RK=2/RS=darBKTs8REd78kRRFhZb8jRT4jY-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;Domino&amp;#39;shttps://www.dominos.com › enPizza Delivery &amp;amp; Carryout, Pasta, Chicken &amp;amp; More | Domino&amp;#39;s&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIAS_JXNyoA;_ylu=Y29sbwNiZjEEcG9zAzMEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.bing.com%2fimages%2fsearch%3fview%3ddetailV2%26ccid%3ds2TCGJY8%26id%3d7236CCFBE7C0B5849BA9DE100BE4F1F32FCD231D%26thid%3dOIP.s2TCGJY8bjV7G5kps1FEwQHaHa%26mediaurl%3dhttps%3a%2f%2fwww.dominos.com%2fstatic%2f1.98.1%2fimages%2ftiles%2fmixAndMatchDeal%2fhero.webp%26exph%3d530%26expw%3d530%26q%3dpizza%26ck%3d8B813BA6312D3F558421CB691D0C6657%26idpp%3drc%26idpview%3dsingleimage%26form%3drc2idp/RK=2/RS=xsbqmguwIFBhAOzGrm.qrjLykcA-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIATPJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzMEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.bing.com%2fimages%2fsearch%3fview%3ddetailV2%26ccid%3d%2f6Qs28Cq%26id%3d7236CCFBE7C0B5849BA9E9CE4472C5692CE3F420%26thid%3dOIP._6Qs28CqWWCt4S-yapYAXwHaHa%26mediaurl%3dhttps%3a%2f%2fwww.dominos.com%2fstatic%2f1.116.0%2fimages%2ftiles%2fmixAndMatchDealPSC%2fhero.webp%26exph%3d530%26expw%3d530%26q%3dpizza%26ck%3d758519383F5F3AF0EA83707449E54C87%26idpp%3drc%26idpview%3dsingleimage%26form%3drc2idp/RK=2/RS=UHqcKBQXuq8AtTptzc.7rkut3rY-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIATfJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzMEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.bing.com%2fimages%2fsearch%3fview%3ddetailV2%26ccid%3dZ33s1urJ%26id%3d7236CCFBE7C0B5849BA9D44071E0F214A85C5EAF%26thid%3dOIP.Z33s1urJ3ZHwJtgKZtWHJAHaDS%26mediaurl%3dhttps%3a%2f%2fwww.dominos.com%2fcms%2fassets%2f58a8e864-d1aa-457a-9d37-fcc1912b10ad%3fim%3dCrop%2crect%3d%28774%2c1015%2c4331%2c1920%29%3bResize%3d%281700%29%2callowExpansion%26exph%3d754%26expw%3d1700%26q%3dpizza%26ck%3d1274A2028C287B1E2E3A8B0EB2F9DE7D%26idpp%3drc%26idpview%3dsingleimage%26form%3drc2idp/RK=2/RS=d9hH9.gzp8cqI8s0XYrAtGSVGXg-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIATvJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzMEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.bing.com%2fimages%2fsearch%3fview%3ddetailV2%26ccid%3deK8nC663%26id%3d7236CCFBE7C0B5849BA99FA63EED83A3990E2BF8%26thid%3dOIP.eK8nC6636jB9TYTyjaHNGgHaFj%26mediaurl%3dhttps%3a%2f%2fwww.dominos.com%2fstatic%2f1.83.3%2fimages%2ftiles%2fperfectComboDeal%2fside.webp%26exph%3d458%26expw%3d610%26q%3dpizza%26ck%3dCD805B6ADACFFC2697D3BE3D36098B7E%26idpp%3drc%26idpview%3dsingleimage%26form%3drc2idp/RK=2/RS=KY2oqWHmG3Y6yqMzcVPRlshaVsg-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIAT_JXNyoA;_ylu=Y29sbwNiZjEEcG9zAzMEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.bing.com%2fimages%2fsearch%3fview%3ddetailV2%26ccid%3d%2bf29F0Yv%26id%3d7236CCFBE7C0B5849BA985F6EAF3041631C46CA1%26thid%3dOIP.-f29F0YvYvZaKklmamQDSwHaDS%26mediaurl%3dhttps%3a%2f%2fwww.dominos.com%2fcms%2fassets%2f43778453-e8b1-4db6-83fa-00f2dc43d6e3%3fim%3dCrop%2crect%3d%28374%2c325%2c3250%2c1441%29%3bResize%3d%281700%29%2callowExpansion%26exph%3d754%26expw%3d1700%26q%3dpizza%26ck%3d66B92DE33E5F605B85BE7C83BE11836C%26idpp%3drc%26idpview%3dsingleimage%26form%3drc2idp/RK=2/RS=15I_QuI3QQbRtWZj5auaBfXOKWQ-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIAYfJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzQEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.albacioixelles.com%2f/RK=2/RS=GTpw.m6z.2eGOKxyo3K8xVrqSPE-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;Albacioixelleshttps://www.albacioixelles.comAuthentic | Albacioixelles | Elsene&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIAYvJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzUEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.nonalife.com%2f/RK=2/RS=d8sI_7Fy4oweSN3IQQ32zJSfgRY-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;Nonahttps://www.nonalife.comNona&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIAY_JXNyoA;_ylu=Y29sbwNiZjEEcG9zAzYEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=https%3a%2f%2fwww.tripadvisor.com%2fRestaurant_Review-g188644-d2480305-Reviews-Pizza_Saco-Brussels.html/RK=2/RS=52RUI7KZf9vt_R13PVY7sv04RMQ-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;Tripadvisorhttps://www.tripadvisor.com › Restaurant_Review-g188644-dPIZZA SACO, Brussels - Avenue Milcamps 154 - Restaurant ...&amp;quot;
##   },
##   {
##     &amp;quot;link&amp;quot;: &amp;quot;https://r.search.yahoo.com/_ylt=AwrEteLKS0ZqawIAZPJXNyoA;_ylu=Y29sbwNiZjEEcG9zAzcEdnRpZAMEc2VjA3Ny/RV=2/RE=1784201418/RO=10/RU=http%3a%2f%2fwww.pizzasaco.com%2f/RK=2/RS=Zi2tEoNCQKejdFUdm0zsZwuqoig-&amp;quot;,
##     &amp;quot;title&amp;quot;: &amp;quot;pizzasaco.comhttp://www.pizzasaco.comSaco Pizza Bar&amp;quot;
##   }
## ]&lt;/code&gt;&lt;/pre&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;This was a simple tutorial in which we scraped Yahoo search results with R. Following the same process, you can create your own web crawler which can scrape search results from Yahoo for any web query.&lt;/p&gt;
&lt;p&gt;Of course, you can scrape other search engines with almost the same technique. Also, you can check out this tutorial on &lt;a href=&#34;https://www.scrapingdog.com/blog/scrape-google-search-results/&#34; target=&#34;_blank&#34;&gt;web scraping Google search results using Python&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;Note that, as for any R package, it must first be installed (with the &lt;code&gt;install.packages()&lt;/code&gt; function) before being loaded (with the &lt;code&gt;library()&lt;/code&gt; function).&lt;a href=&#34;#fnref1&#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>Two-way ANOVA in R</title>
      <link>https://statsandr.com/blog/two-way-anova-in-r/</link>
      <pubDate>Mon, 19 Jun 2023 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/two-way-anova-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#aim-and-hypotheses-of-a-two-way-anova&#34; id=&#34;toc-aim-and-hypotheses-of-a-two-way-anova&#34;&gt;Aim and hypotheses of a two-way ANOVA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#assumptions-of-a-two-way-anova&#34; id=&#34;toc-assumptions-of-a-two-way-anova&#34;&gt;Assumptions of a two-way ANOVA&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#variable-type&#34; id=&#34;toc-variable-type&#34;&gt;Variable type&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#independence&#34; id=&#34;toc-independence&#34;&gt;Independence&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#normality&#34; id=&#34;toc-normality&#34;&gt;Normality&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#homogeneity-of-variances&#34; id=&#34;toc-homogeneity-of-variances&#34;&gt;Homogeneity of variances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#outliers&#34; id=&#34;toc-outliers&#34;&gt;Outliers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#two-way-anova&#34; id=&#34;toc-two-way-anova&#34;&gt;Two-way ANOVA&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#preliminary-analyses&#34; id=&#34;toc-preliminary-analyses&#34;&gt;Preliminary analyses&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#descriptive-statistics&#34; id=&#34;toc-descriptive-statistics&#34;&gt;Descriptive statistics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#plots&#34; id=&#34;toc-plots&#34;&gt;Plots&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#two-way-anova-in-r&#34; id=&#34;toc-two-way-anova-in-r&#34;&gt;Two-way ANOVA in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#pairwise-comparisons&#34; id=&#34;toc-pairwise-comparisons&#34;&gt;Pairwise comparisons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualizations&#34; id=&#34;toc-visualizations&#34;&gt;Visualizations&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;images/two-way-anova-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;The two-way ANOVA (analysis of variance) is a statistical method that allows to &lt;strong&gt;evaluate the simultaneous effect of two &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;categorical&lt;/a&gt; variables on a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;quantitative continuous&lt;/a&gt; variable&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The two-way ANOVA is an extension of the one-way ANOVA since it allows to evaluate the effects on a numerical response of &lt;strong&gt;two&lt;/strong&gt; categorical variables instead of one.&lt;/p&gt;
&lt;p&gt;The advantage of a two-way ANOVA over a one-way ANOVA is that we test the relationship between two variables, while taking into account the effect of a third variable. Moreover, it also allows to include the possible &lt;em&gt;interaction&lt;/em&gt; of the two categorical variables on the response to evaluate whether or not they act &lt;strong&gt;jointly&lt;/strong&gt; on the response variable.&lt;/p&gt;
&lt;p&gt;The advantage of a two-way over a one-way ANOVA is quite similar to the advantage of a &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;multiple linear regression&lt;/a&gt; over a &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The correlation measures the relationship between two quantitative variables. The multiple linear regression also measures the relationship between two variables, but this time taking into account the potential effect of other covariates.&lt;/li&gt;
&lt;li&gt;The one-way ANOVA tests whether a quantitative variable is different between groups. The two-way ANOVA also tests whether a quantitative variable is different between groups, but this time taking into account the effect of another qualitative variable.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Previously, we have discussed about &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;one-way ANOVA in R&lt;/a&gt;. Now, we show when, why and how to perform a &lt;strong&gt;two-way&lt;/strong&gt; ANOVA in R.&lt;/p&gt;
&lt;p&gt;Before going further, I would like to mention and briefly describe some related statistical methods and tests in order to avoid any confusion:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test&lt;/a&gt; is used to evaluate the effect of one categorical variable on a quantitative continuous variable, &lt;strong&gt;when the categorical variable has exactly 2 levels&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Student’s t-test &lt;em&gt;for independent samples&lt;/em&gt; if the observations are &lt;strong&gt;independent&lt;/strong&gt; (for example: if we compare the age between women and men)&lt;/li&gt;
&lt;li&gt;Student’s t-test &lt;em&gt;for paired samples&lt;/em&gt; if the observations are &lt;strong&gt;dependent&lt;/strong&gt;, that is, when they come in pairs (it is the case when the same subjects are measured twice, at two different points in time, before and after a treatment for example)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;To evaluate the effect of one categorical variable on a quantitative variable, &lt;strong&gt;when the categorical variable has 3 or more levels&lt;/strong&gt;:&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;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;one-way ANOVA&lt;/a&gt;&lt;/em&gt; (often simply referred as ANOVA) if the groups are &lt;strong&gt;independent&lt;/strong&gt; (for example a group of patients who received treatment A, another group of patients who received treatment B, and the last group of patients who received no treatment or a placebo)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;repeated measures ANOVA&lt;/em&gt; if the groups are &lt;strong&gt;dependent&lt;/strong&gt; (when the same subjects are measured three times, at three different points in time, before, during and after a treatment for example)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;A two-way ANOVA is used to evaluate the effects of 2 categorical variables (and their potential interaction) on a quantitative continuous variable. This is the topic of the post.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;Linear regression&lt;/a&gt; is used to evaluate the relationship between a quantitative continuous dependent variable and one or several independent variables:
&lt;ul&gt;
&lt;li&gt;simple linear regression if there is only one independent variable (which can be quantitative or qualitative)&lt;/li&gt;
&lt;li&gt;multiple linear regression if there is at least two independent variables (which can be quantitative, qualitative, or a mix of both)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;An ANCOVA (analysis of covariance) is used to evaluate the effect of a categorical variable on a quantitative variable, while controlling for the effect of another quantitative variable (known as covariate). ANCOVA is actually a special case of multiple linear regression with a mix of one qualitative and one quantitative independent variable.&lt;/li&gt;
&lt;li&gt;A mixed ANOVA is used to test differences between two or more groups whilst subjecting participants to repeated measures: one factor (a fixed effects factor) is a between-subjects variable (for example, treatment A and B, with patients receiving only one of the two treatments) and the other (a random effects factor) is a within-subjects variable (for example, measurements are made on day 1, day 2 and day 3 on all subjects).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this post, we start by explaining when and why a two-way ANOVA is useful, we then do some preliminary descriptive analyses and present how to conduct a two-way ANOVA in R. Finally, we show how to interpret and visualize the results. We also briefly mention and illustrate how to verify the underlying assumptions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;To illustrate how to perform a two-way ANOVA in R, we use the &lt;code&gt;penguins&lt;/code&gt; dataset, available from the &lt;code&gt;{palmerpenguins}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;We do not need to &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;import the dataset&lt;/a&gt;, but we need to &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;load the package&lt;/a&gt; first and then call the dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;palmerpenguins&amp;quot;)
library(palmerpenguins)

dat &amp;lt;- penguins # rename dataset
str(dat) # structure of dataset&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## tibble [344 × 8] (S3: tbl_df/tbl/data.frame)
##  $ species          : Factor w/ 3 levels &amp;quot;Adelie&amp;quot;,&amp;quot;Chinstrap&amp;quot;,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ island           : Factor w/ 3 levels &amp;quot;Biscoe&amp;quot;,&amp;quot;Dream&amp;quot;,..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ bill_length_mm   : num [1:344] 39.1 39.5 40.3 NA 36.7 39.3 38.9 39.2 34.1 42 ...
##  $ bill_depth_mm    : num [1:344] 18.7 17.4 18 NA 19.3 20.6 17.8 19.6 18.1 20.2 ...
##  $ flipper_length_mm: int [1:344] 181 186 195 NA 193 190 181 195 193 190 ...
##  $ body_mass_g      : int [1:344] 3750 3800 3250 NA 3450 3650 3625 4675 3475 4250 ...
##  $ sex              : Factor w/ 2 levels &amp;quot;female&amp;quot;,&amp;quot;male&amp;quot;: 2 1 1 NA 1 2 1 2 NA NA ...
##  $ year             : int [1:344] 2007 2007 2007 2007 2007 2007 2007 2007 2007 2007 ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The dataset contains 8 variables for 344 penguins, summarized below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       species          island    bill_length_mm  bill_depth_mm  
##  Adelie   :152   Biscoe   :168   Min.   :32.10   Min.   :13.10  
##  Chinstrap: 68   Dream    :124   1st Qu.:39.23   1st Qu.:15.60  
##  Gentoo   :124   Torgersen: 52   Median :44.45   Median :17.30  
##                                  Mean   :43.92   Mean   :17.15  
##                                  3rd Qu.:48.50   3rd Qu.:18.70  
##                                  Max.   :59.60   Max.   :21.50  
##                                  NA&amp;#39;s   :2       NA&amp;#39;s   :2      
##  flipper_length_mm  body_mass_g       sex           year     
##  Min.   :172.0     Min.   :2700   female:165   Min.   :2007  
##  1st Qu.:190.0     1st Qu.:3550   male  :168   1st Qu.:2007  
##  Median :197.0     Median :4050   NA&amp;#39;s  : 11   Median :2008  
##  Mean   :200.9     Mean   :4202                Mean   :2008  
##  3rd Qu.:213.0     3rd Qu.:4750                3rd Qu.:2009  
##  Max.   :231.0     Max.   :6300                Max.   :2009  
##  NA&amp;#39;s   :2         NA&amp;#39;s   :2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this post, we will focus on the following three variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;species&lt;/code&gt;: the species of the penguin (Adelie, Chinstrap or Gentoo)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sex&lt;/code&gt;: sex of the penguin (female and male)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;body_mass_g&lt;/code&gt;: body mass of the penguin (in grams)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If needed, more information about this dataset can be found by running &lt;code&gt;?penguins&lt;/code&gt; in R.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;body_mass_g&lt;/code&gt; is the quantitative continuous variable and will be the dependent variable, whereas &lt;code&gt;species&lt;/code&gt; and &lt;code&gt;sex&lt;/code&gt; are both qualitative variables.&lt;/p&gt;
&lt;p&gt;Those two last variables will be our independent variables, also referred as factors. Make sure that they are read as &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factors&lt;/a&gt; by R. If it is not the case, they will need to be &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/#factors&#34;&gt;transformed to factors&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;aim-and-hypotheses-of-a-two-way-anova&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Aim and hypotheses of a two-way ANOVA&lt;/h1&gt;
&lt;p&gt;As mentioned above, a two-way ANOVA is used to &lt;strong&gt;evaluate simultaneously the effect of two categorical variables on one quantitative continuous variable&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It is referred as &lt;strong&gt;two&lt;/strong&gt;-way ANOVA because we are comparing groups which are formed by &lt;strong&gt;two&lt;/strong&gt; independent categorical variables.&lt;/p&gt;
&lt;p&gt;Here, we would like to know if body mass depends on species and/or sex. In particular, we are interested in:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;measuring and testing the relationship between species and body mass,&lt;/li&gt;
&lt;li&gt;measuring and testing the relationship between sex and body mass, and&lt;/li&gt;
&lt;li&gt;potentially check whether the relationship between species and body mass is different for females and males (which is equivalent than checking whether the relationship between sex and body mass depends on the species)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first two relationships are referred as &lt;strong&gt;main effects&lt;/strong&gt;, while the third point is known as the &lt;strong&gt;interaction effect&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The main effects test whether at least one group is different from another one (while controlling for the other independent variable). On the other hand, the interaction effect aims at testing whether the relationship between two variables differs &lt;em&gt;depending on the level of a third variable&lt;/em&gt;. In other words, if the evolution between the response and the first categorical variable does not depend on the modalities of the second categorical variable, then there is no interaction between the two variables. If, on the contrary, there is a modification of this evolution, either by an increase in the effect of the first variable, or by a decrease, then there is an interaction.&lt;/p&gt;
&lt;p&gt;When performing a two-way ANOVA, testing the interaction effect is not mandatory. However, omitting an interaction effect may lead to erroneous conclusions if the interaction effect is present.&lt;/p&gt;
&lt;p&gt;If we go back to our example, we have the following &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Main effect of sex on body mass:
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: mean body mass is equal between females and males&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: mean body mass is different between females and males&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Main effect of species on body mass:
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: mean body mass is equal between all 3 species&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: mean body mass is different for at least one species&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Interaction between sex and species:
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: there is no interaction between sex and species, meaning that the relationship between species and body mass is the same for females and males (similarly, the relationship between sex and body mass is the same for all 3 species)&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: there is an interaction between sex and species, meaning that the relationship between species and body mass is different for females than for males (similarly, the relationship between sex and body mass depends on the species)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;assumptions-of-a-two-way-anova&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Assumptions of a two-way ANOVA&lt;/h1&gt;
&lt;p&gt;Most statistical tests require some assumptions for the results to be valid, and a two-way ANOVA is not an exception.&lt;/p&gt;
&lt;p&gt;Assumptions of a two-way ANOVA are similar than for a one-way ANOVA. To summarize:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Variable type&lt;/strong&gt;: the dependent variable must be quantitative continuous, while the two independent variables must be categorical (with at least two levels).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Independence&lt;/strong&gt;: the observations should be independent between groups and within each group.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normality&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;For small samples, data should follow approximately a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;For large samples (usually &lt;span class=&#34;math inline&#34;&gt;\(n \ge 30\)&lt;/span&gt; in each group/sample), normality is not required (thanks to the central limit theorem)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Equality of variances&lt;/strong&gt;: variances should be equal across groups.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Outliers&lt;/strong&gt;: There should be no significant &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt; in any group.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;More details about these assumptions can be found in the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#underlying-assumptions-of-anova&#34;&gt;assumptions of a one-way ANOVA&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now that we have seen the underlying assumptions of the two-way ANOVA, we review them specifically for our dataset before applying the test and interpreting the results.&lt;/p&gt;
&lt;div id=&#34;variable-type&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Variable type&lt;/h2&gt;
&lt;p&gt;The dependent variable body mass is &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;quantitative continuous&lt;/a&gt;, while both independent variables sex and species are &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative variables&lt;/a&gt; (with at least 2 levels).&lt;/p&gt;
&lt;p&gt;Therefore, this assumption is met.&lt;/p&gt;
&lt;p&gt;If your dependent variable is &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#discrete&#34;&gt;quantitative discrete&lt;/a&gt;, this is count data, which, strictly speaking, should be analyzed using a generalized linear model, not an ANOVA.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;independence&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Independence&lt;/h2&gt;
&lt;p&gt;Independence is usually checked based on the design of the experiment and how data have been collected.&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;To keep it simple, observations are usually:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;independent&lt;/strong&gt; if each experimental unit (here a penguin) has been measured only once and the observations are collected from a representative and randomly selected portion of the population, or&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;dependent&lt;/strong&gt; if each experimental unit has been measured at least twice (as it is often the case in the medical field for example, with two measurements on the same subjects; one before and one after the treatment).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In our case, body mass has been measured only once on each penguin, and on a representative and random sample of the population, so the independence assumption is met.&lt;/p&gt;
&lt;p&gt;Note that if your data correspond to observations made several times on the same experimental units (for example, if one of the factors is a treatment (A or B) and the second factor is time (day 1, day 2 and day 3), and measurements are made at each time point on the same subjects), a two-way &lt;em&gt;mixed&lt;/em&gt; ANOVA should be used.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;normality&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Normality&lt;/h2&gt;
&lt;p&gt;We have a large sample in all subgroups (each combination of the levels of the two factors, called cell):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(dat$species, dat$sex)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##            
##             female male
##   Adelie        73   73
##   Chinstrap     34   34
##   Gentoo        58   61&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;so normality does not need to be checked.&lt;/p&gt;
&lt;p&gt;For completeness, we still show how to verify normality, as if we had a small samples.&lt;/p&gt;
&lt;p&gt;There are several methods to test the normality assumption. The most common methods being:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#qq-plot&#34;&gt;QQ-plot&lt;/a&gt; by group or on the residuals, and/or&lt;/li&gt;
&lt;li&gt;a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; by group or on the residuals, and/or&lt;/li&gt;
&lt;li&gt;a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;normality test&lt;/a&gt; (Shapiro-Wilk test for instance) by group or on the residuals.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The easiest/shortest way is to verify the normality with a QQ-plot on the residuals. To draw this plot, we first need to save the model:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# save model
mod &amp;lt;- aov(body_mass_g ~ sex * species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This piece of code will be explained further.&lt;/p&gt;
&lt;p&gt;Now we can draw the QQ-plot on the residuals. We show two ways to do so, first with the &lt;code&gt;plot()&lt;/code&gt; function and second with the &lt;code&gt;qqPlot()&lt;/code&gt; function from the &lt;code&gt;{car}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# method 1
plot(mod, which = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-5-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# method 2
library(car)

qqPlot(mod$residuals,
  id = FALSE # remove point identification
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-5-2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Code for method 1 is slightly shorter, but it misses the confidence interval around the reference line.&lt;/p&gt;
&lt;p&gt;If points follow the straight line (called Henry’s line) and fall within the confidence band, we can assume normality. This is the case here.&lt;/p&gt;
&lt;p&gt;If you prefer to verify the normality based on a histogram of the residuals, here is the code:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# histogram
hist(mod$residuals)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-6-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The histogram of the residuals show a gaussian distribution, which is in line with the conclusion from the QQ-plot.&lt;/p&gt;
&lt;p&gt;Although the QQ-plot and histogram is largely enough to verify the normality, if you want to test it more formally with a statistical test, the Shapiro-Wilk test can be applied on the residuals as well:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# normality test
shapiro.test(mod$residuals)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Shapiro-Wilk normality test
## 
## data:  mod$residuals
## W = 0.99776, p-value = 0.9367&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(\Rightarrow\)&lt;/span&gt; We do not reject the null hypothesis that the residuals follow a normal distribution (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.937).&lt;/p&gt;
&lt;p&gt;From the QQ-plot, histogram and Shapiro-Wilk test, we conclude that we do not reject the null hypothesis of normality of the residuals.&lt;/p&gt;
&lt;p&gt;The normality assumption is thus verified, we can now check the equality of the variances.&lt;/p&gt;
&lt;p&gt;Note that if the normality assumption is not met, many transformations can be applied on the dependent variable to improve it, the most common ones being the logarithmic (&lt;code&gt;log()&lt;/code&gt; function in R) and the Box-Cox transformations. If the normality assumption is still not met on the transformed data, the non-parametric version of the two-way ANOVA, the &lt;a href=&#34;https://rcompanion.org/handbook/F_14.html&#34; target=&#34;_blank&#34;&gt;Scheirer–Ray–Hare test&lt;/a&gt;, can be used. Alternatively, a permutation test can also be used.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;homogeneity-of-variances&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Homogeneity of variances&lt;/h2&gt;
&lt;p&gt;Equality of variances, also referred as homogeneity of variances or homoscedasticity, can be verified visually with the &lt;code&gt;plot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mod, which = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-8-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Since the spread of the residuals is constant, the red smooth line is horizontal and flat, so it looks like the constant variance assumption is satisfied here.&lt;/p&gt;
&lt;p&gt;The diagnostic plot above is sufficient, but if you prefer it can also be tested more formally with the Levene’s test (also from the &lt;code&gt;{car}&lt;/code&gt; package):&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;leveneTest(mod)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Levene&amp;#39;s Test for Homogeneity of Variance (center = median)
##        Df F value Pr(&amp;gt;F)
## group   5  1.3908 0.2272
##       327&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(\Rightarrow\)&lt;/span&gt; We do not reject the null hypothesis that the variances are equal (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.227).&lt;/p&gt;
&lt;p&gt;Both the visual and formal approaches give the same conclusion; we do not reject the hypothesis of homogeneity of the variances.&lt;/p&gt;
&lt;p&gt;Note that, as for the normality, the logarithmic and Box-Cox transformations may improve homogeneity of the residuals.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;outliers&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Outliers&lt;/h2&gt;
&lt;p&gt;The easiest and most common way to &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;detect outliers&lt;/a&gt; is visually thanks to boxplots by groups.&lt;/p&gt;
&lt;p&gt;For females and males:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)

# boxplots by sex
ggplot(dat) +
  aes(x = sex, y = body_mass_g) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-10-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For the three species:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# boxplots by species
ggplot(dat) +
  aes(x = species, y = body_mass_g) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-11-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;There are, as defined by the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#interquartile-range&#34;&gt;interquartile range criterion&lt;/a&gt;, two outliers for the species Chinstrap. These points are, nonetheless, not extreme enough to bias results.&lt;/p&gt;
&lt;p&gt;Therefore, we consider that the assumption of no significant outliers is met.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;two-way-anova&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Two-way ANOVA&lt;/h1&gt;
&lt;p&gt;We have shown that all assumptions are met, so we can now proceed to the implementation of the two-way ANOVA in R.&lt;/p&gt;
&lt;p&gt;This will allow us to answer the following research questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Controlling for the species, is body mass significantly different between the two sexes?&lt;/li&gt;
&lt;li&gt;Controlling for the sex, is body mass significantly different for at least one species?&lt;/li&gt;
&lt;li&gt;Is the relationship between species and body mass different between female and male penguins?&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;preliminary-analyses&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Preliminary analyses&lt;/h2&gt;
&lt;p&gt;Before performing any statistical test, it is a good practice to make some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; in order to have a first overview of the data, and perhaps, have a glimpse of the results to be expected.&lt;/p&gt;
&lt;p&gt;This can be done via descriptive statistics or plots.&lt;/p&gt;
&lt;div id=&#34;descriptive-statistics&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Descriptive statistics&lt;/h3&gt;
&lt;p&gt;If we want to keep it simple, we can compute only the mean for each subgroup:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# mean by group
aggregate(body_mass_g ~ species + sex,
  data = dat,
  FUN = mean
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     species    sex body_mass_g
## 1    Adelie female    3368.836
## 2 Chinstrap female    3527.206
## 3    Gentoo female    4679.741
## 4    Adelie   male    4043.493
## 5 Chinstrap   male    3938.971
## 6    Gentoo   male    5484.836&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or eventually, the mean and &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#standard-deviation&#34;&gt;standard deviation&lt;/a&gt; for each subgroup using the &lt;code&gt;{dplyr}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# mean and sd by group
library(dplyr)

group_by(dat, sex, species) %&amp;gt;%
  summarise(
    mean = round(mean(body_mass_g, na.rm = TRUE)),
    sd = round(sd(body_mass_g, na.rm = TRUE))
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 × 4
## # Groups:   sex [3]
##   sex    species    mean    sd
##   &amp;lt;fct&amp;gt;  &amp;lt;fct&amp;gt;     &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1 female Adelie     3369   269
## 2 female Chinstrap  3527   285
## 3 female Gentoo     4680   282
## 4 male   Adelie     4043   347
## 5 male   Chinstrap  3939   362
## 6 male   Gentoo     5485   313
## 7 &amp;lt;NA&amp;gt;   Adelie     3540   477
## 8 &amp;lt;NA&amp;gt;   Gentoo     4588   338&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;plots&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Plots&lt;/h3&gt;
&lt;p&gt;If you are a frequent reader of the blog, you know that I like to draw plots to visualize the data at hand before interpreting results of a test.&lt;/p&gt;
&lt;p&gt;The most appropriate plot when we have one quantitative and two qualitative variables is a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; by group. This can easily be made 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;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# boxplot by group
library(ggplot2)

ggplot(dat) +
  aes(x = species, y = body_mass_g, fill = sex) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-14-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Some observations are missing for the sex, we can remove them to have a more concise plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat %&amp;gt;%
  filter(!is.na(sex)) %&amp;gt;%
  ggplot() +
  aes(x = species, y = body_mass_g, fill = sex) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-15-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that we could also have made the following plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat %&amp;gt;%
  filter(!is.na(sex)) %&amp;gt;%
  ggplot() +
  aes(x = sex, y = body_mass_g, fill = species) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-16-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;But for a more readable plot, I tend to prefer putting the variable with the smallest number of levels as color (which is in fact the argument &lt;code&gt;fill&lt;/code&gt; in the &lt;code&gt;aes()&lt;/code&gt; layer) and the variable with the largest number of categories on the x-axis (i.e., the argument &lt;code&gt;x&lt;/code&gt; in the &lt;code&gt;aes()&lt;/code&gt; layer).&lt;/p&gt;
&lt;p&gt;From the means and the boxplots by subgroup, we can already see that, &lt;em&gt;in our sample&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;female penguins tend to have a lower body mass than males, and that is the case for all the considered species, and&lt;/li&gt;
&lt;li&gt;body mass is higher for Gentoo penguins than for the other two species.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Bear in mind that these conclusions are only valid within our &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt;! To generalize these conclusions to the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt;, we need to perform the two-way ANOVA and check the significance of the explanatory variables. This is the aim of the next section.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;two-way-anova-in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Two-way ANOVA in R&lt;/h2&gt;
&lt;p&gt;As mentioned earlier, including an interaction effect in a two-way ANOVA is not compulsory. However, in order to avoid flawed conclusions, it is recommended to first check whether the interaction is significant or not, and depending on the results, include it or not.&lt;/p&gt;
&lt;p&gt;If the interaction is not significant, it is safe to remove it from the final model. On the contrary, if the interaction is significant, it should be included in the final model which will be used to interpret results.&lt;/p&gt;
&lt;p&gt;We thus start with a model which includes the two main effects (i.e., sex and species) and the interaction:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Two-way ANOVA with interaction
# save model
mod &amp;lt;- aov(body_mass_g ~ sex * species,
  data = dat
)

# print results
summary(mod)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##              Df    Sum Sq  Mean Sq F value   Pr(&amp;gt;F)    
## sex           1  38878897 38878897 406.145  &amp;lt; 2e-16 ***
## species       2 143401584 71700792 749.016  &amp;lt; 2e-16 ***
## sex:species   2   1676557   838278   8.757 0.000197 ***
## Residuals   327  31302628    95727                     
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 11 observations deleted due to missingness&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Similar to a one-way ANOVA, the principle of a two-way ANOVA is based on the total dispersion of the data, and its decomposition into four components:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the share attributable to the first factor&lt;/li&gt;
&lt;li&gt;the share attributable to the second factor&lt;/li&gt;
&lt;li&gt;the share attributable to the interaction of the 2 factors&lt;/li&gt;
&lt;li&gt;the unexplained, or residual portion.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The sum of squares (column &lt;code&gt;Sum Sq&lt;/code&gt;) shows these four components. The two-way ANOVA consists of using a statistical test to determine whether each of the dispersion component (attributable to the 2 factors studied and to their interaction) is significantly greater than the residual component. If this is the case, we conclude that the effect considered (factor A, factor B or the interaction) is significant.&lt;/p&gt;
&lt;p&gt;We see that the species explain a large part of the variability of body mass. It is the most important factor in explaining this variability.&lt;/p&gt;
&lt;p&gt;The &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values are displayed in the last column of the output above (&lt;code&gt;Pr(&amp;gt;F)&lt;/code&gt;). From these &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values, we conclude that, at the 5% significance level:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;controlling for the species, body mass is significantly different between the two sexes,&lt;/li&gt;
&lt;li&gt;controlling for the sex, body mass is significantly different for at least one species, and&lt;/li&gt;
&lt;li&gt;the interaction between sex and species (displayed at the line &lt;code&gt;sex:species&lt;/code&gt; in the output above) is significant.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So from the significant interaction effect, we have just seen that the relationship between body mass and species is different between males and females. Since it is significant, we have to keep it in the model and we should interpret results from that model.&lt;/p&gt;
&lt;p&gt;If, on the contrary, the interaction was not significant (that is, if the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(\ge\)&lt;/span&gt; 0.05) we would have removed this interaction effect from the model. For illustrative purposes, below the code for a two-way ANOVA without interaction, referred as an additive model:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Two-way ANOVA without interaction
aov(body_mass_g ~ sex + species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the readers who are used to perform &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regressions in R&lt;/a&gt;, you will notice that the structure of the code for a two-way ANOVA is in fact similar:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the formula is &lt;code&gt;dependent variable ~ independent variables&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;+&lt;/code&gt; sign is used to include independent variables &lt;em&gt;without&lt;/em&gt; an interaction&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;*&lt;/code&gt; sign is used to include independent variables &lt;em&gt;with&lt;/em&gt; an interaction&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The resemblance with a linear regression is not a surprise because a two-way ANOVA, like all ANOVA, is actually a linear model.&lt;/p&gt;
&lt;p&gt;Note that the following code works as well, and give the same results:&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# method 2
mod2 &amp;lt;- lm(body_mass_g ~ sex * species,
  data = dat
)

Anova(mod2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Anova Table (Type II tests)
## 
## Response: body_mass_g
##                Sum Sq  Df F value    Pr(&amp;gt;F)    
## sex          37090262   1 387.460 &amp;lt; 2.2e-16 ***
## species     143401584   2 749.016 &amp;lt; 2.2e-16 ***
## sex:species   1676557   2   8.757 0.0001973 ***
## Residuals    31302628 327                      
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the &lt;code&gt;aov()&lt;/code&gt; function assumes a &lt;strong&gt;balanced design&lt;/strong&gt;, meaning that we have equal sample sizes within levels of our independent grouping variables. Moreover, &lt;code&gt;aov()&lt;/code&gt; uses the type I sums of squares, so we can obtain different &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values when we write &lt;code&gt;y ~ A * B&lt;/code&gt; and &lt;code&gt;y ~ B * A&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For &lt;strong&gt;unbalanced design&lt;/strong&gt;, that is, unequal numbers of subjects in each subgroup, the recommended methods are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the type II ANOVA when there is &lt;strong&gt;no&lt;/strong&gt; significant interaction, which can be done in R with &lt;code&gt;Anova(mod, type = &#34;II&#34;)&lt;/code&gt; or &lt;code&gt;Anova(mod, type = 2)&lt;/code&gt;, where &lt;code&gt;mod&lt;/code&gt; is the name of your saved model, and&lt;/li&gt;
&lt;li&gt;the type III ANOVA when there is a significant interaction, which can be done in R with &lt;code&gt;Anova(mod, type = &#34;III&#34;)&lt;/code&gt; or &lt;code&gt;Anova(mod, type = 3)&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is beyond the scope of the post and we assume a balanced design here. For the interested reader, see this &lt;a href=&#34;https://mcfromnz.wordpress.com/2011/03/02/anova-type-iiiiii-ss-explained/&#34; target=&#34;_blank&#34;&gt;detailed discussion&lt;/a&gt; about type I, type II and type III ANOVA.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;pairwise-comparisons&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Pairwise comparisons&lt;/h2&gt;
&lt;p&gt;Through the two main effects being significant, we concluded that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;controlling for the species, body mass is different between females and males, and&lt;/li&gt;
&lt;li&gt;controlling for the sex, body mass is different for at least one species.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If body mass is different between the two sexes, given that there are exactly two sexes, it must be because body mass is significantly different between females and males.&lt;/p&gt;
&lt;p&gt;If one wants to know which sex has the highest body mass, it can be deduced from the means and/or boxplots by subgroup. Here, it is clear that males have a significantly higher body mass than females.&lt;/p&gt;
&lt;p&gt;However, it is not so straightforward for the species. Let me explain why it is not as easy as for the sexes.&lt;/p&gt;
&lt;p&gt;There are three species (Adelie, Chinstrap and Gentoo), so there are 3 pairs of species:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Adelie and Chinstrap&lt;/li&gt;
&lt;li&gt;Adelie and Gentoo&lt;/li&gt;
&lt;li&gt;Chinstrap and Gentoo&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If body mass is significantly different for at least one species, it could be that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;body mass is significantly different between Adelie and Chinstrap but not significantly different between Adelie and Gentoo, and not significantly different between Chinstrap and Gentoo, or&lt;/li&gt;
&lt;li&gt;body mass is significantly different between Adelie and Gentoo but not significantly different between Adelie and Chinstrap, and not significantly different between Chinstrap and Gentoo, or&lt;/li&gt;
&lt;li&gt;body mass is significantly different between Chinstrap and Gentoo but not significantly different between Adelie and Chinstrap, and not significantly different between Adelie and Gentoo.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Or, it could also be that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;body mass is significantly different between Adelie and Chinstrap, and between Adelie and Gentoo, but not significantly different between Chinstrap and Gentoo, or&lt;/li&gt;
&lt;li&gt;body mass is significantly different between Adelie and Chinstrap, and between Chinstrap and Gentoo, but not significantly different between Adelie and Gentoo, or&lt;/li&gt;
&lt;li&gt;body mass is significantly different between Chinstrap and Gentoo, and between Adelie and Gentoo, but not significantly different between Adelie and Chinstrap.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Last, it could also be that body mass is significantly different between &lt;strong&gt;all&lt;/strong&gt; species.&lt;/p&gt;
&lt;p&gt;As for a &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;one-way ANOVA&lt;/a&gt;, we cannot, at this stage, know precisely which species is different from which one in terms of body mass. To know this, we need to compare each species two by two thanks to post-hoc tests (also known as pairwise comparisons).&lt;/p&gt;
&lt;p&gt;There are several post-hoc tests, the most common ones being the Tukey HSD which tests all possible pairs of groups, and the Dunett’s test which compares all groups to a reference group. As mentioned earlier, these tests should not be done on the sex variable because there are only two levels.&lt;/p&gt;
&lt;p&gt;In this post, we show only the Tukey HSD test. For the interested reader, the Dunnett’s test is illustrated &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#dunnetts-test&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As for the one-way ANOVA, the Tukey HSD test can be done in R as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# method 1
TukeyHSD(mod,
  which = &amp;quot;species&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = body_mass_g ~ sex * species, data = dat)
## 
## $species
##                        diff       lwr       upr     p adj
## Chinstrap-Adelie   26.92385  -80.0258  133.8735 0.8241288
## Gentoo-Adelie    1377.65816 1287.6926 1467.6237 0.0000000
## Gentoo-Chinstrap 1350.73431 1239.9964 1461.4722 0.0000000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or using the &lt;code&gt;{multcomp}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# method 2
library(multcomp)

res_tukey &amp;lt;- glht(
  aov(body_mass_g ~ sex + species,
    data = dat
  ),
  linfct = mcp(species = &amp;quot;Tukey&amp;quot;)
)

summary(res_tukey)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	 Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: aov(formula = body_mass_g ~ sex + species, data = dat)
## 
## Linear Hypotheses:
##                         Estimate Std. Error t value Pr(&amp;gt;|t|)    
## Chinstrap - Adelie == 0    26.92      46.48   0.579     0.83    
## Gentoo - Adelie == 0     1377.86      39.10  35.236   &amp;lt;1e-05 ***
## Gentoo - Chinstrap == 0  1350.93      48.13  28.067   &amp;lt;1e-05 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## (Adjusted p values reported -- single-step method)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or using the &lt;code&gt;pairwise.t.test()&lt;/code&gt; function using the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value adjustment method of your choice:&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# method 3
pairwise.t.test(dat$body_mass_g, dat$species,
  p.adjust.method = &amp;quot;BH&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Pairwise comparisons using t tests with pooled SD 
## 
## data:  dat$body_mass_g and dat$species 
## 
##           Adelie Chinstrap
## Chinstrap 0.63   -        
## Gentoo    &amp;lt;2e-16 &amp;lt;2e-16   
## 
## P value adjustment method: BH&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that when using the second method, it is the model without the interaction that needs to be specified into the &lt;code&gt;glht()&lt;/code&gt; function, even if the interaction is significant. Moreover, do not forget to replace &lt;code&gt;mod&lt;/code&gt; and &lt;code&gt;species&lt;/code&gt; in my code with the name of your model and the name of your independent variable.&lt;/p&gt;
&lt;p&gt;Both methods give the same results, that is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;body mass is &lt;em&gt;not&lt;/em&gt; significantly different between Chinstrap and Adelie (adjusted &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.83),&lt;/li&gt;
&lt;li&gt;body mass is significantly different between Gentoo and Adelie (adjusted &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001), and&lt;/li&gt;
&lt;li&gt;body mass is significantly different between Gentoo and Chinstrap (adjusted &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Remember that it is the &lt;strong&gt;adjusted&lt;/strong&gt; &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values that are reported, to prevent the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#issue-of-multiple-testing&#34;&gt;issue of multiple testing&lt;/a&gt; which occurs when comparing several pairs of groups.&lt;/p&gt;
&lt;p&gt;If you would like to compare all combinations of groups, it can be done with the &lt;code&gt;TukeyHSD()&lt;/code&gt; function and specifying the interaction in the &lt;code&gt;which&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# all combinations of sex and species
TukeyHSD(mod,
  which = &amp;quot;sex:species&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = body_mass_g ~ sex * species, data = dat)
## 
## $`sex:species`
##                                      diff       lwr       upr     p adj
## male:Adelie-female:Adelie        674.6575  527.8486  821.4664 0.0000000
## female:Chinstrap-female:Adelie   158.3703  -25.7874  342.5279 0.1376213
## male:Chinstrap-female:Adelie     570.1350  385.9773  754.2926 0.0000000
## female:Gentoo-female:Adelie     1310.9058 1154.8934 1466.9181 0.0000000
## male:Gentoo-female:Adelie       2116.0004 1962.1408 2269.8601 0.0000000
## female:Chinstrap-male:Adelie    -516.2873 -700.4449 -332.1296 0.0000000
## male:Chinstrap-male:Adelie      -104.5226 -288.6802   79.6351 0.5812048
## female:Gentoo-male:Adelie        636.2482  480.2359  792.2606 0.0000000
## male:Gentoo-male:Adelie         1441.3429 1287.4832 1595.2026 0.0000000
## male:Chinstrap-female:Chinstrap  411.7647  196.6479  626.8815 0.0000012
## female:Gentoo-female:Chinstrap  1152.5355  960.9603 1344.1107 0.0000000
## male:Gentoo-female:Chinstrap    1957.6302 1767.8040 2147.4564 0.0000000
## female:Gentoo-male:Chinstrap     740.7708  549.1956  932.3460 0.0000000
## male:Gentoo-male:Chinstrap      1545.8655 1356.0392 1735.6917 0.0000000
## male:Gentoo-female:Gentoo        805.0947  642.4300  967.7594 0.0000000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or with the &lt;code&gt;HSD.test()&lt;/code&gt; function from the &lt;code&gt;{agricolae}&lt;/code&gt; package, which denotes subgroups that are not significantly different from each other with the same letter:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(agricolae)

HSD.test(mod,
  trt = c(&amp;quot;sex&amp;quot;, &amp;quot;species&amp;quot;),
  console = TRUE # print results
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Study: mod ~ c(&amp;quot;sex&amp;quot;, &amp;quot;species&amp;quot;)
## 
## HSD Test for body_mass_g 
## 
## Mean Square Error:  95726.69 
## 
## sex:species,  means
## 
##                  body_mass_g      std  r  Min  Max
## female:Adelie       3368.836 269.3801 73 2850 3900
## female:Chinstrap    3527.206 285.3339 34 2700 4150
## female:Gentoo       4679.741 281.5783 58 3950 5200
## male:Adelie         4043.493 346.8116 73 3325 4775
## male:Chinstrap      3938.971 362.1376 34 3250 4800
## male:Gentoo         5484.836 313.1586 61 4750 6300
## 
## Alpha: 0.05 ; DF Error: 327 
## Critical Value of Studentized Range: 4.054126 
## 
## Groups according to probability of means differences and alpha level( 0.05 )
## 
## Treatments with the same letter are not significantly different.
## 
##                  body_mass_g groups
## male:Gentoo         5484.836      a
## female:Gentoo       4679.741      b
## male:Adelie         4043.493      c
## male:Chinstrap      3938.971      c
## female:Chinstrap    3527.206      d
## female:Adelie       3368.836      d&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you have many groups to compare, plotting them might be easier to interpret:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# set axis margins so labels do not get cut off
par(mar = c(4.1, 13.5, 4.1, 2.1))

# create confidence interval for each comparison
plot(TukeyHSD(mod, which = &amp;quot;sex:species&amp;quot;),
  las = 2 # rotate x-axis ticks
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-25-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the outputs and plot above, we conclude that all combinations of sex and species are significantly different, except between female Chinstrap and female Adelie (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.138) and male Chinstrap and male Adelie (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.581).&lt;/p&gt;
&lt;p&gt;These results, which are by the way in line with the boxplots shown above and which will be confirmed with the visualizations below, concludes the two-way ANOVA in R.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;visualizations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualizations&lt;/h2&gt;
&lt;p&gt;If you would like to visualize results in a different way to what has already been presented in the preliminary analyses, below are some ideas of useful plots.&lt;/p&gt;
&lt;p&gt;First, with the mean and standard error of the mean by subgroup using the &lt;code&gt;allEffects()&lt;/code&gt; function from the &lt;code&gt;{effects}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# method 1
library(effects)

plot(allEffects(mod))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-26-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Or using the &lt;code&gt;{ggpubr}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# method 2
library(ggpubr)

ggline(subset(dat, !is.na(sex)), # remove NA level for sex
  x = &amp;quot;species&amp;quot;,
  y = &amp;quot;body_mass_g&amp;quot;,
  color = &amp;quot;sex&amp;quot;,
  add = c(&amp;quot;mean_se&amp;quot;) # add mean and standard error
) +
  labs(y = &amp;quot;Mean of body mass (g)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-27-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Alternatively, using &lt;code&gt;{Rmisc}&lt;/code&gt; and &lt;code&gt;{ggplot2}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(Rmisc)

# compute mean and standard error of the mean by subgroup
summary_stat &amp;lt;- summarySE(dat,
  measurevar = &amp;quot;body_mass_g&amp;quot;,
  groupvars = c(&amp;quot;species&amp;quot;, &amp;quot;sex&amp;quot;)
)

# plot mean and standard error of the mean
ggplot(
  subset(summary_stat, !is.na(sex)), # remove NA level for sex
  aes(x = species, y = body_mass_g, colour = sex)
) +
  geom_errorbar(aes(ymin = body_mass_g - se, ymax = body_mass_g + se), # add error bars
    width = 0.1 # width of error bars
  ) +
  geom_point() +
  labs(y = &amp;quot;Mean of body mass (g)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-28-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Second, if you prefer to draw only the mean by subgroup:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;with(
  dat,
  interaction.plot(species, sex, body_mass_g)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-29-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Last but not least, for those of you who are familiar with GraphPad, you are most likely familiar with plotting means and error bars as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot mean and standard error of the mean as barplots
ggplot(
  subset(summary_stat, !is.na(sex)), # remove NA level for sex
  aes(x = species, y = body_mass_g, fill = sex)
) +
  geom_bar(position = position_dodge(), stat = &amp;quot;identity&amp;quot;) +
  geom_errorbar(aes(ymin = body_mass_g - se, ymax = body_mass_g + se), # add error bars
    width = 0.25, # width of error bars
    position = position_dodge(.9)
  ) +
  labs(y = &amp;quot;Mean of body mass (g)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/two-way-anova-in-r/index_files/figure-html/unnamed-chunk-30-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&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;In this post, we started with a few reminders of the different tests that exist to compare a quantitative variable across groups. We then focused on the two-way ANOVA, starting from its goal and hypotheses to its implementation in R, together with the interpretations and some visualizations. We also briefly mentioned its underlying assumptions and one post-hoc test to compare all subgroups.&lt;/p&gt;
&lt;p&gt;All this was illustrated with the &lt;code&gt;penguins&lt;/code&gt; dataset available from the &lt;code&gt;{palmerpenguins}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article will help you in conducting a two-way ANOVA with your data.&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;In theory, a one-way ANOVA can also be used to compare 2 groups, and not only 3 or more. Nonetheless, in practice, it is often the case that a Student’s t-test is performed to compare 2 groups, and a one-way ANOVA to compare 3 or more groups. Conclusions obtained via a Student’s t-test for independent samples and a one-way ANOVA with 2 groups will be similar.&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;If you really want to test the independence, you can do so visually with a plot of the residuals vs. fitted values. This plot can be done in R with &lt;code&gt;plot(mod, which = 1)&lt;/code&gt;, where &lt;code&gt;mod&lt;/code&gt; corresponds to the name of your model. Or you can do so with the Durbin-Watson test. In R, it can be done with the &lt;code&gt;durbinWatsonTest()&lt;/code&gt; function from the &lt;code&gt;{car}&lt;/code&gt; package.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Note that the Bartlett’s and Fligner-Killeen tests are also appropriate to test the assumption of equal variances.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;An additive model makes the assumption that the 2 explanatory variables are independent; they do not interact with each other.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;To not be confused with the &lt;code&gt;anova()&lt;/code&gt; function because it provides sequential results that depend on the order in which the variables appear in the model.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;Here, we use the Benjamini &amp;amp; Hochberg (1995) correction, but you can choose between several methods. See &lt;code&gt;?p.adjust&lt;/code&gt; for more details.&lt;a href=&#34;#fnref6&#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>Top 10 errors in R and how to fix them</title>
      <link>https://statsandr.com/blog/top-10-errors-in-r/</link>
      <pubDate>Tue, 07 Feb 2023 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/top-10-errors-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#unmatched-parentheses-curly-braces-square-brackets-or-quotes&#34; id=&#34;toc-unmatched-parentheses-curly-braces-square-brackets-or-quotes&#34;&gt;1. Unmatched parentheses, curly braces, square brackets or quotes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#using-a-function-that-is-not-installed-or-loaded&#34; id=&#34;toc-using-a-function-that-is-not-installed-or-loaded&#34;&gt;2. Using a function that is not installed or loaded&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#typos-in-function-variable-dataset-object-or-package-names&#34; id=&#34;toc-typos-in-function-variable-dataset-object-or-package-names&#34;&gt;3. Typos in function, variable, dataset, object or package names&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#missing-incorrect-or-misspelled-arguments-in-functions&#34; id=&#34;toc-missing-incorrect-or-misspelled-arguments-in-functions&#34;&gt;4. Missing, incorrect or misspelled arguments in functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#wrong-inappropriate-or-inconsistent-data-types&#34; id=&#34;toc-wrong-inappropriate-or-inconsistent-data-types&#34;&gt;5. Wrong, inappropriate or inconsistent data types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#forgetting-the-sign-in-ggplot2&#34; id=&#34;toc-forgetting-the-sign-in-ggplot2&#34;&gt;6. Forgetting the + sign in ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#misunderstanding-between-and&#34; id=&#34;toc-misunderstanding-between-and&#34;&gt;7. Misunderstanding between = and ==&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#undefined-columns-selected&#34; id=&#34;toc-undefined-columns-selected&#34;&gt;8. Undefined columns selected&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#problem-when-importing-or-using-the-wrong-data-file&#34; id=&#34;toc-problem-when-importing-or-using-the-wrong-data-file&#34;&gt;9. Problem when importing or using the wrong data file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#problem-when-using-the-operator&#34; id=&#34;toc-problem-when-using-the-operator&#34;&gt;10. Problem when using the $ operator&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#operator-is-invalid-for-atomic-vectors&#34; id=&#34;toc-operator-is-invalid-for-atomic-vectors&#34;&gt;$ operator is invalid for atomic vectors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#object-of-type-closure-is-not-subsettable&#34; id=&#34;toc-object-of-type-closure-is-not-subsettable&#34;&gt;object of type ‘closure’ is not subsettable&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#warnings&#34; id=&#34;toc-warnings&#34;&gt;Warnings&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#nas-introduced-by-coercion&#34; id=&#34;toc-nas-introduced-by-coercion&#34;&gt;NAs introduced by coercion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#removed-rows-containing-non-finite-values-stat_bin&#34; id=&#34;toc-removed-rows-containing-non-finite-values-stat_bin&#34;&gt;Removed … rows containing non-finite values (stat_bin())&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;images/top-10-errors-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;If you are just starting with R, you will often encounter errors in your code which prevent it to run. I remember when I was just starting to use R, errors in my code were so frequent that I almost gave up learning this programming language. I even recall that I went back to Excel a few times to finish my analyses because I could not find what was causing the issue.&lt;/p&gt;
&lt;p&gt;Fortunately, I forced myself to continue despite the difficulties of the beginning. And today, even if I still encounter errors almost every time I write R code, with experience and practice, it takes less and less time to fix them. If you are also struggling at the beginning, rest assured, it is normal: everyone experiences some frustration when learning a new programming language (and this is the case not only with R).&lt;/p&gt;
&lt;p&gt;In this post, I highlight the &lt;strong&gt;10 most common errors in R and how to fix them&lt;/strong&gt;. Of course, errors depend on your code and your analyses, so it is impossible to cover all of them (and Google does it way better than me). However, I would like to focus on some common syntax mistakes that are frequent when learning R, and which can sometimes take a long time to be fixed before realizing that the solution is right in front of our eyes.&lt;/p&gt;
&lt;p&gt;This collection is based on my personal experience and the errors encountered by my students when I &lt;a href=&#34;https://antoinesoetewey.com/teaching/&#34;&gt;teach&lt;/a&gt; R. This list being non-exhaustive, feel free to comment (at the end of the post) with errors you often face when using R.&lt;/p&gt;
&lt;p&gt;For each error, I provide examples and solutions to fix them. I also mention a couple of warnings (which are, strictly speaking, not errors) at the end of the post.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;unmatched-parentheses-curly-braces-square-brackets-or-quotes&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;1. Unmatched parentheses, curly braces, square brackets or quotes&lt;/h1&gt;
&lt;p&gt;One rather trivial but still quite frequent error is a missing parenthesis, curly brace, square bracket or quotation mark.&lt;/p&gt;
&lt;p&gt;This type of error is applicable to many programming languages. In R, for instance:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## missing a closing parenthesis:
mean(c(1, 7, 13)
     
## missing a curly brace before &amp;quot;else&amp;quot;:
x &amp;lt;- 7 
if(x &amp;gt; 10) {
  print(&amp;quot;x &amp;gt; 10&amp;quot;)
 else {
  print(&amp;quot;x &amp;lt;= 10&amp;quot;)
 }
  
## missing a square bracket:
summary(ggplot2::diamonds[, &amp;quot;price&amp;quot;)

## missing a closing quote in 2nd element:
grp &amp;lt;- c(&amp;quot;Group 1&amp;quot;, &amp;quot;Group 2) 
grp&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These errors are easy to detect when the code is basic, but can become much harder to spot with a more complex code, for instance:&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;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;for (i in y) {
  for (j in x) {
    p &amp;lt;- ggboxplot(dat,
      x = colnames(dat[j]), y = colnames(dat[i]),
      color = colnames(dat[j]),
      legend = &amp;quot;none&amp;quot;,
      palette = &amp;quot;npg&amp;quot;,
      add = &amp;quot;jitter&amp;quot;
    )
    print(
      p + stat_compare_means(aes(label = paste0(..method.., &amp;quot;, p-value = &amp;quot;, ..p.format..),
        method = method1, label.y = max(dat[, i], na.rm = TRUE)
      )
      + stat_compare_means(comparisons = my_comparisons, method = method2, label = &amp;quot;p.format&amp;quot;)
    )
  }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thankfully, if you use RStudio,&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; a closing parenthesis, curly brace, square bracket or quotation mark will automatically be written when you open one.&lt;/p&gt;
&lt;p&gt;Bear in mind that when installing a package, you &lt;em&gt;must&lt;/em&gt; use (single or double) quotation marks around the package’s name:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## NOT correct:
install.packages(ggplot2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in install.packages : object &amp;#39;ggplot2&amp;#39; not found&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Instead, write one of the two following options:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;ggplot2&amp;quot;)

# install.packages(&amp;#39;ggplot2&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;solution&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;The solution of course is to simply match all opening parentheses, curly braces, square brackets and quotation marks with their closing counterparts:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(c(1, 7, 13))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- 7
if (x &amp;gt; 10) {
  print(&amp;quot;x &amp;gt; 10&amp;quot;)
} else {
  print(&amp;quot;x &amp;lt;= 10&amp;quot;)
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;x &amp;lt;= 10&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(ggplot2::diamonds[, &amp;quot;price&amp;quot;])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      price      
##  Min.   :  326  
##  1st Qu.:  950  
##  Median : 2401  
##  Mean   : 3933  
##  3rd Qu.: 5324  
##  Max.   :18823&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grp &amp;lt;- c(&amp;quot;Group 1&amp;quot;, &amp;quot;Group 2&amp;quot;)
grp&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Group 1&amp;quot; &amp;quot;Group 2&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also, make sure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;to correctly place commas:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## NOT correct (misplaced comma):
c(&amp;quot;Group 1,&amp;quot; &amp;quot;Group 2&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error: unexpected string constant in &amp;quot;c(&amp;quot;Group 1,&amp;quot; &amp;quot;Group 2&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## also NOT correct (missing comma):
c(&amp;quot;Group 1&amp;quot; &amp;quot;Group 2&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error: unexpected string constant in &amp;quot;c(&amp;quot;Group 1&amp;quot; &amp;quot;Group 2&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## correct:
c(&amp;quot;Group 1&amp;quot;, &amp;quot;Group 2&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;you do not mix single and double quotation marks for the same element:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## NOT correct:
c(&amp;quot;Group 1&amp;#39;)

## correct:
c(&amp;quot;Group 1&amp;quot;)

## also correct:
c(&amp;#39;Group 1&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that &lt;code&gt;c(&#39;Group 1&#39;, &#34;Group 2&#34;)&lt;/code&gt; does not throw an error but for consistency, it is not recommended to mix single and double quotes within the same vector.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;using-a-function-that-is-not-installed-or-loaded&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;2. Using a function that is not installed or loaded&lt;/h1&gt;
&lt;p&gt;If you encounter the following error: “Error in … : could not find function ‘…’”, for example:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/could-not-find-function-R.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;it means you are trying to use a function belonging to a package which is not yet installed or loaded.&lt;/p&gt;
&lt;div id=&#34;solution-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;To solve this error, you have to install the package (if it is not installed yet) and load it with the &lt;code&gt;install.packages()&lt;/code&gt; and &lt;code&gt;library()&lt;/code&gt; functions, respectively:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## install package:
install.packages(&amp;quot;ggplot2&amp;quot;)

## load package:
library(ggplot2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are not sure about the usage of these two functions, see more details about &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;installing and loading a package in R&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;typos-in-function-variable-dataset-object-or-package-names&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;3. Typos in function, variable, dataset, object or package names&lt;/h1&gt;
&lt;p&gt;Another common mistake is to misspell a function, a variable, a dataset, an object or a package’s name, for example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in function name:
maen(c(1, 7, 13))&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in maen(c(1, 7, 13)) : could not find function &amp;quot;maen&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in variable name:
summary(ggplot2::diamonds[, &amp;quot;detph&amp;quot;])&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error: Column `detph` doesn&amp;#39;t exist&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in dataset name:
data &amp;lt;- data.frame(
  x = rnorm(10),
  y = rnorm(10)
)
summary(dta[, 2])&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in summary(dta[, 2]) : object &amp;#39;dta&amp;#39; not found&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in object name:
test &amp;lt;- c(1, 7, 13)
mean(tset)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in mean(tset) : object &amp;#39;tset&amp;#39; not found&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in package name:
library(&amp;quot;tydiverse&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in library(&amp;quot;tydiverse&amp;quot;) : there is no package called ‘tydiverse’&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;solution-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;Make sure that you correctly spell all your functions, variables, datasets, objects and packages:&lt;/p&gt;
&lt;p&gt;Note that &lt;strong&gt;R is case sensitive&lt;/strong&gt;; &lt;code&gt;mean()&lt;/code&gt; is considered different than &lt;code&gt;Mean()&lt;/code&gt; for R!&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(c(1, 7, 13))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(ggplot2::diamonds[, &amp;quot;depth&amp;quot;])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      depth      
##  Min.   :43.00  
##  1st Qu.:61.00  
##  Median :61.80  
##  Mean   :61.75  
##  3rd Qu.:62.50  
##  Max.   :79.00&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data &amp;lt;- data.frame(
  x = rnorm(10),
  y = rnorm(10)
)
data[, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1.3048697  2.2866454 -1.3888607 -0.2787888 -0.1333213  0.6359504
##  [7] -0.2842529 -2.6564554 -2.4404669  1.3201133&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- c(1, 7, 13)
mean(test)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tidyverse)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (&amp;lt;http://conflicted.r-lib.org/&amp;gt;) to force all conflicts to become errors&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are sure that you correctly spelled an object, a function or a dataset but you still have an error stating that “object ‘…’ is not found”, make sure that you defined your object/function/dataset &lt;em&gt;before&lt;/em&gt; calling it!&lt;/p&gt;
&lt;p&gt;It often happens that a student asks me to come to his/her computer because he/she runs the exact same code than me, but cannot make it work. Most of the time, if his/her code is indeed exactly the same than mine, he/she simply has not executed a object/function/dataset before running the code which includes that object/function/dataset. In other words, he/she simply tries to use an undefined object or variable.&lt;/p&gt;
&lt;p&gt;Remember that writing code in a R script (contrarily to the console) does not mean it is compiled. You actually have to run it (by clicking on the Run button or using the keyboard shortcut) in order the code to be executed and used later. If you are still struggling with this, see the &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;basics of R and RStudio&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;missing-incorrect-or-misspelled-arguments-in-functions&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;4. Missing, incorrect or misspelled arguments in functions&lt;/h1&gt;
&lt;p&gt;Most R functions require arguments. For example, the &lt;code&gt;rnorm()&lt;/code&gt; function requires at least the number of observations, specified via the argument &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Your code will not run if you do not specify compulsory arguments, or if incorrectly specify an argument. Moreover, the result might not be what you expect if you misspell an argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## missing compulsory argument:
rnorm()&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in rnorm() : argument &amp;quot;n&amp;quot; is missing, with no default&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## incorrect argument:
rnorm(n = 3, var = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in rnorm(n = 3, var = 1) : unused argument (var = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## misspelled argument:
mean(c(1, 7, 13, NA), narm = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The last piece of code does not throw an error, but the result is not what we want.&lt;/p&gt;
&lt;div id=&#34;solution-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;To solve these errors, make sure to specify &lt;strong&gt;at least all compulsory arguments&lt;/strong&gt; of the function, and the correct ones:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;rnorm()&lt;/code&gt;, it is the standard deviation, &lt;code&gt;sd&lt;/code&gt;, which can be specified in addition to the number of observations &lt;code&gt;n&lt;/code&gt; (instead of the variance &lt;code&gt;var&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Removing &lt;code&gt;NA&lt;/code&gt; is done with &lt;code&gt;na.rm&lt;/code&gt; (instead of &lt;code&gt;narm&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rnorm(n = 3, sd = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.3066386 -1.7813084 -0.1719174&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(c(1, 7, 13, NA), na.rm = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not know the arguments of a function by heart, you can always check the documentation with &lt;code&gt;?function_name&lt;/code&gt; or &lt;code&gt;help(function_name)&lt;/code&gt;, for example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;?rnorm()

## or:
help(rnorm)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;wrong-inappropriate-or-inconsistent-data-types&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;5. Wrong, inappropriate or inconsistent data types&lt;/h1&gt;
&lt;p&gt;There are several &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/&#34;&gt;data types in R&lt;/a&gt;, the main ones being:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Numeric&lt;/li&gt;
&lt;li&gt;Character&lt;/li&gt;
&lt;li&gt;Factor&lt;/li&gt;
&lt;li&gt;Logical&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You know that some operations and analyses are possible and appropriate only with some specific types of data.&lt;/p&gt;
&lt;p&gt;For example, it is not appropriate to compute the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#mean&#34;&gt;mean&lt;/a&gt; of a factor or character variable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gender &amp;lt;- factor(c(&amp;quot;female&amp;quot;, &amp;quot;female&amp;quot;, &amp;quot;male&amp;quot;, &amp;quot;female&amp;quot;, &amp;quot;male&amp;quot;))

mean(gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning in mean.default(gender): argument is not numeric or logical: returning
## NA&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Likewise, although it is technically possible, it makes little sense to draw a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt; of a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;quantitative continuous&lt;/a&gt; variable because in most cases, the frequency will be 1 for each value:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(rnorm(10)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-33-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;(By the way, if your data is not already displayed in the form of a table, do not forget to add &lt;code&gt;table()&lt;/code&gt; inside the &lt;code&gt;barplot()&lt;/code&gt; function.)&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;solution-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;Make sure to use the appropriate operation and type of analysis depending on the variable(s) of interest.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;for factor variables, it is more appropriate to compute frequencies and/or relative frequencies, and draw barplots&lt;/li&gt;
&lt;li&gt;for quantitative continuous variables, it is more appropriate to compute the mean, median, etc. and draw histograms, boxplots, etc.&lt;/li&gt;
&lt;li&gt;for logical variables, the mean,&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt; a frequency table and a barplot are appropriate&lt;/li&gt;
&lt;li&gt;for character variables, &lt;a href=&#34;https://statsandr.com/blog/draw-a-word-cloud-with-a-shiny-app/&#34;&gt;word clouds&lt;/a&gt; are the most appropriate (unless the variable can be considered as a factor variable because there are not too many different levels)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We now illustrate the examples in R:&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## factor:
table(gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## gender
## female   male 
##      3      2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;prop.table(table(gender))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## gender
## female   male 
##    0.6    0.4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(gender))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-34-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## quantitative continuous:
x &amp;lt;- rnorm(100)

summary(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -2.99309 -0.74143  0.01809 -0.08570  0.58937  2.70189&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;par(mfrow = c(1, 2)) ## combine two plots
hist(x)
boxplot(x)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-34-2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## logical:
x &amp;lt;- c(TRUE, FALSE, FALSE, TRUE, TRUE)

mean(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.6&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## x
## FALSE  TRUE 
##     2     3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(x))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-35-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For the interested reader, see the most common &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics in R&lt;/a&gt; for different types of data.&lt;/p&gt;
&lt;p&gt;Note that, as for descriptive statistics, the choice of the statistical test depends on the variable’s type. See this &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;flowchart&lt;/a&gt; to help you in selecting the most appropriate statistical test depending on the number of variables and their types.&lt;/p&gt;
&lt;p&gt;An error linked to the one mentioned above is &lt;strong&gt;inconsistent&lt;/strong&gt; data type. See it in practice with the following example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(2.4, 3.7, 5.1, 9.8)
class(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;- c(2.4, 3.7, 5.1, &amp;quot;9.8&amp;quot;)
class(y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, vector &lt;code&gt;x&lt;/code&gt; is numerical, whereas vector &lt;code&gt;y&lt;/code&gt; is in the form of character. This is due to the fact that the last element of &lt;code&gt;y&lt;/code&gt; is surrounded with quotation marks (and thus considered as a string instead of a numerical value), so the entire vector takes the character form.&lt;/p&gt;
&lt;p&gt;This can happen when you &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;import a dataset into R&lt;/a&gt; and one or several elements of a variable are not encoded correctly. This leads to the entire variable to be considered as a character variable by R.&lt;/p&gt;
&lt;p&gt;To avoid this, it is a good practice to check the structure of your dataset (with &lt;code&gt;str()&lt;/code&gt;) after importing it to make sure all your variables have the desired format. If not, you can either correct the values in the initial file or change the format in R (with &lt;code&gt;as.numeric()&lt;/code&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;forgetting-the-sign-in-ggplot2&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;6. Forgetting the + sign in ggplot2&lt;/h1&gt;
&lt;p&gt;If you just learned to use the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;ggplot2 package&lt;/a&gt; for your visualizations (and I highly recommend it!), a common mistake is to forget the &lt;code&gt;+&lt;/code&gt; sign.&lt;/p&gt;
&lt;p&gt;You know that a visualization made with ggplot2 is constructed by adding several layers:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## load package:
library(ggplot2)

## first layer, the dataset:
ggplot(data = diamonds) +
  ## second layer, the aesthetics:
  aes(x = cut, y = price) +
  ## third layer, the type of plot:
  geom_boxplot() +
  ## add more layers:
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-37-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;solution-5&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;For all your graphics with ggplot2, do not forget to add a &lt;strong&gt;&lt;code&gt;+&lt;/code&gt; sign after each layer &lt;em&gt;except&lt;/em&gt; the last one&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;misunderstanding-between-and&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;7. Misunderstanding between = and ==&lt;/h1&gt;
&lt;p&gt;Assignment in R can be done in three ways, from the most to the least common:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;-&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;=&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;assign()&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The second method, that is &lt;code&gt;=&lt;/code&gt;, should not be confused with &lt;code&gt;==&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Indeed, assigning an object (with any of the three above methods) is used to save something in R. For example, if we want to save the vector &lt;code&gt;(1, 3, 7)&lt;/code&gt; and rename that vector &lt;code&gt;x&lt;/code&gt;, we can write:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(1, 3, 7)

## or:
x = c(1, 3, 7)

## or:
assign(&amp;quot;x&amp;quot;, c(1, 3, 7))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When executing this piece of code, you will see that the vector &lt;code&gt;x&lt;/code&gt; of size 3 appears in the tab “Environment” (the top right panel if you use the default view of RStudio):&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/R-environment.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From now on, we can use that vector simply by calling it by its name:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 3 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By no means, you can assign an object with &lt;code&gt;==&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## NOT correct if we want to assign c(1, 3, 7) to x:
x == c(1, 3, 7)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So you are wondering, when would we need to use &lt;code&gt;==&lt;/code&gt;? Actually, it is used when you want to use an equal sign.&lt;/p&gt;
&lt;p&gt;I understand that it may be abstract and confusing at the moment, so let’s suppose the following two scenarios as examples (which are the two most common cases when we use &lt;code&gt;==&lt;/code&gt;):&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;we want to check whether an assigned object or variable respects some conditions, and&lt;/li&gt;
&lt;li&gt;we want to subset a dataframe based on one or several conditions.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For these examples, suppose a &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt; of 5 children:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## create dataframe:
dat &amp;lt;- data.frame(
  Name = c(&amp;quot;Mary&amp;quot;, &amp;quot;Linda&amp;quot;, &amp;quot;James&amp;quot;, &amp;quot;John&amp;quot;, &amp;quot;Patricia&amp;quot;),
  Age = c(7, 10, 3, 9, 7),
  Gender = c(&amp;quot;Girl&amp;quot;, &amp;quot;Girl&amp;quot;, &amp;quot;Boy&amp;quot;, &amp;quot;Boy&amp;quot;, &amp;quot;Girl&amp;quot;)
)

## print dataframe:
dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Name Age Gender
## 1     Mary   7   Girl
## 2    Linda  10   Girl
## 3    James   3    Boy
## 4     John   9    Boy
## 5 Patricia   7   Girl&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s now write different pieces of code for these two scenarios to illustrate them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We want to check whether the variable &lt;code&gt;Age&lt;/code&gt; is equal to the vector &lt;code&gt;(1, 2, 3, 4, 5)&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$Age == 1:5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE FALSE  TRUE FALSE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this code, we ask whether the first element of the variable &lt;code&gt;Age&lt;/code&gt; is equal to 1, the second element of the variable &lt;code&gt;Age&lt;/code&gt; is equal to 2, and so on. The answer is of course &lt;code&gt;FALSE&lt;/code&gt;, &lt;code&gt;FALSE&lt;/code&gt;, &lt;code&gt;TRUE&lt;/code&gt;, &lt;code&gt;FALSE&lt;/code&gt; and &lt;code&gt;FALSE&lt;/code&gt; since only the third child has an age &lt;strong&gt;equal&lt;/strong&gt; to 3 years.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We want to know which of our 5 sampled children are girls:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$Gender == &amp;quot;Girl&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  TRUE  TRUE FALSE FALSE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The results show that the first, second and fifth children are girls, while the third and fourth children are not girls.&lt;/p&gt;
&lt;p&gt;If you write any of these two lines:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## this overwrites Age and Gender:
dat$Age = 1:5
dat$Gender = &amp;quot;Girl&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You actually overwrite the &lt;code&gt;Age&lt;/code&gt; and &lt;code&gt;Gender&lt;/code&gt; variables, such that our 5 children will have an age from 1 to 5 (1 year for the first child, up to 5 years for the fifth child) and all of them will be girls.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Now suppose we want to subset our dataframe based on a condition, namely, we want to extract only the children who are 7 years old:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;subset(dat, Age == 7)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Name Age Gender
## 1     Mary   7   Girl
## 5 Patricia   7   Girl&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not want to use the subset function, you can also use square brackets:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[dat$Age == 7, ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Name Age Gender
## 1     Mary   7   Girl
## 5 Patricia   7   Girl&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see in the previous examples, we do not want to assign anything. Instead, we are asking “is this variable or vector &lt;em&gt;equal&lt;/em&gt; to something else?”. For that specific need, we use &lt;code&gt;==&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So to sum up, for technical reasons and in order to distinguish between the two concepts, R uses &lt;code&gt;=&lt;/code&gt; for assignments, and &lt;code&gt;==&lt;/code&gt; for the equality sign. Make sure to understand the difference between the two to avoid any errors.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;undefined-columns-selected&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;8. Undefined columns selected&lt;/h1&gt;
&lt;p&gt;If you are used to subset dataframes with square brackets, &lt;code&gt;[]&lt;/code&gt;, instead of the &lt;code&gt;subset()&lt;/code&gt; or &lt;code&gt;filter()&lt;/code&gt; functions, you may have faced the error “Error in [.data.frame(…) : undefined columns selected”.&lt;/p&gt;
&lt;p&gt;This occurs when R does not understand the column you want to use while subsetting the dataset.&lt;/p&gt;
&lt;p&gt;Considering the same sample of 5 children introduced earlier, the following code will throw an error:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[dat$Age == 7]&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in `[.data.frame`(dat, dat$Age == 7) : undefined columns selected&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;because it does not specify the column dimension.&lt;/p&gt;
&lt;div id=&#34;solution-6&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;Remember that dataframes in R have two dimensions:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the rows (one for each experimental unit), and&lt;/li&gt;
&lt;li&gt;the columns (one for each variable)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;and &lt;strong&gt;in that particular order&lt;/strong&gt; (so row first, then column)!&lt;/p&gt;
&lt;p&gt;Since dataframes have two dimensions, R expects two dimensions when you call &lt;code&gt;dat[]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In particular, it expects the first and then the second dimension, &lt;strong&gt;separated by a comma&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[dat$Age == 7, ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Name Age Gender
## 1     Mary   7   Girl
## 5 Patricia   7   Girl&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code means that we are extracting all rows where &lt;code&gt;Age&lt;/code&gt; is equal to 7 (first dimension, i.e. before the comma), for all variables of the dataset (since we did not specify any column after the comma).&lt;/p&gt;
&lt;p&gt;For the interested reader, see more ways to &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;subset and manipulate data in R&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;problem-when-importing-or-using-the-wrong-data-file&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;9. Problem when importing or using the wrong data file&lt;/h1&gt;
&lt;p&gt;Importing a dataset in R can be quite challenging for beginners, mainly due to the misunderstanding about the working directory.&lt;/p&gt;
&lt;p&gt;When importing a file, &lt;strong&gt;R will not search for the file in all your folders&lt;/strong&gt; of your computer. Instead, it will look only in one specific folder. If your dataset is not inside that folder, it will result in an error such as “cannot open file ‘…’: No such file or directory”:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/cannot-open-file-no-such-file-or-directory.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To fix this, you must specify the path to the folder where your dataset is located. In other words, you need to tell R in which folder you want it to work, hence the name working directory.&lt;/p&gt;
&lt;p&gt;Setting the working directory can be done with the &lt;code&gt;setwd()&lt;/code&gt; function or via the “Files” tab in the lower right panel of RStudio:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/files-r-studio.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Alternatively, you can move the dataset in the folder where R is currently working (this can be found with &lt;code&gt;getwd()&lt;/code&gt;). See more details on &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;importing a file into R and about the working directory&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Another related problem is to use the wrong file. This error is different than the previous ones in the sense that you will not encounter an error but your analyses will still be wrong.&lt;/p&gt;
&lt;p&gt;It may sound trivial, but make sure to import and use the correct data file! This is particularly the case if you have files for different points in time and which have a common structure (for example weekly or monthly data files with the exact same variables). It happened to me that I reported results for the wrong week (fortunately, without much consequence).&lt;/p&gt;
&lt;p&gt;Also, make sure that you actually use all the rows you want to include in your analyses. It happened to me that, in order to test a model (and avoid long computing times), I extracted a random sample of the original dataset, and almost forgot about this sampling when running my final analyses.&lt;/p&gt;
&lt;p&gt;It is thus a good practice to remind you to remove sampling and filters after you have tested your code (and before interpreting the final results).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;problem-when-using-the-operator&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;10. Problem when using the $ operator&lt;/h1&gt;
&lt;p&gt;For the last error of this top 10, I would like to focus on two related errors:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;“$ operator is invalid for atomic vectors”, and&lt;/li&gt;
&lt;li&gt;“object of type ‘closure’ is not subsettable”.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I gather them in one single section because they are linked to each other in the sense that they both involve the &lt;code&gt;$&lt;/code&gt; operator.&lt;/p&gt;
&lt;div id=&#34;operator-is-invalid-for-atomic-vectors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;$ operator is invalid for atomic vectors&lt;/h2&gt;
&lt;p&gt;To understand this error, we first must recall that an atomic vector is a &lt;em&gt;one&lt;/em&gt;-dimensional object (usually created with &lt;code&gt;c()&lt;/code&gt;). This is different than dataframes or matrices which are &lt;em&gt;two&lt;/em&gt;-dimensional (i.e., rows form the first dimension and columns correspond to the second dimension).&lt;/p&gt;
&lt;p&gt;The error “$ operator is invalid for atomic vectors” occurs when we try to access an element of an atomic vector using the dollar operator (&lt;code&gt;$&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## define atomic vector:
x &amp;lt;- c(1, 3, 7)

## set names:
names(x) &amp;lt;- LETTERS[1:3]

## print vector:
x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## A B C 
## 1 3 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## access value of element C:
x$C&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in x$C : $ operator is invalid for atomic vectors&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;solution-7&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;$&lt;/code&gt; operator cannot be used to extract elements in atomic vectors. Instead, we must use double brackets &lt;code&gt;[[]]&lt;/code&gt; notation:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x[[&amp;quot;C&amp;quot;]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember that the &lt;code&gt;$&lt;/code&gt; operator can be used with dataframes, so we can also fix this error by first converting the atomic vector to a dataframe,&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt; and then access an element by its name with the &lt;code&gt;$&lt;/code&gt; operator:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## convert atomic vector to dataframe:
x &amp;lt;- as.data.frame(t(x))

## print x:
x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   A B C
## 1 1 3 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## access value of element C:
x$C&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;object-of-type-closure-is-not-subsettable&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;object of type ‘closure’ is not subsettable&lt;/h2&gt;
&lt;p&gt;Another error (which I must admit is quite obscure and confusing when learning R) is the following: “object of type ‘closure’ is not subsettable”.&lt;/p&gt;
&lt;p&gt;This error occurs when we try to subset or access some elements of a function. An example with the well-known &lt;code&gt;mean()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean[1:3]&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in mean[1:3] : object of type &amp;#39;closure&amp;#39; is not subsettable&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In R, we can subset lists, vectors, matrices, dataframes, but not functions. So it throws an error because it is impossible to subset an object of type “closure”, and a function is of that type:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;typeof(mean)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;closure&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Most of the times, you will not encounter this error when using a basic function such as the &lt;code&gt;mean()&lt;/code&gt; function (because it is unlikely that your goal is really to subset a function…).&lt;/p&gt;
&lt;p&gt;Indeed, you will most likely face this error when trying to subset a dataset named &lt;code&gt;data&lt;/code&gt;, but this dataset is not defined in the environment (because it has not been imported or created properly for instance).&lt;/p&gt;
&lt;p&gt;To understand the concept, see the following examples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## create dataset:
data &amp;lt;- data.frame(
  x = rnorm(10),
  y = rnorm(10)
)

## print variable x:
data$x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1.12288964  1.43985574 -1.09711377 -0.11731956  1.20149840 -0.46972958
##  [7] -0.05246948 -0.08610730 -0.88767902 -0.44468400&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So far so good. Now suppose we made a mistake when creating the dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## create dataset (with mistake):
data &amp;lt;- data.frame(x = rnorm(10)
                   y = rnorm(10))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will notice that a comma is missing between variables &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;. As a result, the dataset named &lt;code&gt;data&lt;/code&gt; is not created and thus not defined.&lt;/p&gt;
&lt;p&gt;Therefore, if we now try to access the variable &lt;code&gt;x&lt;/code&gt; from that dataset &lt;code&gt;data&lt;/code&gt;, R will actually try to subset the function named &lt;code&gt;data&lt;/code&gt; instead of the dataset named &lt;code&gt;data&lt;/code&gt;!&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data$x&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in data$x : object of type &amp;#39;closure&amp;#39; is not subsettable&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This happens because, I repeat, the dataset &lt;code&gt;data&lt;/code&gt; does not exist, so R looks for an object named &lt;code&gt;data&lt;/code&gt; and find a function with that name:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(data)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;function&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;warnings&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Warnings&lt;/h1&gt;
&lt;p&gt;Warnings are different than errors in the sense that they alert you about something, but it does not prevent you from running the code. It is a good practice to read these warnings as they may give you valuable information.&lt;/p&gt;
&lt;p&gt;There are too many warnings to mention them all, but I would like to focus on two common ones:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;“NAs introduced by coercion”, and&lt;/li&gt;
&lt;li&gt;“Removed … rows containing non-finite values (stat_bin())”.&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;nas-introduced-by-coercion&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;NAs introduced by coercion&lt;/h2&gt;
&lt;p&gt;This warning occurs when you try to convert a vector which includes at least one non-numerical value to a numeric vector:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(1, 3, 7, &amp;quot;Emma&amp;quot;)

as.numeric(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: NAs introduced by coercion&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  1  3  7 NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You do not need to fix it since it is only a warning and not an error. R is simply informing you that at least one element in the initial vector was converted to &lt;code&gt;NA&lt;/code&gt; because it could not be converted to a numeric value.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;removed-rows-containing-non-finite-values-stat_bin&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Removed … rows containing non-finite values (stat_bin())&lt;/h2&gt;
&lt;p&gt;This warning occurs when you use &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;ggplot2&lt;/a&gt; to draw plots. For instance:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(airquality) +
  aes(x = Ozone) +
  geom_histogram()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Removed 37 rows containing non-finite values (`stat_bin()`).&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-65-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Again, as it is a warning you do not need to fix it. It is simply informing you that there are some missing values (&lt;code&gt;NA&lt;/code&gt;) in the variable of interest and that these missing values are removed to construct the plot.&lt;/p&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 this collection of errors prevented you from making some coding mistakes, or that it helped you in debugging your code.&lt;/p&gt;
&lt;p&gt;If you still cannot fix your error, I would recommend to read the documentation of the function (if you struggle with a function in particular), or look online for the solution. Bear in mind that if you encounter an error, it is very likely that someone else posted the answer online (Stack Overflow is usually a good resource).&lt;/p&gt;
&lt;p&gt;R has a steep learning curve, in particular if you are not familiar with another programming language. Nonetheless, with practice and time, you will make less and less coding errors, but more importantly, you will be more and more proficient in typing the right keywords in search engines, resulting in less time spent looking for the solution.&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;There are 2 mistakes in that piece of code, feel free to try to fix them as an exercise.&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;And I strongly recommend using RStudio and not just R. See the differences &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;here&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;li id=&#34;fn3&#34;&gt;&lt;p&gt;Note that &lt;code&gt;mean()&lt;/code&gt; applied to a logical variable gives the proportion of &lt;code&gt;TRUE&lt;/code&gt;.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;&lt;code&gt;par(mfrow = c(1, 2))&lt;/code&gt; is used to put two plots next to each other.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;Note that we also need to take the transpose of the vector &lt;code&gt;x&lt;/code&gt; in order to have it as 1 row, 3 columns.&lt;a href=&#34;#fnref5&#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>Web scraping in R</title>
      <link>https://statsandr.com/blog/web-scraping-in-r/</link>
      <pubDate>Mon, 16 Jan 2023 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/web-scraping-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#html-and-css&#34; id=&#34;toc-html-and-css&#34;&gt;HTML and CSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#web-scraping-vs.-apis&#34; id=&#34;toc-web-scraping-vs.-apis&#34;&gt;Web scraping vs. APIs&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#why-does-web-scraping-exist-if-apis-are-so-powerful-and-do-exactly-the-same-work&#34; id=&#34;toc-why-does-web-scraping-exist-if-apis-are-so-powerful-and-do-exactly-the-same-work&#34;&gt;Why does web scraping exist if APIs are so powerful and do exactly the same work?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#web-scraping-in-r&#34; id=&#34;toc-web-scraping-in-r&#34;&gt;Web scraping in R&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#rvest&#34; id=&#34;toc-rvest&#34;&gt;rvest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#http-get-request&#34; id=&#34;toc-http-get-request&#34;&gt;HTTP GET request&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#parsing-html-content&#34; id=&#34;toc-parsing-html-content&#34;&gt;Parsing HTML content&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#css-selector&#34; id=&#34;toc-css-selector&#34;&gt;CSS selector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#xpath&#34; id=&#34;toc-xpath&#34;&gt;XPath&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#getting-attributes&#34; id=&#34;toc-getting-attributes&#34;&gt;Getting attributes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#a-real-application-of-web-scraping-in-r&#34; id=&#34;toc-a-real-application-of-web-scraping-in-r&#34;&gt;A real application of web scraping in R&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#http-get-request-1&#34; id=&#34;toc-http-get-request-1&#34;&gt;HTTP GET request&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#parsing-html-content-and-getting-attributes&#34; id=&#34;toc-parsing-html-content-and-getting-attributes&#34;&gt;Parsing HTML content and getting attributes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#analysis-on-the-database&#34; id=&#34;toc-analysis-on-the-database&#34;&gt;Analysis on the database&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#to-go-further&#34; id=&#34;toc-to-go-further&#34;&gt;To go further&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;images/web-scraping-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: This post has been written in collaboration with Pietro Zanotta.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Almost anyone is familiar with web pages (otherwise you would not be here), but what if we tell you that how you see a site is different from how Google or your browser does?&lt;/p&gt;
&lt;p&gt;In fact, when you type any site address in your browser, your browser will download and render the page for you, but for rendering the page it needs some instructions.&lt;/p&gt;
&lt;p&gt;There are 3 types of instructions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;HTML&lt;/strong&gt;: describes a web page’s infrastructure;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CSS&lt;/strong&gt;: defines the appearance of a site;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;: decides the behavior of the page.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Web scraping&lt;/strong&gt; is the art of extracting information from the HTML, CSS and Javascript lines of code. The term usually refers to an automated process, which is less error-prone and faster than gathering data by hand.&lt;/p&gt;
&lt;p&gt;It is important to note that web scraping can raise &lt;strong&gt;ethical concerns&lt;/strong&gt;, as it involves accessing and using data from websites without the explicit permission of the website owner. It is a good practice to respect the terms of use for a website, and to seek written permission before scraping large amounts of data.&lt;/p&gt;
&lt;p&gt;This article aims to cover the basics of how to do web scraping in R. We will conclude by creating a database on Formula 1 drivers from &lt;a href=&#34;https://en.wikipedia.org/wiki/List_of_Formula_One_drivers&#34; target=&#34;_blank&#34;&gt;Wikipedia&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that this article doesn’t want to be exhaustive on topic. To learn more, see &lt;a href=&#34;https://statsandr.com/blog/web-scraping-in-r/#to-go-further&#34;&gt;this section&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;html-and-css&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;HTML and CSS&lt;/h3&gt;
&lt;p&gt;Before starting it is important to have a basic knowledge of HTML and CSS. This section aims to briefly explain how HTML and CSS work, to learn more we leave you some resources at the bottom of this article.&lt;/p&gt;
&lt;p&gt;Feel free to skip this section if you already are knowledgeable in this topic.&lt;/p&gt;
&lt;p&gt;Starting from &lt;strong&gt;HTML&lt;/strong&gt;, an HTML file looks like the following piece of code.&lt;/p&gt;
&lt;pre class=&#34;html&#34;&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;h1 href=&amp;quot;https://en.wikipedia.org/wiki/Carl_Friedrich_Gauss&amp;quot;&amp;gt; Carl Friedrich Gauss&amp;lt;/h1&amp;gt;
&amp;lt;h2&amp;gt; Biography &amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt; Johann Carl Friedrich Gauss was born on 30 April 1777 in Brunswick. &amp;lt;/p&amp;gt;
&amp;lt;h2&amp;gt; Profession &amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt; Gauss is considered as one of the greatest mathematician, statistician and physicist of all time. &amp;lt;/p&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Those instructions produce the following:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/Screenshot%202023-01-16%20at%2018.24.24.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you read above, &lt;strong&gt;HTML&lt;/strong&gt; is used to describe the infrastructure of a web page, for example we may want to define the headings, the paragraphs, etc.&lt;/p&gt;
&lt;p&gt;This infrastructure is represented by what are called &lt;em&gt;tags&lt;/em&gt; (for example &lt;code&gt;&amp;lt;h1&amp;gt;...&amp;lt;/h1&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;p&amp;gt;...&amp;lt;/p&amp;gt;&lt;/code&gt; are tags). Tags are the core of an HTML document as they represent the nature of what is inside the tag (for example &lt;code&gt;h1&lt;/code&gt; stands for heading 1). It is important to observe that there are two types of tags:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;starting tags (e.g. &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;ending tags (e.g. &lt;code&gt;&amp;lt;/h1&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is what allows to nest different tags.&lt;/p&gt;
&lt;p&gt;Tags can also have attributes, for example in &lt;code&gt;&amp;lt;h1 href=&#34;https://en.wikipedia.org/wiki/Carl_Friedrich_Gauss&#34;&amp;gt;Carl Friedrich Gauss&amp;lt;/h1&amp;gt;&lt;/code&gt;, &lt;code&gt;href&lt;/code&gt; is an attribute of the tag &lt;code&gt;h1&lt;/code&gt; that specifies an URL.&lt;/p&gt;
&lt;p&gt;As the output of the above HTML code is not super elegant, &lt;strong&gt;CSS&lt;/strong&gt; is used to style the final website. For example CSS is used to define the font, the color, the size, the spacing and many more features of a website.&lt;/p&gt;
&lt;p&gt;What is important for this article are &lt;em&gt;CSS selectors&lt;/em&gt;, which are patterns used to select elements. The most important is the &lt;code&gt;.class&lt;/code&gt; selector, which selects all elements with the same class. For example the &lt;code&gt;.xyz&lt;/code&gt; selector selects all elements with &lt;code&gt;class=&#34;xyz&#34;&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;web-scraping-vs.-apis&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Web scraping vs. APIs&lt;/h2&gt;
&lt;p&gt;Going back to web scraping, you may know that APIs are another way to access data from websites and online services.&lt;/p&gt;
&lt;p&gt;In fact an API is a set of rules and protocols that allows two different software systems to communicate with each other. When a website or online service provides an API, it means that they have made it possible for developers to access their data in a structured and controlled way.&lt;/p&gt;
&lt;div id=&#34;why-does-web-scraping-exist-if-apis-are-so-powerful-and-do-exactly-the-same-work&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Why does web scraping exist if APIs are so powerful and do exactly the same work?&lt;/h3&gt;
&lt;p&gt;The main difference between web scraping and using APIs is that APIs are typically provided by the website or service to allow access to their data, while web scraping involves accessing data without the explicit permission of the website owner.&lt;/p&gt;
&lt;p&gt;This means that using APIs is generally considered more ethical than web scraping, as it is done with the explicit permission of the website or service.&lt;/p&gt;
&lt;p&gt;However, there are also some limitations to using APIs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;many APIs have rate limits, which means that they will only allow a certain number of requests to be made within a certain time period, i.e. you may not access large amounts of data;&lt;/li&gt;
&lt;li&gt;not all websites or online services provide APIs, which means the only way to access their data is via web scraping.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;web-scraping-in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Web scraping in R&lt;/h1&gt;
&lt;p&gt;There are several packages for web scraping in R, every package has its strengths and limitations. We will cover only the &lt;code&gt;rvest&lt;/code&gt; package since it is the most used.&lt;/p&gt;
&lt;p&gt;To get started with web scraping in R you will first need R and RStudio installed (if needed, see &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;here&lt;/a&gt;). Once you have R and RStudio installed, you need to install the &lt;code&gt;rvest&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;rvest&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;rvest&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;rvest&lt;/h2&gt;
&lt;p&gt;Inspired by &lt;code&gt;beautiful soup&lt;/code&gt; and &lt;code&gt;RoboBrowser&lt;/code&gt; (two Python libraries for web scraping), &lt;code&gt;rvest&lt;/code&gt; has a similar syntax, which makes it the most eligible package for those who come from Python.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;rvest&lt;/code&gt; provides functions to access a web page and specific elements using CSS selectors and XPath. The library is a part of the &lt;a href=&#34;https://www.tidyverse.org/&#34;&gt;Tidyverse&lt;/a&gt; collection of packages, i.e. it shares some coding conventions (e.g. the pipes) with other libraries as &lt;code&gt;tibble&lt;/code&gt; and &lt;code&gt;ggplot2&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Before the real scraping it is necessary to load the &lt;code&gt;rvest&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(rvest)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that everything is settled down, we can start the web scraping operation, which is usually made in 3 steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;HTTP GET request&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parsing HTML content&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Getting HTML element attributes&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These steps are detailed in the following sections.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;http-get-request&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;HTTP GET request&lt;/h2&gt;
&lt;p&gt;The HTTP GET method is a method used to send a server a question to get certain data and information. It is important to notice that this method does not change the state of the server.&lt;/p&gt;
&lt;p&gt;To send a GET request we need the link (as a character) to the page we want to scrape:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;link &amp;lt;- &amp;quot;https://www.nytimes.com/&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sending the request to the page is simple, &lt;code&gt;rvest&lt;/code&gt; provides the &lt;code&gt;read_html&lt;/code&gt; function, which returns an object of &lt;code&gt;html_document&lt;/code&gt; type:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;NYT_page &amp;lt;- read_html(link)

NYT_page&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## {html_document}
## &amp;lt;html lang=&amp;quot;en&amp;quot; class=&amp;quot;  nytapp-vi-homepage  tpl-always-light&amp;quot; xmlns:og=&amp;quot;http://opengraphprotocol.org/schema/&amp;quot;&amp;gt;
## [1] &amp;lt;head&amp;gt;\n&amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=UTF-8 ...
## [2] &amp;lt;body&amp;gt;\n    \n    &amp;lt;div id=&amp;quot;app&amp;quot;&amp;gt;\n&amp;lt;link rel=&amp;quot;preload&amp;quot; as=&amp;quot;image&amp;quot; href=&amp;quot;/v ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;parsing-html-content&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Parsing HTML content&lt;/h2&gt;
&lt;p&gt;As we saw in the last chunk of code, &lt;code&gt;NYT_page&lt;/code&gt; contains the raw HTML code, which is not so easily readable.&lt;/p&gt;
&lt;p&gt;In order to make it readable from R it has to be parsed, which means generating a Document Object Model (DOM) from the raw HTML. DOM is what connects scripts and web pages by representing the structure of a document in memory. If you retrieve the &lt;a href=&#34;https://www.knowledgehut.com/blog/web-development/creating-http-server-with-node-js&#34; target=&#34;_blank&#34;&gt;HTTP request using Node.js&lt;/a&gt;, you can give the raw HTML response to R for parsing and further analysis.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;rvest&lt;/code&gt; provides 2 ways to select HTML elements:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;XPath&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CSS selectors&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Selecting elements with &lt;code&gt;rvest&lt;/code&gt; is simple, for XPath we use the following syntax:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;NYT_page %&amp;gt;%
  html_elements(xpath = &amp;quot;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;while for CSS elector we need:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;NYT_page %&amp;gt;%
  html_elements(css = &amp;quot;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;css-selector&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;CSS selector&lt;/h3&gt;
&lt;p&gt;Suppose that for a project you need the summaries of the articles of the NYT (note that what is in the following picture is not what you see in the &lt;a href=&#34;https://www.nytimes.com/&#34; target=&#34;_blank&#34;&gt;New York Times web page&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/NYT_screenshot.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Searching in the HTML code, it is not that complex to find &lt;code&gt;&amp;lt;p class=&#34;summary-class&#34;&amp;gt;&lt;/code&gt;, which is the markup of what we are looking for. To parse the HTML using this selector we use the &lt;code&gt;html_element&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summaries_css &amp;lt;- NYT_page %&amp;gt;%
  html_elements(css = &amp;quot;.summary-class&amp;quot;)

head(summaries_css)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## {xml_nodeset (6)}
## [1] &amp;lt;p class=&amp;quot;summary-class css-crclbt&amp;quot;&amp;gt;At least 18 were killed in Kyiv, offi ...
## [2] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;Long-delayed funeral ceremonies for  ...
## [3] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;Senior U.S. officials have said Iran ...
## [4] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;One of England’s greatest World Cup  ...
## [5] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;America’s 2-0 win over Bosnia and He ...
## [6] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;Some data suggest artificial intelli ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The easiest way to obtain a CSS selector is opening the inspect mode, find the element you desire and right click on it. Then click on &lt;code&gt;copy&lt;/code&gt; and &lt;code&gt;copy selector&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;xpath&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;XPath&lt;/h3&gt;
&lt;p&gt;Parsing with &lt;strong&gt;XPath&lt;/strong&gt; is similar to parsing using &lt;strong&gt;selectors&lt;/strong&gt;. In fact, we just need to repeat what we did above using XPath of the element of interest. Moreover, obtaining an element’s XPath is not different form selector: &lt;code&gt;inspector mode -&amp;gt; right click on element of interest -&amp;gt; copy -&amp;gt; copy XPath&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Repeating what we did above with XPath:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summaries_xpath &amp;lt;- NYT_page %&amp;gt;%
  html_elements(xpath = &amp;quot;//*[contains(@class, &amp;#39;summary-class&amp;#39;)]&amp;quot;)

head(summaries_xpath)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## {xml_nodeset (6)}
## [1] &amp;lt;p class=&amp;quot;summary-class css-crclbt&amp;quot;&amp;gt;At least 18 were killed in Kyiv, offi ...
## [2] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;Long-delayed funeral ceremonies for  ...
## [3] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;Senior U.S. officials have said Iran ...
## [4] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;One of England’s greatest World Cup  ...
## [5] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;America’s 2-0 win over Bosnia and He ...
## [6] &amp;lt;p class=&amp;quot;summary-class css-1vqq9lj&amp;quot;&amp;gt;Some data suggest artificial intelli ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Obviously the data we collected with CSS selector and XPath are exactly the same.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;getting-attributes&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Getting attributes&lt;/h2&gt;
&lt;p&gt;Since the chunk of code above collect all the elements &lt;code&gt;p&lt;/code&gt; with the class &lt;code&gt;summary&lt;/code&gt;, we render all the elements of &lt;code&gt;NYT_summary_css&lt;/code&gt; as a text using the &lt;code&gt;html_text&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;NYT_summaries_css &amp;lt;- html_text(summaries_css)
NYT_summaries_xpath &amp;lt;- html_text(summaries_xpath)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We only print some of them:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(NYT_summaries_css)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;At least 18 were killed in Kyiv, officials said. Ukraine’s president had warned of a “massive strike” as his country’s forces hit deeper into Russian territory.&amp;quot;
## [2] &amp;quot;Long-delayed funeral ceremonies for Ayatollah Ali Khamenei, killed during U.S.-Israeli strikes at the war’s outset, are set to begin Friday.&amp;quot;                    
## [3] &amp;quot;Senior U.S. officials have said Iran would be richly rewarded for changing its stance on America. But Tehran has rejected such a bargain in the past.&amp;quot;           
## [4] &amp;quot;One of England’s greatest World Cup moments unfolded on Wednesday, a columnist for The Athletic writes.&amp;quot;                                                         
## [5] &amp;quot;America’s 2-0 win over Bosnia and Herzegovina sets up a round-of-16 showdown with Belgium.&amp;quot;                                                                      
## [6] &amp;quot;Some data suggest artificial intelligence is already causing job losses. Other sources show the opposite. Why is it so hard to figure out what’s going on?&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;a-real-application-of-web-scraping-in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;A real application of web scraping in R&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;images/f1.jpg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To conclude this brief introduction to web scraping we want to use the &lt;code&gt;rvest&lt;/code&gt; package in a real word application of web scraping. The goal is to scrape data from &lt;a href=&#34;https://en.wikipedia.org/wiki/List_of_Formula_One_drivers&#34; target=&#34;_blank&#34;&gt;Formula 1 Wikipedia’s voice&lt;/a&gt; and create a CSV file containing the name, the nationality, the number of podiums and some other statistics for every pilot.&lt;/p&gt;
&lt;p&gt;The table we are going to scrape is the following:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/table_screenshot.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you haven’t done so, you need to install the &lt;code&gt;rvest&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;rvest&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and then load it:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(rvest)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;http-get-request-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;HTTP GET request&lt;/h2&gt;
&lt;p&gt;The GET request is the easiest part of scraping, we just need the following line of code:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;link &amp;lt;- &amp;quot;https://en.wikipedia.org/wiki/List_of_Formula_One_drivers&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;parsing-html-content-and-getting-attributes&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Parsing HTML content and getting attributes&lt;/h2&gt;
&lt;p&gt;Again we repeat what we did before with the NYT example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;page &amp;lt;- read_html(link)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Searching in the HTML code we find that the table is a &lt;code&gt;table&lt;/code&gt; element with the &lt;code&gt;sortable&lt;/code&gt; attribute:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/table_screenshot2.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Therefore we run the following lines of code:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;drivers_F1 &amp;lt;- html_element(page, &amp;quot;table.sortable&amp;quot;) %&amp;gt;%
  html_table()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the chunk of code above, the &lt;code&gt;html_table&lt;/code&gt; function is used to render the HTML code into tables.&lt;/p&gt;
&lt;p&gt;To inspect it, we display the first and last observations, and the structure of the dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(drivers_F1) # first 6 rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 × 11
##   `Driver name`     Nationality    `Seasons competed` `Drivers&amp;#39; Championships`
##   &amp;lt;chr&amp;gt;             &amp;lt;chr&amp;gt;          &amp;lt;chr&amp;gt;              &amp;lt;chr&amp;gt;                   
## 1 Carlo Abate       Italy          1962–1963          0                       
## 2 George Abecassis  United Kingdom 1951–1952          0                       
## 3 Kenny Acheson     United Kingdom 1983, 1985         0                       
## 4 Andrea de Adamich Italy          1968, 1970–1973    0                       
## 5 Philippe Adams    Belgium        1994               0                       
## 6 Walt Ader         United States  1950               0                       
## # ℹ 7 more variables: `Race entries` &amp;lt;chr&amp;gt;, `Race starts` &amp;lt;chr&amp;gt;,
## #   `Pole positions` &amp;lt;chr&amp;gt;, `Race wins` &amp;lt;chr&amp;gt;, Podiums &amp;lt;chr&amp;gt;,
## #   `Fastest laps` &amp;lt;chr&amp;gt;, `Points[a]` &amp;lt;chr&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tail(drivers_F1) # last 6 rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 × 11
##   `Driver name`  Nationality `Seasons competed`   `Drivers&amp;#39; Championships`
##   &amp;lt;chr&amp;gt;          &amp;lt;chr&amp;gt;       &amp;lt;chr&amp;gt;                &amp;lt;chr&amp;gt;                   
## 1 Emilio Zapico  Spain       1976                 0                       
## 2 Zhou Guanyu    China       2022–2024            0                       
## 3 Ricardo Zonta  Brazil      1999–2001, 2004–2005 0                       
## 4 Renzo Zorzi    Italy       1975–1977            0                       
## 5 Ricardo Zunino Argentina   1979–1981            0                       
## 6 Driver name    Nationality Seasons competed     Drivers&amp;#39; Championships  
## # ℹ 7 more variables: `Race entries` &amp;lt;chr&amp;gt;, `Race starts` &amp;lt;chr&amp;gt;,
## #   `Pole positions` &amp;lt;chr&amp;gt;, `Race wins` &amp;lt;chr&amp;gt;, Podiums &amp;lt;chr&amp;gt;,
## #   `Fastest laps` &amp;lt;chr&amp;gt;, `Points[a]` &amp;lt;chr&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(drivers_F1) # structure of the dataset&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## tibble [878 × 11] (S3: tbl_df/tbl/data.frame)
##  $ Driver name           : chr [1:878] &amp;quot;Carlo Abate&amp;quot; &amp;quot;George Abecassis&amp;quot; &amp;quot;Kenny Acheson&amp;quot; &amp;quot;Andrea de Adamich&amp;quot; ...
##  $ Nationality           : chr [1:878] &amp;quot;Italy&amp;quot; &amp;quot;United Kingdom&amp;quot; &amp;quot;United Kingdom&amp;quot; &amp;quot;Italy&amp;quot; ...
##  $ Seasons competed      : chr [1:878] &amp;quot;1962–1963&amp;quot; &amp;quot;1951–1952&amp;quot; &amp;quot;1983, 1985&amp;quot; &amp;quot;1968, 1970–1973&amp;quot; ...
##  $ Drivers&amp;#39; Championships: chr [1:878] &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; ...
##  $ Race entries          : chr [1:878] &amp;quot;3&amp;quot; &amp;quot;2&amp;quot; &amp;quot;10&amp;quot; &amp;quot;36&amp;quot; ...
##  $ Race starts           : chr [1:878] &amp;quot;0&amp;quot; &amp;quot;2&amp;quot; &amp;quot;3&amp;quot; &amp;quot;30&amp;quot; ...
##  $ Pole positions        : chr [1:878] &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; ...
##  $ Race wins             : chr [1:878] &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; ...
##  $ Podiums               : chr [1:878] &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; ...
##  $ Fastest laps          : chr [1:878] &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; ...
##  $ Points[a]             : chr [1:878] &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;0&amp;quot; &amp;quot;6&amp;quot; ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we have a tibble (a sort of dataframe used in the &lt;code&gt;tidyverse&lt;/code&gt; universe), we just need to select the variables of interest and eliminate the last row that contains the name of the variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;drivers_F1 &amp;lt;- drivers_F1[c(1:4, 7:9)] # select variables

drivers_F1 &amp;lt;- drivers_F1[-nrow(drivers_F1), ] # remove last row&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At this point we may want to clean our data. For example, we notice that &lt;code&gt;Drivers&#39; Championships&lt;/code&gt; has a small formatting issue: it returns not only the number of championships the driver won, but also the years of the victories. To extract only the number of victories (without the years) we use the &lt;code&gt;substr()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;drivers_F1$`Drivers&amp;#39; Championships` &amp;lt;- substr(drivers_F1$`Drivers&amp;#39; Championships`,
  start = 1, stop = 1
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this code, we actually extract only the first character since we start at 1 and stop at 1. At the moment, the maximum number of championships won by a driver is 7 (Lewis Hamilton &amp;amp; Michael Schumacher), so it is fine to extract only the first digit.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Et voila!&lt;/em&gt; With only a few lines of code, we scraped a table and we are now ready to perform our analysis.&lt;/p&gt;
&lt;p&gt;If you want to save the dataset, you can always do so:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;write.csv(drivers_F1, &amp;quot;F1_drivers.csv&amp;quot;, row.names = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;analysis-on-the-database&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Analysis on the database&lt;/h2&gt;
&lt;p&gt;To convince you that this is a real database, we will now answer some simple questions.&lt;/p&gt;
&lt;p&gt;First of all, we load the &lt;code&gt;tidyverse&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tidyverse)&lt;/code&gt;&lt;/pre&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Which country has the largest number of wins?&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;drivers_F1 %&amp;gt;%
  group_by(Nationality) %&amp;gt;%
  summarise(championship_country = sum(as.double(`Drivers&amp;#39; Championships`))) %&amp;gt;%
  arrange(desc(championship_country))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 48 × 2
##    Nationality    championship_country
##    &amp;lt;chr&amp;gt;                         &amp;lt;dbl&amp;gt;
##  1 United Kingdom                   21
##  2 Germany                          12
##  3 Brazil                            8
##  4 Argentina                         5
##  5 Australia                         4
##  6 Austria                           4
##  7 Finland                           4
##  8 France                            4
##  9 Netherlands                       4
## 10 Italy                             3
## # ℹ 38 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Who has the most Championships?&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;drivers_F1 %&amp;gt;%
  group_by(`Driver name`) %&amp;gt;%
  summarise(championship_pilot = sum(as.double(`Drivers&amp;#39; Championships`))) %&amp;gt;%
  arrange(desc(championship_pilot))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 877 × 2
##    `Driver name`       championship_pilot
##    &amp;lt;chr&amp;gt;                            &amp;lt;dbl&amp;gt;
##  1 Lewis Hamilton~                      7
##  2 Michael Schumacher^                  7
##  3 Juan Manuel Fangio^                  5
##  4 Alain Prost^                         4
##  5 Max Verstappen~                      4
##  6 Sebastian Vettel^                    4
##  7 Ayrton Senna^                        3
##  8 Jack Brabham^                        3
##  9 Jackie Stewart^                      3
## 10 Nelson Piquet^                       3
## # ℹ 867 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sorry Michael, it looks like Lewis dethroned you.&lt;/p&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Is there a relation between the number of Championships won and the number of race pole positions?&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;drivers_F1 %&amp;gt;%
  filter(`Pole positions` &amp;gt; 1) %&amp;gt;%
  ggplot(aes(x = as.double(`Pole positions`), y = as.double(`Drivers&amp;#39; Championships`))) +
  geom_point(position = &amp;quot;jitter&amp;quot;) +
  labs(y = &amp;quot;Championships won&amp;quot;, x = &amp;quot;Pole positions&amp;quot;) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/web-scraping-in-r/index_files/figure-html/unnamed-chunk-23-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As expected, there seems to be a positive relationship between the number of pole positions and the number of Championships won. To quantify this relationship, we could build a &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear model&lt;/a&gt; but this is beyond the scope of the article.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;to-go-further&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;To go further&lt;/h1&gt;
&lt;p&gt;As you have seen, &lt;code&gt;rvest&lt;/code&gt; is a powerful tool. The goal of the article is to show just the tip of the iceberg regarding web scraping in R.&lt;/p&gt;
&lt;p&gt;There are many resources online that you can read if you want to know more:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://bookdown.org/paul/2021_computational_social_science/web-scraping-basics.html&#34; target=&#34;_blank&#34;&gt;Web scraping: Basics&lt;/a&gt; by Paul Bauer&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/web/packages/rvest/rvest.pdf&#34; target=&#34;_blank&#34;&gt;rvest&lt;/a&gt; CRAN documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/web/packages/xml2/xml2.pdf&#34; target=&#34;_blank&#34;&gt;xml2&lt;/a&gt; CRAN documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/web/packages/httr/httr.pdf&#34; target=&#34;_blank&#34;&gt;httr&lt;/a&gt; CRAN documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/web/packages/rvest/vignettes/rvest.html&#34; target=&#34;_blank&#34;&gt;rvest&lt;/a&gt; CRAN vignette&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/web/packages/httr/vignettes/quickstart.html&#34; target=&#34;_blank&#34;&gt;httr&lt;/a&gt; CRAN vignette&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.crummy.com/software/BeautifulSoup/bs4/doc/&#34; target=&#34;_blank&#34;&gt;Beautiful Soup&lt;/a&gt; documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://robobrowser.readthedocs.io/en/latest/readme.html&#34; target=&#34;_blank&#34;&gt;RoboBrowser&lt;/a&gt; documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/HTML&#34; target=&#34;_blank&#34;&gt;HTML&lt;/a&gt; documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/CSS&#34; target=&#34;_blank&#34;&gt;CSS&lt;/a&gt; documentation&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 this article helped you to learn about web scraping in R, and gave you the incentive to use it for your projects. If you are interested in seeing another example, see how to &lt;a href=&#34;https://statsandr.com/blog/scrape-yahoo-search-engine-results-with-r/&#34;&gt;scrape Yahoo search engine results with R&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;
</description>
    </item>
    
    <item>
      <title>What is survival analysis? Examples by hand and in R</title>
      <link>https://statsandr.com/blog/what-is-survival-analysis/</link>
      <pubDate>Thu, 22 Dec 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/what-is-survival-analysis/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#what-is-survival-analysis&#34; id=&#34;toc-what-is-survival-analysis&#34;&gt;What is survival analysis?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#why-do-we-need-special-methods-for-survival-analysis&#34; id=&#34;toc-why-do-we-need-special-methods-for-survival-analysis&#34;&gt;Why do we need special methods for survival analysis?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#common-functions-in-survival-analysis&#34; id=&#34;toc-common-functions-in-survival-analysis&#34;&gt;Common functions in survival analysis&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#survival-function&#34; id=&#34;toc-survival-function&#34;&gt;Survival function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#cumulative-hazard-function&#34; id=&#34;toc-cumulative-hazard-function&#34;&gt;Cumulative hazard function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hazard-function&#34; id=&#34;toc-hazard-function&#34;&gt;Hazard function&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#estimation&#34; id=&#34;toc-estimation&#34;&gt;Estimation&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand&#34; id=&#34;toc-by-hand&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-r&#34; id=&#34;toc-in-r&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hypothesis-testing&#34; id=&#34;toc-hypothesis-testing&#34;&gt;Hypothesis testing&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#log-rank-test&#34; id=&#34;toc-log-rank-test&#34;&gt;Log-rank test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand-1&#34; id=&#34;toc-by-hand-1&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-r-1&#34; id=&#34;toc-in-r-1&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#to-go-further&#34; id=&#34;toc-to-go-further&#34;&gt;To go further&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/what-is-survival-analysis.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that this article is inspired from:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;the lecture notes of Prof. Van Keilegom and my personal notes as teaching assistant for her course entitled “Analysis of Survival and Duration Data” given at UCLouvain&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;the lecture notes of Prof. Legrand for her course entitled “Statistics in clinical trials” given at UCLouvain&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;For the last post of the year, I would like to present a rather unknown (yet important) statistical method–&lt;strong&gt;survival analysis&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Although survival analysis is a branch of statistics, it is usually not covered in introductory statistics courses and it is rather unknown to the general public. It is mostly taught in biostatistics courses or advanced statistics study programs.&lt;/p&gt;
&lt;p&gt;In this article, I will explain what is survival analysis, in which context and how it is used. I will explain the main tools and methods used by biostatisticians to analyze survival data and how to estimate and interpret survival curves.&lt;/p&gt;
&lt;p&gt;I will show in detail how to apply these techniques in R with concrete examples. In practice, survival analysis is almost always done via a statistical program and never done by hand. However, as for any statistical concept, I believe that doing it by hand allows to really understand the concepts and what these programs actually do. For this reason, I will also show a brief example on how to perform a basic survival analysis by hand.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-is-survival-analysis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What is survival analysis?&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;Survival analysis&lt;/strong&gt; (also called time-to-event analysis or duration analysis) is a branch of statistics aimed at &lt;strong&gt;analyzing the duration of time from a well-defined time origin until one or more events happen&lt;/strong&gt;, called survival times or duration times.&lt;/p&gt;
&lt;p&gt;In other words, in survival analysis, we are interested in a certain event and want to &lt;strong&gt;analyze the time until the event happens&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;While the event of interest is often death (in this case we study the time to death for patients having a specific disease) or recurrence (in this case we study the time to relapse of a certain disease), it is not limited to the medical field or epidemiology.&lt;/p&gt;
&lt;p&gt;In fact, it can be used in many domains. For example, we may also analyze the time until:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;getting cured from a certain disease&lt;/li&gt;
&lt;li&gt;finding a new job after a period of unemployment&lt;/li&gt;
&lt;li&gt;being arrested again after having been released from jail&lt;/li&gt;
&lt;li&gt;the first pregnancy&lt;/li&gt;
&lt;li&gt;the failure of a mechanical system or a machine&lt;/li&gt;
&lt;li&gt;a bank or a company goes bankrupt&lt;/li&gt;
&lt;li&gt;a customer buys a new product or stops its current subscription&lt;/li&gt;
&lt;li&gt;a letter is delivered&lt;/li&gt;
&lt;li&gt;a taxi picks you up after having called the taxi company&lt;/li&gt;
&lt;li&gt;an employee leaves the company&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As you can see, the event of interest does not necessarily have to be the death or the occurrence of a disease, but in all situations &lt;strong&gt;we are interested in analyzing the time until a specific event occurs&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;why-do-we-need-special-methods-for-survival-analysis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Why do we need special methods for survival analysis?&lt;/h1&gt;
&lt;p&gt;Survival data, also referred as time-to-event data, requires a special set of statistical methods for three main reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Duration times&lt;/strong&gt; are &lt;strong&gt;always positive&lt;/strong&gt;: the time until an event of interest occurs cannot be less than 0. Moreover, the distribution of survival times is right-skewed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Different measures&lt;/strong&gt; are of interest depending on the research question, context, etc. For instance, we could be interested in:
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;probability&lt;/strong&gt; that a cancer patient survives longer than 5 years after diagnosis?&lt;/li&gt;
&lt;li&gt;The typical &lt;strong&gt;waiting time&lt;/strong&gt; for a cab to arrive after having called the taxi company?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How many&lt;/strong&gt;, out of 100 unemployed people, are expected to have a job again after 2 months of unemployment?&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Censoring&lt;/strong&gt; is almost always an issue:
&lt;ul&gt;
&lt;li&gt;When the event occurred before the end of the study, the survival time is known.&lt;/li&gt;
&lt;li&gt;However, sometimes, the event is not yet observed at the end of the study. Suppose that we study the time until death of patients with breast cancer. Luckily, some patients will not die before the end of the study.
&lt;!-- + Other times, another event occurs before the event of interest which prevents it from ever happening. For example, a cancer patient may die from a car accident. --&gt;&lt;/li&gt;
&lt;li&gt;It can also happen that the patient withdraws from the study or moves to another country before the end of the study (known as lost to follow up or drop out).&lt;/li&gt;
&lt;li&gt;In all situations, his or her survival time cannot be observed because the event is not observed for the duration of the study.&lt;/li&gt;
&lt;li&gt;Censoring can be seen, in some sense, as a type of missing data.&lt;/li&gt;
&lt;li&gt;For these reasons, many “standard” statistical tools such as &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt;, &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;regression models&lt;/a&gt; are not appropriate for this kind of data. Specific statistical methods are required to take into account the fact that the &lt;em&gt;exact&lt;/em&gt; survival duration for some patients is missing. It is known that they survived a certain amount of time (until the end of the study or until the time of withdrawal), but their exact survival time is unknown.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For your information, there are three types of censoring:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;right-censoring (the most frequent),&lt;/li&gt;
&lt;li&gt;left-censoring (the least frequent) and&lt;/li&gt;
&lt;li&gt;interval-censoring.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When the event is not yet observed at the end of the study (i.e., the survival time is greater than the observed duration), this is referred as right-censoring. Left-censoring occurs if a participant is entered into the study when the event of interest occurred prior to study entry but we do not know exactly when. Interval-censoring implies that the event occurred within a time interval (between two known dates, two visits, etc.); the exact moment of occurrence is not known. The goal is of course to analyze all available data, including information about censored patients.&lt;/p&gt;
&lt;p&gt;The goal of survival analysis is thus to model and describe time-to-event data in an appropriate way, taking the particularities of this type of data into account.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;common-functions-in-survival-analysis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Common functions in survival analysis&lt;/h1&gt;
&lt;p&gt;We are not going to go to much into the details, but it is important to lay the foundation with the most common functions in survival analysis.&lt;/p&gt;
&lt;p&gt;Let &lt;span class=&#34;math inline&#34;&gt;\(T\)&lt;/span&gt; be a non-negative continuous random variable, representing the time until the event of interest. We consider the following functions:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Survival function&lt;/li&gt;
&lt;li&gt;Cumulative hazard function&lt;/li&gt;
&lt;li&gt;Hazard function&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;survival-function&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Survival function&lt;/h2&gt;
&lt;p&gt;The most common one is the survival function.&lt;/p&gt;
&lt;p&gt;Let &lt;span class=&#34;math inline&#34;&gt;\(T\)&lt;/span&gt; be a non-negative continuous random variable, representing the time until the event of interest. The survival function &lt;span class=&#34;math inline&#34;&gt;\(S(t)\)&lt;/span&gt; is the probability that a randomly chosen individual is still at risk at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, where &lt;span class=&#34;math inline&#34;&gt;\(0 \le t \le +\infty\)&lt;/span&gt;. For each &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, it is given by&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{align*}
    S(t) &amp;amp;= P(T &amp;gt; t)\\
    &amp;amp;= 1 - P(T \le t)\\
    &amp;amp;= 1 - F(t)\\
    &amp;amp;= 1 - \int^t_0 f(u)\text{d}u,
\end{align*}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(f(\cdot)\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(F(\cdot)\)&lt;/span&gt; are the density and the cumulative distribution functions of &lt;span class=&#34;math inline&#34;&gt;\(T\)&lt;/span&gt;, respectively.&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(S(t)\)&lt;/span&gt; represents, for each time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, the probability that the time until the event is greater than this time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;. In other words, it models the probability that the event of interest happens &lt;strong&gt;after&lt;/strong&gt; &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In the context of our examples mentioned above, it gives the probability that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a randomly selected patient will survive beyond time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; or the proportion of patients still alive after time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;a cab takes more than &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; minutes to arrive, or&lt;/li&gt;
&lt;li&gt;an unemployed person take more than &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; months to find a new job.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The survival function &lt;span class=&#34;math inline&#34;&gt;\(S(t)\)&lt;/span&gt; is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a decreasing function,&lt;/li&gt;
&lt;li&gt;taking values in &lt;span class=&#34;math inline&#34;&gt;\([0, 1]\)&lt;/span&gt; (since it is a probability), and&lt;/li&gt;
&lt;li&gt;equal to 1 at &lt;span class=&#34;math inline&#34;&gt;\(t = 0\)&lt;/span&gt; (i.e., &lt;span class=&#34;math inline&#34;&gt;\(S(0) = 1\)&lt;/span&gt;) and 0 at &lt;span class=&#34;math inline&#34;&gt;\(t = \infty\)&lt;/span&gt; (i.e., &lt;span class=&#34;math inline&#34;&gt;\(S(\infty) = 0\)&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Visually we have:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-1-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The curve shows the proportion of individuals (or experimental units) who, as time goes on, have not experienced the event of interest. As time progresses, events occur, so the proportion who have not experienced the event decreases.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;cumulative-hazard-function&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Cumulative hazard function&lt;/h2&gt;
&lt;p&gt;The cumulative hazard function, which is the total hazard experienced up to time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, is defined as:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[H(t) = -log\left(S(t)\right)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and has the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;increasing function,&lt;/li&gt;
&lt;li&gt;taking value in &lt;span class=&#34;math inline&#34;&gt;\([0, +\infty]\)&lt;/span&gt;, and&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(S(t) = exp(-H(t))\)&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;hazard-function&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Hazard function&lt;/h2&gt;
&lt;p&gt;The hazard function &lt;span class=&#34;math inline&#34;&gt;\(h(t)\)&lt;/span&gt;, or hazard rate, defines the instantaneous event rate at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; for an individual still at risk at that time. It can be obtained by&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{align*}
h(t) &amp;amp;= \lim_{\Delta t \rightarrow 0} \frac{P(t \le T &amp;lt; t + \Delta t | T \ge t)}{\Delta t}\\
&amp;amp;= \frac{d}{dt} H(t)\\
&amp;amp;= \frac{f(t)}{S(t)}.
\end{align*}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and has the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;positive function (not necessarily increasing or decreasing)&lt;/li&gt;
&lt;li&gt;the hazard function &lt;span class=&#34;math inline&#34;&gt;\(h(t)\)&lt;/span&gt; can have many different shapes and is therefore a useful tool to summarize survival data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the context of cancer research when death is the event of interest, &lt;span class=&#34;math inline&#34;&gt;\(h(t)\)&lt;/span&gt; measures the instantaneous risk of dying right after time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; given the individual is alive at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;To link the hazard rate with the survival function; the survival curve represents the hazard rates. A steeper slope indicates a higher hazard rate because events happen more frequently, reducing the proportion of individuals who have not experienced the event at a faster rate. On the contrary, a gradual and flatter slope indicates a lower hazard rate because events occur less frequently, reducing the proportion of individuals who have not experiences the event at a slower rate. More formally:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[S(t) = \exp\left(-\int^t_0 h(u) \text{d}u\right).\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note that, in contrast to the survival function which focuses on not having an event, the hazard function focuses on the event occurring.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;estimation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Estimation&lt;/h1&gt;
&lt;p&gt;To estimate the survival function, we need to use an estimator which is able to deal with censoring. The most common one is the nonparametric &lt;strong&gt;&lt;span class=&#34;citation&#34;&gt;Kaplan and Meier (&lt;a href=&#34;#ref-kaplan1958nonparametric&#34;&gt;1958&lt;/a&gt;)&lt;/span&gt; estimator&lt;/strong&gt; (also sometimes referred as the product-limit estimator, or more simply, the K-M estimator).&lt;/p&gt;
&lt;p&gt;The advantages of the Kaplan-Meier estimator are that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it is simple and straightforward to use and interpret&lt;/li&gt;
&lt;li&gt;it is a nonparametric estimator, so it constructs a survival curve from the data and no assumptions is made about the shape of the underlying distribution&lt;/li&gt;
&lt;li&gt;it gives a graphical representation of the survival function(s), useful for illustrative purposes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The principle behind this estimator is that surviving beyond time &lt;span class=&#34;math inline&#34;&gt;\(t_i\)&lt;/span&gt; implies surviving beyond time &lt;span class=&#34;math inline&#34;&gt;\(t_{i-1}\)&lt;/span&gt; and surviving at time &lt;span class=&#34;math inline&#34;&gt;\(t_i\)&lt;/span&gt;. Note that an important assumption for the estimation to hold is that censoring is independent of the occurrence of events. We say that censoring is non-informative, that is, censored subjects have the same survival prospects as subjects who are not censored and who continue to be followed.&lt;/p&gt;
&lt;div id=&#34;by-hand&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;By hand&lt;/h2&gt;
&lt;p&gt;To understand how it works, let’s first estimate it by hand on the following dataset:&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;/p&gt;
&lt;div id=&#34;ezedjhlbwf&#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;#ezedjhlbwf table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#ezedjhlbwf thead, #ezedjhlbwf tbody, #ezedjhlbwf tfoot, #ezedjhlbwf tr, #ezedjhlbwf td, #ezedjhlbwf th {
  border-style: none;
}

#ezedjhlbwf p {
  margin: 0;
  padding: 0;
}

#ezedjhlbwf .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  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;
}

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

#ezedjhlbwf .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;
}

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

#ezedjhlbwf .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;
}

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

#ezedjhlbwf .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;
}

#ezedjhlbwf .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;
}

#ezedjhlbwf .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;
}

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

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

#ezedjhlbwf .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%;
}

#ezedjhlbwf .gt_spanner_row {
  border-bottom-style: hidden;
}

#ezedjhlbwf .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;
}

#ezedjhlbwf .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;
}

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

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

#ezedjhlbwf .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  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;
}

#ezedjhlbwf .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;
}

#ezedjhlbwf .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;
}

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

#ezedjhlbwf .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#ezedjhlbwf .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;
}

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

#ezedjhlbwf .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;
}

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

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

#ezedjhlbwf .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;
}

#ezedjhlbwf .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;
}

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

#ezedjhlbwf .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;
}

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

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

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

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

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

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

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

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

#ezedjhlbwf .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#ezedjhlbwf .gt_indent_5 {
  text-indent: 25px;
}

#ezedjhlbwf .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#ezedjhlbwf div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;subject&#34;&gt;subject&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;time&#34;&gt;time&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;event&#34;&gt;event&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;subject&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;0&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;7&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;4&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;18&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;0&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;6&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;16&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;7&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;8&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;9&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;9&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;16&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;10&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;0&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;subject&lt;/code&gt; is the individual’s identifier&lt;/li&gt;
&lt;li&gt;&lt;code&gt;time&lt;/code&gt; is the time to event (in years)&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;/li&gt;
&lt;li&gt;&lt;code&gt;event&lt;/code&gt; is the event status (0 = censored, 1 = event happened)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Remember that for each subject, we need to know at least 2 pieces of information:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the time until the event of interest or the time until the censoring, and&lt;/li&gt;
&lt;li&gt;whether we have observed the event of interest or if we have observed censoring.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We first need to count the number of distinct event times. Ignoring censored observations, we have 5 distinct event times:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;2&lt;/em&gt;, &lt;em&gt;5&lt;/em&gt;, &lt;em&gt;7&lt;/em&gt;, &lt;em&gt;9&lt;/em&gt; and &lt;em&gt;16&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The easiest way to do the calculation by hand is by filling the following table (a table with 5 rows since there are 5 distinct event times):&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_gqi6wniv912vuheaxhyt = TinyTable.createTableFunctions(&#34;tinytable_gqi6wniv912vuheaxhyt&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_63tzhumrxmy06nvag0kk&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_odk2y8mjqugbkfu3h9e3&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_x7q8xsf3ainkuuago1c3&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_gqi6wniv912vuheaxhyt.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_gqi6wniv912vuheaxhyt td.tinytable_css_63tzhumrxmy06nvag0kk, #tinytable_gqi6wniv912vuheaxhyt th.tinytable_css_63tzhumrxmy06nvag0kk {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_gqi6wniv912vuheaxhyt td.tinytable_css_odk2y8mjqugbkfu3h9e3, #tinytable_gqi6wniv912vuheaxhyt th.tinytable_css_odk2y8mjqugbkfu3h9e3 { text-align: left }
    #tinytable_gqi6wniv912vuheaxhyt td.tinytable_css_x7q8xsf3ainkuuago1c3, #tinytable_gqi6wniv912vuheaxhyt th.tinytable_css_x7q8xsf3ainkuuago1c3 {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_gqi6wniv912vuheaxhyt&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;p&gt;We fill columns one by one:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(y_{(j)}\)&lt;/span&gt; = the ordered distinct event times:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;2&lt;/em&gt;, &lt;em&gt;5&lt;/em&gt;, &lt;em&gt;7&lt;/em&gt;, &lt;em&gt;9&lt;/em&gt; and &lt;em&gt;16&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So the table becomes:&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_pfttpztdnahkfolt80rf = TinyTable.createTableFunctions(&#34;tinytable_pfttpztdnahkfolt80rf&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_6a61u2qsubu2inwtd56y&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_8lne9bdpjx6dn6p4x3gd&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_bniz86tc4lp4m19bq9xc&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_pfttpztdnahkfolt80rf.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_pfttpztdnahkfolt80rf td.tinytable_css_6a61u2qsubu2inwtd56y, #tinytable_pfttpztdnahkfolt80rf th.tinytable_css_6a61u2qsubu2inwtd56y {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_pfttpztdnahkfolt80rf td.tinytable_css_8lne9bdpjx6dn6p4x3gd, #tinytable_pfttpztdnahkfolt80rf th.tinytable_css_8lne9bdpjx6dn6p4x3gd { text-align: left }
    #tinytable_pfttpztdnahkfolt80rf td.tinytable_css_bniz86tc4lp4m19bq9xc, #tinytable_pfttpztdnahkfolt80rf th.tinytable_css_bniz86tc4lp4m19bq9xc {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_pfttpztdnahkfolt80rf&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;7&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;9&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;16&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(d_{(j)}\)&lt;/span&gt; = the number of observations for each distinct event time. For this, the frequency for each distinct event time is useful:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;## time
##  2  5  7  9 16 
##  2  1  1  1  2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The table becomes:&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_jyqpf16iauwvmx2i0oim = TinyTable.createTableFunctions(&#34;tinytable_jyqpf16iauwvmx2i0oim&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_p57hqjnq2thdknhk1o3h&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_uci8h8g7nt7wfi557l1d&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_689d9x9gs8twi4f8vbpv&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_jyqpf16iauwvmx2i0oim.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_jyqpf16iauwvmx2i0oim td.tinytable_css_p57hqjnq2thdknhk1o3h, #tinytable_jyqpf16iauwvmx2i0oim th.tinytable_css_p57hqjnq2thdknhk1o3h {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_jyqpf16iauwvmx2i0oim td.tinytable_css_uci8h8g7nt7wfi557l1d, #tinytable_jyqpf16iauwvmx2i0oim th.tinytable_css_uci8h8g7nt7wfi557l1d { text-align: left }
    #tinytable_jyqpf16iauwvmx2i0oim td.tinytable_css_689d9x9gs8twi4f8vbpv, #tinytable_jyqpf16iauwvmx2i0oim th.tinytable_css_689d9x9gs8twi4f8vbpv {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_jyqpf16iauwvmx2i0oim&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;7&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;9&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;16&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(R_{(j)}\)&lt;/span&gt; = the remaining number of individuals at risk. For this, the distribution of time (censored and not censored) is useful:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;## time
##  2  3  5  7  9 16 18 
##  2  1  2  1  1  2  1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At the beginning there are 10 subjects&lt;/li&gt;
&lt;li&gt;Just before time &lt;span class=&#34;math inline&#34;&gt;\(t = 5\)&lt;/span&gt;, there are 7 subjects left (10 subjects - 2 who had the event - 1 who is censored)&lt;/li&gt;
&lt;li&gt;Just before time &lt;span class=&#34;math inline&#34;&gt;\(t = 7\)&lt;/span&gt;, there are 5 subjects left (= 10 - 2 - 1 - 2)&lt;/li&gt;
&lt;li&gt;Just before time &lt;span class=&#34;math inline&#34;&gt;\(t = 9\)&lt;/span&gt;, there are 4 subjects left (= 10 - 2 - 1 - 2 - 1)&lt;/li&gt;
&lt;li&gt;Just before time &lt;span class=&#34;math inline&#34;&gt;\(t = 16\)&lt;/span&gt;, there are 3 subjects left (= 10 - 2 - 1 - 2 - 1 - 1)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The table becomes:&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_13fjo3fhqofxmr77b0ro = TinyTable.createTableFunctions(&#34;tinytable_13fjo3fhqofxmr77b0ro&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_05oab03bspdqdzznbf9c&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_h96li1wtavwkgoy72cy6&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_cb86r59qgslap7na03m7&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_13fjo3fhqofxmr77b0ro.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_13fjo3fhqofxmr77b0ro td.tinytable_css_05oab03bspdqdzznbf9c, #tinytable_13fjo3fhqofxmr77b0ro th.tinytable_css_05oab03bspdqdzznbf9c {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_13fjo3fhqofxmr77b0ro td.tinytable_css_h96li1wtavwkgoy72cy6, #tinytable_13fjo3fhqofxmr77b0ro th.tinytable_css_h96li1wtavwkgoy72cy6 { text-align: left }
    #tinytable_13fjo3fhqofxmr77b0ro td.tinytable_css_cb86r59qgslap7na03m7, #tinytable_13fjo3fhqofxmr77b0ro th.tinytable_css_cb86r59qgslap7na03m7 {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_13fjo3fhqofxmr77b0ro&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;10&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;7&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;7&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;9&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;16&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(1 - \frac{d_{(j)}}{R_{(j)}}\)&lt;/span&gt; is straightforward, so the table becomes:&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_pwro8an6lcdmghyyn84k = TinyTable.createTableFunctions(&#34;tinytable_pwro8an6lcdmghyyn84k&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_kvroag0647on9aibrtmk&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_jdhilsydd0ovjj4g5zxc&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_2l0ch1qqpad19ftfdsmj&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_pwro8an6lcdmghyyn84k.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_pwro8an6lcdmghyyn84k td.tinytable_css_kvroag0647on9aibrtmk, #tinytable_pwro8an6lcdmghyyn84k th.tinytable_css_kvroag0647on9aibrtmk {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_pwro8an6lcdmghyyn84k td.tinytable_css_jdhilsydd0ovjj4g5zxc, #tinytable_pwro8an6lcdmghyyn84k th.tinytable_css_jdhilsydd0ovjj4g5zxc { text-align: left }
    #tinytable_pwro8an6lcdmghyyn84k td.tinytable_css_2l0ch1qqpad19ftfdsmj, #tinytable_pwro8an6lcdmghyyn84k th.tinytable_css_2l0ch1qqpad19ftfdsmj {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_pwro8an6lcdmghyyn84k&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;10.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;0.80&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;5.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;7.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;0.86&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;7.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;5.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;0.80&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;9.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;4.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;0.75&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;16.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;3.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;0.33&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;p&gt;The Kaplan-Meier estimator is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\hat{S}_{KM}(t) = \prod_{j:y_{(j)} \le t} \left(1 - \frac{d_{(j)}}{R_{(j)}} \right)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For each &lt;span class=&#34;math inline&#34;&gt;\(j\)&lt;/span&gt;, we thus take the cumulative product:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_1 = 0.8\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_2 = 0.8 \cdot 0.857 = 0.6856\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_3 = 0.6856 \cdot 0.8 = 0.54848\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_4 = 0.54848 \cdot 0.75 = 0.41136\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_5 = 0.41136 \cdot 0.333 = 0.1369829\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So finally, we have the survival probabilities (rounded to 3 digits):&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_9g2vmc4l85a2ai8cd30l = TinyTable.createTableFunctions(&#34;tinytable_9g2vmc4l85a2ai8cd30l&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 } ], css_id: &#39;tinytable_css_0gsa3vc5mq6m4zyan8g2&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 } ], css_id: &#39;tinytable_css_qudi29yolqth1f9pviev&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 } ], css_id: &#39;tinytable_css_v46u97wgn8bmam0b8xgb&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_9g2vmc4l85a2ai8cd30l.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_9g2vmc4l85a2ai8cd30l td.tinytable_css_0gsa3vc5mq6m4zyan8g2, #tinytable_9g2vmc4l85a2ai8cd30l th.tinytable_css_0gsa3vc5mq6m4zyan8g2 {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_9g2vmc4l85a2ai8cd30l td.tinytable_css_qudi29yolqth1f9pviev, #tinytable_9g2vmc4l85a2ai8cd30l th.tinytable_css_qudi29yolqth1f9pviev { text-align: left }
    #tinytable_9g2vmc4l85a2ai8cd30l td.tinytable_css_v46u97wgn8bmam0b8xgb, #tinytable_9g2vmc4l85a2ai8cd30l th.tinytable_css_v46u97wgn8bmam0b8xgb {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_9g2vmc4l85a2ai8cd30l&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$\hat{S}_{KM}(t)$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;0.80&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;0.80&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;0.86&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;0.69&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;0.80&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;0.55&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;0.75&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;0.41&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;0.33&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;0.14&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;p&gt;We can now represent graphically the Kaplan-Meier estimator:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-13-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To draw this survival curve, remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the x-axis corresponds to the &lt;code&gt;time&lt;/code&gt; variable in the initial dataset, and&lt;/li&gt;
&lt;li&gt;the y-axis corresponds to the survival probabilities found above.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;In R&lt;/h2&gt;
&lt;p&gt;We now compare our results with the results found in R.&lt;/p&gt;
&lt;p&gt;We first create the dataset with the time and event variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create dataset
dat &amp;lt;- data.frame(
  time = c(3, 5, 7, 2, 18, 16, 2, 9, 16, 5),
  event = c(0, 1, 1, 1, 0, 1, 1, 1, 1, 0)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then run the Kaplan-Meier estimator with the &lt;code&gt;survfit()&lt;/code&gt; and &lt;code&gt;Surv()&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# KM
library(survival)

km &amp;lt;- survfit(Surv(time, event) ~ 1,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that the &lt;code&gt;Surv()&lt;/code&gt; function accepts two arguments:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the &lt;code&gt;time&lt;/code&gt; variable, and&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;event&lt;/code&gt; variable.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The &lt;code&gt;~ 1&lt;/code&gt; in the &lt;code&gt;survfit()&lt;/code&gt; function indicates that we estimate the Kaplan-Meier without any grouping. See more on this later in the post.&lt;/p&gt;
&lt;p&gt;Finally, we display the results and draw the Kaplan-Meier plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# results
summary(km)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Call: survfit(formula = Surv(time, event) ~ 1, data = dat)
## 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     2     10       2    0.800   0.126       0.5868        1.000
##     5      7       1    0.686   0.151       0.4447        1.000
##     7      5       1    0.549   0.172       0.2963        1.000
##     9      4       1    0.411   0.176       0.1782        0.950
##    16      3       2    0.137   0.126       0.0225        0.834&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
plot(km,
  xlab = &amp;quot;Time&amp;quot;,
  ylab = &amp;quot;Survival probability&amp;quot;,
  conf.int = FALSE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-16-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The survival probabilities can be found in the &lt;code&gt;survival&lt;/code&gt; column. Remark that results by hand and in R are similar (any difference with the results by hand is due to rounding).&lt;/p&gt;
&lt;p&gt;Alternatively, we can use the &lt;code&gt;ggsurvplot()&lt;/code&gt; function within the &lt;code&gt;{survminer}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(survminer)

# plot
ggsurvplot(km,
  conf.int = FALSE,
  legend = &amp;quot;none&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-17-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that the crosses on the survival curve denote the censored observations.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The advantage with the &lt;code&gt;ggsurvplot()&lt;/code&gt; function is that it is easy to draw the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#median&#34;&gt;median&lt;/a&gt; survival directly on the plot:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggsurvplot(km,
  conf.int = FALSE,
  surv.median.line = &amp;quot;hv&amp;quot;,
  legend = &amp;quot;none&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-18-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To find the median survival:&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(km)$table[&amp;quot;median&amp;quot;]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## median 
##      9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or more simply
km&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Call: survfit(formula = Surv(time, event) ~ 1, data = dat)
## 
##       n events median 0.95LCL 0.95UCL
## [1,] 10      7      9       5      NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Suppose that the event of interest is death:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At time zero, the survival probability is 1 (100% of the subjects are alive).&lt;/li&gt;
&lt;li&gt;The median indicates that the median survival time is 9 years.&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt; This is the time at which the survival &lt;span class=&#34;math inline&#34;&gt;\(S(t)\)&lt;/span&gt; is 50%. In other words, is the time after which half of the subjects are expected to have died.&lt;/li&gt;
&lt;li&gt;From the plot, we also see that &lt;span class=&#34;math inline&#34;&gt;\(S(5) = P(T &amp;gt; 5 \text{ years}) =\)&lt;/span&gt; Probability of survival of more than 5 years for these subjects = 68.6%. This means that 68.6% of all subjects survive longer than 5 years, and that 31.4% of all subjects die within the first 5 years.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the sake of completeness, let’s do another example with a much larger dataset; the &lt;code&gt;tongue&lt;/code&gt; dataset within the &lt;code&gt;{KMsurv}&lt;/code&gt; package.&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load data
library(KMsurv)
data(tongue)

# preview data
head(tongue)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   type time delta
## 1    1    1     1
## 2    1    3     1
## 3    1    3     1
## 4    1    4     1
## 5    1   10     1
## 6    1   13     1&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;type&lt;/code&gt; is the tumor DNA profile (1 = aneuploid tumor, 2 = diploid tumor)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;time&lt;/code&gt; is the time to death or on-study time (in weeks)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;delta&lt;/code&gt; is the death indicator (0 = alive, 1 = dead)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this example, we focus on the aneuploid type:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;anaploid &amp;lt;- subset(tongue, type == 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can now plot the estimated survival function and estimate the median time to death. Since it is an estimator, we can also construct a confidence interval for the estimated survival at each time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; and for the estimated median survival time.&lt;a href=&#34;#fn7&#34; class=&#34;footnote-ref&#34; id=&#34;fnref7&#34;&gt;&lt;sup&gt;7&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# results
fit &amp;lt;- survfit(Surv(time, delta) ~ 1,
  data = anaploid,
  conf.type = &amp;quot;log-log&amp;quot;
)

fit&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Call: survfit(formula = Surv(time, delta) ~ 1, data = anaploid, conf.type = &amp;quot;log-log&amp;quot;)
## 
##       n events median 0.95LCL 0.95UCL
## [1,] 52     31     93      65     157&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
ggsurvplot(fit,
  surv.median.line = &amp;quot;hv&amp;quot;,
  legend = &amp;quot;none&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-22-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The median survival time is estimated to be 93 weeks, with a 95% confidence interval between 65 and 157 weeks.&lt;/p&gt;
&lt;p&gt;Kaplan-Meier curves can be seen as &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; for survival data. We now focus on the second branch of statistics, &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis testing&lt;/a&gt; which allows to draw conclusions on the population based on a sample (see a quick reminder about the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;difference between population and sample&lt;/a&gt; if you need).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;hypothesis-testing&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Hypothesis testing&lt;/h1&gt;
&lt;p&gt;Hypothesis testing in the field of survival analysis mostly concerns:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The hazard function of &lt;strong&gt;one population&lt;/strong&gt;: in this case we test whether a censored sample comes from a population with a known hazard function &lt;span class=&#34;math inline&#34;&gt;\(h_0(t)\)&lt;/span&gt;. For example, we may be interested to compare survival in a sample of patients to the survival in the overall population (derived from the life tables).&lt;/li&gt;
&lt;li&gt;The comparison of the hazard function of &lt;strong&gt;two or more populations&lt;/strong&gt;: in this case we are interested in assessing whether there are differences in survival among different groups of subjects. For example:
&lt;ul&gt;
&lt;li&gt;2 groups: we are interested in comparing survival for female and male colon cancer patients&lt;/li&gt;
&lt;li&gt;3 groups or more: we are interested in comparing survival for melanoma cancer patients according to their treatments (with treatments A, B and C for example)&lt;a href=&#34;#fn8&#34; class=&#34;footnote-ref&#34; id=&#34;fnref8&#34;&gt;&lt;sup&gt;8&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;log-rank-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Log-rank test&lt;/h2&gt;
&lt;p&gt;In this article, we focus on comparing survival between two groups using the &lt;strong&gt;log-rank test&lt;/strong&gt; (also known as Mantel-Cox test). This test is the most common hypothesis test to compare survival between two groups.&lt;/p&gt;
&lt;p&gt;The intuition behind the test is that if the two groups have different hazard rates, the two survival curves (so their slopes) will differ. More precisely, the log-rank test compares the observed number of events in each group to what would be expected if the survival curves were identical (i.e., if the null hypothesis were true).&lt;/p&gt;
&lt;p&gt;Note that, as for the Kaplan-Meier estimator, the log-rank test is a nonparametric test, which makes no assumptions about the survival distributions.&lt;/p&gt;
&lt;p&gt;For this example, consider the following dataset:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;##    patient group time event
## 1        1     1  4.1     1
## 2        2     1  7.8     0
## 3        3     1 10.0     1
## 4        4     1 10.0     1
## 5        5     1 12.3     0
## 6        6     1 17.2     1
## 7        7     2  9.7     1
## 8        8     2 10.0     1
## 9        9     2 11.1     0
## 10      10     2 13.1     0
## 11      11     2 19.7     1
## 12      12     2 24.1     0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;patient&lt;/code&gt; is the patient’s identifier&lt;/li&gt;
&lt;li&gt;&lt;code&gt;group&lt;/code&gt; is the group (group 1 or 2)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;time&lt;/code&gt; is the time to death (in years)&lt;a href=&#34;#fn9&#34; class=&#34;footnote-ref&#34; id=&#34;fnref9&#34;&gt;&lt;sup&gt;9&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;event&lt;/code&gt; is the event status (0 = censored, 1 = death)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Suppose we are interested in comparing group 1 and 2 in terms of survival, that is, we compare survival curves between the 2 groups:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0 : S_1(t) = S_2(t)\)&lt;/span&gt; for all &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1 : S_1(t) \ne S_2(t)\)&lt;/span&gt; for some &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is a statistical test, so if the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (usually 0.05), we reject the null hypothesis and we conclude that survival (or the time to event) is significantly different between the two groups considered.&lt;/p&gt;
&lt;p&gt;To perform the log-rank test, the following test statistic will be useful:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{eqnarray}
U &amp;amp;=&amp;amp; \sum_{j=1}^r w(y_{(j)})\left(O_j - E_j\right) \\
&amp;amp;=&amp;amp; \sum_{j=1}^r w(y_{(j)})\left( d_{(j)1} - \frac{d_{(j)}R_{(j)1}}{R_{(j)}}\right)
\end{eqnarray}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;with &lt;span class=&#34;math inline&#34;&gt;\(U^{obs} = \frac{U}{\sqrt{Var(U)}} \sim N(0,1)\)&lt;/span&gt; and&lt;a href=&#34;#fn10&#34; class=&#34;footnote-ref&#34; id=&#34;fnref10&#34;&gt;&lt;sup&gt;10&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{eqnarray}
Var(U) &amp;amp;=&amp;amp; \sum_{j=1}^r w^2(y_{(j)}) \frac{N_{(j)}}{ D_{(j)}  }\\
&amp;amp;=&amp;amp; \sum_{j=1}^r w^2(y_{(j)}) \frac{ d_{(j)} \frac{R_{(j)1}}{R_{(j)} } \left( 1 - \frac{R_{(j)1}}{R_{(j)} } \right) \left( R_{(j)} - d_{(j)}\right) }{ R_{(j)} - 1  }
\end{eqnarray}\]&lt;/span&gt;&lt;/p&gt;
&lt;div id=&#34;by-hand-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;By hand&lt;/h3&gt;
&lt;p&gt;As for the Kaplan-Meier estimator by hand, it is best to also fill in a table for the log-rank test by hand.&lt;/p&gt;
&lt;p&gt;Let’s present the final table and comment below on how to fill it, column by column:&lt;/p&gt;
&lt;table style=&#34;width:100%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;5%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;7%&#34; /&gt;
&lt;col width=&#34;7%&#34; /&gt;
&lt;col width=&#34;7%&#34; /&gt;
&lt;col width=&#34;7%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;5%&#34; /&gt;
&lt;col width=&#34;5%&#34; /&gt;
&lt;col width=&#34;10%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;6%&#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;&lt;span class=&#34;math inline&#34;&gt;\(j\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(y_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(d_{(j)1}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(R_{(j)1}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(d_{(j)2}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(R_{(j)2}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(d_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(R_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(E_{j}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(O_{j}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(O_{j} - E_{j}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(N_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(D_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(N_{(j)}/D_{(j)}\)&lt;/span&gt;&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;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;12&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2.75&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;11&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9.7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;10&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2.16&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;10&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.333&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.667&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4.44&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.555&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;17.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.333&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.667&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.44&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.22&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;19.7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(Total\)&lt;/span&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2.566&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.433&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.265&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(j\)&lt;/span&gt;&lt;/strong&gt; is the number of distinct event times. We see that there are 5 (ignoring censored observations), so we write 1 to 5 in the table.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(y_{(j)}\)&lt;/span&gt;&lt;/strong&gt; is the ordered distinct event times:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;4.1&lt;/em&gt;, &lt;em&gt;9.7&lt;/em&gt;, &lt;em&gt;10&lt;/em&gt;, &lt;em&gt;17.2&lt;/em&gt; and &lt;em&gt;19.7&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)1}\)&lt;/span&gt;&lt;/strong&gt; is the number of observations for each distinct event time, for group 1:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## time
##  4.1   10 17.2 
##    1    2    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When there is no event, we simply write 0 in the table.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)1}\)&lt;/span&gt;&lt;/strong&gt; is the remaining number of patients at risk, for group 1. For this, the distribution of time (censored and not censored, for group 1) is useful:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## time
##  4.1  7.8   10 12.3 17.2 
##    1    1    2    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At the beginning, there are 6 patients&lt;/li&gt;
&lt;li&gt;Before time 9.7, there are 4 patients left (6 - 1 who had the event at time 4.1 - 1 who was censored at time 7.8)&lt;/li&gt;
&lt;li&gt;Before time 10, there are 4 patients left (6 - 2)&lt;/li&gt;
&lt;li&gt;Before time 17.2, there are 1 patient left (6 - 5)&lt;/li&gt;
&lt;li&gt;Before time 19.7, there are 0 patient left (6 - 6)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Columns &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)2}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)2}\)&lt;/span&gt;&lt;/strong&gt; follow the same principle, but for group 2 this time. So we have, respectively for &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)2}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)2}\)&lt;/span&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## time
##  9.7   10 19.7 
##    1    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## time
##  9.7   10 11.1 13.1 19.7 24.1 
##    1    1    1    1    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Columns &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)}\)&lt;/span&gt;&lt;/strong&gt; also follow the same principle, but this time considering both groups. So we have, respectively for &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)}\)&lt;/span&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## time
##  4.1  9.7   10 17.2 19.7 
##    1    1    3    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## time
##  4.1  7.8  9.7   10 11.1 12.3 13.1 17.2 19.7 24.1 
##    1    1    1    3    1    1    1    1    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(E_{j}\)&lt;/span&gt;&lt;/strong&gt; is the expected number of events in the first group assuming that &lt;span class=&#34;math inline&#34;&gt;\(h_1 \equiv h_2\)&lt;/span&gt;. It is obtained as follows&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[ E_{j} = \frac{d_{(j)}R_{(j)1}}{R_{(j)}}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(O_{j}\)&lt;/span&gt;&lt;/strong&gt; is the observed number of events in the first group, so it is equal to the &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)1}\)&lt;/span&gt; column.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(O_{j} - E_{j}\)&lt;/span&gt;&lt;/strong&gt; is straightforward.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(N_{(j)}\)&lt;/span&gt;&lt;/strong&gt; is defined as follows&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[N_{(j)} = d_{(j)} \frac{R_{(j)1}}{R_{(j)} } \left( 1 - \frac{R_{(j)1}}{R_{(j)} } \right) \left( R_{(j)} - d_{(j)}\right)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(D_{(j)}\)&lt;/span&gt;&lt;/strong&gt; is &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)} - 1\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(N_{(j)}/D_{(j)}\)&lt;/span&gt;&lt;/strong&gt; is straightforward.&lt;/p&gt;
&lt;p&gt;Since &lt;span class=&#34;math inline&#34;&gt;\(w(y_{(j)}) = w^2(y_{(j)}) = 1\)&lt;/span&gt; for a log-rank test, we have&lt;a href=&#34;#fn11&#34; class=&#34;footnote-ref&#34; id=&#34;fnref11&#34;&gt;&lt;sup&gt;11&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[ U^{obs} = \frac{U}{\sqrt{Var(U)}} = \frac{1.434}{\sqrt{1.265}} = 1.275.\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We reject &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; if &lt;span class=&#34;math inline&#34;&gt;\(|U^{obs}|&amp;gt;z_{1-\alpha/2}\)&lt;/span&gt;, so at the 5% significance level we reject &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; if &lt;span class=&#34;math inline&#34;&gt;\(|U^{obs}|&amp;gt;z_{0.975}=1.96\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;We have &lt;span class=&#34;math inline&#34;&gt;\(|U^{obs}| = 1.275 &amp;lt; z_{0.975}=1.96\)&lt;/span&gt;. Hence, at the 5% significance level we do not reject &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. This means that, based on the data, we are not able to conclude that survival is different between the two groups (which is equivalent than saying that we do not reject the hypothesis that survival is equal between the two groups).&lt;/p&gt;
&lt;p&gt;If you are interested in computing the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(= 2\times P(Z&amp;gt;1.275) = 2 \times 0.101 = 0.202 &amp;gt; 0.05\)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;In R&lt;/h3&gt;
&lt;p&gt;We now compare our results in R with the &lt;code&gt;survdiff()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- data.frame(
  group = c(rep(1, 6), rep(2, 6)),
  time = c(4.1, 7.8, 10, 10, 12.3, 17.2, 9.7, 10, 11.1, 13.1, 19.7, 24.1),
  event = c(1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0)
)

dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    group time event
## 1      1  4.1     1
## 2      1  7.8     0
## 3      1 10.0     1
## 4      1 10.0     1
## 5      1 12.3     0
## 6      1 17.2     1
## 7      2  9.7     1
## 8      2 10.0     1
## 9      2 11.1     0
## 10     2 13.1     0
## 11     2 19.7     1
## 12     2 24.1     0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;survdiff(Surv(time, event) ~ group,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Call:
## survdiff(formula = Surv(time, event) ~ group, data = dat)
## 
##         N Observed Expected (O-E)^2/E (O-E)^2/V
## group=1 6        4     2.57     0.800      1.62
## group=2 6        3     4.43     0.463      1.62
## 
##  Chisq= 1.6  on 1 degrees of freedom, p= 0.2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, we can use the &lt;code&gt;ggsurvplot()&lt;/code&gt; function to draw the survival curves and perform the log-rank test at the same time:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fit &amp;lt;- survfit(Surv(time, event) ~ group, data = dat)

ggsurvplot(fit,
  pval = TRUE,
  pval.method = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-30-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values and the conclusions are the same (any difference with the results by hand is due to rounding).&lt;/p&gt;
&lt;p&gt;As for the Kaplan-Meier estimation, we do another example on a larger dataset. Consider the data on the times until staphylococcus infection of burn patients, also available in the &lt;code&gt;{KMsurv}&lt;/code&gt;:&lt;a href=&#34;#fn12&#34; class=&#34;footnote-ref&#34; id=&#34;fnref12&#34;&gt;&lt;sup&gt;12&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load data
data(burn)

# preview data
head(burn)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Obs Z1 Z2 Z3 Z4 Z5 Z6 Z7 Z8 Z9 Z10 Z11 T1 D1 T2 D2 T3 D3
## 1   1  0  0  0 15  0  0  1  1  0   0   2 12  0 12  0 12  0
## 2   2  0  0  1 20  0  0  1  0  0   0   4  9  0  9  0  9  0
## 3   3  0  0  1 15  0  0  0  1  1   0   2 13  0 13  0  7  1
## 4   4  0  0  0 20  1  0  1  0  0   0   2 11  1 29  0 29  0
## 5   5  0  0  1 70  1  1  1  1  0   0   2 28  1 31  0  4  1
## 6   6  0  0  1 20  1  0  1  0  0   0   4 11  0 11  0  8  1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using the log-rank test, we want to test the hypothesis of difference in the time to staphylococcus infection (&lt;code&gt;T3&lt;/code&gt; variable) between patients whose burns were cared for with a routine bathing care method (&lt;code&gt;Z1 = 0&lt;/code&gt;) versus those whose body cleansing was initially performed using 4% chlorhexidine gluconate (&lt;code&gt;Z1 = 1&lt;/code&gt;). The event indicator is in variable &lt;code&gt;D3&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For this test, we use a two-sided alternative and a 5% significance level.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# fit
fit &amp;lt;- survfit(Surv(T3, D3) ~ Z1, data = burn)

# plot with log-rank test
ggsurvplot(fit,
  pval = TRUE,
  pval.method = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-32-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In the sample&lt;/em&gt;, it seems that the time to infection for patients with routine bathing (&lt;code&gt;Z1 = 0&lt;/code&gt;) is smaller than for patients with body cleansing (&lt;code&gt;Z1 = 1&lt;/code&gt;). This is the case because the percentage of patients who have not experienced the infection decreases more quickly, so the hazard rate is greater.&lt;/p&gt;
&lt;p&gt;However, this conclusion cannot be generalized to the &lt;em&gt;population&lt;/em&gt; without performing a sound statistical test. And based on the result of the log-rank test, we do not reject the hypothesis that time to infection is the same between the two groups of patients (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.051).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;to-go-further&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;To go further&lt;/h1&gt;
&lt;p&gt;In this article, we have presented what is survival analysis, when, why and how to use it. We discussed about censoring and survival curves. We showed how to estimate the survival function via the Kaplan-Meier estimator and how to test survival between two groups via the log-rank test. We illustrated these approaches both by hand and in R.&lt;/p&gt;
&lt;p&gt;As you noticed, we did not show how to &lt;em&gt;model&lt;/em&gt; survival data. There are several regression models that can be applied to survival data, the most common one being the semiparametric Cox Proportional Hazards model &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-cox1972regression&#34;&gt;1972&lt;/a&gt;)&lt;/span&gt;. It originated from the medical area to investigate and assess the relationship between the survival times of patients and their corresponding predictor variables.&lt;/p&gt;
&lt;p&gt;We have seen that the Kaplan-Meier estimator is useful to visualize survival between groups and the log-rank test to test whether survival significantly differs between groups (so both approaches use a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;categorical variable&lt;/a&gt; as predictor). However, it does not work well for assessing the effect of &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative predictor&lt;/a&gt;. The Cox model has the advantage that it works for both quantitative as well as for categorical predictors, and for several risk factors at the same time (so it can model the effect of multiple variables at once).&lt;/p&gt;
&lt;p&gt;With the Cox model, we model the impact of different factors &lt;span class=&#34;math inline&#34;&gt;\(X_1, X_2, \ldots, X_q\)&lt;/span&gt; on survival via their impact on the hazard function:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[h(t|\textbf{X}) = h_0 (t) exp(\beta_1 X_1 + \beta_2 X_2 + \cdots + \beta_q X_q),\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(h(t|\textbf{X})\)&lt;/span&gt; is the instantaneous death rate conditional on having survived up to time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(h_0 (t)\)&lt;/span&gt; is the population-level baseline hazard – the underlying hazard function. It describes how the average person’s risk evolves over time.&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(exp(\beta_1 X_1 + \beta_2 X_2 + \cdots + \beta_q X_q)\)&lt;/span&gt; describes how covariates affect the hazard. In particular, a unit increase in &lt;span class=&#34;math inline&#34;&gt;\(x_i\)&lt;/span&gt; leads to an increase of the hazard by a factor of &lt;span class=&#34;math inline&#34;&gt;\(\exp(\beta_i)\)&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This post aimed at presenting the introductory concepts in survival analysis, so this model will be developed in another post. In the meantime, if you would like to learn more about modeling survival data (thanks to the Cox model and other models), see this &lt;a href=&#34;https://rviews.rstudio.com/2022/09/06/deep-survival/&#34;&gt;post&lt;/a&gt; from Joseph Rickert.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-cox1972regression&#34; class=&#34;csl-entry&#34;&gt;
Cox, David R. 1972. &lt;span&gt;“Regression Models and Life-Tables.”&lt;/span&gt; &lt;em&gt;Journal of the Royal Statistical Society: Series B (Methodological)&lt;/em&gt; 34 (2): 187–202.
&lt;/div&gt;
&lt;div id=&#34;ref-kaplan1958nonparametric&#34; class=&#34;csl-entry&#34;&gt;
Kaplan, Edward L, and Paul Meier. 1958. &lt;span&gt;“Nonparametric Estimation from Incomplete Observations.”&lt;/span&gt; &lt;em&gt;Journal of the American Statistical Association&lt;/em&gt; 53 (282): 457–81.
&lt;/div&gt;
&lt;/div&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;Note that in survival analysis, the precision of the estimators (and the power of the tests) does not depend on the number of patients but on the number of events. So it is best to have many observations where the event does occur for the analyses to be effective. Here we work on a small sample for the sake of illustration.&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;Note that the &lt;code&gt;time&lt;/code&gt; variable can be expressed in other units, such as seconds, days, weeks, months, etc.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Median is preferred over mean in survival analysis because survival functions are often skewed to the right. The mean is often influenced by &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;, whereas the median is not. See a discussion comparing the two in this &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#mean-vs.-median&#34;&gt;section&lt;/a&gt;.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Note that if the survival curve does not cross 50% (because survival is greater than 50% at the last time point), then the median survival cannot be computed and is simply undefined.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;Note that the median survival is expressed in the same unit than the unit of the &lt;code&gt;time&lt;/code&gt; variable in the initial dataset. So if the time unit was months, the median survival time would be 9 months.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;More information about the dataset can be found on &lt;a href=&#34;https://cran.r-project.org/web/packages/KMsurv/&#34;&gt;CRAN&lt;/a&gt; or with &lt;code&gt;?tongue&lt;/code&gt;.&lt;a href=&#34;#fnref6&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn7&#34;&gt;&lt;p&gt;See the reason we use &lt;code&gt;log-log&lt;/code&gt; for the confidence interval in this &lt;a href=&#34;https://stats.stackexchange.com/questions/361354/choosing-conf-type-for-survfit-in-r&#34;&gt;thread&lt;/a&gt;.&lt;a href=&#34;#fnref7&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn8&#34;&gt;&lt;p&gt;Note that if the groups to compare have a natural ordering (such as the educational level; none, low, medium, high), tests that take it into consideration have more power to detect significant effects. These tests are referred as tests for trend.&lt;a href=&#34;#fnref8&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn9&#34;&gt;&lt;p&gt;Remember that the time unit can be different than years.&lt;a href=&#34;#fnref9&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn10&#34;&gt;&lt;p&gt;This is the case for large samples. The example described here does not meet this condition, but we still show it as an illustration.&lt;a href=&#34;#fnref10&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn11&#34;&gt;&lt;p&gt;Note that other weights can be considered, but this is beyond the scope of this article.&lt;a href=&#34;#fnref11&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn12&#34;&gt;&lt;p&gt;More information about the dataset can be found on &lt;a href=&#34;https://cran.r-project.org/web/packages/KMsurv/&#34;&gt;CRAN&lt;/a&gt; or with &lt;code&gt;?burn&lt;/code&gt;.&lt;a href=&#34;#fnref12&#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>Google Analytics in R: Review of 2022</title>
      <link>https://statsandr.com/blog/review-of-2022/</link>
      <pubDate>Fri, 16 Dec 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/review-of-2022/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#prerequisites&#34; id=&#34;toc-prerequisites&#34;&gt;Prerequisites&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#analytics&#34; id=&#34;toc-analytics&#34;&gt;Analytics&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-over-time&#34; id=&#34;toc-page-views-over-time&#34;&gt;Page views over time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-per-month-and-year&#34; id=&#34;toc-page-views-per-month-and-year&#34;&gt;Page views per month and year&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#top-performing-pages&#34; id=&#34;toc-top-performing-pages&#34;&gt;Top performing pages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-by-country&#34; id=&#34;toc-page-views-by-country&#34;&gt;Page views by country&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-per-day-of-week&#34; id=&#34;toc-page-views-per-day-of-week&#34;&gt;Page views per day of week&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#thank-you-note&#34; id=&#34;toc-thank-you-note&#34;&gt;Thank you note&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/review-of-2022.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;It is almost the end of the year, which means it is time to do a review of Stats and R and look back on the past year.&lt;/p&gt;
&lt;p&gt;This year’s review will be much shorter compared to previous years because there are already a lot of examples in those &lt;a href=&#34;https://statsandr.com/tags/review/&#34;&gt;previous reviews&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that beginning of September 2022, I moved from Universal Analytics (known as UA) to Google Analytics 4 (known as GA4). As you may know if you often use Google Analytics; on July 1, 2023, standard Universal Analytics properties will stop processing new hits. This means that you will need to move to GA4 if you want to continue using it after this date.&lt;/p&gt;
&lt;p&gt;This year, I will be brief about the different metrics and how to analyze your Google Analytics (GA) data. However, this post will perhaps be helpful for people who also moved (or will move) to GA4 and still want to analyze their GA data from both UA and GA4.&lt;/p&gt;
&lt;p&gt;I have to admit that it is quite time consuming to combine data from both, in particular since metrics and dimensions are not the same between UA and GA4. So if you have not moved yet, I recommend doing it at the end or beginning of a year. This will prevent you from having to fetch data from two GA IDs, and then having to combine both data in R.&lt;/p&gt;
&lt;p&gt;As usual, I analyze my GA data in R thanks to the amazing &lt;code&gt;{googleAnalyticsR}&lt;/code&gt; package from &lt;a href=&#34;https://8-bit-sheep.com/googleAnalyticsR/&#34;&gt;Mark Edmondson&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that the actual number presented below will not be very useful for you. Every blog and website is different, so every audience is different. This post is more about illustrating the process of analyzing GA data in R (and this year, also to illustrate the process of combining GA data from two GA IDs), rather than about showing my numbers.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;prerequisites&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Prerequisites&lt;/h1&gt;
&lt;p&gt;Before anything else, you have to specify the GA ID for which you want to analyze data. Mine are as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ga_id &amp;lt;- c(&amp;quot;208126346&amp;quot;, &amp;quot;250795226&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will find your(s) in the admin section of your GA account.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;analytics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Analytics&lt;/h1&gt;
&lt;p&gt;In this section, I present some visualizations that might be useful when analyzing your GA data. Feel free to comment at the end of the post if you use other interesting visualizations.&lt;/p&gt;
&lt;p&gt;Note that I focus on the page views metrics in this post, but you can edit my code to show other metrics as well. See the metrics available &lt;a href=&#34;https://ga-dev-tools.web.app/dimensions-metrics-explorer/&#34;&gt;for UA&lt;/a&gt; and the ones &lt;a href=&#34;https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema&#34;&gt;for GA4&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;page-views-over-time&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views over time&lt;/h2&gt;
&lt;p&gt;Let’s start with the evolution of the number of page views over the past year, so from December 16, 2021 to December 15, 2022.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(googleAnalyticsR)

# set date range
start_date &amp;lt;- as.Date(&amp;quot;2021-12-16&amp;quot;)
end_date &amp;lt;- as.Date(&amp;quot;2022-12-15&amp;quot;)

# extract data from both IDs
dat1 &amp;lt;- google_analytics(ga_id[1],
  date_range = c(start_date, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = &amp;quot;date&amp;quot;,
  anti_sample = TRUE # avoid sampling
)

dat2 &amp;lt;- ga_data(ga_id[2],
  date_range = c(start_date, end_date),
  metrics = &amp;quot;screenPageViews&amp;quot;,
  dimensions = &amp;quot;date&amp;quot;,
  limit = -1 # return all data (no limit)
)

# combine data from both IDs
library(dplyr)
dat &amp;lt;- full_join(dat1, dat2, by = &amp;quot;date&amp;quot;)
dat$page_views &amp;lt;- rowSums(select(dat, pageviews, screenPageViews),
  na.rm = TRUE
)


# scatter plot with a trend line
library(ggplot2)
dat %&amp;gt;%
  ggplot(aes(x = date, y = page_views)) +
  geom_point(size = 1L, color = &amp;quot;gray&amp;quot;) + # change size and color of points
  geom_smooth(color = &amp;quot;steelblue&amp;quot;, alpha = 0.25) + # change color of smoothed line and transparency of confidence interval
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Evolution of daily page views&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  theme(plot.margin = unit(c(5.5, 17.5, 5.5, 5.5), &amp;quot;pt&amp;quot;)) + # to avoid the plot being cut on the right edge
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;images/page_views.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see in the code above, we need to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extract data from two different IDs: this is done with &lt;code&gt;google_analytics()&lt;/code&gt; for UA and &lt;code&gt;ga_data()&lt;/code&gt; for GA4 (with each function having its own arguments)&lt;/li&gt;
&lt;li&gt;join data from the two IDs (with a &lt;code&gt;full_join()&lt;/code&gt; because even after moving to GA4, there were still some hits on UA, so I need to keep data from the 2 IDs for the entire year)&lt;/li&gt;
&lt;li&gt;sum up the metric for both IDs (with &lt;code&gt;rowSums()&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This process will be done repeatedly for each visualization.&lt;/p&gt;
&lt;p&gt;From the plot above, we see that the number of page views follows a cyclical evolution (with a decrease during summer). This trend follows the same pattern than last year, but the increase in the last quarter of the year is larger in 2022.&lt;/p&gt;
&lt;p&gt;Note that there seems to be consistently some days with a lower number of page views than the rest. This is actually the weekends. See more on that in this &lt;a href=&#34;https://statsandr.com/blog/review-of-2022/#page-views-per-day-of-week&#34;&gt;section&lt;/a&gt;. Note also the presence of an &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outlier&lt;/a&gt; with a number of page views above 5,000. No post has been published on that day, so it probably comes from an old post that was shared to a large audience.&lt;/p&gt;
&lt;p&gt;Finally, summing all days give a total page views of 938,630. Last year, it was 876,280, so 2022 saw an increase of 7.12%.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-per-month-and-year&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views per month and year&lt;/h2&gt;
&lt;p&gt;Comparison of the number of page views per month for all previous years can also be useful. Below two different types of visualizations.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# set new date range to include previous years
start_date_launch &amp;lt;- as.Date(&amp;quot;2019-12-16&amp;quot;)

# extract data from both IDs
dat1 &amp;lt;- google_analytics(ga_id[1],
  date_range = c(start_date_launch, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = &amp;quot;date&amp;quot;,
  anti_sample = TRUE # avoid sampling
)

dat2 &amp;lt;- ga_data(ga_id[2],
  date_range = c(start_date_launch, end_date),
  metrics = &amp;quot;screenPageViews&amp;quot;,
  dimensions = &amp;quot;date&amp;quot;,
  limit = -1 # return all data (no limit)
)

# combine data from both IDs
dat &amp;lt;- full_join(dat1, dat2, by = &amp;quot;date&amp;quot;)
dat$page_views &amp;lt;- rowSums(select(dat, pageviews, screenPageViews),
  na.rm = TRUE
)


# add year and month columns to dataframe
dat$month &amp;lt;- format(dat$date, &amp;quot;%m&amp;quot;)
dat$year &amp;lt;- format(dat$date, &amp;quot;%Y&amp;quot;)

# page views by month by year using dplyr then graph using ggplot2 barplot
dat %&amp;gt;%
  filter(year != 2019) %&amp;gt;% # remove 2019 because there are data for December only
  group_by(year, month) %&amp;gt;%
  summarize(page_views = sum(page_views)) %&amp;gt;%
  ggplot(aes(x = month, y = page_views, fill = year)) +
  geom_bar(position = &amp;quot;dodge&amp;quot;, stat = &amp;quot;identity&amp;quot;) +
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Month&amp;quot;,
    title = &amp;quot;Page views per month and year&amp;quot;,
    subtitle = paste0(format(start_date_launch, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;,
    fill = &amp;quot;&amp;quot; # remove legend title
  ) +
  theme(legend.position = &amp;quot;top&amp;quot;) + # change legend position
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;images/page_views_month.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Another possibility is as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat2 &amp;lt;- dat

library(lubridate)
dat2$day &amp;lt;- day(dat2$date)
dat2$day_month &amp;lt;- as.Date(paste0(dat2$month, &amp;quot;-&amp;quot;, dat2$day), format = &amp;quot;%m-%d&amp;quot;)

dat2 %&amp;gt;%
  filter(year != 2019 &amp;amp; page_views &amp;lt; 7500) %&amp;gt;% # remove 2019 and outliers
  ggplot(aes(x = day_month, y = page_views, color = year)) +
  geom_point(size = 1L, alpha = 0.25) + # change size and alpha of points
  geom_smooth(se = FALSE) + # remove confidence interval
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Evolution of daily page views&amp;quot;,
    subtitle = paste0(format(start_date_launch, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;,
    color = &amp;quot;&amp;quot; # remove legend title
  ) +
  theme(legend.position = &amp;quot;top&amp;quot;) + # change legend position
  scale_y_continuous(labels = scales::comma) + # better y labels
  scale_x_date(date_labels = &amp;quot;%b&amp;quot;) # show only months&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;images/page_views_month_evolution.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the 2 plots above, we see that the blog globally performed better in terms of page views compared to 2020-2021 (with an exception in the first quarter for which it performed better in 2021).&lt;/p&gt;
&lt;p&gt;Note that a comparison between 3 years is fine, but with more years to compare the plots would quickly become unreadable!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;top-performing-pages&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Top performing pages&lt;/h2&gt;
&lt;p&gt;In case you are interested to know the top performing pages (still in terms of page views):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract data from both IDs
dat1 &amp;lt;- google_analytics(ga_id[1],
  date_range = c(start_date, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = &amp;quot;pageTitle&amp;quot;,
  anti_sample = TRUE # avoid sampling
)

dat2 &amp;lt;- ga_data(ga_id[2],
  date_range = c(start_date, end_date),
  metrics = &amp;quot;screenPageViews&amp;quot;,
  dimensions = &amp;quot;pageTitle&amp;quot;,
  limit = -1 # return all data (no limit)
)

# combine data from both IDs
dat &amp;lt;- full_join(dat1, dat2, by = &amp;quot;pageTitle&amp;quot;)
dat$page_views &amp;lt;- rowSums(select(dat, pageviews, screenPageViews),
  na.rm = TRUE
)

## Create a table of the most viewed posts
library(lubridate)
library(reactable)
library(stringr)


most_viewed_posts &amp;lt;- dat %&amp;gt;%
  mutate(Title = str_sub(pageTitle, start = 1, end = -nchar(&amp;quot; - Stats and R&amp;quot;))) %&amp;gt;% # remove blog site in pageTitle
  count(Title, wt = page_views, sort = TRUE) %&amp;gt;%
  mutate(Title = str_trunc(Title, width = 30)) # keep maximum 30 characters

# plot
top_n(most_viewed_posts, n = 7, n) %&amp;gt;% # edit n for more or less pages to display
  ggplot(., aes(x = reorder(Title, n), y = n)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  coord_flip() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Page title&amp;quot;,
    title = &amp;quot;Top performing pages&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;images/top_pages.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Top performing posts are quite similar than last year, that is:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;Descriptive statistics in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;Outliers detection in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;Correlation coefficient and correlation test in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;Chi-square test of independence in R&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Since they are the most read posts for several years, I have made them available to download via &lt;a href=&#34;https://statsandr.gumroad.com/&#34;&gt;Gumroad&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-by-country&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views by country&lt;/h2&gt;
&lt;p&gt;Knowing from which country your readers come from can also be useful, in particular for e-commerce or blogs that sell physical products in addition to writing posts.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract data from both IDs
dat1 &amp;lt;- google_analytics(ga_id[1],
  date_range = c(start_date, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = &amp;quot;country&amp;quot;,
  anti_sample = TRUE # avoid sampling
)

dat2 &amp;lt;- ga_data(ga_id[2],
  date_range = c(start_date, end_date),
  metrics = &amp;quot;screenPageViews&amp;quot;,
  dimensions = &amp;quot;country&amp;quot;,
  limit = -1 # return all data (no limit)
)

# combine data from both IDs
dat &amp;lt;- full_join(dat1, dat2, by = &amp;quot;country&amp;quot;)
dat$page_views &amp;lt;- rowSums(select(dat, pageviews, screenPageViews),
  na.rm = TRUE
)

# table
countries &amp;lt;- dat %&amp;gt;%
  mutate(Country = str_trunc(country, width = 30)) %&amp;gt;% # keep maximum 30 characters
  count(Country, wt = pageviews, sort = TRUE)

# plot
top_n(countries, n = 10, n) %&amp;gt;% # edit n for more or less countries to display
  ggplot(., aes(x = reorder(Country, n), y = n)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  coord_flip() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Country&amp;quot;,
    title = &amp;quot;Top performing countries&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  theme(plot.margin = unit(c(5.5, 7.5, 5.5, 5.5), &amp;quot;pt&amp;quot;)) # to avoid the plot being cut on the right edge&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;images/countries.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For Stats and R, most readers are from the US, and to a large extent since the second top country (UK) is quite far in terms of page views.&lt;/p&gt;
&lt;p&gt;This trend is the same than last years, except that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;UK has surpassed India, and&lt;/li&gt;
&lt;li&gt;Belgium (which used to rank 3rd and 6th in 2020 and 2021, respectively) is now only 8th. Since I am from Belgium, this indicates that the blog is attracting more and more international readers through the years (and proportionally less and less from my country).&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-per-day-of-week&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views per day of week&lt;/h2&gt;
&lt;p&gt;As discussed in the section about the evolution of daily page views (view this &lt;a href=&#34;https://statsandr.com/blog/review-of-2022/#page-views-over-time&#34;&gt;section&lt;/a&gt;), there seem to be some days which consistently perform worse than other days.&lt;/p&gt;
&lt;p&gt;The following plot will show what are these days:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract data from both IDs
dat1 &amp;lt;- google_analytics(ga_id[1],
  date_range = c(start_date, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = c(&amp;quot;date&amp;quot;),
  anti_sample = TRUE # avoid sampling
)

dat2 &amp;lt;- ga_data(ga_id[2],
  date_range = c(start_date, end_date),
  metrics = &amp;quot;screenPageViews&amp;quot;,
  dimensions = c(&amp;quot;date&amp;quot;),
  limit = -1 # return all data (no limit)
)

# combine data from both IDs
dat &amp;lt;- full_join(dat1, dat2, by = &amp;quot;date&amp;quot;)
dat$page_views &amp;lt;- rowSums(select(dat, pageviews, screenPageViews),
  na.rm = TRUE
)
# find day of week
dat$weekday &amp;lt;- wday(dat$date, label = TRUE, abbr = TRUE)

## Reordering dat$weekday so Monday is first
dat$weekday &amp;lt;- factor(dat$weekday,
  levels = c(&amp;quot;Mon&amp;quot;, &amp;quot;Tue&amp;quot;, &amp;quot;Wed&amp;quot;, &amp;quot;Thu&amp;quot;, &amp;quot;Fri&amp;quot;, &amp;quot;Sat&amp;quot;, &amp;quot;Sun&amp;quot;)
)

# boxplot
library(scales)
dat %&amp;gt;%
  ggplot(aes(x = weekday, y = page_views)) +
  geom_boxplot(fill = &amp;quot;steelblue&amp;quot;, outlier.colour = alpha(0.25)) +
  geom_jitter(alpha = 0.25) + # adds transparency
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Page views per day of week&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;images/weekday.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As expected for a technical blog, there are much more readers during the week than during the weekend.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;thank-you-note&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Thank you note&lt;/h1&gt;
&lt;p&gt;Thank you to all readers who came to Stats and R this year. You made this journey incredibly more enriching. For next year and the many more to come, I will keep writing about topics for which I am familiar and interested in. So stay tuned!&lt;/p&gt;
&lt;p&gt;Thanks for reading. I hope this article helped you to analyze your Google Analytics data in R, or helped you to combine your Universal Analytics and Google Analytics 4 data. For more examples of visualizations or summaries of your GA data in R, see also previous years’ &lt;a href=&#34;https://statsandr.com/tags/review/&#34;&gt;reviews&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;
</description>
    </item>
    
    <item>
      <title>Paper: &#39;EpiLPS: A fast and flexible Bayesian tool for estimation of the time-varying reproduction number&#39;</title>
      <link>https://statsandr.com/blog/paper-epilps-a-fast-and-flexible-bayesian-tool-for-estimation-of-the-time-varying-reproduction-number/</link>
      <pubDate>Wed, 19 Oct 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/paper-epilps-a-fast-and-flexible-bayesian-tool-for-estimation-of-the-time-varying-reproduction-number/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#motivation&#34; id=&#34;toc-motivation&#34;&gt;Motivation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#getting-started&#34; id=&#34;toc-getting-started&#34;&gt;Getting started&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#a-simulated-example&#34; id=&#34;toc-a-simulated-example&#34;&gt;A simulated example&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#smoothing-the-epidemic-curve-and-estimating-mathcalr_t&#34; id=&#34;toc-smoothing-the-epidemic-curve-and-estimating-mathcalr_t&#34;&gt;Smoothing the epidemic curve and estimating &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R}_t\)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#usa-hospitalization-data&#34; id=&#34;toc-usa-hospitalization-data&#34;&gt;USA hospitalization data&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/EpiLPS.PNG&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;A colleague (and friend) of mine recently published a research paper entitled “EpiLPS: A fast and flexible Bayesian tool for estimation of the time-varying reproduction number” in PLoS Computational Biology.&lt;/p&gt;
&lt;p&gt;I am not in the habit of sharing research paper to which I did not contribute. Nevertheless, I would like to make an exception with this one because I strongly believe that the method developed in the paper deserves to be known, especially for anyone working in epidemiology.&lt;/p&gt;
&lt;p&gt;Below is the motivation behind the article, as well as an illustration on simulated and real data (US hospitalization data). More information can be found in the &lt;a href=&#34;https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1010618&#34;&gt;paper&lt;/a&gt; and on the accompanying &lt;a href=&#34;https://epilps.com/&#34;&gt;website&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;motivation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Motivation&lt;/h1&gt;
&lt;p&gt;EpiLPS &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-gressani2022epilps&#34; role=&#34;doc-biblioref&#34;&gt;Gressani et al. 2022&lt;/a&gt;)&lt;/span&gt; is a methodology for flexible Bayesian inference of the time-varying reproduction number &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R}_t\)&lt;/span&gt;; the average number of secondary cases generated by an infected agent at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;. This is a key epidemiological parameter that informs about the transmission potential of an infectious disease and can be used by public health authorities to gauge the effectiveness of interventions and propose an orientation for future control strategies.&lt;/p&gt;
&lt;p&gt;This metric has gained in popularity during the SARS-CoV-2 pandemic with wide media coverage as its meaning is easily and intuitively grasped. Put simply, when &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R} &amp;lt; 1\)&lt;/span&gt;, the signal is encouraging as the epidemic is under control and will eventually vanish. On the contrary, a value of &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R} &amp;gt; 1\)&lt;/span&gt; means that the disease keeps spreading and infections are witnessing an expansionary impact. Having a robust and reliable tool to compute the reproduction number from infectious disease data is therefore crucial.&lt;/p&gt;
&lt;p&gt;A group of researchers in the EpiPose team from Hasselt University (Belgium), Leiden University (The Netherlands), and the University of Bern (Switzerland) have recently developed a new methodology for estimating the instantaneous reproduction number from incidence time series data for a given serial interval distribution (the time elapsed between the onset of symptoms in an infector and the onset of symptoms of secondary cases).&lt;/p&gt;
&lt;p&gt;They termed their approach EpiLPS for “&lt;strong&gt;Epi&lt;/strong&gt;demiological modeling with &lt;strong&gt;L&lt;/strong&gt;aplacian-&lt;strong&gt;P&lt;/strong&gt;-&lt;strong&gt;S&lt;/strong&gt;plines” as Laplace approximations and P-splines smoothers are key ingredients that form the backbone of the proposed methodology.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;
&lt;img src=&#34;images/Infographic_EpiLPS.png&#34; style=&#34;width:100.0%&#34; /&gt;
&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The EpiLPS model assumes that the observed reported cases (by reporting date or date of symptom onset) are governed by a negative binomial distribution. As such, it allows to take the feature of overdispersion into account, contrary to a Poisson model. The epidemic curve is smoothed with P-splines (where posterior estimates of latent variables are computed via Laplace approximations) in a first step and a renewal equation model is used in a second step as a bridge between the reproduction number and the estimated spline coefficients through a “plug-in” method.&lt;/p&gt;
&lt;p&gt;The authors also explain the main difference between EpiLPS and EpiEstim, a well established approached for estimating &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R}_t\)&lt;/span&gt; in real-time developed by &lt;span class=&#34;citation&#34;&gt;Cori et al. (&lt;a href=&#34;#ref-cori2013new&#34; role=&#34;doc-biblioref&#34;&gt;2013&lt;/a&gt;)&lt;/span&gt; and make extensive comparisons between the two approaches under different epidemic scenarios.&lt;/p&gt;
&lt;p&gt;An interesting feature of EpiLPS is that the user can choose between a fully “sampling-free” path, where model hyperparameters are fixed at their &lt;em&gt;maximum a posteriori&lt;/em&gt; (LPSMAP) or a fully stochastic path (LPSMALA) based on a Metropolis-adjusted Langevin algorithm (LPSMALA). Talking about efficiency, routines for Laplace approximations and B-splines evaluations have been coded in C++ and integrated in R via the &lt;a href=&#34;https://www.rcpp.org/&#34;&gt;Rcpp package&lt;/a&gt;, so that the underlying algorithm can be executed in negligible time.&lt;/p&gt;
&lt;p&gt;Below, we provide a short example of how to use the EpiLPS routines to estimate &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R}_t\)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;getting-started&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Getting started&lt;/h1&gt;
&lt;p&gt;The EpiLPS package is available from CRAN (see &lt;a href=&#34;https://cran.r-project.org/web/packages/EpiLPS/index.html&#34; class=&#34;uri&#34;&gt;https://cran.r-project.org/web/packages/EpiLPS/index.html&lt;/a&gt;) and can be installed from the R console by typing:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;EpiLPS&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The package can then be loaded as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(&amp;quot;EpiLPS&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The EpiLPS package structure is fairly simple as it consists in a few routines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The function &lt;code&gt;epilps()&lt;/code&gt; is the core routine for fitting the reproduction number.&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;plot.epilps()&lt;/code&gt;, the user can plot the estimated epidemic curve and &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R}_t\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;Finally, two ancillary routines, &lt;code&gt;episim()&lt;/code&gt; and &lt;code&gt;perfcheck()&lt;/code&gt; have been developed to essentially reproduce the simulation results of the associated paper.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;a-simulated-example&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;A simulated example&lt;/h1&gt;
&lt;p&gt;A set of epidemic data can be simulated with the &lt;code&gt;episim()&lt;/code&gt; routine by specifying a serial interval distribution and by choosing among a set of available patterns for the true reproduction number curve (here we choose pattern number 5 corresponding to a rather wiggly curve).&lt;/p&gt;
&lt;p&gt;The simulated outbreak is for a duration of 40 days as specified in the &lt;code&gt;endepi&lt;/code&gt; option. By setting the option &lt;code&gt;plotsim = TRUE&lt;/code&gt;, the routine returns a figure summarizing the incidence time series, a bar plot for the specified serial interval distribution and the true underlying reproduction number curve.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;set.seed(1234)

SI &amp;lt;- c(0.344, 0.316, 0.168, 0.104, 0.068)
simepidemic &amp;lt;- episim(
  serial_interval = SI,
  Rpattern = 5,
  plotsim = TRUE,
  verbose = TRUE,
  endepi = 40
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Chosen scenario: 5 &amp;#39;Wiggly then stable Rt&amp;#39;.
## Incidence of cases generated from a Poisson distribution. 
## Total number of days of epidemic: 40.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/paper-epilps-a-fast-and-flexible-bayesian-tool-for-estimation-of-the-time-varying-reproduction-number/index_files/figure-html/Simul-1-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you want to have an overview of the generated incidence time series, just type:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;simepidemic$y&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  10   6  15  24  37  43  54  46  47  28  20   8  10  10   3   5   3   4   6
## [20]   6  15  21  44  75 135 217 329 409 453 487 457 443 297 290 255 246 246 339
## [39] 395 573&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;smoothing-the-epidemic-curve-and-estimating-mathcalr_t&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Smoothing the epidemic curve and estimating &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R}_t\)&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Let us now use the &lt;code&gt;epilps()&lt;/code&gt; routine to smooth the epidemic curve and estimate the reproduction number.&lt;/p&gt;
&lt;p&gt;We will do this through LPSMAP (a fully sampling-free approach) and via LPSMALA (a fully stochastic approach relying on a MCMC algorithm with Langevin dynamics), where we specify a chain of length 10000 and a burn-in of size 4000.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;LPSMAP_fit &amp;lt;- epilps(
  incidence = simepidemic$y,
  serial_interval = SI,
  tictoc = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Inference method chosen: LPSMAP. 
## CI for LPSMAP computed via lognormal posterior approx. of Rt.Total number of days: 40. 
## Mean Rt discarding first 7 days: 1.327.
## Mean 95% CI of Rt discarding first 7 days: (1.164,1.527) 
## Elapsed real time (wall clock time): 0.261 seconds.&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;LPSMALA_fit &amp;lt;- epilps(
  incidence = simepidemic$y, serial_interval = SI,
  method = &amp;quot;LPSMALA&amp;quot;, chain_length = 10000, burn = 4000
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Inference method chosen: LPSMALA with chain length 10000 and warmup 4000.
## MCMC acceptance rate: 56.41%. 
## Geweke z-score &amp;lt; 2.33 for:  32 / 33  variables. 
## Total number of days: 40. 
## Mean Rt discarding first 7 days: 1.326.
## Mean 95% CI of Rt discarding first 7 days: (1.117,1.555). 
## Timing of routine not requested.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After execution, each routine prints in the console a brief summary of the method that has been requested by the user.&lt;/p&gt;
&lt;p&gt;For LPSMALA, it summarizes the chain length, the acceptance rate (should be around 56%) and other basic information. As can be seen from the printed output, the mean reproduction number for the simulated epidemic is around 1.33.&lt;/p&gt;
&lt;p&gt;We can now use, say, the &lt;code&gt;LPSMALA_fit&lt;/code&gt; object together with the &lt;code&gt;plot()&lt;/code&gt; routine to obtain the smoothed epidemic curve and the estimated reproduction number (by default the credible interval is at a 5% level of significance but this can be changed by the user).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;days &amp;lt;- seq(8, 40)

#--- Smoothed epidemic curve
gridExtra::grid.arrange(
  plot(LPSMALA_fit,
    plotout = &amp;quot;epicurve&amp;quot;, incibars = TRUE, themetype = &amp;quot;light&amp;quot;,
    epicol = &amp;quot;darkgreen&amp;quot;, cicol = rgb(0.3, 0.73, 0.3, 0.2),
    epititle = &amp;quot;Smoothed epidemic curve&amp;quot;, titlesize = 13, barwidth = 0.25
  ),

  #--- Estimated reproduction number
  plot(LPSMALA_fit,
    plotout = &amp;quot;rt&amp;quot;, theme = &amp;quot;light&amp;quot;, rtcol = &amp;quot;black&amp;quot;,
    titlesize = 13, Rtitle = &amp;quot;Estimated R (LPSMALA)&amp;quot;
  ),
  nrow = 1, ncol = 2
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/paper-epilps-a-fast-and-flexible-bayesian-tool-for-estimation-of-the-time-varying-reproduction-number/index_files/figure-html/Simul-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The figure can be customized in various ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Users can specify the theme under &lt;code&gt;themetype&lt;/code&gt;. Available options are &lt;code&gt;gray&lt;/code&gt; (the default), &lt;code&gt;classic&lt;/code&gt;, &lt;code&gt;light&lt;/code&gt; and &lt;code&gt;dark&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Other choices, such as whether or not to show the incidence bars, the color of the credible interval envelope, the color of the smoothed epidemic curve and the estimated reproduction number are also available.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The figure above was generated within 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;, but there is also another way of extracting information directly from the &lt;code&gt;LPSMAP_fit&lt;/code&gt; and &lt;code&gt;LPSMALA_fit&lt;/code&gt; objects. In fact, the estimated reproduction number values and their associated credible interval for each day can be extracted and plotted.&lt;/p&gt;
&lt;p&gt;Below, we make the exercise and plot the estimated &lt;span class=&#34;math inline&#34;&gt;\(\mathcal{R}_t\)&lt;/span&gt; obtained with LPSMAP and LPSMALA, respectively and compare it with the true underlying reproduction number curve. The fit is quite good.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;par(mfrow = c(1, 2))

#--- LPSMAP vs target R
plot(days, sapply(days, simepidemic$Rtrue),
  type = &amp;quot;l&amp;quot;, lwd = 2, ylim = c(0, 4),
  ylab = &amp;quot;Estimated R&amp;quot;, xlab = &amp;quot;Time&amp;quot;
)
polygon(
  x = c(days, rev(days)), y = c(
    LPSMAP_fit$epifit$R95CI_low[8:40],
    rev(LPSMAP_fit$epifit$R95CI_up[8:40])
  ),
  col = rgb(0.23, 0.54, 1, 0.3), border = NA
)
lines(days, LPSMAP_fit$epifit$R_estim[8:40], type = &amp;quot;l&amp;quot;, col = &amp;quot;cornflowerblue&amp;quot;, lwd = 2)
lines(days, sapply(days, simepidemic$Rtrue), type = &amp;quot;l&amp;quot;, lwd = 2)

grid(nx = 10, ny = 10)
legend(&amp;quot;topright&amp;quot;,
  lty = c(1, 1), lwd = c(2, 2),
  col = c(&amp;quot;black&amp;quot;, &amp;quot;blue&amp;quot;, rgb(0.23, 0.54, 1, 0.3)),
  c(&amp;quot;Target R&amp;quot;, &amp;quot;LPSMAP&amp;quot;, &amp;quot;LPSMAP 95% CI&amp;quot;), bty = &amp;quot;n&amp;quot;, cex = 0.9
)

#--- LPSMALA vs target R
plot(days, sapply(days, simepidemic$Rtrue),
  type = &amp;quot;l&amp;quot;, lwd = 2, ylim = c(0, 4),
  ylab = &amp;quot;Estimated R&amp;quot;, xlab = &amp;quot;Time&amp;quot;
)
polygon(
  x = c(days, rev(days)), y = c(
    LPSMALA_fit$epifit$R95CI_low[8:40],
    rev(LPSMALA_fit$epifit$R95CI_up[8:40])
  ),
  col = rgb(1, 0.23, 0.31, 0.3), border = NA
)
lines(days, LPSMALA_fit$epifit$R_estim[8:40], type = &amp;quot;l&amp;quot;, col = &amp;quot;red&amp;quot;, lwd = 2)
lines(days, sapply(days, simepidemic$Rtrue), type = &amp;quot;l&amp;quot;, lwd = 2)

grid(nx = 10, ny = 10)
legend(&amp;quot;topright&amp;quot;,
  lty = c(1, 1), lwd = c(2, 2),
  col = c(&amp;quot;black&amp;quot;, &amp;quot;red&amp;quot;, rgb(1, 0.23, 0.31, 0.3)),
  c(&amp;quot;Target R&amp;quot;, &amp;quot;LPSMALA&amp;quot;, &amp;quot;LPSMALA 95% CI&amp;quot;), bty = &amp;quot;n&amp;quot;, cex = 0.9
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/paper-epilps-a-fast-and-flexible-bayesian-tool-for-estimation-of-the-time-varying-reproduction-number/index_files/figure-html/Simul-5-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You can access, say, the results of the last week of the epidemic by typing:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Estimated R of the last week (with LPSMAP)
round(tail(LPSMAP_fit$epifit[, 1:4], 7), 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    Date R_estim R95CI_low R95CI_up
## 34   34   0.708     0.663    0.756
## 35   35   0.724     0.676    0.775
## 36   36   0.809     0.755    0.868
## 37   37   0.971     0.908    1.039
## 38   38   1.205     1.135    1.279
## 39   39   1.461     1.384    1.541
## 40   40   1.671     1.557    1.794&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Estimated mean number of cases of the last week (with LPSMAP)
round(tail(LPSMAP_fit$epifit[, 5:7], 7))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    mu_estim mu95CI_low mu95CI_up
## 34      284        225       357
## 35      254        202       319
## 36      248        196       312
## 37      267        211       338
## 38      319        253       404
## 39      411        325       520
## 40      552        394       774&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;usa-hospitalization-data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;USA hospitalization data&lt;/h1&gt;
&lt;p&gt;To illustrate EpiLPS on real data, we download hospitalization data from the &lt;code&gt;COVID19&lt;/code&gt; package for the USA in the period ranging from 2021-09-01 to 2022-09-01 and apply the &lt;code&gt;epilps()&lt;/code&gt; routine to estimate the reproduction number.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;COVID19&amp;quot;)
library(&amp;quot;COVID19&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Get data and specify serial interval distribution
USADat &amp;lt;- COVID19::covid19(
  country = &amp;quot;US&amp;quot;, level = 1, start = &amp;quot;2021-09-01&amp;quot;,
  end = &amp;quot;2022-09-01&amp;quot;, verbose = FALSE
)

si &amp;lt;- c(0.344, 0.316, 0.168, 0.104, 0.068)

inciUSA &amp;lt;- USADat$hosp
dateUSA &amp;lt;- USADat$date&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We use the &lt;code&gt;epilps()&lt;/code&gt; routine with method LPSMAP (default) and plot the smoothed epidemic curve and the estimated reproduction number with a 95% credible interval.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;epifit &amp;lt;- epilps(incidence = inciUSA, serial_interval = si, K = 20)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Inference method chosen: LPSMAP. 
## CI for LPSMAP computed via lognormal posterior approx. of Rt.Total number of days: 366. 
## Mean Rt discarding first 7 days: 0.994.
## Mean 95% CI of Rt discarding first 7 days: (0.983,1.005) 
## Timing of routine not requested.&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gridExtra::grid.arrange(
  plot(epifit,
    dates = dateUSA, datelab = &amp;quot;3m&amp;quot;,
    plotout = &amp;quot;epicurve&amp;quot;, incibars = FALSE, themetype = &amp;quot;light&amp;quot;,
    epicol = &amp;quot;darkgreen&amp;quot;, cicol = rgb(0.3, 0.73, 0.3, 0.2),
    epititle = &amp;quot;USA smoothed epidemic curve&amp;quot;, titlesize = 13
  ),
  plot(epifit,
    dates = dateUSA, datelab = &amp;quot;3m&amp;quot;,
    plotout = &amp;quot;rt&amp;quot;, theme = &amp;quot;light&amp;quot;, rtcol = &amp;quot;black&amp;quot;,
    titlesize = 13, Rtitle = &amp;quot;USA Estimated R&amp;quot;
  ),
  nrow = 1, ncol = 2
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/paper-epilps-a-fast-and-flexible-bayesian-tool-for-estimation-of-the-time-varying-reproduction-number/index_files/figure-html/USA-2-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&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 you will find the method developed in the paper as useful as I do. Feel free to reach out to me and to the authors if you happen to use it for your own research.&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-cori2013new&#34; class=&#34;csl-entry&#34;&gt;
Cori, Anne, Neil M Ferguson, Christophe Fraser, and Simon Cauchemez. 2013. &lt;span&gt;“A New Framework and Software to Estimate Time-Varying Reproduction Numbers During Epidemics.”&lt;/span&gt; &lt;em&gt;American Journal of Epidemiology&lt;/em&gt; 178 (9): 1505–12.
&lt;/div&gt;
&lt;div id=&#34;ref-gressani2022epilps&#34; class=&#34;csl-entry&#34;&gt;
Gressani, Oswaldo, Jacco Wallinga, Christian L Althaus, Niel Hens, and Christel Faes. 2022. &lt;span&gt;“EpiLPS: A Fast and Flexible Bayesian Tool for Estimation of the Time-Varying Reproduction Number.”&lt;/span&gt; &lt;em&gt;PLoS Computational Biology&lt;/em&gt; 18 (10): e1010618. &lt;a href=&#34;https://doi.org/10.1371/journal.pcbi.1010618&#34;&gt;https://doi.org/10.1371/journal.pcbi.1010618&lt;/a&gt;.
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>How to keep yourself updated with the latest R news?</title>
      <link>https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/</link>
      <pubDate>Thu, 13 Oct 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/</guid>
      <description>
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/htmltools-fill/fill.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/datatables-css/datatables-crosstalk.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/datatables-binding/datatables.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/jquery/jquery-3.6.0.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-core/css/jquery.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-core/css/jquery.dataTables.extra.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-core/js/jquery.dataTables.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/jszip/jszip.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/pdfmake/pdfmake.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/pdfmake/vfs_fonts.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/css/buttons.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/js/dataTables.buttons.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/js/buttons.html5.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/js/buttons.colVis.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/js/buttons.print.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/nouislider/jquery.nouislider.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/nouislider/jquery.nouislider.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/selectize/selectize.bootstrap3.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/selectize/selectize.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/crosstalk/css/crosstalk.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/crosstalk/js/crosstalk.min.js&#34;&gt;&lt;/script&gt;

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-do-i-keep-track&#34; id=&#34;toc-how-do-i-keep-track&#34;&gt;How do I keep track?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#twitter&#34; id=&#34;toc-twitter&#34;&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#newsletters&#34; id=&#34;toc-newsletters&#34;&gt;Newsletters&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;images/how-to-keep-up-to-date-with-the-latest-R-news.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;At the end of one of the training sessions I gave on R, a student asked me the following question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;How do you keep yourself updated with the latest R news?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It is true that R, being open source (meaning that everyone can contribute), is evolving rapidly. This means that even if I am using R for several years and on a daily basis, I like to stay informed in order to stay up to date with the program and the latest coding practices.&lt;/p&gt;
&lt;p&gt;In fact, I learn about new packages, new functions and new features almost everyday. Most of them are not particularly useful for my research or my teaching tasks, but sometimes I discover such a nice package or function that I replace my code with new one.&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;/p&gt;
&lt;p&gt;The training was an advanced one, so the student had a good knowledge of R and was not looking for more tutorials or courses. She was interested in knowing where to look for updates about current and new R packages and functions.&lt;/p&gt;
&lt;p&gt;After sharing my sources with all students following the training, I thought it would be useful to others. In this article, I share my sources—from where I get the latest R updates and news.&lt;/p&gt;
&lt;p&gt;The sources are divided into two main categories: &lt;strong&gt;Twitter and newsletters.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-do-i-keep-track&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How do I keep track?&lt;/h1&gt;
&lt;div id=&#34;twitter&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Twitter&lt;/h2&gt;
&lt;p&gt;To be honest, I mostly use Twitter to keep up to date with R news.&lt;/p&gt;
&lt;p&gt;Twitter allows me to follow discussions about statistical methods or approaches, and to keep me informed about publications of new blog posts.&lt;/p&gt;
&lt;p&gt;What I particularly like with Twitter is that there is a mix between:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;short messages about new functions or packages (most of the time with an illustration or an example), and&lt;/li&gt;
&lt;li&gt;announcements of new blog posts that cover specific subjects in details.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this, I follow people (researchers, professors, bloggers, statisticians, data scientists, etc.) that are working in my domains of interest. For instance, I am mostly interested in the application of statistics in R, data science, biostatistics and data visualization. I thus follow accounts which regularly post about these topics. I also avoid following accounts that cover topics I am not interested in, so that my Twitter feed really shows information I am most likely to be interested in.&lt;/p&gt;
&lt;p&gt;Below, you will see a list of some of the accounts I follow, classified by themes. Of course, this is a &lt;strong&gt;non-exhaustive list!&lt;/strong&gt; There are plenty of very inspiring and intelligent people that are not in the list, simply because I cannot afford to put them all.&lt;/p&gt;
&lt;p&gt;If you follow people that post regularly about the themes covered below, feel free to add them in the comments. I am always looking for new inspiring accounts to follow.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that the accounts are displayed in alphabetical order and the table is searchable.&lt;/em&gt;&lt;/p&gt;
&lt;div class=&#34;datatables html-widget html-fill-item&#34; id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:auto;&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;filter&#34;:&#34;top&#34;,&#34;vertical&#34;:false,&#34;filterHTML&#34;:&#34;&lt;tr&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n&lt;\/tr&gt;&#34;,&#34;extensions&#34;:[&#34;Buttons&#34;],&#34;data&#34;:[[&#34;R for Data Science&#34;,&#34;Allison Horst&#34;,&#34;Kyle Cuilla&#34;,&#34;R4DS online learning community&#34;,&#34;Julia Silge&#34;,&#34;Tanya Shapiro&#34;,&#34;rOpenSci&#34;,&#34;Shannon Pileggi&#34;,&#34;R for the Rest of Us&#34;,&#34;David Keyes&#34;,&#34;Jenny Bryan&#34;,&#34;David Robinson&#34;,&#34;Sharon Machlis&#34;,&#34;Chelsea Parlett-Pelleriti&#34;,&#34;Mara Averick&#34;,&#34;Rohan Alexander&#34;,&#34;JD Long&#34;,&#34;Achim Zeileis&#34;,&#34;Oscar Baruffa&#34;,&#34;Cosima Meyer&#34;,&#34;Alison Hill&#34;,&#34;Keith McNulty&#34;,&#34;mikefc&#34;,&#34;Mark Edmondson&#34;,&#34;Rafael Irizarry&#34;,&#34;Rami Krispin&#34;,&#34;Indrajeet Patil&#34;,&#34;Lucy D&#39;Agostino McGowan&#34;,&#34;Daniela Witten&#34;,&#34;Jim Frost&#34;,&#34;easystats&#34;,&#34;Frank Harrell&#34;,&#34;Dan Quintana&#34;,&#34;Laurent Gatto&#34;,&#34;Maarten van Smeden&#34;,&#34;Ted Laderas&#34;,&#34;R Medicine&#34;,&#34;Ewen Harrison&#34;,&#34;Cédric Scherer&#34;,&#34;Tom Mock&#34;,&#34;Cara Thompson&#34;,&#34;Alex Albright&#34;,&#34;Maarten Lambrechts&#34;,&#34;r/DataIsBeautiful&#34;,&#34;Cole Knaflic&#34;,&#34;Yan Holtz&#34;,&#34;Kieran Healy&#34;,&#34;Will Chase&#34;,&#34;Dean Attali&#34;,&#34;Nick Strayer&#34;,&#34;R-bloggers&#34;,&#34;Hadley Wickham&#34;,&#34;One R Package a Day&#34;,&#34;R Function A Day&#34;,&#34;ThinkR&#34;,&#34;#RStats Question A Day&#34;,&#34;Maëlle Salmon&#34;,&#34;R Weekly&#34;,&#34;R Weekly Live&#34;,&#34;We are R-Ladies&#34;,&#34;Colin Fay&#34;,&#34;R Tweets&#34;,&#34;R posts you might have missed!&#34;,&#34;Quarto&#34;,&#34;R Markdown&#34;,&#34;The R Foundation&#34;,&#34;Alastair Rushworth&#34;,&#34;Rstats&#34;,&#34;Charlotte Wickham&#34;,&#34;Garrett Grolemund&#34;,&#34;Yihui Xie&#34;,&#34;Garrick Aden-Buie&#34;,&#34;RStudio Tips&#34;,&#34;Jeff Leek&#34;,&#34;RStudio&#34;,&#34;Stats and R&#34;,&#34;Roger D. Peng&#34;,&#34;Claire Della Vedova (in French)&#34;],[&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Biostatistics&#34;],[&#34;&lt;a href=&#39;https://twitter.com/rstats4ds&#39; target=&#39;_blank&#39;&gt;@rstats4ds&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/allison_horst&#39; target=&#39;_blank&#39;&gt;@allison_horst&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/kc_analytics&#39; target=&#39;_blank&#39;&gt;@kc_analytics&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/R4DScommunity&#39; target=&#39;_blank&#39;&gt;@R4DScommunity&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/juliasilge&#39; target=&#39;_blank&#39;&gt;@juliasilge&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/tanya_shapiro&#39; target=&#39;_blank&#39;&gt;@tanya_shapiro&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rOpenSci&#39; target=&#39;_blank&#39;&gt;@rOpenSci&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/PipingHotData&#39; target=&#39;_blank&#39;&gt;@PipingHotData&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rfortherest&#39; target=&#39;_blank&#39;&gt;@rfortherest&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/dgkeyes&#39; target=&#39;_blank&#39;&gt;@dgkeyes&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/JennyBryan&#39; target=&#39;_blank&#39;&gt;@JennyBryan&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/drob&#39; target=&#39;_blank&#39;&gt;@drob&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/sharon000&#39; target=&#39;_blank&#39;&gt;@sharon000&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/ChelseaParlett&#39; target=&#39;_blank&#39;&gt;@ChelseaParlett&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/dataandme&#39; target=&#39;_blank&#39;&gt;@dataandme&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/RohanAlexander&#39; target=&#39;_blank&#39;&gt;@RohanAlexander&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/CMastication&#39; target=&#39;_blank&#39;&gt;@CMastication&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/AchimZeileis&#39; target=&#39;_blank&#39;&gt;@AchimZeileis&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/OscarBaruffa&#39; target=&#39;_blank&#39;&gt;@OscarBaruffa&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/cosima_meyer&#39; target=&#39;_blank&#39;&gt;@cosima_meyer&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/apreshill&#39; target=&#39;_blank&#39;&gt;@apreshill&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/dr_keithmcnulty&#39; target=&#39;_blank&#39;&gt;@dr_keithmcnulty&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/coolbutuseless&#39; target=&#39;_blank&#39;&gt;@coolbutuseless&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/HoloMarkeD&#39; target=&#39;_blank&#39;&gt;@HoloMarkeD&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rafalab&#39; target=&#39;_blank&#39;&gt;@rafalab&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/Rami_Krispin&#39; target=&#39;_blank&#39;&gt;@Rami_Krispin&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/patilindrajeets&#39; target=&#39;_blank&#39;&gt;@patilindrajeets&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/LucyStats&#39; target=&#39;_blank&#39;&gt;@LucyStats&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/daniela_witten&#39; target=&#39;_blank&#39;&gt;@daniela_witten&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/statisticsbyjim&#39; target=&#39;_blank&#39;&gt;@statisticsbyjim&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/easystats4u&#39; target=&#39;_blank&#39;&gt;@easystats4u&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/f2harrell&#39; target=&#39;_blank&#39;&gt;@f2harrell&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/dsquintana&#39; target=&#39;_blank&#39;&gt;@dsquintana&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/lgatt0&#39; target=&#39;_blank&#39;&gt;@lgatt0&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/MaartenvSmeden&#39; target=&#39;_blank&#39;&gt;@MaartenvSmeden&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/tladeras&#39; target=&#39;_blank&#39;&gt;@tladeras&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/r_medicine&#39; target=&#39;_blank&#39;&gt;@r_medicine&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/ewenharrison&#39; target=&#39;_blank&#39;&gt;@ewenharrison&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/CedScherer&#39; target=&#39;_blank&#39;&gt;@CedScherer&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/thomas_mock&#39; target=&#39;_blank&#39;&gt;@thomas_mock&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/cararthompson&#39; target=&#39;_blank&#39;&gt;@cararthompson&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/AllbriteAllday&#39; target=&#39;_blank&#39;&gt;@AllbriteAllday&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/maartenzam&#39; target=&#39;_blank&#39;&gt;@maartenzam&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/DataIsBeautiful&#39; target=&#39;_blank&#39;&gt;@DataIsBeautiful&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/storywithdata&#39; target=&#39;_blank&#39;&gt;@storywithdata&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/R_Graph_Gallery&#39; target=&#39;_blank&#39;&gt;@R_Graph_Gallery&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/kjhealy&#39; target=&#39;_blank&#39;&gt;@kjhealy&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/W_R_Chase&#39; target=&#39;_blank&#39;&gt;@W_R_Chase&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/daattali&#39; target=&#39;_blank&#39;&gt;@daattali&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/NicholasStrayer&#39; target=&#39;_blank&#39;&gt;@NicholasStrayer&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/Rbloggers&#39; target=&#39;_blank&#39;&gt;@Rbloggers&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/hadleywickham&#39; target=&#39;_blank&#39;&gt;@hadleywickham&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/RLangPackage&#39; target=&#39;_blank&#39;&gt;@RLangPackage&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rfunctionaday&#39; target=&#39;_blank&#39;&gt;@rfunctionaday&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/thinkR_fr&#39; target=&#39;_blank&#39;&gt;@thinkR_fr&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/data_question&#39; target=&#39;_blank&#39;&gt;@data_question&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/ma_salmon&#39; target=&#39;_blank&#39;&gt;@ma_salmon&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rweekly_org&#39; target=&#39;_blank&#39;&gt;@rweekly_org&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rweekly_live&#39; target=&#39;_blank&#39;&gt;@rweekly_live&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/WeAreRLadies&#39; target=&#39;_blank&#39;&gt;@WeAreRLadies&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/_ColinFay&#39; target=&#39;_blank&#39;&gt;@_ColinFay&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rstats_tweets&#39; target=&#39;_blank&#39;&gt;@rstats_tweets&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/icymi_r&#39; target=&#39;_blank&#39;&gt;@icymi_r&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/quarto_pub&#39; target=&#39;_blank&#39;&gt;@quarto_pub&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rmarkdown&#39; target=&#39;_blank&#39;&gt;@rmarkdown&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/_R_Foundation&#39; target=&#39;_blank&#39;&gt;@_R_Foundation&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rushworth_a&#39; target=&#39;_blank&#39;&gt;@rushworth_a&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rstatstweet&#39; target=&#39;_blank&#39;&gt;@rstatstweet&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/CVWickham&#39; target=&#39;_blank&#39;&gt;@CVWickham&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/StatGarrett&#39; target=&#39;_blank&#39;&gt;@StatGarrett&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/xieyihui&#39; target=&#39;_blank&#39;&gt;@xieyihui&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/grrrck&#39; target=&#39;_blank&#39;&gt;@grrrck&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rstudiotips&#39; target=&#39;_blank&#39;&gt;@rstudiotips&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/jtleek&#39; target=&#39;_blank&#39;&gt;@jtleek&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rstudio&#39; target=&#39;_blank&#39;&gt;@rstudio&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/statsandr&#39; target=&#39;_blank&#39;&gt;@statsandr&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rdpeng&#39; target=&#39;_blank&#39;&gt;@rdpeng&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/blog_SLR&#39; target=&#39;_blank&#39;&gt;@blog_SLR&lt;\/a&gt;&#34;]],&#34;container&#34;:&#34;&lt;table class=\&#34;display\&#34;&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th&gt;Name&lt;\/th&gt;\n      &lt;th&gt;Category&lt;\/th&gt;\n      &lt;th&gt;Link&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n&lt;\/table&gt;&#34;,&#34;options&#34;:{&#34;pageLength&#34;:78,&#34;order&#34;:[0,&#34;asc&#34;],&#34;autoWidth&#34;:true,&#34;dom&#34;:&#34;Blfrtip&#34;,&#34;buttons&#34;:[&#34;copy&#34;,&#34;csv&#34;,&#34;excel&#34;,&#34;pdf&#34;,&#34;print&#34;],&#34;columnDefs&#34;:[{&#34;name&#34;:&#34;Name&#34;,&#34;targets&#34;:0},{&#34;name&#34;:&#34;Category&#34;,&#34;targets&#34;:1},{&#34;name&#34;:&#34;Link&#34;,&#34;targets&#34;:2}],&#34;orderClasses&#34;:false,&#34;orderCellsTop&#34;:true,&#34;lengthMenu&#34;:[10,25,50,78,100]}},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;You will also find many news when exploring &lt;a href=&#34;https://twitter.com/hashtag/rstats?src=hashtag_click&#34;&gt;#rstats&lt;/a&gt; on Twitter.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;newsletters&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Newsletters&lt;/h2&gt;
&lt;p&gt;Besides Twitter, I also read new blog posts and stay informed through these newsletters:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://www.r-bloggers.com/&#34;&gt;R-Bloggers&lt;/a&gt; (daily)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rweekly.org/&#34;&gt;R Weekly&lt;/a&gt; (weekly)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.r-project.org/mail.html&#34;&gt;R mailing lists&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The 2 first newsletters are actually blog aggregators, so collections of many many blogs. If you have your own blog, don’t hesitate to submit it to make it accessible to more people.&lt;/p&gt;
&lt;p&gt;You can always subscribe to a blog you like, but if it is related to R, it will most likely be shared via R-Bloggers or R Weekly.&lt;/p&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 this article will help you to keep track of great blogs, tutorials and other resources about R. Feel free to follow me on Twitter (&lt;a href=&#34;https://twitter.com/statsandr&#34;&gt;&lt;span class=&#34;citation&#34;&gt;@statsandr&lt;/span&gt;&lt;/a&gt;), where I tweet my new articles and retweet everything I find interesting or worth mentioning.&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;See for example this &lt;a href=&#34;https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/#update-with-the-ggstatsplot-package&#34;&gt;article&lt;/a&gt;. The package I discovered was so useful and interesting (to me), that I added a new section to the post and now use it instead of the older package.&lt;a href=&#34;#fnref1&#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>One-sample Wilcoxon test in R</title>
      <link>https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/</link>
      <pubDate>Thu, 07 Jul 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#when&#34; id=&#34;toc-when&#34;&gt;When?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how&#34; id=&#34;toc-how&#34;&gt;How?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combine-statistical-test-and-plot&#34; id=&#34;toc-combine-statistical-test-and-plot&#34;&gt;Combine statistical test and plot&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/one-sample-wilcoxon-test-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In a previous article, we showed how to do a &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;two-sample Wilcoxon test&lt;/a&gt; in R. Remember that there are actually two versions of this test:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The &lt;strong&gt;Mann-Whitney-Wilcoxon test&lt;/strong&gt; (also referred as Wilcoxon rank sum test or Mann-Whitney U test), used to compare two &lt;strong&gt;independent&lt;/strong&gt; samples. This test is the non-parametric version of the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test for independent samples&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Wilcoxon signed-rank test&lt;/strong&gt; (also referred as Wilcoxon test for paired samples), used to compare two paired samples. This test is the non-parametric version of the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test for paired samples&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In another article, we also showed how to do a &lt;a href=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/&#34;&gt;one-sample t-test&lt;/a&gt; by hand and in R. This test is used to determine whether the mean of a measurement variable is different from a specified value (a value that you specify based on your beliefs or a theoretical expectation for example). Since it is a parametric test, the data should follow a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt; (or sample size should be large enough (i.e., above 30), thanks to the central limit theorem) for the results to be valid.&lt;/p&gt;
&lt;p&gt;Unlike the one-sample t-test, the &lt;strong&gt;one-sample Wilcoxon test&lt;/strong&gt; (also referred as the one-sample Wilcoxon signed-rank test) is a non-parametric test, meaning that it does not rely on data belonging to any particular parametric family of probability distributions. Non-parametric tests usually have the same goal as their parametric counterparts (in this case, compare data to a given value). Nonetheless, they do not require the assumption of normality and they can deal with &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt; and Likert scales.&lt;/p&gt;
&lt;p&gt;In this article, we show when to perform the one-sample Wilcoxon test, how to do it in R and how to interpret its results. We will also briefly show some appropriate visualizations.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;when&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;When?&lt;/h1&gt;
&lt;p&gt;The &lt;strong&gt;one-sample Wilcoxon test is used to compare our observations to a given default value&lt;/strong&gt;—a value that you specify based on your beliefs or a theoretical expectation for example. In other words, it is used to determine if a group is significantly different from a known or hypothesized population value on the variable of interest.&lt;/p&gt;
&lt;p&gt;Since the test statistic is computed based on the ranks of the difference between the observed values and the default value (making it a non-parametric test), the one-sample Wilcoxon test is more appropriate than a one-sample t-test when the observations do not follow a normal distribution.&lt;/p&gt;
&lt;p&gt;The goal of this test is to verify whether the observations are significantly different from our default value. In terms of null and alternative hypotheses, we have (for a two-tailed test):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0:\)&lt;/span&gt; location of the data is &lt;em&gt;equal&lt;/em&gt; to the chosen value&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1:\)&lt;/span&gt; location of the data is &lt;em&gt;different&lt;/em&gt; from the chosen value&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In other words, a significant result (i.e., a rejection of the null hypothesis) suggests that the location of the data is &lt;em&gt;different&lt;/em&gt; from the chosen value.&lt;/p&gt;
&lt;p&gt;Note that some authors suggest that this test is a test of the median, that is (for a two-tailed test):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0:\)&lt;/span&gt; the median is &lt;em&gt;equal&lt;/em&gt; to the chosen value&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1:\)&lt;/span&gt; the median is &lt;em&gt;different&lt;/em&gt; from the chosen value&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However, this is the case only if the data are symmetric. Without further assumptions about the distribution of the data, the one-sample Wilcoxon test is not a test of the median but a test about the location of the data.&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;/p&gt;
&lt;p&gt;Note that although the normality assumption is not required, the independence assumption must still be verified. This means that observations must be independent of one another (usually, random sampling is sufficient to have independence).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;For our illustration, suppose we want to test whether the scores at an exam differ from 10, that is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0:\)&lt;/span&gt; scores at the exam &lt;span class=&#34;math inline&#34;&gt;\(= 10\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1:\)&lt;/span&gt; scores at the exam &lt;span class=&#34;math inline&#34;&gt;\(\ne 10\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To verify this, we have a sample of 15 students and their score at the exam:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    Student_ID Score
## 1           1    17
## 2           2     5
## 3           3     1
## 4           4    10
## 5           5     4
## 6           6    18
## 7           7    17
## 8           8    15
## 9           9     7
## 10         10     4
## 11         11     5
## 12         12    14
## 13         13    20
## 14         14    18
## 15         15    15&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Scores between students are assumed to be independent (a student’s score is not impacted or influenced by the score of another student). Therefore, the independence assumption is met.&lt;/p&gt;
&lt;p&gt;Moreover, sample size is small (n &amp;lt; 30) and based on the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; the data do not follow a normal distribution:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# histogram
hist(dat$Score)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/index_files/figure-html/unnamed-chunk-3-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that we refrain from verifying the normality via a normality test (such as the &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;Shapiro-Wilk test&lt;/a&gt; for instance) because for small sample sizes, normality tests have little power to reject the null hypothesis and therefore small samples most often pass normality tests &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-oztuna2006investigation&#34;&gt;Öztuna et al. 2006&lt;/a&gt;; &lt;a href=&#34;#ref-ghasemi2012normality&#34;&gt;Ghasemi and Zahediasl 2012&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Note also that although we use a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative variable&lt;/a&gt; for the illustration, the one-sample Wilcoxon test is also appropriate for interval data and Likert scales.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How?&lt;/h1&gt;
&lt;p&gt;The one-sample Wilcoxon test can be done in R with the &lt;code&gt;wilcox.test()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;But first, it is a good practice to visualize our data in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; and compute some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; to compare our observations with our default value:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# boxplot
boxplot(dat$Score,
  ylab = &amp;quot;Score&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/index_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;If like me you prefer to use 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; for your plots:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# boxplot
library(ggplot2)

ggplot(dat, aes(y = Score)) +
  geom_boxplot() +
  labs(y = &amp;quot;Score&amp;quot;) +
  theme( # remove axis text and ticks
    axis.text.x = element_blank(),
    axis.ticks = element_blank()
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/index_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;Some basic descriptive statistics (rounded to two decimals):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round(summary(dat$Score),
  digits = 2
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    5.00   14.00   11.33   17.00   20.00&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From the boxplot and the descriptive statistics above, we see that the mean and median of the scores in our sample are respectively 11.33 and 14.&lt;/p&gt;
&lt;p&gt;The one-sample Wilcoxon test will tell us whether the scores are &lt;em&gt;significantly&lt;/em&gt; different from 10 or not (and thus whether they are different from 10 in the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt; or not):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;wilcox.test(dat$Score,
  mu = 10 # default value
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Wilcoxon signed rank test with continuity correction
## 
## data:  dat$Score
## V = 67, p-value = 0.3779
## alternative hypothesis: true location is not equal to 10&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output presents several information such as the:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title of the test&lt;/li&gt;
&lt;li&gt;data&lt;/li&gt;
&lt;li&gt;test statistic&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value&lt;/li&gt;
&lt;li&gt;alternative hypothesis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We focus on the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value to interpret and conclude the test.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Interpretation:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Based on the results of the test, (at the significance level of 0.05) we do not reject the null hypothesis, so we do not reject the hypothesis that the scores at this exam are equal to 10, and we cannot conclude that the scores are significantly different from 10 (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.378).&lt;/p&gt;
&lt;p&gt;By default, it is a two-tailed test that is done. As for the &lt;code&gt;t.test()&lt;/code&gt; function, we can specify that a one-sided test is required by using either the &lt;code&gt;alternative = &#34;greater&#34;&lt;/code&gt; or &lt;code&gt;alternative = &#34;less&lt;/code&gt; argument in the &lt;code&gt;wilcox.test()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;For example, if we want to test that the scores are &lt;em&gt;higher&lt;/em&gt; than 10:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;wilcox.test(dat$Score,
  mu = 10, # default value
  alternative = &amp;quot;greater&amp;quot; # H1: scores &amp;gt; 10
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Wilcoxon signed rank test with continuity correction
## 
## data:  dat$Score
## V = 67, p-value = 0.189
## alternative hypothesis: true location is greater than 10&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Interpretation:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this case, we still do not reject the hypothesis that scores are equal to 10 and we cannot conclude that scores are significantly higher than 10 (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.189).&lt;/p&gt;
&lt;p&gt;For more information about the arguments available in the function, see &lt;code&gt;?wilcox.test&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Note that you may encounter the following warnings when using &lt;code&gt;wilcox.test()&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Warning messages:
1: In wilcox.test.default(dat$Score, mu = 10) :
  cannot compute exact p-value with ties
2: In wilcox.test.default(dat$Score, mu = 10) :
  cannot compute exact p-value with zeroes&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is a warning rather than an indication that your results are incorrect. R is informing you that it is reporting a &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value based on a normal approximation rather than an exact &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value based on the data because there are ties (some values are the same). Use the &lt;code&gt;exact = FALSE&lt;/code&gt; option if you want to remove the warning.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;combine-statistical-test-and-plot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Combine statistical test and plot&lt;/h1&gt;
&lt;p&gt;If you are a frequent user of the blog, you know that I like to present results of a test directly on a plot. This allows me to visualize the data and conclude the test in a concise manner.&lt;/p&gt;
&lt;p&gt;This is possible thanks to the &lt;code&gt;gghistostats()&lt;/code&gt; function within the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(ggstatsplot)

# combine plot and test
gghistostats(
  data = dat, # dataframe
  x = Score, # variable
  type = &amp;quot;nonparametric&amp;quot;, # nonparametric = Wilcoxon, parametric = t-test
  test.value = 10 # default value
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/index_files/figure-html/unnamed-chunk-9-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The histogram&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; shows the distribution of the scores and results of the test is shown in the title of the plot.&lt;/p&gt;
&lt;p&gt;As you can see, results of the test are the same, that is, there is not enough evidence in the data to conclude that scores are significantly different from 10 (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.378).&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 helped you to understand the one-sample Wilcoxon test and how to do it in R.&lt;/p&gt;
&lt;p&gt;As always, if you have any question related to the topic covered in this paper, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-ghasemi2012normality&#34; class=&#34;csl-entry&#34;&gt;
Ghasemi, Asghar, and Saleh Zahediasl. 2012. &lt;span&gt;“Normality Tests for Statistical Analysis: A Guide for Non-Statisticians.”&lt;/span&gt; &lt;em&gt;International Journal of Endocrinology and Metabolism&lt;/em&gt; 10 (2): 486.
&lt;/div&gt;
&lt;div id=&#34;ref-oztuna2006investigation&#34; class=&#34;csl-entry&#34;&gt;
Öztuna, Derya, Atilla Halil Elhan, and Ersöz Tüccar. 2006. &lt;span&gt;“Investigation of Four Different Normality Tests in Terms of Type 1 Error Rate and Power Under Different Distributions.”&lt;/span&gt; &lt;em&gt;Turkish Journal of Medical Sciences&lt;/em&gt; 36 (3): 171–76.
&lt;/div&gt;
&lt;/div&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;See more information in this &lt;a href=&#34;https://rcompanion.org/handbook/F_02.html&#34;&gt;article&lt;/a&gt;.&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;This histogram looks different than the previous one because the number of bins is different (4 versus 5 bins).&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>Koh-Lanta 2022: the ambassadors probability problem</title>
      <link>https://statsandr.com/blog/koh-lanta-2022-ambassadors-probability-problem/</link>
      <pubDate>Mon, 16 May 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/koh-lanta-2022-ambassadors-probability-problem/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#before-2022&#34; id=&#34;toc-before-2022&#34;&gt;Before 2022&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-2022&#34; id=&#34;toc-in-2022&#34;&gt;In 2022&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#probabilities-computation-in-r&#34; id=&#34;toc-probabilities-computation-in-r&#34;&gt;Probabilities computation in R&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#first-draw&#34; id=&#34;toc-first-draw&#34;&gt;First draw&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#second-draw&#34; id=&#34;toc-second-draw&#34;&gt;Second draw&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#third-draw&#34; id=&#34;toc-third-draw&#34;&gt;Third draw&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#game-limited-to-3-draws&#34; id=&#34;toc-game-limited-to-3-draws&#34;&gt;Game limited to 3 draws&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#game-limited-to-5-draws&#34; id=&#34;toc-game-limited-to-5-draws&#34;&gt;Game limited to 5 draws&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#game-limited-to-100-draws&#34; id=&#34;toc-game-limited-to-100-draws&#34;&gt;Game limited to 100 draws&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#game-limited-to-the-number-of-necessary-draws&#34; id=&#34;toc-game-limited-to-the-number-of-necessary-draws&#34;&gt;Game limited to the number of necessary draws&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#final-winning-probabilities&#34; id=&#34;toc-final-winning-probabilities&#34;&gt;Final winning probabilities&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visual-representations&#34; id=&#34;toc-visual-representations&#34;&gt;Visual representations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coded-into-a-function&#34; id=&#34;toc-coded-into-a-function&#34;&gt;Coded into a function&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;images/koh-lanta-2022-ambassadors-probability-problem.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;There is a popular TV show broadcasted in France and the french-speaking part of Belgium called “&lt;strong&gt;Koh-Lanta&lt;/strong&gt;”.&lt;/p&gt;
&lt;p&gt;In this show, several adventurers are dropped off on a desert island with almost no food nor equipment (just a personal backpack with their clothes and a small portion of rice). They must learn to survive on the hostile island by building their hut, finding water and food, etc.&lt;/p&gt;
&lt;p&gt;Each season, adventurers are divided into teams (called tribes), and the teams compete against each other in games involving ability, strength, thinking and endurance. Every other game, the winning tribe receives some food or survival equipment (something to fish or something to make a fire, for instance). The losing tribe receives nothing. For the other half of the games, each member of the losing tribe has to elect an adventurer. The adventurer with the most votes leaves the show definitely. The winning tribe goes back to its island with all of its members.&lt;/p&gt;
&lt;p&gt;At some point during the show, the two competing tribes are grouped together into one single tribe, and it continues this time with each adventurer competing against each other (so they play individually). The winner of the show is the last one to “survive”.&lt;/p&gt;
&lt;p&gt;The 2022 season started with 24 adventurers. Just before being grouped together, each tribe has to select an adventurer in the opposing tribe. The two selected adventurers become ambassadors of their tribe. The two ambassadors must then go to another island in order to choose the adventurer who is going to leaves the show definitely. The adventurer selected by the two ambassadors will not be part of the reunification of the two tribes and her adventure stops there.&lt;/p&gt;
&lt;p&gt;Of course, both ambassadors want to eliminate a member of the opposing tribe (to arrive at the reunification with the most allies). If the two ambassadors cannot agree, they have to play a game that will determine which of the 2 ambassadors must leave the show. This game is entirely based on luck. For the rest of the article, we call this game the &lt;em&gt;ambassadors’ game&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;before-2022&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Before 2022&lt;/h1&gt;
&lt;p&gt;Here were the rules of the ambassadors’ game &lt;em&gt;before&lt;/em&gt; the 2022 season:&lt;/p&gt;
&lt;p&gt;There are two identical urns, one in front of each ambassador. Each urn contains exactly &lt;strong&gt;one black ball&lt;/strong&gt; and &lt;strong&gt;one white ball&lt;/strong&gt;. Each ambassador has to draw a ball among the 2 from his urn. Both urns are of course closed, so no one sees which ball is picked (nor which one is not picked). The winner of the game (remember that the winner stays in the show, the loser has to leave definitely) is the one who picks a white ball while the other ambassador draws a black ball. If both ambassadors draw the same ball (both black or both white), the balls are put back in the urns and the game start over (with the exact same conditions) until the two ambassadors draw a ball of different color.&lt;/p&gt;
&lt;p&gt;For each draw, there are thus four possible results:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Ambassador from tribe A draws a white ball and ambassador from tribe B draws a black ball: ambassador from tribe A wins.&lt;/li&gt;
&lt;li&gt;Ambassador from tribe A draws a black ball and ambassador from tribe B draws a white ball: ambassador from tribe B wins.&lt;/li&gt;
&lt;li&gt;Both ambassadors draw a black ball: the game start over.&lt;/li&gt;
&lt;li&gt;Both ambassadors draw a white ball: the game start over.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s compute the probability for each result to occur. Since the two events are &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/#independence-of-two-events&#34;&gt;independent&lt;/a&gt; (the fact that ambassador A draws a white ball does not change the probability for ambassador B to draw a white ball makes the two events independent), we can multiply the probabilities to compute the joint probability of the two events.&lt;/p&gt;
&lt;p&gt;With &lt;span class=&#34;math inline&#34;&gt;\(P_A\)&lt;/span&gt; (&lt;span class=&#34;math inline&#34;&gt;\(P_B\)&lt;/span&gt;) denoting the probability that ambassador from tribe A (B) draws a white ball, we have:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(P_A \cdot (1 - P_B) = 0.5 \cdot 0.5 = 0.25\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\((1 - P_A) \cdot P_B = 0.5 \cdot 0.5 = 0.25\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\((1 - P_A) \cdot (1 - P_B) = 0.5 \cdot 0.5 = 0.25\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(P_A \cdot P_B = 0.5 \cdot 0.5 = 0.25\)&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The sum of the 4 probabilities gives 1 (i.e., 100%), which makes sense since it covers all possible outcomes.&lt;/p&gt;
&lt;p&gt;This means that, &lt;em&gt;on the first draw&lt;/em&gt;, each ambassador has a probability of 25% to win the game (outcome 1 for ambassador A, outcome 2 for ambassador B).&lt;/p&gt;
&lt;p&gt;Of course, since the game is repeated until there is a winner, probabilities for outcomes 3 and 4 tend, in the long run, to decrease until it becomes null (0%). If this statement is not straightforward to you, think about it like this: if you play that game with your friend up to 100 times, what is the probability that there is still no winner, meaning that you and your friend drew the same ball (never a different color) 100 times in a row. You conceive that it is highly unlikely.&lt;/p&gt;
&lt;p&gt;In this context, since both urns are identical and the game is played indefinitely until there is a winner, ambassadors have exactly the same probability of winning that game. It is indeed a 50-50 chance for each of them.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-2022&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;In 2022&lt;/h1&gt;
&lt;p&gt;Of course, I would not write an article about that ambassadors’ game if it is was this easy and straightforward.&lt;/p&gt;
&lt;p&gt;The 2022 season differs from the previous ones in the sense that for each game, the losing tribe receives an additional punishment (called a curse in the show). As a consequence, this year, the two urns at the ambassadors’ game were &lt;strong&gt;not&lt;/strong&gt; identical.&lt;/p&gt;
&lt;p&gt;To give you some context, the red tribe won against the yellow tribe in the last game before the ambassadors’ negotiation. The punishment for the yellow tribe was the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The yellow tribe (with its ambassador Colin) had an urn with &lt;strong&gt;2 black balls&lt;/strong&gt; and 1 white ball.&lt;/li&gt;
&lt;li&gt;The red tribe (with its ambassador Louana) had an urn with &lt;strong&gt;1 black ball&lt;/strong&gt; and 1 white ball.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is indeed a punishment for the yellow tribe since the game is not fair anymore: the ambassador of the red tribe clearly has a higher chance of winning that game compared to the ambassador of the yellow tribe.&lt;/p&gt;
&lt;p&gt;For the curious among you, here is how it happened:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The two ambassadors were informed by the presenter Denis Brogniart about the composition of the urns for each tribe.&lt;/li&gt;
&lt;li&gt;Knowing that the odds were not in his favour, Colin (ambassador of the yellow tribe), chose not to play the game.&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;li&gt;They finally agreed on the name of the adventurer who would leave the show (an adventurer of the yellow tribe).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You guessed it by now, the reason for writing this article is of course not to explain you what actually happened—the news sites do it better and much faster than me. The reason is that I wanted to compute the chance of winning the game for each ambassador if they had not agreed on an adventurer to eliminate.&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;Moreover, I wanted to compute these probabilities in R through simulation. And why not, reuse the code in case organizers of Koh-Lanta decide to change the rules again in the future.&lt;/p&gt;
&lt;p&gt;Even if you do not watch Koh-Lanta (because it is not broadcasted in your country, or you do not like the show), it could be of interest to those of you who want to see:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how a real life example can be transferred into R,&lt;/li&gt;
&lt;li&gt;and how a &lt;code&gt;for loop&lt;/code&gt; and a function can be used to answer the initial question.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;probabilities-computation-in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Probabilities computation in R&lt;/h1&gt;
&lt;p&gt;For the remaining of this article, we denote:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(p_c\)&lt;/span&gt;, the probability that Colin (ambassador of the yellow tribe) draws a white ball,&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(p_l\)&lt;/span&gt;, the probability that Louana (ambassador of the red tribe) draws a white ball,&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(q_c\)&lt;/span&gt;, the probability that Colin draws a black ball,&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(q_l\)&lt;/span&gt;, the probability that Louana draws a black ball.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Based on the composition of the urns given by Denis Brogniart, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p_c &amp;lt;- 1 / 3
p_l &amp;lt;- 1 / 2
q_c &amp;lt;- (1 - p_c)
q_l &amp;lt;- (1 - p_l)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;first-draw&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;First draw&lt;/h2&gt;
&lt;p&gt;To start easy, let’s first compute the winning probabilities for each ambassador &lt;em&gt;on the first draw only&lt;/em&gt;. Remember that to have a winner, balls must be of different colors.&lt;/p&gt;
&lt;p&gt;Louana wins if and only if Colin draws a black ball and Louana draws a white ball:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Louana winning on first draw
l_win &amp;lt;- q_c * p_l
l_win&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.3333333&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Louana has a 33.33% chance of winning on the first draw.&lt;/p&gt;
&lt;p&gt;On the other hand, Colin wins if and only if Louana draws a black ball and Colin draws a white ball:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Colin winning on first draw
c_win &amp;lt;- q_l * p_c
c_win&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.1666667&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Colin has a 16.67% chance of winning on the first draw.&lt;/p&gt;
&lt;p&gt;You can already see that the game is in favour of Louana, as expected. Let’s see now how it evolves when playing several times.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;second-draw&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Second draw&lt;/h2&gt;
&lt;p&gt;To win exactly on the second draw, it must be a tie on the first draw.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Louana winning on second draw
tie &amp;lt;- (p_c * p_l) + (q_c * q_l)

l_win2 &amp;lt;- tie * l_win
l_win2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.1666667&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Colin winning on second draw
c_win2 &amp;lt;- tie * c_win
c_win2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.08333333&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Louana has a 16.67% chance of winning on the second draw.&lt;/li&gt;
&lt;li&gt;Colin has a 8.33% chance of winning on the second draw.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;third-draw&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Third draw&lt;/h2&gt;
&lt;p&gt;To win exactly on the third draw, it must be a tie on the first two draws.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Louana winning on third draw
l_win3 &amp;lt;- (tie^2) * l_win
l_win3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.08333333&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Colin winning on third draw
c_win3 &amp;lt;- (tie^2) * c_win
c_win3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.04166667&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Louana has a 8.33% chance of winning on the third draw.&lt;/li&gt;
&lt;li&gt;Colin has a 4.17% chance of winning on the third draw.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A pattern seems to emerge in the code.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;game-limited-to-3-draws&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Game limited to 3 draws&lt;/h2&gt;
&lt;p&gt;We can already compute the probabilities of winning for each ambassador as if the game was limited to three draws, by summing the probabilities for each of the first three draws:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Louana winning on draw 1, 2 or 3
l_win_tot &amp;lt;- l_win + l_win2 + l_win3
l_win_tot&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.5833333&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Colin winning on draw 1, 2 or 3
c_win_tot &amp;lt;- c_win + c_win2 + c_win3
c_win_tot&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.2916667&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Louana has a 58.33% chance of winning if the game is limited to three draws.&lt;/li&gt;
&lt;li&gt;Colin has a 29.17% chance of winning if the game is limited to three draws.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;game-limited-to-5-draws&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Game limited to 5 draws&lt;/h2&gt;
&lt;p&gt;Now if we compute the probabilities as if the game was limited to 5 draws and generalize the computation to see the pattern even more clearly, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Louana winning
l_win_tot &amp;lt;- ((tie^0) * l_win) +
  ((tie^1) * l_win) +
  ((tie^2) * l_win) +
  ((tie^3) * l_win) +
  ((tie^4) * l_win)

l_win_tot&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.6458333&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Colin winning
c_win_tot &amp;lt;- ((tie^0) * c_win) +
  ((tie^1) * c_win) +
  ((tie^2) * c_win) +
  ((tie^3) * c_win) +
  ((tie^4) * c_win)

c_win_tot&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.3229167&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Louana has a 64.58% chance of winning if the game is limited to 5 draws.&lt;/li&gt;
&lt;li&gt;Colin has a 32.29% chance of winning if the game is limited to 5 draws.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;game-limited-to-100-draws&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Game limited to 100 draws&lt;/h2&gt;
&lt;p&gt;We could continue like this for a long time, but for now let’s compute it for up to 100 draws, using a &lt;code&gt;for loop&lt;/code&gt;. Using a &lt;code&gt;for loop&lt;/code&gt; is necessary here in order to avoid to copy-paste our computations a hundred times.&lt;/p&gt;
&lt;p&gt;For the ease of illustration, we compute only the probability of winning for Louana. We will show later on how the probability for Colin can easily be computed.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;n_draws &amp;lt;- 100 # number of draws
l_win_tot &amp;lt;- c() # set empty vector

for (i in 1:n_draws) {
  l_win_tot[i] &amp;lt;- ((tie^(i - 1)) * l_win) # prob of Louana winning up to n_draws
  print(paste0(&amp;quot;Draw &amp;quot;, i, &amp;quot;: &amp;quot;, sum(l_win_tot))) # print sum of winning up to n_draws
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Draw 1: 0.333333333333333&amp;quot;
## [1] &amp;quot;Draw 2: 0.5&amp;quot;
## [1] &amp;quot;Draw 3: 0.583333333333333&amp;quot;
## [1] &amp;quot;Draw 4: 0.625&amp;quot;
## [1] &amp;quot;Draw 5: 0.645833333333333&amp;quot;
## [1] &amp;quot;Draw 6: 0.65625&amp;quot;
## [1] &amp;quot;Draw 7: 0.661458333333333&amp;quot;
## [1] &amp;quot;Draw 8: 0.6640625&amp;quot;
## [1] &amp;quot;Draw 9: 0.665364583333333&amp;quot;
## [1] &amp;quot;Draw 10: 0.666015625&amp;quot;
## [1] &amp;quot;Draw 11: 0.666341145833333&amp;quot;
## [1] &amp;quot;Draw 12: 0.66650390625&amp;quot;
## [1] &amp;quot;Draw 13: 0.666585286458333&amp;quot;
## [1] &amp;quot;Draw 14: 0.6666259765625&amp;quot;
## [1] &amp;quot;Draw 15: 0.666646321614583&amp;quot;
## [1] &amp;quot;Draw 16: 0.666656494140625&amp;quot;
## [1] &amp;quot;Draw 17: 0.666661580403646&amp;quot;
## [1] &amp;quot;Draw 18: 0.666664123535156&amp;quot;
## [1] &amp;quot;Draw 19: 0.666665395100911&amp;quot;
## [1] &amp;quot;Draw 20: 0.666666030883789&amp;quot;
## [1] &amp;quot;Draw 21: 0.666666348775228&amp;quot;
## [1] &amp;quot;Draw 22: 0.666666507720947&amp;quot;
## [1] &amp;quot;Draw 23: 0.666666587193807&amp;quot;
## [1] &amp;quot;Draw 24: 0.666666626930237&amp;quot;
## [1] &amp;quot;Draw 25: 0.666666646798452&amp;quot;
## [1] &amp;quot;Draw 26: 0.666666656732559&amp;quot;
## [1] &amp;quot;Draw 27: 0.666666661699613&amp;quot;
## [1] &amp;quot;Draw 28: 0.66666666418314&amp;quot;
## [1] &amp;quot;Draw 29: 0.666666665424903&amp;quot;
## [1] &amp;quot;Draw 30: 0.666666666045785&amp;quot;
## [1] &amp;quot;Draw 31: 0.666666666356226&amp;quot;
## [1] &amp;quot;Draw 32: 0.666666666511446&amp;quot;
## [1] &amp;quot;Draw 33: 0.666666666589056&amp;quot;
## [1] &amp;quot;Draw 34: 0.666666666627862&amp;quot;
## [1] &amp;quot;Draw 35: 0.666666666647264&amp;quot;
## [1] &amp;quot;Draw 36: 0.666666666656965&amp;quot;
## [1] &amp;quot;Draw 37: 0.666666666661816&amp;quot;
## [1] &amp;quot;Draw 38: 0.666666666664241&amp;quot;
## [1] &amp;quot;Draw 39: 0.666666666665454&amp;quot;
## [1] &amp;quot;Draw 40: 0.66666666666606&amp;quot;
## [1] &amp;quot;Draw 41: 0.666666666666364&amp;quot;
## [1] &amp;quot;Draw 42: 0.666666666666515&amp;quot;
## [1] &amp;quot;Draw 43: 0.666666666666591&amp;quot;
## [1] &amp;quot;Draw 44: 0.666666666666629&amp;quot;
## [1] &amp;quot;Draw 45: 0.666666666666648&amp;quot;
## [1] &amp;quot;Draw 46: 0.666666666666657&amp;quot;
## [1] &amp;quot;Draw 47: 0.666666666666662&amp;quot;
## [1] &amp;quot;Draw 48: 0.666666666666664&amp;quot;
## [1] &amp;quot;Draw 49: 0.666666666666666&amp;quot;
## [1] &amp;quot;Draw 50: 0.666666666666666&amp;quot;
## [1] &amp;quot;Draw 51: 0.666666666666666&amp;quot;
## [1] &amp;quot;Draw 52: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 53: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 54: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 55: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 56: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 57: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 58: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 59: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 60: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 61: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 62: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 63: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 64: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 65: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 66: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 67: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 68: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 69: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 70: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 71: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 72: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 73: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 74: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 75: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 76: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 77: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 78: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 79: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 80: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 81: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 82: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 83: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 84: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 85: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 86: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 87: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 88: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 89: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 90: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 91: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 92: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 93: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 94: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 95: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 96: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 97: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 98: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 99: 0.666666666666667&amp;quot;
## [1] &amp;quot;Draw 100: 0.666666666666667&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The probabilities found up to draw 1, 3 and 5 are coherent with what we found in the previous sections. Moreover, we see that from draw 52 onwards, the probability of Louana winning remains constant at 66.67%. This is referred as the limit.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;game-limited-to-the-number-of-necessary-draws&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Game limited to the number of necessary draws&lt;/h2&gt;
&lt;p&gt;Without printing the results of the above &lt;code&gt;for loop&lt;/code&gt;, we do not know how many draws are necessary to reach the limit.&lt;/p&gt;
&lt;p&gt;Let’s now try to include the information about the number of necessary draws in order to avoid computing unnecessary draws:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;n_draws &amp;lt;- 9999 # initial number of draws, set intentionally to a high number
p_tie &amp;lt;- c() # set empty vector for prob of ties
l_win_tot &amp;lt;- c() # set empty vector for prob of Louana winning

# find number of necessary draws:
for (i in 1:n_draws) {
  p_tie[i] &amp;lt;- tie^i # prob of tie for each draw
  limit_ndraws &amp;lt;- sum(p_tie &amp;gt; 2.2e-16) # number of necessary draws
}

# compute Louana winning probabilities with the smallest number of necessary draws
for (i in 1:limit_ndraws) {
  l_win_tot[i] &amp;lt;- ((tie^(i - 1)) * l_win) # prob of Louana winning up to limited number of draws
  print(paste0(&amp;quot;Draw &amp;quot;, i, &amp;quot;: &amp;quot;, sum(l_win_tot))) # sum of winning up to limited number of draws
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Draw 1: 0.333333333333333&amp;quot;
## [1] &amp;quot;Draw 2: 0.5&amp;quot;
## [1] &amp;quot;Draw 3: 0.583333333333333&amp;quot;
## [1] &amp;quot;Draw 4: 0.625&amp;quot;
## [1] &amp;quot;Draw 5: 0.645833333333333&amp;quot;
## [1] &amp;quot;Draw 6: 0.65625&amp;quot;
## [1] &amp;quot;Draw 7: 0.661458333333333&amp;quot;
## [1] &amp;quot;Draw 8: 0.6640625&amp;quot;
## [1] &amp;quot;Draw 9: 0.665364583333333&amp;quot;
## [1] &amp;quot;Draw 10: 0.666015625&amp;quot;
## [1] &amp;quot;Draw 11: 0.666341145833333&amp;quot;
## [1] &amp;quot;Draw 12: 0.66650390625&amp;quot;
## [1] &amp;quot;Draw 13: 0.666585286458333&amp;quot;
## [1] &amp;quot;Draw 14: 0.6666259765625&amp;quot;
## [1] &amp;quot;Draw 15: 0.666646321614583&amp;quot;
## [1] &amp;quot;Draw 16: 0.666656494140625&amp;quot;
## [1] &amp;quot;Draw 17: 0.666661580403646&amp;quot;
## [1] &amp;quot;Draw 18: 0.666664123535156&amp;quot;
## [1] &amp;quot;Draw 19: 0.666665395100911&amp;quot;
## [1] &amp;quot;Draw 20: 0.666666030883789&amp;quot;
## [1] &amp;quot;Draw 21: 0.666666348775228&amp;quot;
## [1] &amp;quot;Draw 22: 0.666666507720947&amp;quot;
## [1] &amp;quot;Draw 23: 0.666666587193807&amp;quot;
## [1] &amp;quot;Draw 24: 0.666666626930237&amp;quot;
## [1] &amp;quot;Draw 25: 0.666666646798452&amp;quot;
## [1] &amp;quot;Draw 26: 0.666666656732559&amp;quot;
## [1] &amp;quot;Draw 27: 0.666666661699613&amp;quot;
## [1] &amp;quot;Draw 28: 0.66666666418314&amp;quot;
## [1] &amp;quot;Draw 29: 0.666666665424903&amp;quot;
## [1] &amp;quot;Draw 30: 0.666666666045785&amp;quot;
## [1] &amp;quot;Draw 31: 0.666666666356226&amp;quot;
## [1] &amp;quot;Draw 32: 0.666666666511446&amp;quot;
## [1] &amp;quot;Draw 33: 0.666666666589056&amp;quot;
## [1] &amp;quot;Draw 34: 0.666666666627862&amp;quot;
## [1] &amp;quot;Draw 35: 0.666666666647264&amp;quot;
## [1] &amp;quot;Draw 36: 0.666666666656965&amp;quot;
## [1] &amp;quot;Draw 37: 0.666666666661816&amp;quot;
## [1] &amp;quot;Draw 38: 0.666666666664241&amp;quot;
## [1] &amp;quot;Draw 39: 0.666666666665454&amp;quot;
## [1] &amp;quot;Draw 40: 0.66666666666606&amp;quot;
## [1] &amp;quot;Draw 41: 0.666666666666364&amp;quot;
## [1] &amp;quot;Draw 42: 0.666666666666515&amp;quot;
## [1] &amp;quot;Draw 43: 0.666666666666591&amp;quot;
## [1] &amp;quot;Draw 44: 0.666666666666629&amp;quot;
## [1] &amp;quot;Draw 45: 0.666666666666648&amp;quot;
## [1] &amp;quot;Draw 46: 0.666666666666657&amp;quot;
## [1] &amp;quot;Draw 47: 0.666666666666662&amp;quot;
## [1] &amp;quot;Draw 48: 0.666666666666664&amp;quot;
## [1] &amp;quot;Draw 49: 0.666666666666666&amp;quot;
## [1] &amp;quot;Draw 50: 0.666666666666666&amp;quot;
## [1] &amp;quot;Draw 51: 0.666666666666666&amp;quot;
## [1] &amp;quot;Draw 52: 0.666666666666667&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;final-winning-probabilities&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Final winning probabilities&lt;/h2&gt;
&lt;p&gt;Remember that the initial question was:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What is the probability of winning the game for each ambassador?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The probability that Louana wins the game can easily be extracted as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sum(l_win_tot)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.6666667&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And since the game only stops when there is a winner, the sum of the winning probabilities for Louana and Colin must be equal to 1, so the probability that Colin wins the game is:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;c_win_tot &amp;lt;- 1 - sum(l_win_tot)
c_win_tot&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.3333333&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;To summarize:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Louana has 66.67% chance to win the ambassadors’ game.&lt;/li&gt;
&lt;li&gt;Colin has 33.33% chance to win the ambassadors’ game.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;visual-representations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visual representations&lt;/h2&gt;
&lt;p&gt;To visualize the probabilities for each ambassador, we miss the probabilities of winning for Colin so let’s compute them first:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;c_win_tot &amp;lt;- c() # set empty vector for prob of Colin winning

# compute Colin winning probabilities with the smallest number of necessary draws
for (i in 1:limit_ndraws) {
  c_win_tot[i] &amp;lt;- ((tie^(i - 1)) * c_win) # prob of Colin winning
  print(paste0(&amp;quot;Draw &amp;quot;, i, &amp;quot;: &amp;quot;, sum(c_win_tot))) # print sum of winning
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Draw 1: 0.166666666666667&amp;quot;
## [1] &amp;quot;Draw 2: 0.25&amp;quot;
## [1] &amp;quot;Draw 3: 0.291666666666667&amp;quot;
## [1] &amp;quot;Draw 4: 0.3125&amp;quot;
## [1] &amp;quot;Draw 5: 0.322916666666667&amp;quot;
## [1] &amp;quot;Draw 6: 0.328125&amp;quot;
## [1] &amp;quot;Draw 7: 0.330729166666667&amp;quot;
## [1] &amp;quot;Draw 8: 0.33203125&amp;quot;
## [1] &amp;quot;Draw 9: 0.332682291666667&amp;quot;
## [1] &amp;quot;Draw 10: 0.3330078125&amp;quot;
## [1] &amp;quot;Draw 11: 0.333170572916667&amp;quot;
## [1] &amp;quot;Draw 12: 0.333251953125&amp;quot;
## [1] &amp;quot;Draw 13: 0.333292643229167&amp;quot;
## [1] &amp;quot;Draw 14: 0.33331298828125&amp;quot;
## [1] &amp;quot;Draw 15: 0.333323160807292&amp;quot;
## [1] &amp;quot;Draw 16: 0.333328247070312&amp;quot;
## [1] &amp;quot;Draw 17: 0.333330790201823&amp;quot;
## [1] &amp;quot;Draw 18: 0.333332061767578&amp;quot;
## [1] &amp;quot;Draw 19: 0.333332697550456&amp;quot;
## [1] &amp;quot;Draw 20: 0.333333015441895&amp;quot;
## [1] &amp;quot;Draw 21: 0.333333174387614&amp;quot;
## [1] &amp;quot;Draw 22: 0.333333253860474&amp;quot;
## [1] &amp;quot;Draw 23: 0.333333293596904&amp;quot;
## [1] &amp;quot;Draw 24: 0.333333313465118&amp;quot;
## [1] &amp;quot;Draw 25: 0.333333323399226&amp;quot;
## [1] &amp;quot;Draw 26: 0.33333332836628&amp;quot;
## [1] &amp;quot;Draw 27: 0.333333330849806&amp;quot;
## [1] &amp;quot;Draw 28: 0.33333333209157&amp;quot;
## [1] &amp;quot;Draw 29: 0.333333332712452&amp;quot;
## [1] &amp;quot;Draw 30: 0.333333333022892&amp;quot;
## [1] &amp;quot;Draw 31: 0.333333333178113&amp;quot;
## [1] &amp;quot;Draw 32: 0.333333333255723&amp;quot;
## [1] &amp;quot;Draw 33: 0.333333333294528&amp;quot;
## [1] &amp;quot;Draw 34: 0.333333333313931&amp;quot;
## [1] &amp;quot;Draw 35: 0.333333333323632&amp;quot;
## [1] &amp;quot;Draw 36: 0.333333333328483&amp;quot;
## [1] &amp;quot;Draw 37: 0.333333333330908&amp;quot;
## [1] &amp;quot;Draw 38: 0.333333333332121&amp;quot;
## [1] &amp;quot;Draw 39: 0.333333333332727&amp;quot;
## [1] &amp;quot;Draw 40: 0.33333333333303&amp;quot;
## [1] &amp;quot;Draw 41: 0.333333333333182&amp;quot;
## [1] &amp;quot;Draw 42: 0.333333333333258&amp;quot;
## [1] &amp;quot;Draw 43: 0.333333333333295&amp;quot;
## [1] &amp;quot;Draw 44: 0.333333333333314&amp;quot;
## [1] &amp;quot;Draw 45: 0.333333333333324&amp;quot;
## [1] &amp;quot;Draw 46: 0.333333333333329&amp;quot;
## [1] &amp;quot;Draw 47: 0.333333333333331&amp;quot;
## [1] &amp;quot;Draw 48: 0.333333333333332&amp;quot;
## [1] &amp;quot;Draw 49: 0.333333333333333&amp;quot;
## [1] &amp;quot;Draw 50: 0.333333333333333&amp;quot;
## [1] &amp;quot;Draw 51: 0.333333333333333&amp;quot;
## [1] &amp;quot;Draw 52: 0.333333333333333&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We create a dataset with the probabilities for both ambassadors:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- data.frame(
  Draw = rep(1:limit_ndraws, 2),
  Probability = c(cumsum(l_win_tot), cumsum(c_win_tot)),
  Ambassador = c(rep(&amp;quot;Louana&amp;quot;, limit_ndraws), rep(&amp;quot;Colin&amp;quot;, limit_ndraws))
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can now visualize these probabilities up to the number of necessary draws:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(ggplot2)

# plot
ggplot(dat) +
  aes(x = Draw, y = Probability, colour = Ambassador) +
  geom_line(linewidth = 2L) +
  labs(
    y = &amp;quot;Probability of winning&amp;quot;,
    caption = &amp;quot;Source: Koh-Lanta 2022&amp;quot;
  ) +
  scale_y_continuous(labels = scales::percent_format(accuracy = 1), limits = c(0, 1)) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/koh-lanta-2022-ambassadors-probability-problem/index_files/figure-html/unnamed-chunk-14-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;But I believe the most appropriate plot to answer the initial question is with a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create dataset
dat_barplot &amp;lt;- data.frame(
  Ambassador = c(&amp;quot;Louana&amp;quot;, &amp;quot;Colin&amp;quot;),
  Probability = c(sum(l_win_tot), sum(c_win_tot))
)

# plot
ggplot(data = dat_barplot, aes(x = Ambassador, y = Probability)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  labs(
    y = &amp;quot;Probability of winning&amp;quot;,
    caption = &amp;quot;Source: Koh-Lanta 2022&amp;quot;
  ) +
  scale_y_continuous(labels = scales::percent_format(accuracy = 1), limits = c(0, 1)) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/koh-lanta-2022-ambassadors-probability-problem/index_files/figure-html/unnamed-chunk-15-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coded-into-a-function&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coded into a function&lt;/h2&gt;
&lt;p&gt;Let’s try to implement this problem in a function to be able to reuse it with other initial probabilities.&lt;/p&gt;
&lt;p&gt;With:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;p_a&lt;/code&gt; and &lt;code&gt;p_b&lt;/code&gt; denoting, respectively, the probability that ambassador A and ambassador B draw a white ball,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;n_draws&lt;/code&gt; denoting the maximum number of draws that is allowed (default = 9999),&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;we have the following function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ambassadors_game &amp;lt;- function(p_a, p_b, n_draws = 9999) {
  q_a &amp;lt;- (1 - p_a)
  q_b &amp;lt;- (1 - p_b)

  a_win &amp;lt;- q_b * p_a
  b_win &amp;lt;- q_a * p_b

  tie &amp;lt;- (p_a * p_b) + (q_a * q_b)

  p_tie &amp;lt;- c() # set empty vector for prob of ties
  a_win_tot &amp;lt;- c() # set empty vector for prob of A winning
  b_win_tot &amp;lt;- c() # set empty vector for prob of B winning

  # find number of necessary draws:
  for (i in 1:n_draws) {
    p_tie[i] &amp;lt;- tie^i # prob of tie for each draw
    limit_ndraws &amp;lt;- sum(p_tie &amp;gt; 2.2e-16) # number of necessary draws
  }

  # compute A and B winning probabilities with the smallest number of necessary draws:
  for (i in 1:limit_ndraws) {
    a_win_tot[i] &amp;lt;- ((tie^(i - 1)) * a_win) # prob of A winning up to limited number of draws
    b_win_tot[i] &amp;lt;- ((tie^(i - 1)) * b_win) # prob of B winning up to limited number of draws
  }

  # save P(A), P(B) and number of necessary draws:
  res &amp;lt;- list(
    &amp;quot;p_a&amp;quot; = sum(a_win_tot),
    &amp;quot;p_b&amp;quot; = sum(b_win_tot),
    &amp;quot;ndraws&amp;quot; = limit_ndraws
  )
  # print results:
  return(res)
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We test the function to see if it matches results found above.&lt;/p&gt;
&lt;p&gt;First, if both ambassadors have identical urns as it was the case before the 2022 season:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ambassadors_game(
  p_a = 1 / 2,
  p_b = 1 / 2
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $p_a
## [1] 0.5
## 
## $p_b
## [1] 0.5
## 
## $ndraws
## [1] 52&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The game is indeed fair, with a 50% chance of winning for each ambassador.&lt;/p&gt;
&lt;p&gt;Second, with the urns presented to Louana and Colin, but for the first draw only (setting arbitrarily that Louana is ambassador A and Colin is ambassador B):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# first draw only
ambassadors_game(
  p_a = 1 / 2,
  p_b = 1 / 3,
  n_draws = 1
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $p_a
## [1] 0.3333333
## 
## $p_b
## [1] 0.1666667
## 
## $ndraws
## [1] 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Third, still with the urns presented to Louana and Colin, but for a game limited to exactly 3 and 5 draws:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# up to 3 draws
ambassadors_game(
  p_a = 1 / 2,
  p_b = 1 / 3,
  n_draws = 3
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $p_a
## [1] 0.5833333
## 
## $p_b
## [1] 0.2916667
## 
## $ndraws
## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# up to 5 draws
ambassadors_game(
  p_a = 1 / 2,
  p_b = 1 / 3,
  n_draws = 5
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $p_a
## [1] 0.6458333
## 
## $p_b
## [1] 0.3229167
## 
## $ndraws
## [1] 5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now, the final verification with the real situation of Louana and Colin in Koh-Lanta 2022:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Koh-Lanta 2022 situation
out &amp;lt;- ambassadors_game(
  p_a = 1 / 2,
  p_b = 1 / 3
)

out&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $p_a
## [1] 0.6666667
## 
## $p_b
## [1] 0.3333333
## 
## $ndraws
## [1] 52&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All results match the ones presented above.&lt;/p&gt;
&lt;p&gt;(Note that the probabilities for each ambassador can be extracted as follows:)&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# prob ambassador A
out$p_a&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.6666667&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# prob ambassador B
out$p_b&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.3333333&lt;/code&gt;&lt;/pre&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;The initial question, coming from the television show Koh-Lanta, was “what is the probability of winning for each participant if they play the ambassadors’ game?”.&lt;/p&gt;
&lt;p&gt;In this article, we have shown how to compute these probabilities. Moreover, we have illustrated the process of how a simple probability problem could be generalized to suit many real life situations, and how a &lt;code&gt;for loop&lt;/code&gt; and a function could be used to implement a real life situation into R.&lt;/p&gt;
&lt;p&gt;Last but not least, I would like to focus on something Denis Brogniart (the well-known presenter of the show) said just after the two ambassadors came back to the island to announce their choice to the other adventurers. He mentioned that, due to the punishment afflicted to the yellow tribe, there was a difference of chances of 16% between Louana and Colin.&lt;/p&gt;
&lt;p&gt;This comes naturally from the following two situations:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;First situation:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Louana has a 50% chance of picking a white ball.&lt;/li&gt;
&lt;li&gt;Colin has a 33.33% chance of picking a white ball.&lt;/li&gt;
&lt;li&gt;The difference is 50 - 33.33 = 16.67%, truncated to 16%.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Or, if the game is limited to the first draw only:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Second situation:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Louana has 33.33% chance of winning the game.&lt;/li&gt;
&lt;li&gt;Colin has a 16.67% chance of winning the game.&lt;/li&gt;
&lt;li&gt;The difference is 33.33 - 16.67 = 16.66%, truncated to 16%.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is true that, seeing the problem from those two angles, the difference is ~16%. Denis Brogniart is right in mentioning this 16% difference.&lt;/p&gt;
&lt;p&gt;However, the difference of chances between the two ambassadors is larger &lt;em&gt;if we see the game from a broader perspective&lt;/em&gt;. The rules of the game say that it stops only when there is a winner. From that point of view, as demonstrated above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Louana has 66.67% chance of winning the game.&lt;/li&gt;
&lt;li&gt;Colin has 33.33% chance of winning the game.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this situation, the difference in probability of winning between the 2 ambassadors is 66.67 - 33.33 = 33.34%!&lt;/p&gt;
&lt;p&gt;I must admit that I was not expecting such a large difference between the two ambassadors. Seeing the ambassadors’ game from that perspective looks different to what we were told, or to what we thought before actually computing the probabilities. (Denis Brogniart, if you happen to read this, feel free to let me know whether this relatively large difference was intended or not.)&lt;/p&gt;
&lt;p&gt;For those of you who do not watch the show: upon the return of the ambassadors on the island with all adventurers, Colin has been heavily criticized by the members of his tribe. His decision not to play the ambassadors’ game (and the decision to eliminate one member of his tribe with the aim of saving himself) was seen as a betrayal. As a consequence of this, he was eliminated by the reunited tribe directly after that episode.&lt;/p&gt;
&lt;p&gt;I am going to conclude this article with the following question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you were an ambassador in the 2022 Koh-Lanta season and given that now you know the exact probabilites of winning for each tribe, what would you have done?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;As always, if you have any question 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;We will never know if he would have played the game if the chances of winning were equal for both ambassadors. Since I started to watch this television show, I have never seen any ambassadors’ negotiation leading to the ambassadors’ game, they all ended with the designation of an adventurer.&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;And to be honest, I wanted to compute these probabilities because while I was watching the show with my girlfriend, she looked at me and asked “what are the probabilities for each of them?”. I am now able to give her a precise answer.&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>Kruskal-Wallis test, or the nonparametric version of the ANOVA</title>
      <link>https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/</link>
      <pubDate>Thu, 24 Mar 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#kruskal-wallis-test&#34; id=&#34;toc-kruskal-wallis-test&#34;&gt;Kruskal-Wallis test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#aim-and-hypotheses&#34; id=&#34;toc-aim-and-hypotheses&#34;&gt;Aim and hypotheses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#assumptions&#34; id=&#34;toc-assumptions&#34;&gt;Assumptions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-r&#34; id=&#34;toc-in-r&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interpretations&#34; id=&#34;toc-interpretations&#34;&gt;Interpretations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#post-hoc-tests&#34; id=&#34;toc-post-hoc-tests&#34;&gt;Post-hoc tests&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#dunn-test&#34; id=&#34;toc-dunn-test&#34;&gt;Dunn test&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-statistical-results-and-plot&#34; id=&#34;toc-combination-of-statistical-results-and-plot&#34;&gt;Combination of statistical results and plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#summary&#34; id=&#34;toc-summary&#34;&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/kruskal-wallis-test-nonparametric-version-anova.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In a previous article, we showed how to do an &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA in R&lt;/a&gt; to compare three or more groups.&lt;/p&gt;
&lt;p&gt;Remember that, as for many &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt;, the one-way ANOVA requires that some assumptions are satisfied in order to be able to use and interpret the results. In particular, the ANOVA requires that residuals follow approximately a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt;.&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;/p&gt;
&lt;p&gt;Luckily, if the normality assumption is not satisfied, there is the nonparametric version of the ANOVA: the &lt;strong&gt;Kruskal-Wallis&lt;/strong&gt; test.&lt;/p&gt;
&lt;p&gt;In the rest of the article, we show how to perform the Kruskal-Wallis test in R and how to interpret its results. We will also briefly show how to do post-hoc tests and how to present all necessary statistical results directly on a plot.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;Data for the present article is based on the &lt;code&gt;penguins&lt;/code&gt; dataset (an alternative to the well-known &lt;code&gt;iris&lt;/code&gt; dataset), accessible via the &lt;code&gt;{palmerpenguins}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;palmerpenguins&amp;quot;)
library(palmerpenguins)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The original dataset contains data for 344 penguins of 3 different species (Adelie, Chinstrap and Gentoo).&lt;/p&gt;
&lt;p&gt;It contains 8 variables, but we focus only on the flipper length and the species for this article, so we keep only those 2 variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tidyverse)

dat &amp;lt;- penguins %&amp;gt;%
  select(species, flipper_length_mm)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(If you are unfamiliar with the pipe operator (&lt;code&gt;%&amp;gt;%&lt;/code&gt;), you can also select variables with &lt;code&gt;penguins[, c(&#34;species&#34;, &#34;flipper_length_mm&#34;)]&lt;/code&gt;. Learn more ways to select variables in the article about &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;data manipulation&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;It is always a good practice to do some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; for the entire sample and by group before doing the test, so we have a broad overview of the data at hand.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# entire sample
summary(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       species    flipper_length_mm
##  Adelie   :152   Min.   :172.0    
##  Chinstrap: 68   1st Qu.:190.0    
##  Gentoo   :124   Median :197.0    
##                  Mean   :200.9    
##                  3rd Qu.:213.0    
##                  Max.   :231.0    
##                  NA&amp;#39;s   :2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# by group
library(doBy)
summaryBy(flipper_length_mm ~ species,
  data = dat,
  FUN = median,
  na.rm = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 2
##   species   flipper_length_mm.median
##   &amp;lt;fct&amp;gt;                        &amp;lt;dbl&amp;gt;
## 1 Adelie                         190
## 2 Chinstrap                      196
## 3 Gentoo                         216&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# boxplot by species
ggplot(dat) +
  aes(x = species, y = flipper_length_mm, fill = species) +
  geom_boxplot() +
  theme(legend.position = &amp;quot;none&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/index_files/figure-html/unnamed-chunk-3-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Based on the boxplots and the summary statistics, we already see that, in our &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt;, penguins from the Adelie species seem to have the smallest flippers, while those from the Gentoo species seem to have the biggest flippers. However, only a sound statistical test will tell us whether we can infer this conclusion to our &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;kruskal-wallis-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Kruskal-Wallis test&lt;/h1&gt;
&lt;div id=&#34;aim-and-hypotheses&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Aim and hypotheses&lt;/h2&gt;
&lt;p&gt;As mentioned earlier, the Kruskal-Wallis test allows to compare three or more groups. More precisely, it is used to compare three or more groups in terms of a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative variable&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It can be seen as the extension to the &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Mann-Whitney&lt;/a&gt; test which allows to compare 2 groups under the non-normality assumption.&lt;/p&gt;
&lt;p&gt;In the context of our example, we are going to use the Kruskal-Wallis test to help us answer the following question: “Is the length of the flippers different between the 3 species of penguins?”.&lt;/p&gt;
&lt;p&gt;The null and alternative hypotheses of the Kruskal-Wallis test are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: The 3 species are equal in terms of flipper length&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: At least one species is different from the other 2 species in terms of flipper length&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Be careful that, as for the ANOVA, the alternative hypothesis is &lt;strong&gt;&lt;em&gt;not&lt;/em&gt;&lt;/strong&gt; that all species are different in terms of flipper length. The opposite of all species being equal (&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;) is that &lt;em&gt;at least&lt;/em&gt; one species is different from the others (&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;In this sense, if the null hypothesis is rejected, it means that at least one species is different from the other 2, but not necessarily that all 3 species are different from each other. It could be that flipper length for the species Gentoo is different than for the species Chinstrap and Adelie, but flipper length is similar between Chinstrap and Adelie. Other types of test (known as post-hoc tests and covered later) must be performed to test whether all 3 species differ.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;assumptions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Assumptions&lt;/h2&gt;
&lt;p&gt;First, the Kruskal-Wallis test compares several groups in terms of a quantitative variable. So there must be one quantitative dependent variable (which corresponds to the measurements to which the question relates) and one qualitative independent variable (with at least 2 levels which will determine the groups to compare).&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;Second, remember that the Kruskal-Wallis test is a nonparametric test, so the &lt;strong&gt;normality assumption is not required&lt;/strong&gt;. However, the &lt;strong&gt;independence assumption still holds&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This means that the data, collected from a representative and randomly selected portion of the total population, should be independent between groups and within each group. The assumption of independence is most often verified based on the design of the experiment and on the good control of experimental conditions rather than via a formal test. If you are still unsure about independence based on the experiment design, ask yourself if one observation is related to another (if one observation has an impact on another) within each group or between the groups themselves. If not, it is most likely that you have independent samples. If observations between samples (forming the different groups to be compared) are dependent (for example, if three measurements have been collected on the &lt;strong&gt;same individuals&lt;/strong&gt; as it is often the case in medical studies when measuring a metric (i) before, (ii) during and (iii) after a treatment), the Friedman test should be preferred in order to take into account the dependency between the samples.&lt;/p&gt;
&lt;p&gt;Regarding the homoscedasticity (i.e., equality of the variances): As long as you use the Kruskal-Wallis test to, &lt;em&gt;in fine&lt;/em&gt;, compare groups, homoscedasticity is not required. If you wish to compare medians, the Kruskal-Wallis test requires homoscedasticity.&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In our example, independence is assumed and we do not need to compare medians (we are only interested in comparing groups), so we can proceed to how to do the test in R. Note that the normality assumption may or may not hold, but for this article we assume it is &lt;em&gt;not&lt;/em&gt; satisfied.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;In R&lt;/h2&gt;
&lt;p&gt;The Kruskal-Wallis test in R can be done with the &lt;code&gt;kruskal.test()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;kruskal.test(flipper_length_mm ~ species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Kruskal-Wallis rank sum test
## 
## data:  flipper_length_mm by species
## Kruskal-Wallis chi-squared = 244.89, df = 2, p-value &amp;lt; 2.2e-16&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The most important result in this output is the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;&lt;em&gt;p&lt;/em&gt;-value&lt;/a&gt;. We show how to interpret it in the next section.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;interpretations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Interpretations&lt;/h2&gt;
&lt;p&gt;Based on the Kruskal-Wallis test, we reject the null hypothesis and we conclude that at least one species is different in terms of flippers length (&lt;em&gt;p&lt;/em&gt;-value &amp;lt; 0.001).&lt;/p&gt;
&lt;p&gt;(&lt;em&gt;For the sake of illustration&lt;/em&gt;, if the &lt;em&gt;p&lt;/em&gt;-value was larger than the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;: we cannot reject the null hypothesis so we cannot reject the hypothesis that the 3 considered species of penguins are equal in terms of flippers length.)&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;post-hoc-tests&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Post-hoc tests&lt;/h1&gt;
&lt;p&gt;We have just showed that at least one species is different from the others in terms of flippers length. Nonetheless, here comes the limitations of the Kruskal-Wallis test: it does not say which group(s) is(are) different from the others.&lt;/p&gt;
&lt;p&gt;To know this, we need to use other types of test, referred as post-hoc tests (in Latin, “after this”, so after obtaining statistically significant Kruskal-Wallis results) or multiple pairwise-comparison tests. For the interested reader, a more detailed explanation of post-hoc tests can be found &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#post-hoc-test&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The most common post-hoc tests after a significant Kruskal-Wallis test are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dunn test&lt;/li&gt;
&lt;li&gt;Conover test&lt;/li&gt;
&lt;li&gt;Nemenyi test&lt;/li&gt;
&lt;li&gt;Pairwise Wilcoxon test&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The Dunn test being the most common one, here is how to do it in R.&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div id=&#34;dunn-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Dunn test&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(FSA)

dunnTest(flipper_length_mm ~ species,
  data = dat,
  method = &amp;quot;holm&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##           Comparison          Z      P.unadj        P.adj
## 1 Adelie - Chinstrap  -3.629336 2.841509e-04 2.841509e-04
## 2    Adelie - Gentoo -15.476612 4.990733e-54 1.497220e-53
## 3 Chinstrap - Gentoo  -8.931938 4.186100e-19 8.372200e-19&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is the last column (the adjusted &lt;em&gt;p&lt;/em&gt;-values, adjusted for multiple comparisons) that is of interest. These &lt;em&gt;p&lt;/em&gt;-values should be compared to your desired &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;significance level&lt;/a&gt; (usually 5%).&lt;/p&gt;
&lt;p&gt;Based on the output, we conclude that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Adelie and Chinstrap differ significantly (p &amp;lt; 0.001)&lt;/li&gt;
&lt;li&gt;Adelie and Gentoo differ significantly (p &amp;lt; 0.001)&lt;/li&gt;
&lt;li&gt;Chinstrap and Gentoo differ significantly (p &amp;lt; 0.001)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Therefore, based on the Dunn test, we can now conclude that &lt;strong&gt;all 3 species differ in terms of flipper length&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-statistical-results-and-plot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Combination of statistical results and plot&lt;/h1&gt;
&lt;p&gt;A very good alternative for performing a Kruskal-Wallis and the post-hoc tests in R is with the &lt;code&gt;ggbetweenstats()&lt;/code&gt; function from the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggstatsplot)

ggbetweenstats(
  data = dat,
  x = species,
  y = flipper_length_mm,
  type = &amp;quot;nonparametric&amp;quot;, # ANOVA or Kruskal-Wallis
  plot.type = &amp;quot;box&amp;quot;,
  pairwise.comparisons = TRUE,
  pairwise.display = &amp;quot;significant&amp;quot;,
  centrality.plotting = FALSE,
  bf.message = FALSE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/index_files/figure-html/unnamed-chunk-6-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This method has the advantage that all necessary statistical results are displayed directly on the plot.&lt;/p&gt;
&lt;p&gt;The results of the Kruskal-Wallis test are shown in the subtitle above the plot (the &lt;em&gt;p&lt;/em&gt;-value is after &lt;code&gt;p =&lt;/code&gt;). Moreover, the results of the post-hoc test are displayed between each group via accolades, and the boxplots allow to visualize the distribution for each species.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Summary&lt;/h1&gt;
&lt;p&gt;In this post, we reviewed the aim and hypotheses of the Kruskal-Wallis test and its underlying assumptions. We then showed how to do the test in R and how to interpret the results.&lt;/p&gt;
&lt;p&gt;We also showed the most common post-hoc test after a significant Kruskal-Wallis test—the Dunn test.&lt;/p&gt;
&lt;p&gt;Last but not least, we presented a concise way to present both the data by group and all the statistical results on the same plot.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-stevens2013intermediate&#34; class=&#34;csl-entry&#34;&gt;
Stevens, James P. 2013. &lt;em&gt;Intermediate Statistics: A Modern Approach&lt;/em&gt;. Routledge.
&lt;/div&gt;
&lt;/div&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;This is the case for small sample sizes. For large sample sizes, normality is not required (this is a common misconception!). By the &lt;a href=&#34;https://en.wikipedia.org/wiki/Central_limit_theorem&#34; target=&#34;_blank&#34;&gt;central limit theorem&lt;/a&gt;, sample means of large samples are often well-approximated by a normal distribution even if the data are not normally distributed &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-stevens2013intermediate&#34;&gt;Stevens 2013&lt;/a&gt;)&lt;/span&gt;. See more details in this &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#fn3&#34;&gt;note&lt;/a&gt;.&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;Note that in theory, Kruskal-Wallis test can also be used for only two groups. However, in practice we use the &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Mann-Whitney test&lt;/a&gt; for two groups and Kruskal-Wallis for three or more groups.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;See more information about the difference in this &lt;a href=&#34;https://influentialpoints.com/Training/Kruskal-Wallis_ANOVA_use_and_misuse.htm&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Note that there are other &lt;em&gt;p&lt;/em&gt;-value adjustment methods. See &lt;code&gt;?dunnTest&lt;/code&gt; for more options.&lt;a href=&#34;#fnref4&#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>Stats and R is 2 years old!</title>
      <link>https://statsandr.com/blog/statsandr-is-2-years-old/</link>
      <pubDate>Thu, 16 Dec 2021 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/statsandr-is-2-years-old/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#analytics&#34; id=&#34;toc-analytics&#34;&gt;Analytics&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#users-and-page-views&#34; id=&#34;toc-users-and-page-views&#34;&gt;Users and page views&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-over-time&#34; id=&#34;toc-page-views-over-time&#34;&gt;Page views over time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-per-channel&#34; id=&#34;toc-page-views-per-channel&#34;&gt;Page views per channel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-per-day-of-week-and-month-of-year&#34; id=&#34;toc-page-views-per-day-of-week-and-month-of-year&#34;&gt;Page views per day of week and month of year&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-per-month-and-year&#34; id=&#34;toc-page-views-per-month-and-year&#34;&gt;Page views per month and year&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#top-performing-pages&#34; id=&#34;toc-top-performing-pages&#34;&gt;Top performing pages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-by-country&#34; id=&#34;toc-page-views-by-country&#34;&gt;Page views by country&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#user-engagement-by-devices&#34; id=&#34;toc-user-engagement-by-devices&#34;&gt;User engagement by devices&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#browser-information&#34; id=&#34;toc-browser-information&#34;&gt;Browser information&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#end-note&#34; id=&#34;toc-end-note&#34;&gt;End note&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/statsandr-is-2-years-old.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Stats and R has been launched exactly two years ago. Like &lt;a href=&#34;https://statsandr.com/blog/track-blog-performance-in-r/&#34;&gt;last year&lt;/a&gt;, I think it is a good time to do a review of the past 12 months by sharing some figures about the audience of the blog.&lt;/p&gt;
&lt;p&gt;This article is not about showing off my numbers, but rather a way to illustrate &lt;strong&gt;how to analyze your blog or your website’s traffic using Google Analytics data&lt;/strong&gt;. Figures regarding the audience of my blog is probably useless to you (and I believe, should not be compared with). However, the code used in this post can be reused for your own blog or website (provided you also use Google Analytics to track your audience).&lt;/p&gt;
&lt;p&gt;Note that I use the &lt;code&gt;{googleAnalyticsR}&lt;/code&gt; R package to analyze my blog’s Google Analytics data. If you are unfamiliar with this package, see the &lt;a href=&#34;https://statsandr.com/blog/track-blog-performance-in-r/#prerequisites&#34;&gt;prerequisites&lt;/a&gt; first.&lt;/p&gt;
&lt;p&gt;If you have already used that package, you can select your account as followed (make sure to edit the code with your own property name):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(googleAnalyticsR)

accounts &amp;lt;- ga_account_list()

# select the view ID by property name
view_id &amp;lt;- accounts$viewId[which(accounts$webPropertyName == &amp;quot;statsandr.com&amp;quot;)]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On top of that, I also assume that you have basic knowledge of &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt;—a popular R package to draw nice plots and visualizations.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;analytics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Analytics&lt;/h1&gt;
&lt;p&gt;Last year, I mainly focused on the number of sessions. This year, I mainly concentrate on the number of page views to illustrate a different metrics.&lt;/p&gt;
&lt;p&gt;For your information, a &lt;strong&gt;session&lt;/strong&gt; is a group of user interactions with your website that take place within a given time frame, whereas a &lt;strong&gt;page view&lt;/strong&gt;, as the name suggests, is defined as a view of a page on your site.&lt;/p&gt;
&lt;p&gt;You can always change the metrics by editing &lt;code&gt;metrics = c(&#34;pageviews&#34;)&lt;/code&gt; in the code below. See all available metrics provided by Google Analytics in this &lt;a href=&#34;https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;users-and-page-views&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Users and page views&lt;/h2&gt;
&lt;p&gt;As for &lt;a href=&#34;https://statsandr.com/blog/track-blog-performance-in-r/&#34;&gt;last year’s review&lt;/a&gt;, let’s start with some general numbers, such as the number of &lt;strong&gt;users and page views&lt;/strong&gt; for the entire site.&lt;/p&gt;
&lt;p&gt;Note that we analyze traffic over the last year only so we extract data from December 16, 2020 to yesterday (December 15, 2021):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# set date range
start_date &amp;lt;- as.Date(&amp;quot;2020-12-16&amp;quot;)
end_date &amp;lt;- as.Date(&amp;quot;2021-12-15&amp;quot;)

# get Google Analytics (GA) data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;users&amp;quot;, &amp;quot;pageviews&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

gadata&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    users pageviews
## 1 549360    876280&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Over this past year, Stats and R has attracted &lt;strong&gt;549,360 users&lt;/strong&gt; (number of new and returning people who visited the site), who generated a total of &lt;strong&gt;876,280 page views&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;That is an average of &lt;em&gt;2401&lt;/em&gt; page views per day in 2021, compared to 1,531 page views per day in 2020 (an increase of 56.81%).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-over-time&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views over time&lt;/h2&gt;
&lt;p&gt;One of the first interesting metrics to analyze your blog’s audience is the evolution of traffic over time.&lt;/p&gt;
&lt;p&gt;The daily number of &lt;strong&gt;page views over time&lt;/strong&gt; can be presented in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#scatterplot&#34;&gt;scatterplot&lt;/a&gt;—together with a smoothed line—to analyze the &lt;strong&gt;evolution&lt;/strong&gt; of the audience of your blog:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get the Google Analytics (GA) data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;pageviews&amp;quot;), # edit for other metrics
  dimensions = c(&amp;quot;date&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# load required libraries
library(dplyr)
library(ggplot2)

# scatter plot with a trend line
gadata %&amp;gt;%
  ggplot(aes(x = date, y = pageviews)) +
  geom_point(size = 1L, color = &amp;quot;steelblue&amp;quot;) + # change size and color of points
  geom_smooth(color = &amp;quot;steelblue&amp;quot;, alpha = 0.25) + # change color of smoothed line and transparency of confidence interval
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Evolution of daily page views&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  theme(plot.margin = unit(c(5.5, 17.5, 5.5, 5.5), &amp;quot;pt&amp;quot;)) + # to avoid the plot being cut on the right edge
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Although the number of page views varies quite a bit (with an &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outlier&lt;/a&gt; at more than 5,000 page views in a day and as low as less than 1,000 page views for some days), it seems to be cyclical with a dip during summer. It is worth noting that the same dip appeared last year, probably due to the fact that people are less likely to read posts about &lt;a href=&#34;https://statsandr.com/tags/statistics/&#34;&gt;statistics&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/tags/r/&#34;&gt;R&lt;/a&gt; during summer holidays.&lt;/p&gt;
&lt;p&gt;So if you write about technical stuff in your blog, low numbers during summer may be expected and does not necessarily mean something is broken on your website.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-per-channel&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views per channel&lt;/h2&gt;
&lt;p&gt;Knowing &lt;strong&gt;how people come to your blog&lt;/strong&gt; is also a pretty important factor.&lt;/p&gt;
&lt;p&gt;Here is how to visualize the evolution of daily page views per channel in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#line-plot&#34;&gt;line plot&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Get the data
trend_data &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  dimensions = c(&amp;quot;date&amp;quot;),
  metrics = &amp;quot;pageviews&amp;quot;,
  pivots = pivot_ga4(&amp;quot;medium&amp;quot;, &amp;quot;pageviews&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# edit variable names
names(trend_data) &amp;lt;- c(&amp;quot;Date&amp;quot;, &amp;quot;Total&amp;quot;, &amp;quot;Organic&amp;quot;, &amp;quot;Referral&amp;quot;, &amp;quot;Direct&amp;quot;, &amp;quot;Email&amp;quot;, &amp;quot;Social&amp;quot;)

# Change the data into a long format
library(tidyr)
trend_long &amp;lt;- gather(trend_data, Channel, Page_views, -Date)

# Build up the line plot
trend_long %&amp;gt;%
  filter(Channel != &amp;quot;Total&amp;quot;) %&amp;gt;%
  ggplot() +
  aes(x = Date, y = Page_views, group = Channel) +
  theme_minimal() +
  geom_line(aes(colour = Channel)) +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Evolution of daily page views per channel&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see from the plot above, the large majority of page views come from the organic channel (so from search engines such as Google, Bing, etc.), with some peaks from referral (mainly from R-bloggers and RWeekly) when an article is published. (By the way, you can always &lt;a href=&#34;https://statsandr.com/subscribe/&#34;&gt;subscribe to the newsletter&lt;/a&gt; if you want to be informed by email when a new post goes out.)&lt;/p&gt;
&lt;p&gt;If you happen to write tutorials, you can also expect that most visitors come from the organic channel. If you are very present on social media, you will most likely attract more visitors from the social channel.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-per-day-of-week-and-month-of-year&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views per day of week and month of year&lt;/h2&gt;
&lt;p&gt;As seen in the previous plot, there are many ups and downs and traffic seems to be cyclical.&lt;/p&gt;
&lt;p&gt;To investigate this further, we draw a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; of the number of page views for each &lt;strong&gt;day of the week&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = c(&amp;quot;dayOfWeek&amp;quot;, &amp;quot;date&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

## Recoding gadata$dayOfWeek following GA naming conventions
gadata$dayOfWeek &amp;lt;- recode_factor(gadata$dayOfWeek,
  &amp;quot;0&amp;quot; = &amp;quot;Sunday&amp;quot;,
  &amp;quot;1&amp;quot; = &amp;quot;Monday&amp;quot;,
  &amp;quot;2&amp;quot; = &amp;quot;Tuesday&amp;quot;,
  &amp;quot;3&amp;quot; = &amp;quot;Wednesday&amp;quot;,
  &amp;quot;4&amp;quot; = &amp;quot;Thursday&amp;quot;,
  &amp;quot;5&amp;quot; = &amp;quot;Friday&amp;quot;,
  &amp;quot;6&amp;quot; = &amp;quot;Saturday&amp;quot;
)

## Reordering gadata$dayOfWeek to have Monday as first day of the week
gadata$dayOfWeek &amp;lt;- factor(gadata$dayOfWeek,
  levels = c(
    &amp;quot;Monday&amp;quot;, &amp;quot;Tuesday&amp;quot;, &amp;quot;Wednesday&amp;quot;, &amp;quot;Thursday&amp;quot;, &amp;quot;Friday&amp;quot;, &amp;quot;Saturday&amp;quot;,
    &amp;quot;Sunday&amp;quot;
  )
)

# Boxplot
gadata %&amp;gt;%
  ggplot(aes(x = dayOfWeek, y = pageviews)) +
  geom_boxplot(fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Page views per day of week&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-5-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We can also compute the sum and the mean number of page views per day to have a numerical summary instead of a plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# compute sum
dat_sum &amp;lt;- aggregate(pageviews ~ dayOfWeek,
  data = gadata,
  FUN = sum
)

# compute mean
dat_mean &amp;lt;- aggregate(pageviews ~ dayOfWeek,
  data = gadata,
  FUN = mean
)

# combine both in one table
dat_summary &amp;lt;- cbind(dat_sum, dat_mean[, 2])

# rename columns
names(dat_summary) &amp;lt;- c(&amp;quot;Day of week&amp;quot;, &amp;quot;Sum&amp;quot;, &amp;quot;Mean&amp;quot;)

# display table
dat_summary&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Day of week    Sum     Mean
## 1      Monday 141115 2713.750
## 2     Tuesday 143145 2752.788
## 3   Wednesday 146472 2763.623
## 4    Thursday 140712 2706.000
## 5      Friday 128223 2465.827
## 6    Saturday  85766 1649.346
## 7      Sunday  90847 1747.058&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As expected, there are more readers during the week compared to the weekends.&lt;/p&gt;
&lt;p&gt;The same analysis can be done for each &lt;strong&gt;month of the year&lt;/strong&gt; instead of days of the week:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = c(&amp;quot;month&amp;quot;, &amp;quot;date&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# Boxplot
gadata %&amp;gt;%
  ggplot(aes(x = month, y = pageviews)) +
  geom_boxplot(fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Month&amp;quot;,
    title = &amp;quot;Page views per month&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-7-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# compute sum
dat_sum &amp;lt;- aggregate(pageviews ~ month,
  data = gadata,
  FUN = sum
)

# compute mean
dat_mean &amp;lt;- aggregate(pageviews ~ month,
  data = gadata,
  FUN = mean
)

# combine both in one table
dat_summary &amp;lt;- cbind(dat_sum, dat_mean[, 2])

# rename columns
names(dat_summary) &amp;lt;- c(&amp;quot;Month&amp;quot;, &amp;quot;Sum&amp;quot;, &amp;quot;Mean&amp;quot;)

# display table
dat_summary&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    Month   Sum     Mean
## 1     01 68534 2210.774
## 2     02 80953 2891.179
## 3     03 92629 2988.032
## 4     04 88679 2955.967
## 5     05 81739 2636.742
## 6     06 64460 2148.667
## 7     07 49772 1605.548
## 8     08 46389 1496.419
## 9     09 68046 2268.200
## 10    10 79237 2556.032
## 11    11 77745 2591.500
## 12    12 78097 2519.258&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From the plots and the numerical summaries, it is clear that the number of page views is not the same between the days of the week and the months of the year.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-per-month-and-year&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views per month and year&lt;/h2&gt;
&lt;p&gt;If you have data over more than a year, it could be useful to compare your monthly blog’s traffic over the years.&lt;/p&gt;
&lt;p&gt;With the following code, we create a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt; of the number of &lt;strong&gt;daily page views per month and year&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# set new date range
start_date_launch &amp;lt;- as.Date(&amp;quot;2019-12-16&amp;quot;)

# get data
df2 &amp;lt;- google_analytics(view_id,
  date_range = c(start_date_launch, end_date),
  metrics = c(&amp;quot;pageviews&amp;quot;),
  dimensions = c(&amp;quot;date&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# add in year month columns to dataframe
df2$month &amp;lt;- format(df2$date, &amp;quot;%m&amp;quot;)
df2$year &amp;lt;- format(df2$date, &amp;quot;%Y&amp;quot;)

# page views by month by year using dplyr then graph using ggplot2 barplot
df2 %&amp;gt;%
  filter(year != 2019) %&amp;gt;% # remove 2019 because there are data for December only
  group_by(year, month) %&amp;gt;%
  summarize(pageviews = sum(pageviews)) %&amp;gt;%
  # print table steps by month by year
  # print(n = 100) %&amp;gt;%
  # graph data by month by year
  ggplot(aes(x = month, y = pageviews, fill = year)) +
  geom_bar(position = &amp;quot;dodge&amp;quot;, stat = &amp;quot;identity&amp;quot;) +
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Month&amp;quot;,
    title = &amp;quot;Page views per month and year&amp;quot;,
    subtitle = paste0(format(start_date_launch, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-8-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This barplot allows to easily see the evolution of the number of page views over the months, but more importantly, compare this evolution across different years.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;top-performing-pages&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Top performing pages&lt;/h2&gt;
&lt;p&gt;Another important factor when measuring the performance of your blog or website is the &lt;strong&gt;number of page views per pages&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It is true that the top performing pages in terms of page views over the year can easily be found in Google Analytics (you can access it via &lt;code&gt;Behavior &amp;gt; Site Content &amp;gt; All pages&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;However, for the interested reader, here is how to get the data in R (note that you can change &lt;code&gt;n = 7&lt;/code&gt; in the code below to change the number of top performing pages to display):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Make the request to GA
data_fetch &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;pageviews&amp;quot;),
  dimensions = c(&amp;quot;pageTitle&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

## Create a table of the most viewed posts
library(lubridate)
library(reactable)
library(stringr)

most_viewed_posts &amp;lt;- data_fetch %&amp;gt;%
  mutate(Title = str_trunc(pageTitle, width = 40)) %&amp;gt;% # keep maximum 40 characters
  count(Title, wt = pageviews, sort = TRUE)

head(most_viewed_posts, n = 7) # edit n for more or less pages to display&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                      Title      n
## 1    Outliers detection in R - Stats and R 119747
## 2 Descriptive statistics in R - Stats a... 109473
## 3 Variable types and examples - Stats a...  83025
## 4 Correlation coefficient and correlati...  65703
## 5 Chi-square test of independence in R ...  62100
## 6 The complete guide to clustering anal...  40440
## 7                 ANOVA in R - Stats and R  32914&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If like me you prefer a visualization over a table, here is how to draw this table of top performing pages in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
top_n(most_viewed_posts, n = 7, n) %&amp;gt;% # edit n for more or less pages to display
  ggplot(., aes(x = reorder(Title, n), y = n)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  coord_flip() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Page title&amp;quot;,
    title = &amp;quot;Top performing pages in terms of page views&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  theme(plot.margin = unit(c(5.5, 17.5, 5.5, 5.5), &amp;quot;pt&amp;quot;)) # to avoid the plot being cut on the right edge&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-10-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This gives me a good first overview on how posts performed in terms of page views, so in some sense, what people find useful. The top 3 articles in the past year were:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;Outliers detection in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;Descriptive statistics in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;Variable types and examples&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Be careful that this ranking is based on the total number of page views over the last 12 months. A recent article may thus be found at the bottom of the list simply because it collected page views over a &lt;em&gt;shorter&lt;/em&gt; period of time compared to an old article. So it is best to avoid comparing recent articles with older ones, or you can compare articles after having “time-normalized” the number of page views. See &lt;a href=&#34;https://statsandr.com/blog/track-blog-performance-in-r/#time-normalized-page-views&#34;&gt;previous year’s review&lt;/a&gt; for more details and illustrations of this metrics.&lt;/p&gt;
&lt;p&gt;You could also be interested in knowing the worst performing ones (to eventually improve them or include them in higher quality posts):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tail(subset(most_viewed_posts, n &amp;gt; 1000),
  n = 7
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                       Title    n
## 49 A guide on how to read statistical ta... 1477
## 50                      About - Stats and R 1470
## 51 How to embed a Shiny app in blogdown?... 1455
## 52                   About me - Stats and R 1277
## 53 One-proportion and chi-square goodnes... 1226
## 54 Running pace calculator in R Shiny - ... 1049
## 55                      Shiny - Stats and R 1018&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that I intentionally excluded pages with less than 1000 views to remove deleted or hidden pages from the ranking.&lt;/p&gt;
&lt;p&gt;Another issue with this ranking is that it may be biased due to some pages which have been duplicated (if you edited the title for example), but at least you have a broad idea of the worst performing pages.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-by-country&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views by country&lt;/h2&gt;
&lt;p&gt;Knowing the &lt;strong&gt;country where your readers come from&lt;/strong&gt; may also be handy for some content creators or marketers.&lt;/p&gt;
&lt;p&gt;Location of my readers is not really important for me because I intend to write for everyone, but this may be completely the opposite if you are selling things or running a business/ecommerce.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get GA data
data_fetch &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = &amp;quot;country&amp;quot;,
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# table
countries &amp;lt;- data_fetch %&amp;gt;%
  mutate(Country = str_trunc(country, width = 40)) %&amp;gt;% # keep maximum 40 characters
  count(Country, wt = pageviews, sort = TRUE)

head(countries, n = 10) # edit n for more or less countries to display&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##           Country      n
## 1   United States 244752
## 2           India  71797
## 3  United Kingdom  53272
## 4         Germany  38322
## 5          Canada  33812
## 6         Belgium  26421
## 7       Australia  26225
## 8     Philippines  23193
## 9     Netherlands  21944
## 10         Brazil  17956&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Again, if you prefer a plot over a table, you can visualize the top countries in terms of page views in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
top_n(countries, n = 10, n) %&amp;gt;% # edit n for more or less countries to display
  ggplot(., aes(x = reorder(Country, n), y = n)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  coord_flip() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Country&amp;quot;,
    title = &amp;quot;Top performing countries in terms of page views&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  theme(plot.margin = unit(c(5.5, 7.5, 5.5, 5.5), &amp;quot;pt&amp;quot;)) # to avoid the plot being cut on the right edge&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-13-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We see that a large share of readers are from the US—and Belgium (my country) comes only in &lt;span class=&#34;math inline&#34;&gt;\(6^{th}\)&lt;/span&gt; place in terms of number of page views.&lt;/p&gt;
&lt;p&gt;Be careful that, as the number of people located in different countries differs widely, this ranking may hide some insights if you are comparing page views by countries in absolute terms. See why in this &lt;a href=&#34;https://statsandr.com/blog/track-blog-performance-in-r/#page-views-by-country&#34;&gt;section&lt;/a&gt; of last year’s review.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;user-engagement-by-devices&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;User engagement by devices&lt;/h2&gt;
&lt;p&gt;One may also be interested in checking &lt;strong&gt;how users are engaged&lt;/strong&gt; depending on device’s type. To investigate this, we plot 3 charts describing:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;How &lt;strong&gt;page views&lt;/strong&gt; are distributed by type of device?&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;average time on page&lt;/strong&gt; (in seconds) by type of device&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;number of page views per session&lt;/strong&gt; by device type&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So first, how page views are distributed by device type?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# GA data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;pageviews&amp;quot;, &amp;quot;avgTimeOnPage&amp;quot;),
  dimensions = c(&amp;quot;date&amp;quot;, &amp;quot;deviceCategory&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# plot pageviews by deviceCategory
gadata %&amp;gt;%
  ggplot(aes(deviceCategory, pageviews)) +
  geom_bar(aes(fill = deviceCategory), stat = &amp;quot;identity&amp;quot;) +
  theme_minimal() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Page views per device&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;,
    fill = &amp;quot;Device&amp;quot; # edit legend title
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-14-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the above plot, we see that the large majority of readers visited the blog from a desktop and only a very small proportion comes from a tablet.&lt;/p&gt;
&lt;p&gt;This makes sense since I guess many visitors are reading my articles or tutorials while using R (which is only available on desktop).&lt;/p&gt;
&lt;p&gt;However, this information of total number of page views per device type does not tell me anything about the time spent on each page and thus the engagement by device type. The following plot answers this question:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# add median of average time on page per device
gadata &amp;lt;- gadata %&amp;gt;%
  group_by(deviceCategory) %&amp;gt;%
  mutate(med = median(avgTimeOnPage))

# plot avgTimeOnPage by deviceCategory
ggplot(gadata) +
  aes(x = avgTimeOnPage, fill = deviceCategory) +
  geom_histogram(bins = 30L) +
  scale_fill_hue() +
  theme_minimal() +
  theme(legend.position = &amp;quot;none&amp;quot;) +
  facet_wrap(vars(deviceCategory)) +
  labs(
    y = &amp;quot;Frequency&amp;quot;,
    x = &amp;quot;Average time on page (in seconds)&amp;quot;,
    title = &amp;quot;Average time on page per device&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  geom_vline(aes(xintercept = med, group = deviceCategory),
    color = &amp;quot;darkgrey&amp;quot;,
    linetype = &amp;quot;dashed&amp;quot;
  ) +
  geom_text(
    aes(
      x = med, y = 125,
      label = paste0(&amp;quot;Median = &amp;quot;, round(med), &amp;quot; seconds&amp;quot;)
    ),
    angle = 90,
    vjust = 3,
    color = &amp;quot;darkgrey&amp;quot;,
    size = 3
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-15-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the above plot, we see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Most readers coming from a tablet actually leave the page very quickly (see the peak around 0 second in the tablet facet).&lt;/li&gt;
&lt;li&gt;Distributions of the average time on page for readers on desktop and mobile were quite similar, with an average time on page mostly between 125 seconds (= 2 minutes and 5 seconds) and 375 seconds (= 6 minutes and 15 seconds).&lt;/li&gt;
&lt;li&gt;Quite surprisingly, the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#median&#34;&gt;median&lt;/a&gt; of the average time spent on page is slightly higher for visitors on mobile than on desktop (median = 316 seconds on mobile and 266 seconds on desktop, see the dashed vertical lines representing the medians in the desktop and mobile facets). This indicates that, although more people visit the blog from desktop (as shown by the total number of page views by device), it seems that &lt;strong&gt;people on mobile spend more time per page&lt;/strong&gt;. I find this result quite surprising given that most of my articles include R code and require a computer to run the code. Therefore, I expected that people would spend more time on desktop than on mobile because on mobile they would quickly scan the article, while on desktop they would read the article more carefully and try to reproduce the code on their own computer. At least that is what I do when I read blogs on mobile versus reading them on desktop. What is even more intriguing, is that it was already the case &lt;a href=&#34;https://statsandr.com/blog/track-blog-performance-in-r/#user-engagement-by-devices&#34;&gt;last year&lt;/a&gt;. If someone finds similar results and have a possible explanation, I would be glad to hear from her (if possible, in the comments at the end of the article so everyone can benefit from the discussion).&lt;/li&gt;
&lt;li&gt;As a side note, we see that these medians are higher this year compared to last year (266, 316 and 114 seconds in 2021 compared to 190, 228 and 106 seconds in 2020 on desktop, mobile and tablet, respectively). This is somewhat encouraging because it indicates that people spend more time on each page (which is an indication, at least partially, of the quality of the blog for Google).&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;/ul&gt;
&lt;p&gt;Given this result, I also believe it is helpful to illustrate the &lt;strong&gt;number of page views during a session&lt;/strong&gt; by device type.&lt;/p&gt;
&lt;p&gt;In fact, it may be the case that visitors on mobile spend, on average, more time on each page &lt;em&gt;but people on desktop visit more pages per session&lt;/em&gt; (remember that a session is a set of interactions with your website that take place within a given time frame).&lt;/p&gt;
&lt;p&gt;We verify this belief via a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#density-plot&#34;&gt;density plot&lt;/a&gt;, and for better readability we exclude visits from tablet:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# GA data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;pageviewsPerSession&amp;quot;),
  dimensions = c(&amp;quot;date&amp;quot;, &amp;quot;deviceCategory&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# add median of number of page views/session
gadata &amp;lt;- gadata %&amp;gt;%
  group_by(deviceCategory) %&amp;gt;%
  mutate(med = median(pageviewsPerSession))

## Reordering gadata$deviceCategory
gadata$deviceCategory &amp;lt;- factor(gadata$deviceCategory,
  levels = c(&amp;quot;mobile&amp;quot;, &amp;quot;desktop&amp;quot;, &amp;quot;tablet&amp;quot;)
)

# plot pageviewsPerSession by deviceCategory
gadata %&amp;gt;%
  filter(deviceCategory != &amp;quot;tablet&amp;quot;) %&amp;gt;% # filter out pageviewsPerSession &amp;gt; 2.5 and visits from tablet
  ggplot(aes(x = pageviewsPerSession, fill = deviceCategory, color = deviceCategory)) +
  geom_density(alpha = 0.5) +
  scale_fill_hue() +
  theme_minimal() +
  labs(
    y = &amp;quot;Frequency&amp;quot;,
    x = &amp;quot;Page views per session&amp;quot;,
    title = &amp;quot;Page views per session by device&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com\nDashed lines represent the medians&amp;quot;,
    color = &amp;quot;Device&amp;quot;, # edit legend title
    fill = &amp;quot;Device&amp;quot; # edit legend title
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  geom_vline(aes(xintercept = med, group = deviceCategory, color = deviceCategory),
    linetype = &amp;quot;dashed&amp;quot;,
    show.legend = FALSE # remove legend
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-16-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This last plot shows that readers on desktop and mobile visit approximately the same number of pages per session, as indicated by the fact that the two distributions overlap each other and are not distant from each other. It is true that the median is higher for people on desktop than on mobile, but to a very small margin only (and the difference between the two is smaller than in last year’s review).&lt;/p&gt;
&lt;p&gt;So to summarize what we learned based on the 3 last plots, we now know that&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;most readers visited the blog from desktop;&lt;/li&gt;
&lt;li&gt;readers on mobile spent more time on each page than readers on desktop (and even more compared to readers on tablet);&lt;/li&gt;
&lt;li&gt;users on desktop and mobile seem to have visited approximately the same number of pages per session.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One may wonder why I chose to compare medians instead of means. The main reason is that the median is a more robust way to represent &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;non-normal&lt;/a&gt; data. For the interested reader, see a note on the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#mean-vs.-median&#34;&gt;difference between mean and median&lt;/a&gt;, and the context in which each measure is more appropriate.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;browser-information&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Browser information&lt;/h2&gt;
&lt;p&gt;From a more technical perspective, you could also be interested in the number of &lt;strong&gt;page views by browser&lt;/strong&gt;. I am personally not really interested in knowing which browser my visitors are using the most (mostly because this blog is available on all common browsers), but the most geeky among you may be so.&lt;/p&gt;
&lt;p&gt;This information can be visualized with the following &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get data
browser_info &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;pageviews&amp;quot;),
  dimensions = c(&amp;quot;browser&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# table
browser &amp;lt;- browser_info %&amp;gt;%
  mutate(Browser = str_trunc(browser, width = 40)) %&amp;gt;% # keep maximum 40 characters
  count(Browser, wt = pageviews, sort = TRUE)

# plot
top_n(browser, n = 10, n) %&amp;gt;% # edit n for more or less browser to display
  ggplot(., aes(x = reorder(Browser, n), y = n)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  coord_flip() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Browser&amp;quot;,
    title = &amp;quot;Which browsers are our visitors using?&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/statsandr-is-2-years-old/index_files/figure-html/unnamed-chunk-17-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Most readers visited the site using &lt;em&gt;Chrome&lt;/em&gt;, &lt;em&gt;Safari&lt;/em&gt; and &lt;em&gt;Firefox&lt;/em&gt; (this was expected since they are the most common browsers).&lt;/p&gt;
&lt;p&gt;This was the last metrics presented in this review. Of course, many more are possible depending on your R skills (mainly, &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;data manipulation&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt;) and your expertise in SEO or analyzing Google Analytics data. Hopefully, thanks to this review and possibly from &lt;a href=&#34;https://statsandr.com/blog/track-blog-performance-in-r/&#34;&gt;last year&lt;/a&gt; too, you will be able to analyze your own blog or website using R and the &lt;code&gt;{googleAnalyticsR}&lt;/code&gt; package. At least, this was the aim of the present article.&lt;/p&gt;
&lt;p&gt;For those of you who are interested in a more condensed analysis, see my &lt;a href=&#34;https://antoinesoetewey.com/files/google-analytics-dashboard&#34;&gt;custom Google Analytics dashboard&lt;/a&gt;.&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;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;end-note&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;End note&lt;/h1&gt;
&lt;p&gt;I would also like to add that these figures are not done to be compared with. Every website or blog is unique, every author is unique (with different priorities and different agendas) and more is not always better. I &lt;a href=&#34;https://statsandr.com/blog/7-benefits-of-sharing-your-code-in-a-data-science-blog/#learn-by-writing&#34;&gt;learn a lot&lt;/a&gt; thanks to this blog, I use it for &lt;a href=&#34;https://statsandr.com/blog/7-benefits-of-sharing-your-code-in-a-data-science-blog/#personal-note-to-remind-my-future-self&#34;&gt;personal purposes&lt;/a&gt; and for my students as part of my &lt;a href=&#34;https://antoinesoetewey.com/teaching/&#34;&gt;teaching&lt;/a&gt; tasks. I will keep writing on it as long as I enjoy it and as long as I have the time to do so, not matter how low or high the number of clicks.&lt;/p&gt;
&lt;p&gt;Thanks to all readers of the past year, and see you in a year for another review! In the meantime, if you maintain a blog I would be really happy to hear how you track its performance.&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;More time spend on each page is a favorable factor for Google because it means that people are reading it more carefully. If the blog or the post is of mediocre quality, users tend to bounce back quickly (known as bounce rate) and look for an answer to their question somewhere else (leading ultimately to less time spend on the page or site).&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 the &lt;a href=&#34;https://blog.rstudio.com/2021/01/06/google-analytics-part2/&#34; target=&#34;_blank&#34;&gt;RStudio blog&lt;/a&gt; for the inspiration.&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>Multiple linear regression made simple</title>
      <link>https://statsandr.com/blog/multiple-linear-regression-made-simple/</link>
      <pubDate>Mon, 04 Oct 2021 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/multiple-linear-regression-made-simple/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#simple-linear-regression-reminder&#34; id=&#34;toc-simple-linear-regression-reminder&#34;&gt;Simple linear regression: reminder&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#principle&#34; id=&#34;toc-principle&#34;&gt;Principle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#equation&#34; id=&#34;toc-equation&#34;&gt;Equation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interpretations-of-coefficients-widehatbeta&#34; id=&#34;toc-interpretations-of-coefficients-widehatbeta&#34;&gt;Interpretations of coefficients &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta\)&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#another-interpretation-of-the-intercept&#34; id=&#34;toc-another-interpretation-of-the-intercept&#34;&gt;Another interpretation of the intercept&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#significance-of-the-relationship&#34; id=&#34;toc-significance-of-the-relationship&#34;&gt;Significance of the relationship&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-does-not-imply-causation&#34; id=&#34;toc-correlation-does-not-imply-causation&#34;&gt;Correlation does not imply causation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conditions-of-application&#34; id=&#34;toc-conditions-of-application&#34;&gt;Conditions of application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualizations&#34; id=&#34;toc-visualizations&#34;&gt;Visualizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#multiple-linear-regression&#34; id=&#34;toc-multiple-linear-regression&#34;&gt;Multiple linear regression&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#principle-1&#34; id=&#34;toc-principle-1&#34;&gt;Principle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#equation-1&#34; id=&#34;toc-equation-1&#34;&gt;Equation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interpretations-of-coefficients-widehatbeta-1&#34; id=&#34;toc-interpretations-of-coefficients-widehatbeta-1&#34;&gt;Interpretations of coefficients &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta\)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conditions-of-application-1&#34; id=&#34;toc-conditions-of-application-1&#34;&gt;Conditions of application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-choose-a-good-linear-model&#34; id=&#34;toc-how-to-choose-a-good-linear-model&#34;&gt;How to choose a good linear model?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#p-value-associated-to-the-model&#34; id=&#34;toc-p-value-associated-to-the-model&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(P\)&lt;/span&gt;-value associated to the model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coefficient-of-determination-r2&#34; id=&#34;toc-coefficient-of-determination-r2&#34;&gt;Coefficient of determination &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#parsimony&#34; id=&#34;toc-parsimony&#34;&gt;Parsimony&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualizations-1&#34; id=&#34;toc-visualizations-1&#34;&gt;Visualizations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#to-go-further&#34; id=&#34;toc-to-go-further&#34;&gt;To go further&lt;/a&gt;
&lt;ul&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;#automatic-reporting&#34; id=&#34;toc-automatic-reporting&#34;&gt;Automatic reporting&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#predictions&#34; id=&#34;toc-predictions&#34;&gt;Predictions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#linear-hypothesis-tests&#34; id=&#34;toc-linear-hypothesis-tests&#34;&gt;Linear hypothesis tests&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#overall-effect-of-categorical-variables&#34; id=&#34;toc-overall-effect-of-categorical-variables&#34;&gt;Overall effect of categorical variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interaction&#34; id=&#34;toc-interaction&#34;&gt;Interaction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#summary&#34; id=&#34;toc-summary&#34;&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/multiple-linear-regression.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Remember that &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; is a branch of statistics that allows to describe your data at hand.&lt;/p&gt;
&lt;p&gt;Inferential statistics (with the popular &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt; and confidence intervals) is another branch of statistics that allows to make inferences, that is, to draw conclusions about a population based on a &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The last branch of statistics is about &lt;strong&gt;modeling the relationship between two or more variables&lt;/strong&gt;.&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; The most common statistical tool to describe and evaluate the link between variables is linear regression.&lt;/p&gt;
&lt;p&gt;There are two types of linear regression:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;Simple linear regression&lt;/strong&gt; is a statistical approach that allows to assess the linear relationship between two &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative variables&lt;/a&gt;. More precisely, it enables the relationship to be quantified and its significance to be evaluated.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple linear regression&lt;/strong&gt; is a generalization of simple linear regression, in the sense that this approach makes it possible to evaluate the linear relationships between a response variable (quantitative) and several explanatory variables (quantitative or &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the real world, multiple linear regression is used more frequently than simple linear regression. This is mostly the case because:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Multiple linear regression allows to evaluate the relationship between two variables, while &lt;strong&gt;controlling for the effect&lt;/strong&gt; (i.e., removing the effect) &lt;strong&gt;of other variables&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;With data collection becoming easier, more variables can be included and taken into account when analyzing data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Multiple linear regression being such a powerful statistical tool, I would like to present it so that everyone understands it, and perhaps even use it when deemed necessary. However, I cannot afford to write about multiple linear regression without first presenting simple linear regression.&lt;/p&gt;
&lt;p&gt;So after a reminder about the principle and the interpretations that can be drawn from a simple linear regression, I will illustrate how to perform multiple linear regression in R. I will also show, in the context of multiple linear regression, how to interpret the output and discuss about its conditions of application. I will then conclude the article by presenting more advanced topics directly linked to linear regression.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;simple-linear-regression-reminder&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Simple linear regression: reminder&lt;/h1&gt;
&lt;p&gt;Simple linear regression is an asymmetric procedure in which:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;one of the variable is considered the response or the variable to be explained. It is also called &lt;strong&gt;dependent variable&lt;/strong&gt;, and is represented on the &lt;span class=&#34;math inline&#34;&gt;\(y\)&lt;/span&gt;-axis&lt;/li&gt;
&lt;li&gt;the other variable is the explanatory or also called &lt;strong&gt;independent variable&lt;/strong&gt;, and is represented on the &lt;span class=&#34;math inline&#34;&gt;\(x\)&lt;/span&gt;-axis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Simple linear regression allows to &lt;strong&gt;evaluate the existence of a &lt;em&gt;linear&lt;/em&gt; relationship between two variables&lt;/strong&gt; and to quantify this link. Note that linearity is a strong assumption in linear regression in the sense that it tests and quantifies whether the two variables are &lt;em&gt;linearly&lt;/em&gt; dependent.&lt;/p&gt;
&lt;p&gt;What makes linear regression a powerful statistical tool is that it allows to &lt;strong&gt;quantify by what quantity the response/dependent variable varies when the explanatory/independent variable increases by one unit&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This concept is key in linear regression and helps to answer the following questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is there a link between the amount spent in advertising and the sales during a certain period?&lt;/li&gt;
&lt;li&gt;Is the number of years of schooling valued, in financial terms, in the first job?&lt;/li&gt;
&lt;li&gt;Will an increase in tobacco taxes reduce its consumption?&lt;/li&gt;
&lt;li&gt;What is the most likely price of an apartment, depending on the area?&lt;/li&gt;
&lt;li&gt;Does a person’s reaction time to a stimulus depend on gender?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Simple linear regression can be seen as an extension to the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;analysis of variance (ANOVA)&lt;/a&gt; and the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test&lt;/a&gt;. ANOVA and t-test allow to compare groups in terms of a quantitative variable—2 groups for t-test and 3 or more groups for ANOVA.&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;For these tests, the independent variable, that is, the grouping variable forming the different groups to compare must be a qualitative variable. Linear regression is an extension because in addition to be used to compare groups, it is also used with quantitative independent variables (which is not possible with t-test and ANOVA).&lt;/p&gt;
&lt;p&gt;In this article, we are interested in assessing whether there is a linear relationship between the distance traveled with a gallon of fuel and the weight of cars. For this example, we use the &lt;code&gt;mtcars&lt;/code&gt; dataset (preloaded in R).&lt;/p&gt;
&lt;p&gt;The dataset includes fuel consumption and 10 aspects of automotive design and performance for 32 automobiles:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;mpg&lt;/code&gt; Miles/(US) gallon (with a gallon &lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 3.79 liters)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cyl&lt;/code&gt; Number of cylinders&lt;/li&gt;
&lt;li&gt;&lt;code&gt;disp&lt;/code&gt; Displacement (cu.in.)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hp&lt;/code&gt; Gross horsepower&lt;/li&gt;
&lt;li&gt;&lt;code&gt;drat&lt;/code&gt; Rear axle ratio&lt;/li&gt;
&lt;li&gt;&lt;code&gt;wt&lt;/code&gt; Weight (1000 lbs, with 1000 lbs &lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 453.59 kg)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;qsec&lt;/code&gt; 1/4 mile time (with 1/4 mile &lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 402.34 meters)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;vs&lt;/code&gt; Engine (0 = V-shaped, 1 = straight)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;am&lt;/code&gt; Transmission (0 = automatic, 1 = manual)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gear&lt;/code&gt; Number of forward gears&lt;/li&gt;
&lt;li&gt;&lt;code&gt;carb&lt;/code&gt; Number of carburetors&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- mtcars

library(ggplot2)
ggplot(dat, aes(x = wt, y = mpg)) +
  geom_point() +
  labs(
    y = &amp;quot;Miles per gallon&amp;quot;,
    x = &amp;quot;Car&amp;#39;s weight (1000 lbs)&amp;quot;
  ) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-1-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/#scatter-plot&#34;&gt;scatterplot&lt;/a&gt; above shows that there seems to be a &lt;strong&gt;negative relationship between the distance traveled with a gallon of fuel and the weight of a car&lt;/strong&gt;. This makes sense, as the heavier the car, the more fuel it consumes and thus the fewer miles it can drive with a gallon.&lt;/p&gt;
&lt;p&gt;This is already a good overview of the relationship between the two variables, but a simple linear regression with the miles per gallon as dependent variable and the car’s weight as independent variable goes further. It will tell us by &lt;strong&gt;how many miles the distance varies, on average, when the weight varies by one unit&lt;/strong&gt; (1000 lbs in this case). This is possible thanks to the regression line.&lt;/p&gt;
&lt;div id=&#34;principle&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Principle&lt;/h2&gt;
&lt;p&gt;The principle of simple linear regression is to &lt;strong&gt;find the line&lt;/strong&gt; (i.e., determine its equation) &lt;strong&gt;which passes as close as possible to the observations&lt;/strong&gt;, that is, the set of points formed by the pairs &lt;span class=&#34;math inline&#34;&gt;\((x_i, y_i)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In the first step, there are many potential lines. Three of them are plotted:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-2-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To find the line which passes as close as possible to all the points, we take the square of the vertical distance between each point and each potential line. Note that we take the square of the distances to make sure that a negative gap (i.e., a point below the line) is not compensated by a positive gap (i.e., a point above the line). The line which passes closest to the set of points is the one which &lt;strong&gt;&lt;em&gt;minimizes&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;the sum of these squared distances&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The resulting regression line is presented in blue in the following plot, and the dashed gray lines represent the vertical distance between the points and the fitted line. These vertical distances between each observed point and the fitted line determined by the least squares method are called the &lt;strong&gt;residuals&lt;/strong&gt; of the linear regression model and denoted &lt;span class=&#34;math inline&#34;&gt;\(\epsilon\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-3-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;By definition, there is no other line with a smaller total distance between the points and the line. This method is called the least squares method, or &lt;strong&gt;OLS&lt;/strong&gt; for &lt;strong&gt;ordinary least squares&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;equation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Equation&lt;/h2&gt;
&lt;p&gt;The regression model can be written in the form of the equation:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[Y = \beta_0 + \beta_1 X + \epsilon\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; the dependent variable&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; the independent variable&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\beta_0\)&lt;/span&gt; the intercept (the mean value of &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; when &lt;span class=&#34;math inline&#34;&gt;\(x = 0\)&lt;/span&gt;), also sometimes denoted &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt; the slope (the expected increase in &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; when &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; increases by one unit)&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\epsilon\)&lt;/span&gt; the residuals (the error term of mean 0 which describes the variations of &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; not captured by the model, also referred as the noise)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When we determine the line which passes closest to all the points (we say that we fit a line to the observed data), we actually &lt;strong&gt;estimate the unknown parameters &lt;span class=&#34;math inline&#34;&gt;\(\beta_0\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt;&lt;/strong&gt; based on the data at hand. Remember from your geometry classes, to draw a line you only need two parameters—the intercept and the slope.&lt;/p&gt;
&lt;p&gt;These estimates (and thus the blue line shown in the previous scatterplot) can be computed by hand with the following formulas:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
\widehat\beta_1 &amp;amp;= \frac{\sum^n_{i = 1} (x_i - \bar{x})(y_i - \bar{y})}{\sum^n_{i = 1}(x_i - \bar{x})^2} \\
&amp;amp;= \frac{\left(\sum^n_{i = 1}x_iy_i\right) - n\bar{x}\bar{y}}{\sum^n_{i = 1}(x_i - \bar{x})^2}
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\widehat\beta_0 = \bar{y} - \widehat\beta_1 \bar{x}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;with &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\bar{y}\)&lt;/span&gt; denoting the sample mean of &lt;span class=&#34;math inline&#34;&gt;\(x\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(y\)&lt;/span&gt;, respectively.&lt;/p&gt;
&lt;p&gt;(If you struggle to compute &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_0\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1\)&lt;/span&gt; by hand, see this &lt;a href=&#34;https://statsandr.com/blog/a-shiny-app-for-simple-linear-regression-by-hand-and-in-r/&#34;&gt;Shiny app&lt;/a&gt; which helps you to easily find these estimates based on your data.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;interpretations-of-coefficients-widehatbeta&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Interpretations of coefficients &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta\)&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;intercept &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_0\)&lt;/span&gt;&lt;/strong&gt; is the &lt;strong&gt;mean value of the dependent variable &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; when the independent variable &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; takes the value 0&lt;/strong&gt;. Its estimation has no interest in evaluating whether there is a linear relationship between two variables. It has, however, an interest if you want to know what the mean value of &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; could be when &lt;span class=&#34;math inline&#34;&gt;\(x = 0\)&lt;/span&gt;.&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;slope &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1\)&lt;/span&gt;&lt;/strong&gt;, on the other hand, corresponds to the expected &lt;strong&gt;variation of &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; when &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; varies by one unit&lt;/strong&gt;. It tells us two important informations:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The &lt;strong&gt;sign of the slope&lt;/strong&gt; indicates the &lt;strong&gt;direction of the line&lt;/strong&gt;—a positive slope (&lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1 &amp;gt; 0\)&lt;/span&gt;) indicates that there is a positive relationship between the two variables of interest (they vary in the same direction), whereas a negative slope (&lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1 &amp;lt; 0\)&lt;/span&gt;) means that there is a negative relationship between the two variables (they vary in opposite directions).&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;value of the slope&lt;/strong&gt; provides information on the &lt;strong&gt;speed of evolution&lt;/strong&gt; of the variable &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; as a function of the variable &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;. The larger the slope in absolute value, the larger the expected variation of &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; for each unit of &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;. Note, however, that a large value does not necessarily mean that the relationship is statistically significant (more on that in the section about &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#significance-of-the-relationship&#34;&gt;significance of the relationship&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is similar to the &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation coefficient&lt;/a&gt;, which gives information about the direction and the strength of the relationship between two variables.&lt;/p&gt;
&lt;p&gt;To perform a linear regression in R, we use the &lt;code&gt;lm()&lt;/code&gt; function (which stands for linear model). The function requires to set the dependent variable first then the independent variable, separated by a tilde (&lt;code&gt;~&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Applied to our example of weight and car’s consumption, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- lm(mpg ~ wt, data = dat)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;summary()&lt;/code&gt; function gives the results of the model:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt, data = dat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.5432 -2.3647 -0.1252  1.4096  6.8727 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)  37.2851     1.8776  19.858  &amp;lt; 2e-16 ***
## wt           -5.3445     0.5591  -9.559 1.29e-10 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 3.046 on 30 degrees of freedom
## Multiple R-squared:  0.7528,	Adjusted R-squared:  0.7446 
## F-statistic: 91.38 on 1 and 30 DF,  p-value: 1.294e-10&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In practice, we usually check the conditions of application &lt;em&gt;before&lt;/em&gt; interpreting the coefficients (because if they are not respected, results may be biased).&lt;/p&gt;
&lt;p&gt;In this article, however, I present the interpretations before testing the conditions because the point is to show how to interpret the results, and less about finding a valid model.&lt;/p&gt;
&lt;p&gt;The results can be summarized as follows (see the column &lt;code&gt;Estimate&lt;/code&gt; in the table &lt;code&gt;Coefficients&lt;/code&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The intercept &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_0 =\)&lt;/span&gt; 37.29 indicates that, for a hypothetical car weighting 0 lbs, we can expect, on average, a consumption of 37.29 miles/gallon. This interpretation is shown for illustrative purposes, but as a car weighting 0 lbs is impossible, the interpretation has no meaning. In practice, we would therefore refrain from interpreting the intercept in this case. See another interpretation of the intercept when the independent variable is centered around its mean in this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#another-interpretation-of-the-intercept&#34;&gt;section&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The slope &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1 =\)&lt;/span&gt; -5.34 indicates that:
&lt;ul&gt;
&lt;li&gt;There is a &lt;strong&gt;negative relationship&lt;/strong&gt; between the weight and the distance a car can drive with a gallon (this was expected given the negative trend of the points in the scatterplot shown previously).&lt;/li&gt;
&lt;li&gt;But more importantly, a slope of -5.34 means that, for an increase of one unit in the weight (that is, an increase of 1000 lbs), the number of miles per gallon decreases, on average, by 5.34 units. In other words, &lt;strong&gt;for an increase of 1000 lbs, the number of miles/gallon decreases, on average, by 5.34&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;another-interpretation-of-the-intercept&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Another interpretation of the intercept&lt;/h3&gt;
&lt;p&gt;Another useful interpretation of the intercept is when the independent variable is centered around its mean. In this case, the intercept is interpreted as the mean value of &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; for individuals who have a value of &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; equal to the mean of &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Let’s see it in practice.&lt;/p&gt;
&lt;p&gt;We first center the &lt;code&gt;wt&lt;/code&gt; variable around the mean then rerun a simple linear model with this new variable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat_centered &amp;lt;- dat

dat_centered$wt_centered &amp;lt;- dat$wt - mean(dat$wt)

mod_centered &amp;lt;- lm(mpg ~ wt_centered,
  data = dat_centered
)

summary(mod_centered)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt_centered, data = dat_centered)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.5432 -2.3647 -0.1252  1.4096  6.8727 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)  20.0906     0.5384  37.313  &amp;lt; 2e-16 ***
## wt_centered  -5.3445     0.5591  -9.559 1.29e-10 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 3.046 on 30 degrees of freedom
## Multiple R-squared:  0.7528,	Adjusted R-squared:  0.7446 
## F-statistic: 91.38 on 1 and 30 DF,  p-value: 1.294e-10&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on the results, we see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The slope has not changed, the interpretation is the same than without the centering (which makes sense since the regression line has simply been shifted to the right or left).&lt;/li&gt;
&lt;li&gt;More importantly, the intercept is now &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_0 =\)&lt;/span&gt; 20.09, so we can expect, on average, a consumption of 20.09 miles/gallon for a car with an average weight (the mean of weight is 3.22 so 3220 lbs).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This centering is particularly interesting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;when the continuous independent variable has &lt;strong&gt;no&lt;/strong&gt; meaningful value of 0 (which is the case here as a car with a weight of 0 lbs is not meaningful), or&lt;/li&gt;
&lt;li&gt;when interpreting the intercept is important.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that centering does not have to be done around the mean only. The independent variable can also be centered at some value that is actually in the range of the data. The exact value you center on does not matter as long it’s meaningful and within the range of data (it is not recommended to center it on a value that is not in the range of the data because we are not sure about the type of relationship between the two variables outside that range).&lt;/p&gt;
&lt;p&gt;For our example, we may find that choosing the lowest value or the highest value of weight is the best option. So it’s up to us to decide the weight at which it’s most meaningful to interpret the intercept.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;significance-of-the-relationship&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Significance of the relationship&lt;/h2&gt;
&lt;p&gt;As mentioned earlier, the &lt;strong&gt;value of the slope does not&lt;/strong&gt;, by itself, make it possible to &lt;strong&gt;assess the significance of the linear relationship&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In other words, a slope different from 0 does not necessarily mean it is &lt;em&gt;significantly&lt;/em&gt; different from 0, so it does not mean that there is a &lt;strong&gt;significant&lt;/strong&gt; relationship between the two variables in the population. There could be a slope of 10 that is not significant, and a slope of 2 that is significant.&lt;/p&gt;
&lt;p&gt;Significance of the relationship also depends on the variability of the slope, which is measured by its standard error and generally noted &lt;span class=&#34;math inline&#34;&gt;\(se(\widehat\beta_1)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Without going too much into details, to assess the significance of the linear relationship, we divide the slope by its standard error. This ratio is the test statistic and follows a Student distribution with &lt;span class=&#34;math inline&#34;&gt;\(n - 2\)&lt;/span&gt; degrees of freedom:&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[T_{n - 2} = \frac{\widehat\beta_1}{se(\widehat\beta_1)}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For a bilateral test, the null and alternative hypotheses are:&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0 : \beta_1 = 0\)&lt;/span&gt; (there is no (linear) relationship between the two variables)&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1 : \beta_1 \ne 0\)&lt;/span&gt; (there is a (linear) relationship between the two variables)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Roughly speaking, if this ratio is greater than 2 in absolute value then the slope is significantly different from 0, and therefore the relationship between the two variables is significant (and in that case it is positive or negative depending on the sign of the estimate &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1\)&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;The standard error and the test statistic are shown in the column &lt;code&gt;Std. Error&lt;/code&gt; and &lt;code&gt;t value&lt;/code&gt; in the table &lt;code&gt;Coefficients&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Fortunately, R gives a more precise and easier way to assess to the significance of the relationship. The information is provided in the column &lt;code&gt;Pr(&amp;gt;|t|)&lt;/code&gt; of the &lt;code&gt;Coefficients&lt;/code&gt; table. This is the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;&lt;em&gt;p&lt;/em&gt;-value&lt;/a&gt; of the test. As for any &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt;, if the &lt;em&gt;p&lt;/em&gt;-value is greater than or equal to the significance level (usually &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;), we do not reject the null hypothesis, and if the &lt;em&gt;p&lt;/em&gt;-value is lower than the significance level, we reject the null hypothesis.&lt;/p&gt;
&lt;p&gt;If we do not reject the null hypothesis, we do not reject the hypothesis of no relationship between the two variables (because we do not reject the hypothesis of a slope of 0). On the contrary, if we reject the null hypothesis of no relationship, we can conclude that there is a significant linear relationship between the two variables.&lt;/p&gt;
&lt;p&gt;In our example, the &lt;em&gt;p&lt;/em&gt;-value = 1.29e-10 &amp;lt; 0.05 so we reject the null hypothesis at the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 5\%\)&lt;/span&gt;. We therefore conclude that there is a &lt;strong&gt;significant relationship between a car’s weight and its fuel consumption&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Tip:&lt;/em&gt; In order to make sure I interpret only parameters that are significant, I tend to first check the significance of the parameters thanks to the &lt;em&gt;p&lt;/em&gt;-values, and then interpret the estimates accordingly. For completeness, note that the test is also performed on the intercept. The &lt;em&gt;p&lt;/em&gt;-value being smaller than 0.05, we also conclude that the intercept is significantly different from 0.&lt;/p&gt;
&lt;div id=&#34;correlation-does-not-imply-causation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Correlation does not imply causation&lt;/h3&gt;
&lt;p&gt;Be careful that a significant relationship between two variables does not necessarily mean that there is an influence of one variable on the other or that there is a causal effect between these two variables!&lt;/p&gt;
&lt;p&gt;A significant relationship between &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; can appear in several cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; causes &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; causes &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;a third variable cause &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;a combination of these three reasons&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A statistical model alone cannot establish a causal link between two variables. Demonstrating causality between two variables is more complex and requires, among others, a specific experimental design, the repeatability of the results over time, as well as various samples.&lt;/p&gt;
&lt;p&gt;This is the reason you will often read “&lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/#correlation-does-not-imply-causation&#34;&gt;Correlation does not imply causation&lt;/a&gt;” and linear regression follows the same principle.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conditions-of-application&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Conditions of application&lt;/h2&gt;
&lt;p&gt;Unfortunately, linear regression cannot be used in all situations.&lt;/p&gt;
&lt;p&gt;In addition to the requirement that the dependent variable must be a continuous quantitative variables, simple linear regression requires that the data satisfy the following conditions:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;Linearity:&lt;/strong&gt; The relationship between the two variables should be linear (at least roughly). For this reason it is always necessary to represent graphically the data with a scatterplot before performing a simple linear regression.&lt;a href=&#34;#fn7&#34; class=&#34;footnote-ref&#34; id=&#34;fnref7&#34;&gt;&lt;sup&gt;7&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-7-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;Independence:&lt;/strong&gt; Observations must be independent. It is the sampling plan and the experimental design that usually provide information on this condition. If the data come from different individuals or experimental units, they are usually independent. On the other hand, if the same individuals are measured at different periods, the data are probably not independent.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normality of the residuals:&lt;/strong&gt; For large sample sizes, confidence intervals and tests on the coefficients are (approximately) valid whether the error follows a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt; or not (a consequence of the central limit theorem, see more in &lt;span class=&#34;citation&#34;&gt;Ernst and Albers (&lt;a href=&#34;#ref-ernst2017regression&#34;&gt;2017&lt;/a&gt;)&lt;/span&gt; and &lt;span class=&#34;citation&#34;&gt;Lumley et al. (&lt;a href=&#34;#ref-lumley2002importance&#34;&gt;2002&lt;/a&gt;)&lt;/span&gt;)! For small sample sizes, residuals should follow a normal distribution. This condition can be tested visually (via a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#qq-plot&#34;&gt;QQ-plot&lt;/a&gt; and/or a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt;), or more formally (via the &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;Shapiro-Wilk test&lt;/a&gt; for instance).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Homoscedasticity of the residuals:&lt;/strong&gt; The variance of the errors should be constant. There is a lack of homoscedasticity when the dispersion of the residuals increases with the predicted values (fitted values). This condition can be tested visually (by plotting the standardized residuals vs. the fitted values) or more formally (via the Breusch-Pagan test).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No influential points:&lt;/strong&gt; If the data contain &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;, it is essential to identify them so that they &lt;strong&gt;do not&lt;/strong&gt;, on their own, &lt;strong&gt;influence&lt;/strong&gt; the results of the regression. Note that an outlier is not an issue &lt;em&gt;per se&lt;/em&gt; if the point is in the alignment of the regression line for example because it does not influence the regression line. It becomes a problem in the context of linear regression if it influences in a substantial manner the estimates (and in particular the slope of the regression line). This can be tackled by identifying outliers (via the Cook’s distance&lt;a href=&#34;#fn8&#34; class=&#34;footnote-ref&#34; id=&#34;fnref8&#34;&gt;&lt;sup&gt;8&lt;/sup&gt;&lt;/a&gt; or the leverage index&lt;a href=&#34;#fn9&#34; class=&#34;footnote-ref&#34; id=&#34;fnref9&#34;&gt;&lt;sup&gt;9&lt;/sup&gt;&lt;/a&gt; for instance), and comparing the results with and without the potential outliers. Do the results remain the same with the two approaches? If yes, outliers are not really an issue in this case. If results are much different, you can use the Theil-Sen estimator, robust regression or quantile regression which are all more robust to outliers.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;Tip:&lt;/em&gt; I remember the first 4 conditions thanks to the acronym “LINE”, for Linearity, Independence, Normality and Equality of variance.&lt;/p&gt;
&lt;p&gt;If any of the condition is not met, the tests and the conclusions could be erroneous so it is best to avoid using and interpreting the model. If this is the case, sometimes the conditions can be met by transforming the data (e.g., logarithmic transformation, square or square root, Box-Cox transformation, etc.) or by adding a quadratic or cubic (or even a higher-order polynomial) term to the model.&lt;/p&gt;
&lt;p&gt;If it does not help, it could be worth thinking about removing some variables or adding other variables, or even considering other types of models such as non-linear models.&lt;/p&gt;
&lt;p&gt;Keep in mind that in practice, &lt;strong&gt;conditions of application should be verified before drawing any conclusion&lt;/strong&gt; based on the model. I refrain here from testing the conditions on our data because it will be covered in details in the context of multiple linear regression (see this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#conditions-of-application-1&#34;&gt;section&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;visualizations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualizations&lt;/h2&gt;
&lt;p&gt;If you are a frequent reader of the blog, you may know that I like to draw (simple but efficient) &lt;a href=&#34;https://statsandr.com/tags/visualization/&#34;&gt;visualizations&lt;/a&gt; to illustrate my statistical analyses. Linear regression is not an exception.&lt;/p&gt;
&lt;p&gt;There are numerous ways to visualize the relationship between the two variables of interest, but the easiest one I found so far is via the &lt;code&gt;visreg()&lt;/code&gt; function from the package of the same name:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(visreg)
visreg(model)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-8-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;I like this approach for its simplicity—only a single line of code.&lt;/p&gt;
&lt;p&gt;However, other elements could be displayed on the regression plot (for example the regression equation and the &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt;). This can easily be done with the &lt;code&gt;stat_regline_equation()&lt;/code&gt; and &lt;code&gt;stat_cor()&lt;/code&gt; functions from the &lt;code&gt;{ggpubr}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load necessary libraries
library(ggpubr)

# create plot with regression line, regression equation and R^2
ggplot(dat, aes(x = wt, y = mpg)) +
  geom_smooth(method = &amp;quot;lm&amp;quot;) +
  geom_point() +
  stat_regline_equation(label.x = 3, label.y = 32) + # for regression equation
  stat_cor(aes(label = after_stat(rr.label)), label.x = 3, label.y = 30) + # for R^2
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-9-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-linear-regression&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Multiple linear regression&lt;/h1&gt;
&lt;p&gt;Now that you understand the principle behind simple linear regression and you know how to interpret the results, it is time to discuss about multiple linear regression.&lt;/p&gt;
&lt;p&gt;We also start with the underlying principle of multiple linear regression, then show how to interpret the results, how to test the conditions of application and finish with more advanced topics.&lt;/p&gt;
&lt;div id=&#34;principle-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Principle&lt;/h2&gt;
&lt;p&gt;Multiple linear regression is a generalization of simple linear regression, in the sense that this approach makes it possible to relate one variable with &lt;strong&gt;several variables&lt;/strong&gt; through a linear function in its parameters.&lt;/p&gt;
&lt;p&gt;Multiple linear regression is used to assess the relationship between two variables &lt;strong&gt;while taking into account the effect of other variables&lt;/strong&gt;. By taking into account the effect of other variables, we cancel out the effect of these other variables in order to &lt;strong&gt;isolate&lt;/strong&gt; and measure the relationship between the two variables of interest. This point is the main difference with simple linear regression.&lt;/p&gt;
&lt;p&gt;To illustrate how to perform a multiple linear regression in R, we use the same dataset than the one used for simple linear regression (&lt;code&gt;mtcars&lt;/code&gt;). Below a short preview:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
## Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
## Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have seen that there is a significant and negative linear relationship between the distance a car can drive with a gallon and its weight (&lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1 =\)&lt;/span&gt; -5.34, &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001).&lt;/p&gt;
&lt;p&gt;However, one may wonder whether there are not in reality other factors that could explain a car’s fuel consumption.&lt;/p&gt;
&lt;p&gt;To explore this, we can visualize the relationship between a car’s fuel consumption (&lt;code&gt;mpg&lt;/code&gt;) together with its weight (&lt;code&gt;wt&lt;/code&gt;), horsepower (&lt;code&gt;hp&lt;/code&gt;) and displacement (&lt;code&gt;disp&lt;/code&gt;) (engine displacement is the combined swept (or displaced) volume of air resulting from the up-and-down movement of pistons in the cylinders, usually the higher the more powerful the car):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = wt, y = mpg, colour = hp, size = disp) +
  geom_point() +
  scale_color_gradient() +
  labs(
    y = &amp;quot;Miles per gallon&amp;quot;,
    x = &amp;quot;Weight (1000 lbs)&amp;quot;,
    color = &amp;quot;Horsepower&amp;quot;,
    size = &amp;quot;Displacement&amp;quot;
  ) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-11-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It seems that, in addition to the negative relationship between miles per gallon and weight, there is also:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a negative relationship between miles/gallon and horsepower (lighter points, indicating more horsepower, tend to be more present in low levels of miles per gallon)&lt;/li&gt;
&lt;li&gt;a negative relationship between miles/gallon and displacement (bigger points, indicating larger values of displacement, tend to be more present in low levels of miles per gallon).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Therefore, we would like to evaluate the relation between the fuel consumption and the weight, but this time by adding information on the horsepower and displacement. By adding this additional information, we are able to &lt;strong&gt;capture only the direct relationship between miles/gallon and weight&lt;/strong&gt; (the indirect effect due to horsepower and displacement is canceled out).&lt;/p&gt;
&lt;p&gt;This is the whole point of multiple linear regression! In fact, in multiple linear regression, the estimated relationship between the dependent variable and an explanatory variable is an &lt;strong&gt;adjusted&lt;/strong&gt; relationship, that is, free of the linear effects of the other explanatory variables.&lt;/p&gt;
&lt;p&gt;Let’s illustrate this notion of adjustment by adding both horsepower and displacement in our linear regression model:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model2 &amp;lt;- lm(mpg ~ wt + hp + disp,
  data = dat
)

summary(model2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt + hp + disp, data = dat)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -3.891 -1.640 -0.172  1.061  5.861 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept) 37.105505   2.110815  17.579  &amp;lt; 2e-16 ***
## wt          -3.800891   1.066191  -3.565  0.00133 ** 
## hp          -0.031157   0.011436  -2.724  0.01097 *  
## disp        -0.000937   0.010350  -0.091  0.92851    
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 2.639 on 28 degrees of freedom
## Multiple R-squared:  0.8268,	Adjusted R-squared:  0.8083 
## F-statistic: 44.57 on 3 and 28 DF,  p-value: 8.65e-11&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can see that now, the relationship between miles/gallon and weight is weaker in terms of slope (&lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1 =\)&lt;/span&gt; -3.8 now, against &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta_1 =\)&lt;/span&gt; -5.34 when only the weight was considered).&lt;/p&gt;
&lt;p&gt;The effect of weight on fuel consumption was adjusted according to the effect of horsepower and displacement. This is the remaining effect between miles/gallon and weight after the effects of horsepower and displacement have been taken into account. More detailed interpretations in this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#interpretations-of-coefficients-widehatbeta-1&#34;&gt;section&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;equation-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Equation&lt;/h2&gt;
&lt;p&gt;Multiple linear regression models are defined by the equation&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \dots + \beta_p X_p + \epsilon\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It is similar than the equation of simple linear regression, except that there is more than one independent variables (&lt;span class=&#34;math inline&#34;&gt;\(X_1, X_2, \dots, X_p\)&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;Estimation of the parameters &lt;span class=&#34;math inline&#34;&gt;\(\beta_0, \dots, \beta_p\)&lt;/span&gt; by the method of least squares is based on the same principle as that of simple linear regression, but applied to &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt; dimensions. It is thus no longer a question of finding the best line (the one which passes closest to the pairs of points (&lt;span class=&#34;math inline&#34;&gt;\(y_i, x_i\)&lt;/span&gt;)), but finding the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-dimensional plane which passes closest to the coordinate points (&lt;span class=&#34;math inline&#34;&gt;\(y_i, x_{i1}, \dots, x_{ip}\)&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;This is done by &lt;strong&gt;&lt;em&gt;minimizing&lt;/em&gt; the sum of the squares of the deviations of the points on the plane&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;images/multiple-linear-regression-plane.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Source: James, G., Witten, D., Hastie, T., &amp;amp; Tibshirani, R. (2013)&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Source: James, G., Witten, D., Hastie, T., &amp;amp; Tibshirani, R. (2013)&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;interpretations-of-coefficients-widehatbeta-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Interpretations of coefficients &lt;span class=&#34;math inline&#34;&gt;\(\widehat\beta\)&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The least squares method results in an adjusted estimate of the coefficients. The term adjusted means &lt;strong&gt;after taking into account the linear effects&lt;/strong&gt; of the other independent variables on the dependent variable, but also on the predictor variable.&lt;/p&gt;
&lt;p&gt;In other words, the coefficient &lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt; corresponds to the slope of the relationship between &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(X_1\)&lt;/span&gt; when the linear effects of the other explanatory variables (&lt;span class=&#34;math inline&#34;&gt;\(X_2, \dots, X_p\)&lt;/span&gt;) have been removed, both at the level of the dependent variable &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; but also at the level of &lt;span class=&#34;math inline&#34;&gt;\(X_1\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Applied to our model with weight, horsepower and displacement as independent variables, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(model2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt + hp + disp, data = dat)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -3.891 -1.640 -0.172  1.061  5.861 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept) 37.105505   2.110815  17.579  &amp;lt; 2e-16 ***
## wt          -3.800891   1.066191  -3.565  0.00133 ** 
## hp          -0.031157   0.011436  -2.724  0.01097 *  
## disp        -0.000937   0.010350  -0.091  0.92851    
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 2.639 on 28 degrees of freedom
## Multiple R-squared:  0.8268,	Adjusted R-squared:  0.8083 
## F-statistic: 44.57 on 3 and 28 DF,  p-value: 8.65e-11&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The table &lt;code&gt;Coefficients&lt;/code&gt; gives the estimate for each parameter (column &lt;code&gt;Estimate&lt;/code&gt;), together with the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value of the nullity of the parameter (column &lt;code&gt;Pr(&amp;gt;|t|)&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;The hypotheses are the same as for simple linear regression, that is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0 : \beta_j = 0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1 : \beta_j \ne 0\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The test of &lt;span class=&#34;math inline&#34;&gt;\(\beta_j = 0\)&lt;/span&gt; is equivalent to testing the hypothesis: is the dependent variable associated with the independent variable studied, all other things being equal, that is to say, at constant level of the other independent variables.&lt;/p&gt;
&lt;p&gt;In other words:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the test of &lt;span class=&#34;math inline&#34;&gt;\(\beta_1 = 0\)&lt;/span&gt; corresponds to testing the hypothesis: is fuel consumption associated with a car’s weight, at a constant level of horsepower and displacement&lt;/li&gt;
&lt;li&gt;the test of &lt;span class=&#34;math inline&#34;&gt;\(\beta_2 = 0\)&lt;/span&gt; corresponds to testing the hypothesis: is fuel consumption associated with horsepower, at a constant level of weight and displacement&lt;/li&gt;
&lt;li&gt;the test of &lt;span class=&#34;math inline&#34;&gt;\(\beta_3 = 0\)&lt;/span&gt; corresponds to testing the hypothesis: is fuel consumption associated with displacement, at a constant level of weight and horsepower&lt;/li&gt;
&lt;li&gt;(for the sake of completeness: the test of &lt;span class=&#34;math inline&#34;&gt;\(\beta_0 = 0\)&lt;/span&gt; corresponds to testing the hypothesis: is miles/gallon different from 0 when weight, horsepower and displacement are equal to 0)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In practice, we usually check the conditions of application &lt;em&gt;before&lt;/em&gt; interpreting the coefficients (because if they are not respected, results may be biased). In this article, however, I present the interpretations before testing the conditions because the point is to show how to interpret the results, and less about finding a valid model.&lt;/p&gt;
&lt;p&gt;Based on the output of our model, we conclude that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;There is a significant and negative relationship between miles/gallon and weight, &lt;strong&gt;all else being equal&lt;/strong&gt;. So for an increase of one unit in the weight (that is, an increase of 1000 lbs), the number of miles/gallon decreases, on average, by 3.8, for a constant level of horsepower and displacement (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.001).&lt;/li&gt;
&lt;li&gt;There is a significant and negative relationship between miles/gallon and horsepower, all else being equal. So for an increase of one unit of horsepower, the distance traveled with a gallon decreases, on average, by 0.03 mile, for a constant level of weight and displacement (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.011).&lt;/li&gt;
&lt;li&gt;We do not reject the hypothesis of no relationship between miles/gallon and displacement when weight and horsepower stay constant (because &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.929 &amp;gt; 0.05).&lt;/li&gt;
&lt;li&gt;(For completeness but it should be interpreted only when it makes sense: for a weight, horsepower and displacement = 0, we can expect that a car has, on average, a fuel consumption of 37.11 miles/gallon (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001). See a more useful interpretation of the intercept when the independent variables are centered in this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#another-interpretation-of-the-intercept&#34;&gt;section&lt;/a&gt;.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is how to interpret quantitative independent variables. &lt;strong&gt;Interpreting qualitative independent variables&lt;/strong&gt; is slightly different in the sense that it quantifies the effect of a level in comparison with the reference level, sill all else being equal.&lt;/p&gt;
&lt;p&gt;So it compares the different groups (formed by the different levels of the categorical variable) in terms of the dependent variable (this is why linear regression can be seen as an extension to the t-test and ANOVA).&lt;/p&gt;
&lt;p&gt;For the illustration, we model the fuel consumption (&lt;code&gt;mpg&lt;/code&gt;) on the weight (&lt;code&gt;wt&lt;/code&gt;) and the shape of the engine (&lt;code&gt;vs&lt;/code&gt;). The variable &lt;code&gt;vs&lt;/code&gt; has two levels: V-shaped (the &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/#change-reference-level&#34;&gt;reference level&lt;/a&gt;) and straight engine.&lt;a href=&#34;#fn10&#34; class=&#34;footnote-ref&#34; id=&#34;fnref10&#34;&gt;&lt;sup&gt;10&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Recoding dat$vs
library(forcats)
dat$vs &amp;lt;- as.character(dat$vs)
dat$vs &amp;lt;- fct_recode(dat$vs,
  &amp;quot;V-shaped&amp;quot; = &amp;quot;0&amp;quot;,
  &amp;quot;Straight&amp;quot; = &amp;quot;1&amp;quot;
)

model3 &amp;lt;- lm(mpg ~ wt + vs,
  data = dat
)

summary(model3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt + vs, data = dat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7071 -2.4415 -0.3129  1.4319  6.0156 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)  33.0042     2.3554  14.012 1.92e-14 ***
## wt           -4.4428     0.6134  -7.243 5.63e-08 ***
## vsStraight    3.1544     1.1907   2.649   0.0129 *  
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 2.78 on 29 degrees of freedom
## Multiple R-squared:  0.801,	Adjusted R-squared:  0.7873 
## F-statistic: 58.36 on 2 and 29 DF,  p-value: 6.818e-11&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on the output of our model, we conclude that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For a V-shaped engine and for an increase of one unit in the weight (that is, an increase of 1000 lbs), the number of miles/gallon decreases, on average, by 4.44 (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001).&lt;/li&gt;
&lt;li&gt;The distance traveled with a gallon of fuel increases by, on average, 3.15 miles &lt;strong&gt;when the engine is straight compared to a V-shaped engine&lt;/strong&gt;, for a constant weight (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.013).&lt;/li&gt;
&lt;li&gt;(For completeness but it should be interpreted only when it makes sense: for a weight = 0 and a V-shaped engine, we can expect that the car has, on average, a fuel consumption of 33 miles/gallon (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001). See a more useful interpretation of the intercept when the independent variables are centered in this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#another-interpretation-of-the-intercept&#34;&gt;section&lt;/a&gt;.)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;conditions-of-application-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Conditions of application&lt;/h2&gt;
&lt;p&gt;As for simple linear regression, multiple linear regression requires some conditions of application for the model to be usable and the results to be interpretable. Conditions for simple linear regression also apply to multiple linear regression, that is:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;Linearity&lt;/strong&gt; of the relationships between the dependent and independent variables&lt;a href=&#34;#fn11&#34; class=&#34;footnote-ref&#34; id=&#34;fnref11&#34;&gt;&lt;sup&gt;11&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Independence&lt;/strong&gt; of the observations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normality&lt;/strong&gt; of the residuals&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Homoscedasticity&lt;/strong&gt; of the residuals&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No influential points&lt;/strong&gt; (&lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;But there is one more condition for multiple linear regression:&lt;/p&gt;
&lt;ol start=&#34;6&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;No multicollinearity:&lt;/strong&gt; Multicollinearity arises when there is a strong linear &lt;strong&gt;&lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation&lt;/a&gt; between the independent variables&lt;/strong&gt;, conditional on the other variables in the model. It is important to check it because it may lead to an imprecision or an instability of the estimated parameters when a variable changes. It can be assessed by studying the correlation between each pair of independent variables, or even better, by computing the variance inflation factor (VIF). The VIF measures how much the variance of an estimated regression coefficient increases, relative to a situation in which the explanatory variables are strictly independent. A high value of VIF is a sign of multicollinearity (the threshold is generally admitted at 5 or 10 depending on the domain). The easiest way to reduce the VIF is to remove some correlated independent variables, or eventually to &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/#scale&#34;&gt;standardize&lt;/a&gt; the data.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You will often see that these conditions are verified by running &lt;code&gt;plot(model, which = 1:6)&lt;/code&gt; and it is totally correct. However, I recently discovered the &lt;code&gt;check_model()&lt;/code&gt; function from the &lt;code&gt;{performance}&lt;/code&gt; package which tests these conditions all at the same time (and let’s be honest, in a more elegant way).&lt;a href=&#34;#fn12&#34; class=&#34;footnote-ref&#34; id=&#34;fnref12&#34;&gt;&lt;sup&gt;12&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Applied on our &lt;code&gt;model2&lt;/code&gt; with miles/gallon as dependent variable, and weight, horsepower and displacement as independent variables, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;performance&amp;quot;)
# install.packages(&amp;quot;see&amp;quot;)
library(performance)

check_model(model2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-15-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In addition to testing all conditions at the same time, it also gives insight on how to interpret the different diagnostic plots and what you should expect (see in the subtitles of each plot).&lt;/p&gt;
&lt;p&gt;Based on these diagnostic plots, we see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Homogeneity of variance (middle left plot) is respected&lt;/li&gt;
&lt;li&gt;Multicollinearity (bottom left plot) is not an issue (I tend to use the threshold of 10 for VIF, and all of them are below 10)&lt;a href=&#34;#fn13&#34; class=&#34;footnote-ref&#34; id=&#34;fnref13&#34;&gt;&lt;sup&gt;13&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;There is no influential points (middle right plot)&lt;/li&gt;
&lt;li&gt;Normality of the residuals (bottom right plot) is also not perfect due to 3 points deviating from the reference line but it still seems acceptable to me. In any case, the number of observations is large enough given the number of parameters&lt;a href=&#34;#fn14&#34; class=&#34;footnote-ref&#34; id=&#34;fnref14&#34;&gt;&lt;sup&gt;14&lt;/sup&gt;&lt;/a&gt; and given the small deviation from normality so tests on the coefficients are (approximately) valid whether the error follows a normal distribution or not&lt;/li&gt;
&lt;li&gt;Linearity (top right plot) is not perfect so let’s check each independent variable separately:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# weight
ggplot(dat, aes(x = wt, y = mpg)) +
  geom_point() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-16-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# horsepower
ggplot(dat, aes(x = hp, y = mpg)) +
  geom_point() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-16-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# displacement
ggplot(dat, aes(x = disp, y = mpg)) +
  geom_point() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-16-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It seems that the relationship between miles/gallon and horsepower is not linear, which could be the main component of the slight linearity defect of the model.&lt;/p&gt;
&lt;p&gt;To improve linearity, the variable could be removed, a transformation could be applied (logarithmic and/or squared for instance) or a quadratic or cubic (or even a higher-order polynomial) term could be added to the model.&lt;a href=&#34;#fn15&#34; class=&#34;footnote-ref&#34; id=&#34;fnref15&#34;&gt;&lt;sup&gt;15&lt;/sup&gt;&lt;/a&gt; If this does not fix the issue of linearity, other types of models could be considered.&lt;/p&gt;
&lt;p&gt;If you want to read more about these conditions of applications and how to deal with them, here is a very complete &lt;a href=&#34;http://quantpsych.net/stats_modeling/diagnostics.html&#34;&gt;chapter&lt;/a&gt; on diagnostics for linear models written by Prof. Dustin Fife.&lt;/p&gt;
&lt;p&gt;For the sake of easiness and for illustrative purposes, we assume linearity for the rest of the article.&lt;/p&gt;
&lt;p&gt;When the conditions of application are met, we usually say that the model is valid. But not all valid models are &lt;em&gt;good&lt;/em&gt; models. The next section deals with model selection.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-choose-a-good-linear-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;How to choose a good linear model?&lt;/h2&gt;
&lt;p&gt;A model which satisfies the conditions of application is the minimum requirement, but you will likely find several models that meet this criteria. So one may wonder &lt;strong&gt;how to choose between different models&lt;/strong&gt; that are all valid?&lt;/p&gt;
&lt;p&gt;The three most common tools to select a good linear model are according to:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value associated to the model,&lt;/li&gt;
&lt;li&gt;the coefficient of determination &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; and&lt;/li&gt;
&lt;li&gt;the Akaike Information Criterion&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The approaches are detailed in the next sections. Note that the first two are applicable to simple and multiple linear regression, whereas the third is only applicable to multiple linear regression.&lt;/p&gt;
&lt;div id=&#34;p-value-associated-to-the-model&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;&lt;span class=&#34;math inline&#34;&gt;\(P\)&lt;/span&gt;-value associated to the model&lt;/h3&gt;
&lt;p&gt;Before interpreting the estimates of a model, it is a good practice to first check the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value associated to the model. This &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value indicates if the model is &lt;strong&gt;better than a model with only the intercept&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The hypotheses of the test (called F-test) are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \beta_1 = \beta_2 = \dots = \beta_p = 0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1:\)&lt;/span&gt; at least one coefficient &lt;span class=&#34;math inline&#34;&gt;\(\beta \ne 0\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value can be found at the bottom of the &lt;code&gt;summary()&lt;/code&gt; output:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(model2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt + hp + disp, data = dat)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -3.891 -1.640 -0.172  1.061  5.861 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept) 37.105505   2.110815  17.579  &amp;lt; 2e-16 ***
## wt          -3.800891   1.066191  -3.565  0.00133 ** 
## hp          -0.031157   0.011436  -2.724  0.01097 *  
## disp        -0.000937   0.010350  -0.091  0.92851    
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 2.639 on 28 degrees of freedom
## Multiple R-squared:  0.8268,	Adjusted R-squared:  0.8083 
## F-statistic: 44.57 on 3 and 28 DF,  p-value: 8.65e-11&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 8.65e-11. The null hypothesis is rejected, so we conclude that our model is better than a model with only the intercept because at least one coefficient &lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt; is significantly different from 0.&lt;/p&gt;
&lt;p&gt;If this &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;gt; 0.05 for one of your model, it means that none of the variables you selected help in explaining the dependent variable. In other words, you should completely forget about this model because it cannot do better than simply taking the mean of the dependent variable.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coefficient-of-determination-r2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Coefficient of determination &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;The coefficient of determination, &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt;, is a measure of the &lt;strong&gt;goodness of fit of the model&lt;/strong&gt;. It measures the proportion of the total variability that is explained by the model, or how well the model fits the data.&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; varies between 0 and 1:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(R^2 = 0\)&lt;/span&gt;: the model explains nothing&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(R^2 = 1\)&lt;/span&gt;: the model explains everything&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(0 &amp;lt; R^2 &amp;lt; 1\)&lt;/span&gt;: the model explains part of the variability&lt;/li&gt;
&lt;li&gt;the higher the &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt;, the better the model explains the dependent variable. As a rule of thumb, a &lt;span class=&#34;math inline&#34;&gt;\(R^2 &amp;gt; 0.7\)&lt;/span&gt; indicates a good fit of the model&lt;a href=&#34;#fn16&#34; class=&#34;footnote-ref&#34; id=&#34;fnref16&#34;&gt;&lt;sup&gt;16&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that in a simple linear regression model, the coefficient of determination is equal to the square of the Pearson &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation coefficient&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[R^2 = corr(X, Y)^2\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Applied on our &lt;code&gt;model2&lt;/code&gt; with miles/gallon as dependent variable, and weight, horsepower and displacement as independent variables, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(model2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt + hp + disp, data = dat)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -3.891 -1.640 -0.172  1.061  5.861 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept) 37.105505   2.110815  17.579  &amp;lt; 2e-16 ***
## wt          -3.800891   1.066191  -3.565  0.00133 ** 
## hp          -0.031157   0.011436  -2.724  0.01097 *  
## disp        -0.000937   0.010350  -0.091  0.92851    
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 2.639 on 28 degrees of freedom
## Multiple R-squared:  0.8268,	Adjusted R-squared:  0.8083 
## F-statistic: 44.57 on 3 and 28 DF,  p-value: 8.65e-11&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; is displayed at the bottom of the &lt;code&gt;summary()&lt;/code&gt; output or can be extracted with &lt;code&gt;summary(model2)$r.squared&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; for this model is 0.8268, which means that 82.68% of the variability of the distance traveled with a gallon is explained by the weight, horsepower and displacement of the car. The relatively high &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; means that the weight, horsepower and displacement of a car are good characteristics to explain the distance it can drive with a gallon of fuel.&lt;/p&gt;
&lt;p&gt;Note that if you want to compare models with different number of independent variables, it is best to refer to the adjusted &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; (= 0.8083 here).&lt;/p&gt;
&lt;p&gt;Indeed, adding variables to the model cannot make the &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; to decrease, even if the variables are not related to the dependent variables (so the &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; will artificially increase when adding variables to the model, or at least stay constant). Therefore, the adjusted &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; takes into account the complexity of the model (the number of variables) by penalizing for additional variables, so it is a compromise between goodness of fit and parsimony.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;parsimony&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Parsimony&lt;/h3&gt;
&lt;p&gt;A &lt;strong&gt;parsimonious model (few variables) is usually preferred&lt;/strong&gt; over a complex model (many variables). There are two ways to obtain a parsimonious model from a model with many independent variables:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;We can &lt;strong&gt;iteratively remove the independent variable least significantly related to the dependent variable&lt;/strong&gt; (i.e., the one with the highest &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value in an &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#overall-effect-of-categorical-variables&#34;&gt;analysis of variance table&lt;/a&gt;) until all of them are significantly associated to the response variable, or&lt;/li&gt;
&lt;li&gt;We can select the model based on the &lt;strong&gt;Akaike Information Criterion (AIC)&lt;/strong&gt;. AIC expresses a desire to fit the model with the smallest number of coefficients possible and allows to compare models. According to this criterion, the best model is the one with the lowest AIC. This criterion is based on a compromise between the quality of the fit and its complexity. We usually start from a global model with many independent variables, and the procedure (referred as stepwise algorithm)&lt;a href=&#34;#fn17&#34; class=&#34;footnote-ref&#34; id=&#34;fnref17&#34;&gt;&lt;sup&gt;17&lt;/sup&gt;&lt;/a&gt; automatically compares models then selects the best one according to the AIC.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We show how to do the second option in R. For the illustration, we start with a model with all variables in the dataset as independent variables (do not forget to transform the factor variables first):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## vs has already been transformed into factor
## so only am is transformed here

## Recoding dat$vs
library(forcats)
dat$am &amp;lt;- as.character(dat$am)
dat$am &amp;lt;- fct_recode(dat$am,
  &amp;quot;Automatic&amp;quot; = &amp;quot;0&amp;quot;,
  &amp;quot;Manual&amp;quot; = &amp;quot;1&amp;quot;
)

model4 &amp;lt;- lm(mpg ~ .,
  data = dat
)

model4 &amp;lt;- step(model4, trace = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(&lt;em&gt;Tip:&lt;/em&gt; The formula &lt;code&gt;mpg ~ .&lt;/code&gt; is a shortcut to consider all variables present in the dataset as independent variables, except the one that has been specified as the dependent variable (&lt;code&gt;mpg&lt;/code&gt; here)).&lt;/p&gt;
&lt;p&gt;The model that has been selected according to this criterion is the following:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(model4)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt + qsec + am, data = dat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.4811 -1.5555 -0.7257  1.4110  4.6610 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)   9.6178     6.9596   1.382 0.177915    
## wt           -3.9165     0.7112  -5.507 6.95e-06 ***
## qsec          1.2259     0.2887   4.247 0.000216 ***
## amManual      2.9358     1.4109   2.081 0.046716 *  
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 2.459 on 28 degrees of freedom
## Multiple R-squared:  0.8497,	Adjusted R-squared:  0.8336 
## F-statistic: 52.75 on 3 and 28 DF,  p-value: 1.21e-11&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Be careful when using an automatic procedure because, even though it is the best model that is selected, it is based:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;on a single criterion (AIC in this case), but more importantly;&lt;/li&gt;
&lt;li&gt;it is based on some set of mathematical rules, which means that industry knowledge or human expertise is not taken into consideration.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I believe that this kind of automatic procedure for model’s selection is a good starting point, but I also believe that the final model should always be checked and tested against other models to make sure it makes sense in practice (apply common sense).&lt;/p&gt;
&lt;p&gt;Last but not least, do not forget to also verify the &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#conditions-of-application-1&#34;&gt;conditions of application&lt;/a&gt; because the stepwise procedure does not guarantee that they are respected.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;visualizations-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualizations&lt;/h2&gt;
&lt;p&gt;There are many ways to visualize results of a linear regression. The easiest ones I am aware of are:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;visreg()&lt;/code&gt; illustrates the relationships between the dependent and independent variables in different plots (one for each independent variable unless you specify which relationship you want to illustrate):&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(visreg)

visreg(model4)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-21-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-21-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-21-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;ggcoefstats()&lt;/code&gt; illustrates the results in one single plot, with many statistical details:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggstatsplot)

ggcoefstats(model4)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-22-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this plot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;when the solid line does not cross the vertical dashed line, the estimates is significantly different from 0 at the 5% significance level (i.e., &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.05)&lt;/li&gt;
&lt;li&gt;furthermore, a point to the right (left) of the vertical dashed line means that there is a positive (negative) relationship between the two variables&lt;/li&gt;
&lt;li&gt;the more extreme the point, the stronger the relationship&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;plot_summs()&lt;/code&gt; which also illustrates the results but in a more concise way:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(jtools)
library(ggstance)

plot_summs(model4,
  omit.coefs = NULL
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-23-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The advantage of this approach is that it is possible to compare coefficients of multiple models simultaneously (particularly interesting when the models are nested):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model4bis &amp;lt;- lm(mpg ~ wt + qsec + am + hp,
  data = dat
)

plot_summs(model4,
  model4bis,
  omit.coefs = NULL
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-24-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;to-go-further&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;To go further&lt;/h2&gt;
&lt;p&gt;Below some more advanced topics related to linear regression. Feel free to comment at the end of the article if you believe I missed an important one.&lt;/p&gt;
&lt;div id=&#34;print-models-parameters&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Print model’s parameters&lt;/h3&gt;
&lt;p&gt;Thanks to the &lt;code&gt;model_parameters()&lt;/code&gt; function from the &lt;code&gt;{parameters}&lt;/code&gt; package, you can print a summary of the model in a nicely formatted way to make the output more readable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(parameters)

model_parameters(model4, summary = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Parameter   | Coefficient |   SE |         95% CI | t(28) |      p
## ------------------------------------------------------------------
## (Intercept) |        9.62 | 6.96 | [-4.64, 23.87] |  1.38 | 0.178 
## wt          |       -3.92 | 0.71 | [-5.37, -2.46] | -5.51 | &amp;lt; .001
## qsec        |        1.23 | 0.29 | [ 0.63,  1.82] |  4.25 | &amp;lt; .001
## am [Manual] |        2.94 | 1.41 | [ 0.05,  5.83] |  2.08 | 0.047&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And if you are using &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt;, you can use the &lt;code&gt;print_html()&lt;/code&gt; function to get a compact and yet comprehensive summary table in your HTML file:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(gt)

print_html(model_parameters(model4, summary = TRUE))&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;yywrdylzvd&#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;#yywrdylzvd table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#yywrdylzvd thead, #yywrdylzvd tbody, #yywrdylzvd tfoot, #yywrdylzvd tr, #yywrdylzvd td, #yywrdylzvd th {
  border-style: none;
}

#yywrdylzvd p {
  margin: 0;
  padding: 0;
}

#yywrdylzvd .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  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;
}

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

#yywrdylzvd .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;
}

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

#yywrdylzvd .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;
}

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

#yywrdylzvd .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;
}

#yywrdylzvd .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;
}

#yywrdylzvd .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;
}

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

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

#yywrdylzvd .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%;
}

#yywrdylzvd .gt_spanner_row {
  border-bottom-style: hidden;
}

#yywrdylzvd .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;
}

#yywrdylzvd .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;
}

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

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

#yywrdylzvd .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;
}

#yywrdylzvd .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;
}

#yywrdylzvd .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;
}

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

#yywrdylzvd .gt_row_group_first th {
  border-top-width: 2px;
}

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

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

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

#yywrdylzvd .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;
}

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

#yywrdylzvd .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;
}

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

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

#yywrdylzvd .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;
}

#yywrdylzvd .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;
}

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

#yywrdylzvd .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;
}

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

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

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

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

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

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

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

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

#yywrdylzvd .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

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

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

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

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

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

#yywrdylzvd .gt_indent_5 {
  text-indent: 25px;
}

#yywrdylzvd .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#yywrdylzvd div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&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;a95%-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(28)&#34;&gt;t(28)&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;9.62&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;6.96&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(-4.64, 23.87)&lt;/td&gt;
&lt;td headers=&#34;t(28)&#34; class=&#34;gt_row gt_center&#34;&gt;1.38&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;0.178 &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;wt&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;-3.92&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;0.71&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(-5.37, -2.46)&lt;/td&gt;
&lt;td headers=&#34;t(28)&#34; class=&#34;gt_row gt_center&#34;&gt;-5.51&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;qsec&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;1.23&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;0.29&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(0.63, 1.82)&lt;/td&gt;
&lt;td headers=&#34;t(28)&#34; class=&#34;gt_row gt_center&#34;&gt;4.25&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;am (Manual)&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;2.94&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;1.41&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(0.05, 5.83)&lt;/td&gt;
&lt;td headers=&#34;t(28)&#34; class=&#34;gt_row gt_center&#34;&gt;2.08&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;0.047 &lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;automatic-reporting&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Automatic reporting&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;report()&lt;/code&gt; function from the package of the same name allows to automatically produces reports of models according to best practices guidelines:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(report)

report(model4)[1]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;We fitted a linear model (estimated using OLS) to predict mpg with wt, qsec and am (formula: mpg ~ wt + qsec + am). The model explains a statistically significant and substantial proportion of variance (R2 = 0.85, F(3, 28) = 52.75, p &amp;lt; .001, adj. R2 = 0.83). The model&amp;#39;s intercept, corresponding to wt = 0, qsec = 0 and am = Automatic, is at 9.62 (95% CI [-4.64, 23.87], t(28) = 1.38, p = 0.178). Within this model:\n\n  - The effect of wt is statistically significant and negative (beta = -3.92, 95% CI [-5.37, -2.46], t(28) = -5.51, p &amp;lt; .001; Std. beta = -0.64, 95% CI [-0.87, -0.40])\n  - The effect of qsec is statistically significant and positive (beta = 1.23, 95% CI [0.63, 1.82], t(28) = 4.25, p &amp;lt; .001; Std. beta = 0.36, 95% CI [0.19, 0.54])\n  - The effect of am [Manual] is statistically significant and positive (beta = 2.94, 95% CI [0.05, 5.83], t(28) = 2.08, p = 0.047; Std. beta = 0.49, 95% CI [7.59e-03, 0.97])\n\nStandardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using a Wald t-distribution approximation.&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the function also works for dataframes, &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt; and other models.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;predictions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Predictions&lt;/h3&gt;
&lt;p&gt;Linear regression is also very often used for &lt;strong&gt;predictive purposes&lt;/strong&gt;. Confidence and prediction intervals for &lt;strong&gt;new data&lt;/strong&gt; can be computed with the &lt;code&gt;predict()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;Suppose we want to predict the miles/gallon for a car with a manual transmission, weighting 3000 lbs and which drives a quarter of a mile (&lt;code&gt;qsec&lt;/code&gt;) in 18 seconds:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# confidence interval for new data
predict(model4,
  new = data.frame(wt = 3, qsec = 18, am = &amp;quot;Manual&amp;quot;),
  interval = &amp;quot;confidence&amp;quot;,
  level = .95
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        fit      lwr    upr
## 1 22.87005 21.09811 24.642&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# prediction interval for new data
predict(model4,
  new = data.frame(wt = 3, qsec = 18, am = &amp;quot;Manual&amp;quot;),
  interval = &amp;quot;prediction&amp;quot;,
  level = .95
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        fit      lwr      upr
## 1 22.87005 17.53074 28.20937&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on our model, it is expected that this car will drive 22.87 miles with a gallon.&lt;/p&gt;
&lt;p&gt;The difference between the confidence and prediction interval is that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;strong&gt;confidence&lt;/strong&gt; interval gives the predicted value for the &lt;strong&gt;mean&lt;/strong&gt; of &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; for a new observation, whereas&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;prediction&lt;/strong&gt; interval gives the predicted value for an &lt;strong&gt;individual&lt;/strong&gt; &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt; for a new observation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The prediction interval is wider than the confidence interval to account for the &lt;strong&gt;additional uncertainty due to predicting an individual response&lt;/strong&gt;, and not the mean, for a given value of &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;linear-hypothesis-tests&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Linear hypothesis tests&lt;/h3&gt;
&lt;p&gt;Linear hypothesis tests make it possible to generalize the F-test mentioned in this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#p-value-associated-to-the-model&#34;&gt;section&lt;/a&gt;, while offering the possibility to perform either tests of comparison of coefficients, or tests of equality of linear combinations of coefficients.&lt;/p&gt;
&lt;p&gt;For example, to test the linear constraint:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \beta_1 = \beta_2 = 0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1:\)&lt;/span&gt; not &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;we use the &lt;code&gt;linearHypothesis()&lt;/code&gt; function of the &lt;code&gt;{car}&lt;/code&gt; package as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(car)
linearHypothesis(model4, c(&amp;quot;wt = 0&amp;quot;, &amp;quot;qsec = 0&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Linear hypothesis test:
## wt = 0
## qsec = 0
## 
## Model 1: restricted model
## Model 2: mpg ~ wt + qsec + am
## 
##   Res.Df    RSS Df Sum of Sq      F   Pr(&amp;gt;F)    
## 1     30 720.90                                 
## 2     28 169.29  2    551.61 45.618 1.55e-09 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We reject the null hypothesis and we conclude that at least one of &lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\beta_2\)&lt;/span&gt; is different from 0 (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 1.55e-09).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;overall-effect-of-categorical-variables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Overall effect of categorical variables&lt;/h3&gt;
&lt;p&gt;When the independent variables are categorical with &lt;span class=&#34;math inline&#34;&gt;\(k\)&lt;/span&gt; categories, the regression table provides &lt;span class=&#34;math inline&#34;&gt;\(k-1\)&lt;/span&gt; &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model5 &amp;lt;- lm(mpg ~ vs + am + as.factor(cyl),
  data = dat
)

summary(model5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ vs + am + as.factor(cyl), data = dat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.2821 -1.4402  0.0391  1.8845  6.2179 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)       22.809      2.928   7.789 2.24e-08 ***
## vsStraight         1.708      2.235   0.764  0.45135    
## amManual           3.165      1.528   2.071  0.04805 *  
## as.factor(cyl)6   -5.399      1.837  -2.938  0.00668 ** 
## as.factor(cyl)8   -8.161      2.892  -2.822  0.00884 ** 
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 3.097 on 27 degrees of freedom
## Multiple R-squared:  0.7701,	Adjusted R-squared:  0.736 
## F-statistic: 22.61 on 4 and 27 DF,  p-value: 2.741e-08&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The variables &lt;code&gt;vs&lt;/code&gt; and &lt;code&gt;am&lt;/code&gt; have 2 levels so one is displayed in the regression output. The variable &lt;code&gt;cyl&lt;/code&gt; has 3 levels (4, 6 and 8) so 2 of them are displayed. The overall effect of &lt;code&gt;vs&lt;/code&gt; and &lt;code&gt;am&lt;/code&gt; are reported in the &lt;code&gt;Pr(&amp;gt;|t|)&lt;/code&gt; column, but not the &lt;strong&gt;overall&lt;/strong&gt; effect of &lt;code&gt;cyl&lt;/code&gt; because there are more than 2 levels for this variable.&lt;/p&gt;
&lt;p&gt;To get the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value of the overall effect of a categorical variable, we need to get an analysis of variance table via the &lt;code&gt;Anova()&lt;/code&gt; function from the &lt;code&gt;{car}&lt;/code&gt; package:&lt;a href=&#34;#fn18&#34; class=&#34;footnote-ref&#34; id=&#34;fnref18&#34;&gt;&lt;sup&gt;18&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(car)
Anova(model5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Anova Table (Type II tests)
## 
## Response: mpg
##                 Sum Sq Df F value  Pr(&amp;gt;F)  
## vs               5.601  1  0.5841 0.45135  
## am              41.122  1  4.2886 0.04805 *
## as.factor(cyl)  94.591  2  4.9324 0.01493 *
## Residuals      258.895 27                  
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From this analysis of variance table, we conclude that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;vs&lt;/code&gt; is not significantly associated with &lt;code&gt;mpg&lt;/code&gt; (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.451)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;am&lt;/code&gt; and &lt;code&gt;cyl&lt;/code&gt; are significantly associated with &lt;code&gt;mpg&lt;/code&gt; (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values &amp;lt; 0.05)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;interaction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Interaction&lt;/h3&gt;
&lt;p&gt;So far we have covered multiple linear regression without any interaction.&lt;/p&gt;
&lt;p&gt;There is an &lt;strong&gt;interaction&lt;/strong&gt; effect between factors A and B &lt;strong&gt;if the effect of factor A on the response depends on the level taken by factor B&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In R, interaction can be added as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model6 &amp;lt;- lm(mpg ~ wt + am + wt:am,
  data = dat
)

# Or in a shorter way:
model6 &amp;lt;- lm(mpg ~ wt * am,
  data = dat
)

summary(model6)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ wt * am, data = dat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.6004 -1.5446 -0.5325  0.9012  6.0909 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)  31.4161     3.0201  10.402 4.00e-11 ***
## wt           -3.7859     0.7856  -4.819 4.55e-05 ***
## amManual     14.8784     4.2640   3.489  0.00162 ** 
## wt:amManual  -5.2984     1.4447  -3.667  0.00102 ** 
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 2.591 on 28 degrees of freedom
## Multiple R-squared:  0.833,	Adjusted R-squared:  0.8151 
## F-statistic: 46.57 on 3 and 28 DF,  p-value: 5.209e-11&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From the output we conclude that there is an interaction between the weight and the transmission (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.00102). This means that the effect of the weight on the distance traveled with a gallon &lt;strong&gt;depends on the transmission type&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The easiest way to handle interaction is to visualize the relationship for each level of the categorical variable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;visreg(model6, &amp;quot;wt&amp;quot;, by = &amp;quot;am&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/index_files/figure-html/unnamed-chunk-33-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We see that the relationship between weight and miles/gallon is stronger (the slope is steeper) for cars with a manual transmission compared to cars with an automatic transmission.&lt;/p&gt;
&lt;p&gt;This is a good example to illustrate the point that when studying a relationship between two variables, say &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt;, if one also has data for other variables which are potentially associated with both &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(Y\)&lt;/span&gt;, it is important to include them in the regression and to analyze the relationship &lt;strong&gt;conditionally on these variables&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Omitting some variables that should be included in the model may lead to erroneous and misleading conclusions, up to the point that the relationship is completely reversed (a phenomenon referred as &lt;a href=&#34;https://en.wikipedia.org/wiki/Simpson%27s_paradox&#34; target=&#34;_blank&#34;&gt;Simpson’s paradox&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Summary&lt;/h1&gt;
&lt;p&gt;In this article, we started with a reminder of &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#simple-linear-regression-reminder&#34;&gt;simple linear regression&lt;/a&gt; and in particular its &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#principle&#34;&gt;principle&lt;/a&gt; and how to &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#interpretations-of-coefficients-widehatbeta&#34;&gt;interpret the results&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This laid the foundations for a better understanding of &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#multiple-linear-regression&#34;&gt;multiple linear regression&lt;/a&gt;. After explaining its &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#principle-1&#34;&gt;principle&lt;/a&gt;, we showed how to &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#interpretations-of-coefficients-widehatbeta-1&#34;&gt;interpret the output&lt;/a&gt; and how to choose a &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#how-to-choose-a-good-linear-model&#34;&gt;good linear model&lt;/a&gt;. We then mentioned a couple of &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#visualizations-1&#34;&gt;visualizations&lt;/a&gt; and finished the article with some more &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#to-go-further&#34;&gt;advanced topics&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article helped you to understand better linear regression and gave you the confidence to do your own linear regressions in R. If you need to model a binary variable instead of a quantitative continuous variable, see how to perform a &lt;a href=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/&#34;&gt;binary logistic regression in R&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-austin2015number&#34; class=&#34;csl-entry&#34;&gt;
Austin, Peter C, and Ewout W Steyerberg. 2015. &lt;span&gt;“The Number of Subjects Per Variable Required in Linear Regression Analyses.”&lt;/span&gt; &lt;em&gt;Journal of Clinical Epidemiology&lt;/em&gt; 68 (6): 627–36.
&lt;/div&gt;
&lt;div id=&#34;ref-ernst2017regression&#34; class=&#34;csl-entry&#34;&gt;
Ernst, Anja F, and Casper J Albers. 2017. &lt;span&gt;“Regression Assumptions in Clinical Psychology Research Practice?a Systematic Review of Common Misconceptions.”&lt;/span&gt; &lt;em&gt;PeerJ&lt;/em&gt; 5: e3323.
&lt;/div&gt;
&lt;div id=&#34;ref-james2013introduction&#34; class=&#34;csl-entry&#34;&gt;
James, Gareth, Daniela Witten, Trevor Hastie, and Robert Tibshirani. 2013. &lt;em&gt;An Introduction to Statistical Learning&lt;/em&gt;. Vol. 112. Springer.
&lt;/div&gt;
&lt;div id=&#34;ref-lumley2002importance&#34; class=&#34;csl-entry&#34;&gt;
Lumley, Thomas, Paula Diehr, Scott Emerson, and Lu Chen. 2002. &lt;span&gt;“The Importance of the Normality Assumption in Large Public Health Data Sets.”&lt;/span&gt; &lt;em&gt;Annual Review of Public Health&lt;/em&gt; 23 (1): 151–69.
&lt;/div&gt;
&lt;div id=&#34;ref-schmidt2018linear&#34; class=&#34;csl-entry&#34;&gt;
Schmidt, Amand F, and Chris Finan. 2018. &lt;span&gt;“Linear Regression and the Normality Assumption.”&lt;/span&gt; &lt;em&gt;Journal of Clinical Epidemiology&lt;/em&gt; 98: 146–51.
&lt;/div&gt;
&lt;/div&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;Some people see regression analysis as a part of inferential statistics. It is true, as a sample is taken to evaluate the link between two or more variables in a population of interest. I tend to distinguish regression from inferential statistics for the simple reasons that (i) regressions are often used to a broader extent (for predictive analyses, among others), and because (ii) the main goal of linear regression (see this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#simple-linear-regression-reminder&#34;&gt;section&lt;/a&gt;) differs from the objectives of confidence intervals and hypothesis testing well known in the field of inferential statistics.&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;Formally, ANOVA can also be used to compare 2 groups, but in practice we tend to use it for 3 or more groups, leaving the t-test for 2 groups.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;More information about the dataset can be found by executing &lt;code&gt;?mtcars&lt;/code&gt;.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Note that it best to avoid interpreting the intercept when &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; cannot be equal to 0 or when it makes no sense in practice.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; is the number of observations.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;Other values than 0 are accepted as well. In that case, the test statistic becomes &lt;span class=&#34;math inline&#34;&gt;\(T_{n - 2} = \frac{\widehat\beta - a}{se(\widehat\beta_1)}\)&lt;/span&gt; where &lt;span class=&#34;math inline&#34;&gt;\(a\)&lt;/span&gt; is the hypothesized slope.&lt;a href=&#34;#fnref6&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn7&#34;&gt;&lt;p&gt;Note that linearity can be checked with a scatterplot of the two variables, or via a scatterplot of the residuals and the fitted values. See more about this in this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/#conditions-of-application-1&#34;&gt;section&lt;/a&gt;.&lt;a href=&#34;#fnref7&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn8&#34;&gt;&lt;p&gt;An observation is considered as an outlier based on the Cook’s distance if its value is &amp;gt; 1.&lt;a href=&#34;#fnref8&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn9&#34;&gt;&lt;p&gt;An observation has a high leverage value (and thus needs to be investigated) if it is greater than &lt;span class=&#34;math inline&#34;&gt;\(2p/n\)&lt;/span&gt;, where &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt; is the number of parameters in the model (intercept included) and &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; is the number of observations.&lt;a href=&#34;#fnref9&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn10&#34;&gt;&lt;p&gt;You can always change the reference level with the &lt;code&gt;relevel()&lt;/code&gt; function. See more &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;data manipulation techniques&lt;/a&gt;.&lt;a href=&#34;#fnref10&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn11&#34;&gt;&lt;p&gt;Note that linearity can also be tested with a scatterplot of the residuals and the fitted values.&lt;a href=&#34;#fnref11&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn12&#34;&gt;&lt;p&gt;After installing the &lt;code&gt;{performance}&lt;/code&gt; package, you will also need to install the &lt;code&gt;{see}&lt;/code&gt; package manually. See &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;how to install a R package&lt;/a&gt; if you need more help.&lt;a href=&#34;#fnref12&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn13&#34;&gt;&lt;p&gt;I use the threshold of 10 because, as shown by &lt;span class=&#34;citation&#34;&gt;James et al. (&lt;a href=&#34;#ref-james2013introduction&#34;&gt;2013&lt;/a&gt;)&lt;/span&gt;, a value between 5 and 10 indicates a moderate correlation, while VIF values greater than 10 indicate a high and &lt;em&gt;non-tolerable&lt;/em&gt; correlation.&lt;a href=&#34;#fnref13&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn14&#34;&gt;&lt;p&gt;&lt;span class=&#34;citation&#34;&gt;Austin and Steyerberg (&lt;a href=&#34;#ref-austin2015number&#34;&gt;2015&lt;/a&gt;)&lt;/span&gt; showed that two subjects per variable tends to permit accurate estimation of regression coefficients in a linear regression model estimated using ordinary least squares. Moreover, the general rule of thumb says that there should be at least 10 observations per variable &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-schmidt2018linear&#34;&gt;Schmidt and Finan 2018&lt;/a&gt;)&lt;/span&gt;. Our dataset contains 32 observations, above the minimum of 10 subjects per variable.&lt;a href=&#34;#fnref14&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn15&#34;&gt;&lt;p&gt;If you apply a logarithmic transformation, see two guides on how to interpret the results: in &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/images/Interpret-Regression-Coefficient-Estimates-in-linear-regression.png&#34;&gt;English&lt;/a&gt; and in &lt;a href=&#34;https://www.parisschoolofeconomics.eu/docs/yin-remi/interpretation-des-coefficients.pdf&#34; target=&#34;_blank&#34;&gt;French&lt;/a&gt;.&lt;a href=&#34;#fnref15&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn16&#34;&gt;&lt;p&gt;Note that a high &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; does not guarantee that you selected the best variables or that your model is good. It simply tells that the model fits the data quite well. It is advised to apply common sense when comparing models and not only refer to &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; (in particular when &lt;span class=&#34;math inline&#34;&gt;\(R^2\)&lt;/span&gt; are close).&lt;a href=&#34;#fnref16&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn17&#34;&gt;&lt;p&gt;There are two main methods; backward and forward. The backward method consists in starting from the model containing all the explanatory variables likely to be relevant, then recursively removing the variable which reduces the information criterion of the model, until no reduction is possible. The forward method is the reverse of the backward method in the sense that we start from a one-variable model with the lowest information criterion and at each step, an explanatory variable is added. By default, the &lt;code&gt;step()&lt;/code&gt; function in R combines the backward and forward methods.&lt;a href=&#34;#fnref17&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn18&#34;&gt;&lt;p&gt;To not be confused with the &lt;code&gt;anova()&lt;/code&gt; function because it provides results that depend on the order in which the variables appear in the model.&lt;a href=&#34;#fnref18&#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>Running pace calculator in R Shiny</title>
      <link>https://statsandr.com/blog/running-pace-calculator/</link>
      <pubDate>Mon, 15 Mar 2021 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/running-pace-calculator/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#running-pace-calculator&#34; id=&#34;toc-running-pace-calculator&#34;&gt;Running pace calculator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-use-it&#34; id=&#34;toc-how-to-use-it&#34;&gt;How to use it?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#code&#34; id=&#34;toc-code&#34;&gt;Code&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;images/running-pace-calculator.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;If you are a runner yourself, you are certainly aware of how important preparation is before a race. For the preparation of my first &lt;a href=&#34;https://www.strava.com/activities/1928117850/overview&#34; target=&#34;_blank&#34;&gt;marathon&lt;/a&gt;, I used to rely on a training plan.&lt;/p&gt;
&lt;p&gt;This running plan was great, but an important information was missing: the running pace. Most of the time, the distance and the time was given, but I needed to figure out the pace myself.&lt;/p&gt;
&lt;p&gt;Although the computation is fairly easy, I felt like I was missing a quick way to compute my running pace based on the distance and expected time given by the training plan.&lt;/p&gt;
&lt;p&gt;So I started to look for a solution online, but I was never completely satisfied. Some running pace calculators were too detailed (showing way too much information) others were too basic (showing not enough information).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;running-pace-calculator&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Running pace calculator&lt;/h1&gt;
&lt;p&gt;I thus decided to create one myself so I could really choose what information would be displayed, and how it would be displayed.&lt;/p&gt;
&lt;p&gt;For the runners among you, here is a link to the application:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://antoinesoetewey.shinyapps.io/running-pace-calculator/&#34; target=&#34;_blank&#34;&gt;&lt;strong&gt;Running pace calculator&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you follow the blog, you know how much I like R Shiny, so you probably guessed that the calculator is built with this technology.&lt;/p&gt;
&lt;p&gt;Note that this running pace calculator is inspired by several calculators I found online. I kept it quite basic so that it goes straight to the point, but most importantly so that it would fit to my needs (which may be different than yours).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-use-it&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to use it?&lt;/h1&gt;
&lt;p&gt;I try to keep all my &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny apps&lt;/a&gt; easy to use for everyone. However, here is how to use it in case it is not intuitive enough:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Access the app via this &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/running-pace-calculator/&#34; target=&#34;_blank&#34;&gt;link&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Choose the units (kilometers or miles)&lt;/li&gt;
&lt;li&gt;Enter the distance you plan to run&lt;/li&gt;
&lt;li&gt;Enter the time for which you would like to run that distance&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;On the right panel (or bottom if you use the app on mobile) you will see:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The pace you will need to respect in order to run the distance within the time you specified&lt;/li&gt;
&lt;li&gt;Depending on the units you selected, your pace will be displayed in minutes/km or minutes/miles, and kilometers/hour or miles/hour&lt;/li&gt;
&lt;li&gt;The table below displays the splits—the time at each kilometer or mile&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Update of January 11, 2023:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Until now, only the conversion from distance and time to pace was possible. For completeness, I have added to following conversions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pace and time to distance: enter the pace and the time you plan to run to find the expected running distance.&lt;/li&gt;
&lt;li&gt;Pace and distance to time: enter the pace and the distance you plan to run to find the expected running time.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;code&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Code&lt;/h1&gt;
&lt;p&gt;As for all my &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny apps&lt;/a&gt;, the code is available on &lt;a href=&#34;https://github.com/AntoineSoetewey/running-pace-calculator&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;. Feel free to open an issue if you find a bug or if you have a suggestion. And if you are proficient in R Shiny, do not hesitate to propose a pull request with your suggestions implemented.&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 &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/running-pace-calculator/&#34; target=&#34;_blank&#34;&gt;running pace calculator&lt;/a&gt; will be useful if you are a runner, or if you plan to start running.&lt;/p&gt;
&lt;p&gt;As always, if you have a question about the app, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Hypothesis test by hand</title>
      <link>https://statsandr.com/blog/hypothesis-test-by-hand/</link>
      <pubDate>Wed, 27 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/hypothesis-test-by-hand/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#descriptive-versus-inferential-statistics&#34; id=&#34;toc-descriptive-versus-inferential-statistics&#34;&gt;Descriptive versus inferential statistics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#motivations-and-limitations&#34; id=&#34;toc-motivations-and-limitations&#34;&gt;Motivations and limitations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hypothesis-test&#34; id=&#34;toc-hypothesis-test&#34;&gt;Hypothesis test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#why&#34; id=&#34;toc-why&#34;&gt;Why?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#when&#34; id=&#34;toc-when&#34;&gt;When?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how&#34; id=&#34;toc-how&#34;&gt;How?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#method-a-comparing-the-test-statistic-with-the-critical-value&#34; id=&#34;toc-method-a-comparing-the-test-statistic-with-the-critical-value&#34;&gt;Method A: Comparing the test statistic with the critical value&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#step-1-stating-the-null-and-alternative-hypothesis&#34; id=&#34;toc-step-1-stating-the-null-and-alternative-hypothesis&#34;&gt;Step #1: Stating the null and alternative hypothesis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-2-computing-the-test-statistic&#34; id=&#34;toc-step-2-computing-the-test-statistic&#34;&gt;Step #2: Computing the test statistic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-3-finding-the-critical-value&#34; id=&#34;toc-step-3-finding-the-critical-value&#34;&gt;Step #3: Finding the critical value&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-4-concluding-and-interpreting-the-results&#34; id=&#34;toc-step-4-concluding-and-interpreting-the-results&#34;&gt;Step #4: Concluding and interpreting the results&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#why-dont-we-accept-h_0&#34; id=&#34;toc-why-dont-we-accept-h_0&#34;&gt;Why don’t we accept &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#method-b-comparing-the-p-value-with-the-significance-level-alpha&#34; id=&#34;toc-method-b-comparing-the-p-value-with-the-significance-level-alpha&#34;&gt;Method B: Comparing the &lt;em&gt;p&lt;/em&gt;-value with the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#step-1-stating-the-null-and-alternative-hypothesis-1&#34; id=&#34;toc-step-1-stating-the-null-and-alternative-hypothesis-1&#34;&gt;Step #1: Stating the null and alternative hypothesis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-2-computing-the-test-statistic-1&#34; id=&#34;toc-step-2-computing-the-test-statistic-1&#34;&gt;Step #2: Computing the test statistic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-3-computing-the-p-value&#34; id=&#34;toc-step-3-computing-the-p-value&#34;&gt;Step #3: Computing the &lt;em&gt;p&lt;/em&gt;-value&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-4-concluding-and-interpreting-the-results-1&#34; id=&#34;toc-step-4-concluding-and-interpreting-the-results-1&#34;&gt;Step #4: Concluding and interpreting the results&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#method-c-comparing-the-target-parameter-with-the-confidence-interval&#34; id=&#34;toc-method-c-comparing-the-target-parameter-with-the-confidence-interval&#34;&gt;Method C: Comparing the target parameter with the confidence interval&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#step-1-stating-the-null-and-alternative-hypothesis-2&#34; id=&#34;toc-step-1-stating-the-null-and-alternative-hypothesis-2&#34;&gt;Step #1: Stating the null and alternative hypothesis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-2-computing-the-confidence-interval&#34; id=&#34;toc-step-2-computing-the-confidence-interval&#34;&gt;Step #2: Computing the confidence interval&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-3-concluding-and-interpreting-the-results&#34; id=&#34;toc-step-3-concluding-and-interpreting-the-results&#34;&gt;Step #3: Concluding and interpreting the results&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#which-method-to-choose&#34; id=&#34;toc-which-method-to-choose&#34;&gt;Which method to choose?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#summary&#34; id=&#34;toc-summary&#34;&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2021-01-27-hypothesis-test-by-hand_files/hypothesis-test-by-hand.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;descriptive-versus-inferential-statistics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Descriptive versus inferential statistics&lt;/h1&gt;
&lt;p&gt;Remember that &lt;strong&gt;&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;descriptive statistics&lt;/a&gt;&lt;/strong&gt; is the branch of statistics aiming at &lt;strong&gt;describing and summarizing a set of data&lt;/strong&gt; in the best possible manner, that is, by reducing it down to a few meaningful key measures and visualizations—with as little loss of information as possible. In other words, the branch of &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;descriptive statistics&lt;/a&gt; helps to have a better understanding and a clear image about a set of observations thanks to summary statistics and graphics. With descriptive statistics, there is no uncertainty because we describe only the group of observations that we decided to work on and no attempt is made to generalize the observed characteristics to another or to a larger group of observations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&#34;https://statsandr.com/tags/inferential-statistics/&#34;&gt;Inferential statistics&lt;/a&gt;&lt;/strong&gt;, one the other hand, is the branch of statistics that uses a random sample of data taken from a population to make inferences, i.e., to &lt;strong&gt;draw conclusions about the &lt;em&gt;population&lt;/em&gt; of interest&lt;/strong&gt; (see the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;difference between population and sample&lt;/a&gt; if you need a refresh of the two concepts). In other words, information from the sample is used to make generalizations about the parameter of interest in the population.&lt;/p&gt;
&lt;p&gt;The two most important tools used in the domain of inferential statistics are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;hypothesis test (which is the main subject of the present article), and&lt;/li&gt;
&lt;li&gt;confidence interval (which is briefly discussed in this &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#method-c-comparing-the-target-parameter-with-the-confidence-interval&#34;&gt;section&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;motivations-and-limitations&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Motivations and limitations&lt;/h1&gt;
&lt;p&gt;Via my &lt;a href=&#34;https://www.antoinesoetewey.com/teaching/&#34; target=&#34;_blank&#34;&gt;teaching&lt;/a&gt; tasks, I realized that many students (especially in introductory statistic classes) struggle to perform hypothesis tests and interpret the results. It seems to me that these students often encounter difficulties mainly because hypothesis testing is rather unclear and abstract to them.&lt;/p&gt;
&lt;p&gt;One of the reason it looks abstract to them is because they do not understand the final goal of hypothesis testing—the “why” behind this tool. They often do inferential statistics without understanding the reasoning behind it, as if they were following a cooking recipe which does not require any thinking. However, as soon as they understand the principle underlying hypothesis testing, it is much easier for them to apply the concepts and solve the exercises.&lt;/p&gt;
&lt;p&gt;For this reason, I though it would be useful to write an article on the goal of hypothesis tests (the “why?”), in which context they should be used (the “when?”), how they work (the “how?”) and how to interpret the results (the “so what?”). Like anything else in statistics, it becomes much easier to apply a concept in practice when we understand what we are testing or what we are trying to demonstrate beforehand.&lt;/p&gt;
&lt;p&gt;In this article, I present—as comprehensibly as possible—the different &lt;strong&gt;steps required to perform and conclude a hypothesis test by hand&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;These steps are illustrated with a basic example. This will build the theoretical foundations of hypothesis testing, which will in turn be of great help for the understanding of most &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hypothesis tests come in many forms and can be used for many parameters or research questions. The steps I present in this article are not applicable to &lt;em&gt;all&lt;/em&gt; hypothesis test, unfortunately.&lt;/p&gt;
&lt;p&gt;They are however, appropriate for &lt;em&gt;at least&lt;/em&gt; the most common hypothesis tests—the tests on:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;One mean: &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Two means:
&lt;ul&gt;
&lt;li&gt;independent samples: &lt;span class=&#34;math inline&#34;&gt;\(\mu_1\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\mu_2\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;paired samples: &lt;span class=&#34;math inline&#34;&gt;\(\mu_D\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;One proportion: &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Two proportions: &lt;span class=&#34;math inline&#34;&gt;\(p_1\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(p_2\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;One variance: &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Two variances: &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_1\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_2\)&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The good news is that the principles behind these 6 statistical tests (and many more) are exactly the same. So if you understand the intuition and the process for one of them, all others pretty much follow.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;hypothesis-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Hypothesis test&lt;/h1&gt;
&lt;div id=&#34;why&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Why?&lt;/h2&gt;
&lt;p&gt;Unlike &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; where we only describe the data at hand, &lt;strong&gt;hypothesis tests use a subset of observations&lt;/strong&gt;, referred as a &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt;, &lt;strong&gt;to draw conclusions about a population&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;One may wonder why we would try to “guess” or make inference about a parameter of a population based on a sample, instead of simply collecting data for the entire population, compute statistics we are interested in and take decisions based upon that.&lt;/p&gt;
&lt;p&gt;The main reason we actually use a sample instead of the entire population is because, most of the time, collecting data on the entire population is practically impossible, too complex, too expensive, it would take too long, or a combination of any of these.&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;/p&gt;
&lt;p&gt;So the &lt;strong&gt;overall objective of a hypothesis test is to draw conclusions in order to confirm or refute a belief about a population&lt;/strong&gt;, based on a smaller group of observations.&lt;/p&gt;
&lt;p&gt;In practice, we take some measurements of the variable of interest—representing the sample(s)—and we check whether our measurements are likely or not given our assumption (our belief). Based on the &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/&#34;&gt;probability&lt;/a&gt; of observing the sample(s) we have, we decide whether we can trust our belief or not.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;when&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;When?&lt;/h2&gt;
&lt;p&gt;Hypothesis tests have many practical applications.&lt;/p&gt;
&lt;p&gt;Here are different situations illustrating when the 6 tests mentioned above would be appropriate:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;One mean: suppose that a health professional would like to test whether the mean weight of Belgian adults is different than 80 kg (176.4 lbs).&lt;/li&gt;
&lt;li&gt;Two means:
&lt;ul&gt;
&lt;li&gt;Independent samples: suppose that a physiotherapist would like to test the effectiveness of a new treatment by measuring the mean response time (in seconds) for patients in a control group and patients in a treatment group, where patients in the two groups are different.&lt;/li&gt;
&lt;li&gt;Paired samples: suppose that a physiotherapist would like to test the effectiveness of a new treatment by measuring the mean response time (in seconds) before and after a treatment, where patients are measured twice—before and after treatment, so patients are the same in the 2 samples.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;One proportion: suppose that a political pundit would like to test whether the proportion of citizens who are going to vote for a specific candidate is smaller than 30%.&lt;/li&gt;
&lt;li&gt;Two proportions: suppose that a doctor would like to test whether the proportion of smokers is different between professional and amateur athletes.&lt;/li&gt;
&lt;li&gt;One variance: suppose that an engineer would like to test whether a voltmeter has a lower variability than what is imposed by the safety standards.&lt;/li&gt;
&lt;li&gt;Two variances: suppose that, in a factory, two production lines work independently from each other. The financial manager would like to test whether the costs of the weekly maintenance of these two machines have the same variance. Note that a test on two variances is also often performed to verify the assumption of equal variances, which is required for several other statistical tests, such as the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test&lt;/a&gt; for instance.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Of course, this is a non-exhaustive list of potential applications and many research questions can be answered thanks to a hypothesis test.&lt;/p&gt;
&lt;p&gt;One important point to remember is that in hypothesis testing we are always interested in the population and not in the sample. The sample is used for the aim of drawing conclusions about the population, so we always test in terms of the population.&lt;/p&gt;
&lt;p&gt;Usually, &lt;strong&gt;hypothesis tests are used to answer research questions in confirmatory analyses&lt;/strong&gt;. Confirmatory analyses refer to statistical analyses where hypotheses—deducted from theory—are defined beforehand (preferably before data collection). In this approach, the researcher has a specific idea about the variables under consideration and she is trying to see if her idea, specified as hypotheses, is supported by data.&lt;/p&gt;
&lt;p&gt;On the other hand, hypothesis tests are rarely used in exploratory analyses.&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; Exploratory analyses aims to uncover possible relationships between the variables under investigation. In this approach, the researcher does not have any clear theory-driven assumptions or ideas in mind before data collection. This is the reason exploratory analyses are sometimes referred as hypothesis-generating analyses—they are used to create some hypotheses, which in turn may be tested via confirmatory analyses at a later stage.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;How?&lt;/h2&gt;
&lt;p&gt;There are, to my knowledge, 3 different methods to perform a hypothesis tests:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#method-a-comparing-the-test-statistic-with-the-critical-value&#34;&gt;Method A: Comparing the test statistic with the &lt;strong&gt;critical value&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#method-b-comparing-the-p-value-with-the-significance-level-alpha&#34;&gt;Method B: Comparing the &lt;strong&gt;&lt;em&gt;p&lt;/em&gt;-value&lt;/strong&gt; with the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#method-c-comparing-the-target-parameter-with-the-confidence-interval&#34;&gt;Method C: Comparing the target parameter with the &lt;strong&gt;confidence interval&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Although the process for these 3 approaches may slightly differ, they all lead to the exact same conclusions. Using one method or another is, therefore, more often than not a matter of personal choice or a matter of context. See this &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#which-method-to-choose&#34;&gt;section&lt;/a&gt; to know which method I use depending on the context.&lt;/p&gt;
&lt;p&gt;I present the 3 methods in the following sections, starting with, in my opinion, the most comprehensive one when it comes to doing it by hand: comparing the test statistic with the critical value.&lt;/p&gt;
&lt;p&gt;For the three methods, I will explain the required steps to perform a hypothesis test from a general point of view and illustrate them with the following situation:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Suppose a health professional who would like to test whether the mean weight of Belgian adults is different than 80 kg.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Note that, as for most hypothesis tests, the test we are going to use as example below requires some assumptions. Since the aim of the present article is to explain a hypothesis test, we assume that all assumptions are met. For the interested reader, see the assumptions (and how to verify them) for this type of hypothesis test in the article presenting the &lt;a href=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/#assumptions&#34;&gt;one-sample t-test&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;method-a-comparing-the-test-statistic-with-the-critical-value&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Method A: Comparing the test statistic with the critical value&lt;/h3&gt;
&lt;p&gt;Method A, which consists in comparing the test statistic with the critical value, boils down to the following 4 steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Stating the &lt;strong&gt;null and alternative hypothesis&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Computing the &lt;strong&gt;test statistic&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Finding the &lt;strong&gt;critical value&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Concluding&lt;/strong&gt; and interpreting the results&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Each step is detailed below.&lt;/p&gt;
&lt;div id=&#34;step-1-stating-the-null-and-alternative-hypothesis&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #1: Stating the null and alternative hypothesis&lt;/h4&gt;
&lt;p&gt;As discussed before, a hypothesis test first requires an idea, that is, an assumption about a phenomenon. This assumption, referred as hypothesis, is derived from the theory and/or the research question.&lt;/p&gt;
&lt;p&gt;Since a hypothesis test is used to confirm or refute a prior belief, we need to &lt;strong&gt;formulate our belief so that there is a null and an alternative hypothesis&lt;/strong&gt;. Those hypotheses must be &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/#union-of-two-events&#34;&gt;mutually exclusive&lt;/a&gt;, which means that they cannot be true at the same time. This is step #1.&lt;/p&gt;
&lt;p&gt;In the context of our scenario, the null and alternative hypothesis are thus:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Null hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu = 80\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Alternative hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu \ne 80\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When stating the null and alternative hypothesis, bear in mind the following three points:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;em&gt;We are always interested in the population and not in the sample.&lt;/em&gt; This is the reason &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt; will always be written in terms of the population and not in terms of the sample (in this case, &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; and not &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}\)&lt;/span&gt;).&lt;/li&gt;
&lt;li&gt;&lt;em&gt;The assumption we would like to test is often the alternative hypothesis.&lt;/em&gt; If the researcher wanted to test whether the mean weight of Belgian adults was less than 80 kg, she would have stated &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu = 80\)&lt;/span&gt; (or equivalently, &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu \ge 80\)&lt;/span&gt;) and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu &amp;lt; 80\)&lt;/span&gt;.&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt; Do not mix the null with the alternative hypothesis, or the conclusions will be diametrically opposed!&lt;/li&gt;
&lt;li&gt;&lt;em&gt;The null hypothesis is often the status quo.&lt;/em&gt; For instance, suppose that a doctor wants to test whether the new treatment A is more efficient than the old treatment B. The status quo is that the new and old treatments are equally efficient. Assuming a larger value is better, she will then write &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_A = \mu_B\)&lt;/span&gt; (or equivalently, &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_A - \mu_B = 0\)&lt;/span&gt;) and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_A &amp;gt; \mu_B\)&lt;/span&gt; (or equivalently, &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_A - \mu_B &amp;gt; 0\)&lt;/span&gt;). On the opposite, if the lower the better, she would have written &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_A = \mu_B\)&lt;/span&gt; (or equivalently, &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_A - \mu_B = 0\)&lt;/span&gt;) and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_A &amp;lt; \mu_B\)&lt;/span&gt; (or equivalently, &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_A - \mu_B &amp;lt; 0\)&lt;/span&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-computing-the-test-statistic&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #2: Computing the test statistic&lt;/h4&gt;
&lt;p&gt;The &lt;strong&gt;test statistic&lt;/strong&gt; (often called &lt;strong&gt;t-stat&lt;/strong&gt;) is, in some sense, a metric indicating &lt;strong&gt;how extreme the observations are compared to the null hypothesis&lt;/strong&gt;. The higher the t-stat (in absolute value), the more extreme the observations are.&lt;/p&gt;
&lt;p&gt;There are several formulas to compute the t-stat, with one formula for each type of hypothesis test—one or two means, one or two proportions, one or two variances. This means that there is a formula to compute the t-stat for a hypothesis test on one mean, another formula for a test on two means, another for a test on one proportion, etc.&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The only difficulty in this second step is to choose the appropriate formula. As soon as you know which formula to use based on the type of test, you simply have to apply it to the data. For the interested reader, see the different formulas to compute the t-stat for the most common tests in this &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/statistics-201/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Luckily, formulas for hypothesis tests on one and two means, and one and two proportions follow the same structure.&lt;/p&gt;
&lt;p&gt;Computing the test statistic for these tests is similar than &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#probabilities-and-standard-normal-distribution&#34;&gt;scaling&lt;/a&gt; a random variable (a process also knows as “standardization” or “normalization”) which consists in subtracting the mean from that random variable, and dividing the result by the standard deviation:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[Z = \frac{X - \mu}{\sigma}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For these 4 hypothesis tests (one/two means and one/two proportions), computing the test statistic is like scaling the estimator (computed from the sample) corresponding to the parameter of interest (in the population). So we basically subtract the target parameter from the point estimator and then divide the result by the standard error (which is equivalent to the standard deviation but for an estimator).&lt;/p&gt;
&lt;p&gt;If this is unclear, here is how the test statistic (denoted &lt;span class=&#34;math inline&#34;&gt;\(t_{obs}\)&lt;/span&gt;) is computed in our scenario (assuming that the variance of the population is unknown):&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[t_{obs} = \frac{\bar{x} - \mu}{\frac{s}{\sqrt{n}}}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\bar{x}\)&lt;/span&gt; is the sample mean (i.e., the estimator)&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; is the mean under the null hypothesis (i.e., the target parameter)&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(s\)&lt;/span&gt; is the sample standard deviation&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; is the sample size&lt;/li&gt;
&lt;li&gt;(&lt;span class=&#34;math inline&#34;&gt;\(\frac{s}{\sqrt{n}}\)&lt;/span&gt; is the standard error)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Notice the similarity between the formula of this test statistic and the formula used to standardize a random variable. This structure is the same for a test on two means, one proportion and two proportions, except that the estimator, the parameter and the standard error are, of course, slightly different for each type of test.&lt;/p&gt;
&lt;p&gt;Suppose that in our case we have a sample mean of 71 kg (&lt;span class=&#34;math inline&#34;&gt;\(\bar{x}\)&lt;/span&gt; = 71), a sample standard deviation of 13 kg (&lt;span class=&#34;math inline&#34;&gt;\(s\)&lt;/span&gt; = 13) and a sample size of 10 adults (&lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; = 10). Remember that the population mean (the mean under the null hypothesis) is 80 kg (&lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; = 80).&lt;/p&gt;
&lt;p&gt;The t-stat is thus:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[t_{obs} = \frac{\bar{x} - \mu}{\frac{s}{\sqrt{n}}} = \frac{71 - 80}{\frac{13}{\sqrt{10}}} = -2.189\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Although formulas are different depending on which parameter you are testing, the value found for the test statistic gives us an indication on how extreme our observations are.&lt;/p&gt;
&lt;p&gt;We keep this value of -2.189 in mind because it will be used again in step #4.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3-finding-the-critical-value&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #3: Finding the critical value&lt;/h4&gt;
&lt;p&gt;Although the t-stat gives us an indication of how extreme our observations are, we cannot tell whether this “score of extremity” is &lt;em&gt;too&lt;/em&gt; extreme or not based on its value only.&lt;/p&gt;
&lt;p&gt;So, at this point, we cannot yet tell whether our data are too extreme or not. For this, we need to compare our t-stat with a threshold—referred as &lt;strong&gt;critical value&lt;/strong&gt;—given by the &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;probability distribution&lt;/a&gt; tables (and which can, of course, also be found with R).&lt;/p&gt;
&lt;p&gt;In the same way that the formula to compute the t-stat is different for each parameter of interest, the underlying probability distribution—and thus the statistical table—on which the critical value is based is also different for each target parameter. This means that, in addition to choosing the appropriate formula to compute the t-stat, we also need to select the appropriate probability distribution depending on the parameter we are testing.&lt;/p&gt;
&lt;p&gt;Luckily, there are only 4 different probability distributions for the 6 hypothesis tests covered in this article (one/two means, one/two proportions and one/two variances):&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#probabilities-and-standard-normal-distribution&#34;&gt;Standard Normal distribution&lt;/a&gt;:
&lt;ul&gt;
&lt;li&gt;test on one and two means with known population variance(s)&lt;/li&gt;
&lt;li&gt;test on two paired samples where the variance of the difference between the 2 samples &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_D\)&lt;/span&gt; is known&lt;/li&gt;
&lt;li&gt;test on one and two proportions (given that some assumptions are met)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Student distribution:
&lt;ul&gt;
&lt;li&gt;test on one and two means with &lt;em&gt;un&lt;/em&gt;known population variance(s)&lt;/li&gt;
&lt;li&gt;test on two paired samples where the variance of the difference between the 2 samples &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_D\)&lt;/span&gt; is &lt;em&gt;un&lt;/em&gt;known&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Chi-square distribution:
&lt;ul&gt;
&lt;li&gt;test on one variance&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Fisher distribution:
&lt;ul&gt;
&lt;li&gt;test on two variances&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Each probability distribution also has its own parameters (up to two parameters for the 4 distribution considered here), defining its shape and/or location. Parameter(s) of a probability distribution can be seen as its DNA; meaning that the distribution is entirely defined by its parameter(s).&lt;/p&gt;
&lt;p&gt;Taking our initial scenario—a health professional who would like to test whether the mean weight of Belgian adults is different than 80 kg—as example.&lt;/p&gt;
&lt;p&gt;The underlying probability distribution of a test on one mean is either the standard Normal or the Student distribution, depending on whether the variance of the &lt;em&gt;population&lt;/em&gt; (not sample variance!) is known or unknown:&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the population variance is known &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; the standard Normal distribution is used&lt;/li&gt;
&lt;li&gt;If the population variance is &lt;em&gt;un&lt;/em&gt;known &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; the Student distribution is used&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If no population variance is explicitly given, you can assume that it is unknown since you cannot compute it based on a sample. If you could compute it, that would mean you have access to the entire population and there is, in this case, no point in performing a hypothesis test (you could simply use some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; to confirm or refute your belief).&lt;/p&gt;
&lt;p&gt;In our example, no population variance is specified so it is assumed to be unknown. We therefore use the Student distribution.&lt;/p&gt;
&lt;p&gt;The Student distribution has one parameter which defines it; the number of degrees of freedom. The number of degrees of freedom depends on the type of hypothesis test. For instance, the number of degrees of freedom for a test on one mean is equal to the number of observations minus one (&lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; - 1). Without going too far into the details, the - 1 comes from the fact that there is one quantity which is estimated (i.e., the mean).&lt;a href=&#34;#fn7&#34; class=&#34;footnote-ref&#34; id=&#34;fnref7&#34;&gt;&lt;sup&gt;7&lt;/sup&gt;&lt;/a&gt; The sample size being equal to 10 in our example, the degrees of freedom is equal to &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; - 1 = 10 - 1 = 9.&lt;/p&gt;
&lt;p&gt;There is only one last element missing to find the critical value: the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;significance level&lt;/a&gt;. The &lt;strong&gt;significance level&lt;/strong&gt;, denoted &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;, is the probability of wrongly rejecting the null hypothesis, so the &lt;strong&gt;probability of rejecting the null hypothesis although it is in reality true&lt;/strong&gt;. In this sense, it is an error (type I error, as opposed to the type II error&lt;a href=&#34;#fn8&#34; class=&#34;footnote-ref&#34; id=&#34;fnref8&#34;&gt;&lt;sup&gt;8&lt;/sup&gt;&lt;/a&gt;) that we accept to deal with, in order to be able to draw conclusions about a population based on a subset of it.&lt;/p&gt;
&lt;p&gt;As you may have read in many statistical textbooks, the significance level is very often set to 5%.&lt;a href=&#34;#fn9&#34; class=&#34;footnote-ref&#34; id=&#34;fnref9&#34;&gt;&lt;sup&gt;9&lt;/sup&gt;&lt;/a&gt; In some fields (such as medicine or engineering, among others), the significance level is also sometimes set to 1% to decrease the error rate.&lt;/p&gt;
&lt;p&gt;It is best to specify the significance level &lt;em&gt;before&lt;/em&gt; performing a hypothesis test to avoid the temptation to set the significance level in accordance to the results (the temptation is even bigger when the results are on the edge of being significant). As I always tell my students, you cannot “guess” nor compute the significance level. Therefore, if it is not explicitly specified, you can safely assume it is 5%. In our case, we did not indicate it, so we take &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; = 5% = 0.05.&lt;/p&gt;
&lt;p&gt;Furthermore, in our example, we want to test whether the mean weight of Belgian adults is &lt;strong&gt;different&lt;/strong&gt; than 80 kg. Since we do not specify the direction of the test, it is a &lt;strong&gt;two-sided test&lt;/strong&gt;. If we wanted to test that the mean weight was less than 80 kg (&lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu &amp;lt;\)&lt;/span&gt; 80) or greater than 80 kg (&lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu &amp;gt;\)&lt;/span&gt; 80), we would have done a one-sided test.&lt;/p&gt;
&lt;p&gt;Make sure that you perform the correct test (two-sided or one-sided) because it has an impact on how to find the critical value (see more in the following paragraphs).&lt;/p&gt;
&lt;p&gt;So now that we know the appropriate distribution (Student distribution), its parameter (degrees of freedom (df) = 9), the significance level (&lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; = 0.05) and the direction (two-sided), we have all we need to find the critical value in the &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;statistical tables&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2021-01-27-hypothesis-test-by-hand_files/critical_value_student_distribution.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;By looking at the row df = 9 and the column &lt;span class=&#34;math inline&#34;&gt;\(t_.025\)&lt;/span&gt; in the Student’s distribution table, we find a critical value of:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[t_{n-1; \alpha / 2} = t_{9; 0.025} = 2.262\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;One may wonder why we take &lt;span class=&#34;math inline&#34;&gt;\(t_{\alpha/2} = t_.025\)&lt;/span&gt; and not &lt;span class=&#34;math inline&#34;&gt;\(t_\alpha = t_.05\)&lt;/span&gt; since the significance level is 0.05. The reason is that we are doing a two-sided test (&lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu \ne\)&lt;/span&gt; 80), so the error rate of 0.05 must be divided in 2 to find the critical value to the right of the distribution. Since the Student’s distribution is symmetric, the critical value to the left of the distribution is simply: -2.262.&lt;/p&gt;
&lt;p&gt;Visually, the error rate of 0.05 is partitioned into two parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;0.025 to the left of -2.262 and&lt;/li&gt;
&lt;li&gt;0.025 to the right of 2.262&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2021-01-27-hypothesis-test-by-hand_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We keep in mind these critical values of -2.262 and 2.262 for the fourth and last step.&lt;/p&gt;
&lt;p&gt;Note that the red shaded areas in the previous plot are also known as the rejection regions. More on that in the following section.&lt;/p&gt;
&lt;p&gt;These critical values can also be found in R, thanks to the &lt;code&gt;qt()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qt(0.025, df = 9, lower.tail = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -2.262157&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qt(0.025, df = 9, lower.tail = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2.262157&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;qt()&lt;/code&gt; function is used for the Student’s distribution (&lt;code&gt;q&lt;/code&gt; stands for quantile and &lt;code&gt;t&lt;/code&gt; for Student). There are other functions accompanying the different distributions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;qnorm()&lt;/code&gt; for the Normal distribution&lt;/li&gt;
&lt;li&gt;&lt;code&gt;qchisq()&lt;/code&gt; for the Chi-square distribution&lt;/li&gt;
&lt;li&gt;&lt;code&gt;qf()&lt;/code&gt; for the Fisher distribution&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;step-4-concluding-and-interpreting-the-results&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #4: Concluding and interpreting the results&lt;/h4&gt;
&lt;p&gt;In this fourth and last step, all we have to do is to &lt;strong&gt;compare the test statistic&lt;/strong&gt; (computed in step #2) &lt;strong&gt;with the critical values&lt;/strong&gt; (found in step #3) in order to &lt;strong&gt;conclude the hypothesis test&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The only two possibilities when concluding a hypothesis test are:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Rejection of the null hypothesis&lt;/li&gt;
&lt;li&gt;Non-rejection of the null hypothesis&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In our example of adult weight, remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the t-stat is -2.189&lt;/li&gt;
&lt;li&gt;the critical values are -2.262 and 2.262&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the &lt;strong&gt;t-stat gives an indication on how extreme our sample is&lt;/strong&gt; compared to the null hypothesis&lt;/li&gt;
&lt;li&gt;the &lt;strong&gt;critical values are the threshold from which the t-stat is considered as &lt;em&gt;too&lt;/em&gt; extreme&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To compare the t-stat with the critical values, I always recommend to plot them:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2021-01-27-hypothesis-test-by-hand_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;These two critical values form the rejection regions (the red shaded areas):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;from &lt;span class=&#34;math inline&#34;&gt;\(- \infty\)&lt;/span&gt; to -2.262, and&lt;/li&gt;
&lt;li&gt;from 2.262 to &lt;span class=&#34;math inline&#34;&gt;\(\infty\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the &lt;strong&gt;t-stat lies within one of the rejection region, we reject the null hypothesis&lt;/strong&gt;. On the contrary, if the &lt;strong&gt;t-stat does &lt;em&gt;not&lt;/em&gt; lie within any of the rejection region, we do &lt;em&gt;not&lt;/em&gt; reject the null hypothesis&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;As we can see from the above plot, the t-stat is less extreme than the critical value and therefore does not lie within any of the rejection region. In conclusion, we do not reject the null hypothesis that &lt;span class=&#34;math inline&#34;&gt;\(\mu = 80\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;This is the conclusion in statistical terms but they are meaningless without proper interpretation. So it is a good practice to also interpret the result in the context of the problem:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;At the 5% significance level, we do not reject the hypothesis that the mean weight of Belgian adults is 80 kg.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div id=&#34;why-dont-we-accept-h_0&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Why don’t we accept &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;?&lt;/h5&gt;
&lt;p&gt;From a more philosophical (but still very important) perspective, note that we wrote “we &lt;em&gt;do not reject&lt;/em&gt; the null hypothesis” and “we &lt;em&gt;do not reject&lt;/em&gt; the hypothesis that the mean weight of Belgian adults is equal to 80 kg”. We did not write “we &lt;em&gt;accept&lt;/em&gt; the null hypothesis” nor “the mean weight of Belgian adults is 80 kg”.&lt;/p&gt;
&lt;p&gt;The reason is due to the fact that, in hypothesis testing, we conclude something about the population based on a sample. There is, therefore, always some uncertainty and we cannot be 100% sure that our conclusion is correct.&lt;/p&gt;
&lt;p&gt;Perhaps it is the case that the mean weight of Belgian adults is in reality different than 80 kg, but &lt;strong&gt;we failed to prove it&lt;/strong&gt; based on the data at hand. It may be the case that if we had more observations, we would have rejected the null hypothesis (since all else being equal, a larger sample size implies a more extreme t-stat). Or, it may be the case that even with more observations, we would not have rejected the null hypothesis because the mean weight of Belgian adults is in reality close to 80 kg. We cannot distinguish between the two.&lt;/p&gt;
&lt;p&gt;So we can just say that we did not find enough evidence against the hypothesis that the mean weight of Belgian adults is 80 kg, but we do not conclude that the mean is equal to 80 kg.&lt;/p&gt;
&lt;p&gt;If the difference is still not clear to you, the following example may help. Suppose a person is suspected of having committed a crime. This person is either innocent—the null hypothesis—or guilty—the alternative hypothesis. In the attempt to know if the suspect committed the crime, the police collects as much information and proof as possible. This is similar to the researcher collecting data to form a sample. And then the judge, based on the collected evidence, decides whether the suspect is considered as innocent or guilty. If there is enough evidence that the suspect committed the crime, the judge will conclude that the suspect is guilty. In other words, she will reject the null hypothesis of the suspect being innocent because there are enough evidence that the suspect committed the crime.&lt;/p&gt;
&lt;p&gt;This is similar to the t-stat being more extreme than the critical value: we have enough information (based on the sample) to say that the null hypothesis is unlikely because our data would be too extreme if the null hypothesis were true. Since the sample cannot be “wrong” (it corresponds to the collected data), the only remaining possibility is that the null hypothesis is in fact wrong. This is the reason we write “we reject the null hypothesis”.&lt;/p&gt;
&lt;p&gt;On the other hand, if there is not enough evidence that the suspect committed the crime (or no evidence at all), the judge will conclude that the suspect is considered as not guilty. In other words, she will not reject the null hypothesis of the suspect being innocent. But even if she concludes that the suspect is considered as not guilty, she will never be 100% sure that he is really innocent.&lt;/p&gt;
&lt;p&gt;It may be the case that:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the suspect did not commit the crime, or&lt;/li&gt;
&lt;li&gt;the suspect committed the crime but the police was not able to collect enough information against the suspect.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the former case the suspect is really innocent, whereas in the latter case the suspect is guilty but the police and the judge failed to prove it because they failed to find enough evidence against him. Similar to hypothesis testing, the judge has to conclude the case by considering the suspect not guilty, without being able to distinguish between the two.&lt;/p&gt;
&lt;p&gt;This is the main reason we write “we do not reject the null hypothesis” or “we fail to reject the null hypothesis” (you may even read in some textbooks conclusion such as “there is no sufficient evidence in the data to reject the null hypothesis”), and we do not write “we accept the null hypothesis”.&lt;/p&gt;
&lt;p&gt;I hope this metaphor helped you to understand the reason why we reject the null hypothesis instead of accepting it.&lt;/p&gt;
&lt;p&gt;In the following sections, we present two other methods used in hypothesis testing.&lt;/p&gt;
&lt;p&gt;These methods will result in the exact same conclusion: non-rejection of the null hypothesis, that is, we do not reject the hypothesis that the mean weight of Belgian adults is 80 kg. It is thus presented only if you prefer to use these methods over the first one.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;method-b-comparing-the-p-value-with-the-significance-level-alpha&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Method B: Comparing the &lt;em&gt;p&lt;/em&gt;-value with the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Method B, which consists in computing the &lt;em&gt;p&lt;/em&gt;-value and comparing this &lt;em&gt;p&lt;/em&gt;-value with the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;, boils down to the following 4 steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Stating the &lt;strong&gt;null and alternative hypothesis&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Computing the &lt;strong&gt;test statistic&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Computing the &lt;strong&gt;&lt;em&gt;p&lt;/em&gt;-value&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Concluding&lt;/strong&gt; and interpreting the results&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In this second method which uses the &lt;em&gt;p&lt;/em&gt;-value, the first and second steps are similar than in the first method.&lt;/p&gt;
&lt;div id=&#34;step-1-stating-the-null-and-alternative-hypothesis-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #1: Stating the null and alternative hypothesis&lt;/h4&gt;
&lt;p&gt;The null and alternative hypotheses remain the same:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu = 80\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu \ne 80\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-computing-the-test-statistic-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #2: Computing the test statistic&lt;/h4&gt;
&lt;p&gt;Remember that the formula for the t-stat is different depending on the type of hypothesis test (one or two means, one or two proportions, one or two variances). In our case of one mean with unknown variance, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[t_{obs} = \frac{\bar{x} - \mu}{\frac{s}{\sqrt{n}}} = \frac{71 - 80}{\frac{13}{\sqrt{10}}} = -2.189\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3-computing-the-p-value&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #3: Computing the &lt;em&gt;p&lt;/em&gt;-value&lt;/h4&gt;
&lt;p&gt;The &lt;strong&gt;&lt;em&gt;p&lt;/em&gt;-value&lt;/strong&gt; is the &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/&#34;&gt;probability&lt;/a&gt; (so it goes from 0 to 1) of observing a sample at least as extreme as the one we observed if the null hypothesis were true. In some sense, it &lt;strong&gt;gives you an indication on how likely your null hypothesis is&lt;/strong&gt;. It is also defined as the smallest level of significance for which the data indicate rejection of the null hypothesis.&lt;/p&gt;
&lt;p&gt;For more information about the &lt;em&gt;p&lt;/em&gt;-value, I recommend reading this &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;note about the &lt;em&gt;p&lt;/em&gt;-value and the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Formally, the &lt;em&gt;p&lt;/em&gt;-value is the area beyond the test statistic. Since we are doing a two-sided test, the &lt;em&gt;p&lt;/em&gt;-value is thus the sum of the area above 2.189 and below -2.189.&lt;/p&gt;
&lt;p&gt;Visually, the &lt;em&gt;p&lt;/em&gt;-value is the sum of the two blue shaded areas in the following plot:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2021-01-27-hypothesis-test-by-hand_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value can computed with precision in R with the &lt;code&gt;pt()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p_val &amp;lt;- pt(-2.189, df = 9, lower.tail = TRUE) + pt(2.189, df = 9, lower.tail = FALSE)
p_val&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.05634202&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# which is equivalent than:
p_val &amp;lt;- 2 * pt(2.189, df = 9, lower.tail = FALSE)
p_val&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.05634202&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.0563, which indicates that there is a 5.63% chance to observe a sample at least as extreme as the one observed if the null hypothesis were true. This already gives us a hint on whether our t-stat is too extreme or not (and thus whether our null hypothesis is likely or not), but we formally conclude in step #4.&lt;/p&gt;
&lt;p&gt;Like the &lt;code&gt;qt()&lt;/code&gt; function to find the critical value, we use &lt;code&gt;pt()&lt;/code&gt; to find the &lt;em&gt;p&lt;/em&gt;-value because the underlying distribution is the Student’s distribution.&lt;/p&gt;
&lt;p&gt;Use &lt;code&gt;pnorm()&lt;/code&gt;, &lt;code&gt;pchisq()&lt;/code&gt; and &lt;code&gt;pf()&lt;/code&gt; for the Normal, Chi-square and Fisher distribution, respectively. See also this &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/statistics-101/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; to compute the &lt;em&gt;p&lt;/em&gt;-value given a certain t-stat for most probability distributions.&lt;/p&gt;
&lt;p&gt;If you do not have access to a computer (during exams for example) you will not be able to compute the &lt;em&gt;p&lt;/em&gt;-value precisely, but you can bound it using the statistical table referring to your test.&lt;/p&gt;
&lt;p&gt;In our case, we use the Student distribution and we look at the row df = 9 (since df = &lt;em&gt;n&lt;/em&gt; - 1):&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2021-01-27-hypothesis-test-by-hand_files/p-value-student-distribution.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The test statistic is -2.189&lt;/li&gt;
&lt;li&gt;We take the absolute value, which gives 2.189&lt;/li&gt;
&lt;li&gt;The value 2.189 is between 1.833 and 2.262 (highlighted in blue in the above table)&lt;/li&gt;
&lt;li&gt;From the column names &lt;span class=&#34;math inline&#34;&gt;\(t_{.050}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(t_{.025}\)&lt;/span&gt; related to 1.833 and 2.262, we know that:
&lt;ul&gt;
&lt;li&gt;the area to the right of 1.833 is 0.05&lt;/li&gt;
&lt;li&gt;the area to the right of 2.262 is 0.025&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;So we know that the area to the right of 2.189 must be between 0.025 and 0.05&lt;/li&gt;
&lt;li&gt;Since the Student distribution is symmetric, we know that the area to the left of -2.189 must also be between 0.025 and 0.05&lt;/li&gt;
&lt;li&gt;Therefore, the sum of the two areas must be between 0.05 and 0.10&lt;/li&gt;
&lt;li&gt;In other words, the &lt;em&gt;p&lt;/em&gt;-value is between 0.05 and 0.10 (i.e., 0.05 &amp;lt; &lt;em&gt;p&lt;/em&gt;-value &amp;lt; 0.10)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Although we could not compute it precisely, it is enough to conclude our hypothesis test in the last step.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-4-concluding-and-interpreting-the-results-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #4: Concluding and interpreting the results&lt;/h4&gt;
&lt;p&gt;The final step is now to simply compare the &lt;em&gt;p&lt;/em&gt;-value (computed in step #3) with the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;. As for all &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the &lt;strong&gt;&lt;em&gt;p&lt;/em&gt;-value is smaller&lt;/strong&gt; than &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (&lt;em&gt;p&lt;/em&gt;-value &amp;lt; 0.05) &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow H_0\)&lt;/span&gt; is unlikely &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; we &lt;strong&gt;reject&lt;/strong&gt; the null hypothesis&lt;/li&gt;
&lt;li&gt;If the &lt;strong&gt;&lt;em&gt;p&lt;/em&gt;-value is greater&lt;/strong&gt; than or equal to &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (&lt;em&gt;p&lt;/em&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(\ge\)&lt;/span&gt; 0.05) &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow H_0\)&lt;/span&gt; is likely &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; we do &lt;strong&gt;not reject&lt;/strong&gt; the null hypothesis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;No matter if we take into consideration the exact &lt;em&gt;p&lt;/em&gt;-value (i.e., 0.0563) or the bounded one (0.05 &amp;lt; &lt;em&gt;p&lt;/em&gt;-value &amp;lt; 0.10), it is larger than 0.05, so we do not reject the null hypothesis.&lt;a href=&#34;#fn10&#34; class=&#34;footnote-ref&#34; id=&#34;fnref10&#34;&gt;&lt;sup&gt;10&lt;/sup&gt;&lt;/a&gt; In the context of the problem, we do not reject the null hypothesis that the mean weight of Belgian adults is 80 kg.&lt;/p&gt;
&lt;p&gt;Remember that rejecting (or not rejecting) a null hypothesis at the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; using the critical value method (method A) is equivalent to rejecting (or not rejecting) the null hypothesis when the &lt;em&gt;p&lt;/em&gt;-value is lower (equal or greater) than &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (method B).&lt;/p&gt;
&lt;p&gt;This is the reason we find the exact same conclusion than with method A, and why you should too if you use both methods on the same data and with the same significance level.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;method-c-comparing-the-target-parameter-with-the-confidence-interval&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Method C: Comparing the target parameter with the confidence interval&lt;/h3&gt;
&lt;p&gt;Method C, which consists in computing the confidence interval and comparing this confidence interval with the target parameter (the parameter under the null hypothesis), boils down to the following 3 steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Stating the &lt;strong&gt;null and alternative hypothesis&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Computing the &lt;strong&gt;confidence interval&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Concluding&lt;/strong&gt; and interpreting the results&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In this last method which uses the confidence interval, the first step is similar than in the first two methods.&lt;/p&gt;
&lt;div id=&#34;step-1-stating-the-null-and-alternative-hypothesis-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #1: Stating the null and alternative hypothesis&lt;/h4&gt;
&lt;p&gt;The null and alternative hypotheses remain the same:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu = 80\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu \ne 80\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-computing-the-confidence-interval&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #2: Computing the confidence interval&lt;/h4&gt;
&lt;p&gt;Like hypothesis testing, confidence intervals are a well-known tool in inferential statistics.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Confidence interval is&lt;/strong&gt; an estimation procedure which produces &lt;strong&gt;an interval&lt;/strong&gt; (i.e., a range of values) &lt;strong&gt;containing the true parameter with a certain&lt;/strong&gt;—usually high—&lt;strong&gt;probability&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In the same way that there is a formula for each type of hypothesis test when computing the test statistics, there exists a formula for each type of confidence interval. Formulas for the different types of confidence intervals can be found in this &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/statistics-201/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here is the formula for a confidence interval on one mean &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; (with unknown population variance):&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
(1-\alpha)\text{% CI for } \mu = \bar{x} \pm t_{\alpha/2, n - 1} \frac{s}{\sqrt{n}}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(t_{\alpha/2, n - 1}\)&lt;/span&gt; is found in the Student distribution table (and is similar to the critical value found in step #3 of method A).&lt;/p&gt;
&lt;p&gt;Given our data and with &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; = 0.05, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{aligned}
95\text{% CI for } \mu &amp;amp;= \bar{x} \pm t_{\alpha/2, n - 1} \frac{s}{\sqrt{n}} \\
&amp;amp;= 71 \pm 2.262 \frac{13}{\sqrt{10}} \\
&amp;amp;= [61.70; 80.30]
\end{aligned}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The 95% confidence interval for &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; is [61.70; 80.30] kg. But &lt;strong&gt;what does a 95% confidence interval mean?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We know that this estimation procedure has a 95% probability of producing an interval containing the true mean &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt;. In other words, &lt;strong&gt;if we construct many confidence intervals&lt;/strong&gt; (with different samples of the same size), &lt;strong&gt;95% of them will&lt;/strong&gt;, on average, &lt;strong&gt;include the mean of the population&lt;/strong&gt; (the true parameter). So on average, 5% of these confidence intervals will not cover the true mean.&lt;/p&gt;
&lt;p&gt;If you wish to decrease this last percentage, you can decrease the significance level (set &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; = 0.01 or 0.02 for instance). All else being equal, this will increase the range of the confidence interval and thus increase the probability that it includes the true parameter.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3-concluding-and-interpreting-the-results&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step #3: Concluding and interpreting the results&lt;/h4&gt;
&lt;p&gt;The final step is simply to compare the confidence interval (constructed in step #2) with the value of the target parameter (the value under the null hypothesis, mentioned in step #1):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the &lt;strong&gt;confidence interval does not include&lt;/strong&gt; the hypothesized value &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow H_0\)&lt;/span&gt; is unlikely &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; we &lt;strong&gt;reject&lt;/strong&gt; the null hypothesis&lt;/li&gt;
&lt;li&gt;If the &lt;strong&gt;confidence interval includes&lt;/strong&gt; the hypothesized value &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow H_0\)&lt;/span&gt; is likely &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; we do &lt;strong&gt;not reject&lt;/strong&gt; the null hypothesis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In our example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the hypothesized value is 80 (since &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu\)&lt;/span&gt; = 80)&lt;/li&gt;
&lt;li&gt;80 is included in the 95% confidence interval since it goes from 61.70 to 80.30 kg&lt;/li&gt;
&lt;li&gt;So we do not reject the null hypothesis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the terms of the problem, we do not reject the hypothesis that the mean weight of Belgian adults is 80 kg.&lt;/p&gt;
&lt;p&gt;As you can see, the conclusion is equivalent than with the critical value method (method A) and the &lt;em&gt;p&lt;/em&gt;-value method (method B). Again, this must be the case since we use the same data and the same significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; for all three methods.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;which-method-to-choose&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Which method to choose?&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;All three methods give the same conclusion.&lt;/strong&gt; However, each method has its own advantage so I usually select the most convenient one depending on the situation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Method A (comparing the test statistic with the critical value):
&lt;ul&gt;
&lt;li&gt;It is, in my opinion, the &lt;strong&gt;easiest and most straightforward method&lt;/strong&gt; of the three when I do not have access to R.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Method B (comparing the &lt;em&gt;p&lt;/em&gt;-value with the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;):
&lt;ul&gt;
&lt;li&gt;In addition to being able to know whether the null hypothesis is rejected or not, computing the &lt;strong&gt;exact &lt;em&gt;p&lt;/em&gt;-value can be very convenient&lt;/strong&gt; so I tend to use this method if I have access to R.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Method C (comparing the target parameter with the confidence interval):
&lt;ul&gt;
&lt;li&gt;If I need to test &lt;strong&gt;several hypothesized values&lt;/strong&gt;, I tend to choose this method because I can construct one single confidence interval and compare it to as many values as I want. For example, with our 95% confidence interval [61.70; 80.30], I know that any value below 61.70 kg and above 80.30 kg will be rejected, without testing it for each value.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Summary&lt;/h1&gt;
&lt;p&gt;In this article, we reviewed the &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#why&#34;&gt;goals&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#when&#34;&gt;when&lt;/a&gt; hypothesis testing is used. We then showed &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#how&#34;&gt;how to do a hypothesis test by hand&lt;/a&gt; through three different methods (A. &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#method-a-comparing-the-test-statistic-with-the-critical-value&#34;&gt;critical value&lt;/a&gt;, B. &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#method-b-comparing-the-p-value-with-the-significance-level-alpha&#34;&gt;&lt;em&gt;p&lt;/em&gt;-value&lt;/a&gt; and C. &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#method-c-comparing-the-target-parameter-with-the-confidence-interval&#34;&gt;confidence interval&lt;/a&gt;). We also showed how to &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#step-4-concluding-and-interpreting-the-results&#34;&gt;interpret the results&lt;/a&gt; in the context of the initial problem.&lt;/p&gt;
&lt;p&gt;Although all three methods give the exact same conclusion when using the same data and the same significance level (otherwise there is a mistake somewhere), I also presented my personal &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#which-method-to-choose&#34;&gt;preferences&lt;/a&gt; when it comes to choosing one method over the other two.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article helped you to understand the structure of a hypothesis by hand. I remind you that, at least for the 6 hypothesis tests covered in this article, the formulas are different, but the structure and the reasoning behind it remain the same. So you basically have to know which formulas to use, and simply follow the steps mentioned in this article.&lt;/p&gt;
&lt;p&gt;For the interested reader, I created two accompanying Shiny apps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://antoinesoetewey.shinyapps.io/statistics-201/&#34; target=&#34;_blank&#34;&gt;Hypothesis testing and confidence intervals&lt;/a&gt;: after entering your data, the app illustrates all the steps in order to conclude the test and compute a confidence interval. See more information in this &lt;a href=&#34;https://statsandr.com/blog/a-shiny-app-for-inferential-statistics-by-hand/&#34;&gt;article&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://antoinesoetewey.shinyapps.io/statistics-101/&#34; target=&#34;_blank&#34;&gt;How to read statistical tables&lt;/a&gt;: the app helps you to compute the &lt;em&gt;p&lt;/em&gt;-value given a t-stat for most probability distributions. See more information in this &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;article&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&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;Suppose a researcher wants to test whether Belgian women are taller than French women. Suppose a health professional would like to know whether the proportion of smokers is different among athletes and non-athletes. It would take way too long to measure the height of all Belgian and French women and to ask all athletes and non-athletes their smoking habits. So most of the time, decisions are based on a representative sample of the population and not on the whole population. If we could measure the entire population in a reasonable time frame, we would not do any inferential statistics.&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;Don’t get me wrong, this does not mean that hypothesis tests are &lt;em&gt;never&lt;/em&gt; used in exploratory analyses. It is just much less frequent in exploratory research than in confirmatory research.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;You may see more or less steps in other articles or textbooks, depending on whether these steps are detailed or concise. Hypothesis testing should, however, follows the same process regardless of the number of steps.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;For one-sided tests, writing &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu = 80\)&lt;/span&gt; or &lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu \ge 80\)&lt;/span&gt; are both correct. The point is that the null and alternative hypothesis must be mutually exclusive since you are testing one hypothesis against the other, so both cannot be true at the same time.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;To be complete, there are even different formulas within each type of test, depending on whether some assumptions are met or not. For the interested reader, see all the different scenarios and thus the different formulas for a test on &lt;a href=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/&#34;&gt;one mean&lt;/a&gt; and on &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;two means&lt;/a&gt;.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;There are more uncertainty if the population variance is unknown than if it is known, and this greater uncertainty is taken into account by using the Student distribution instead of the standard Normal distribution. Also note that as the sample size increases, the degrees of freedom of the Student distribution increases and the two distributions become more and more similar. For large sample size (usually from &lt;span class=&#34;math inline&#34;&gt;\(n &amp;gt;\)&lt;/span&gt; 30), the Student distribution becomes so close to the standard Normal distribution that, even if the population variance is unknown, the standard Normal distribution can be used.&lt;a href=&#34;#fnref6&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn7&#34;&gt;&lt;p&gt;For a test on two independent samples, the degrees of freedom is &lt;span class=&#34;math inline&#34;&gt;\(n_1 + n_2 - 2\)&lt;/span&gt;, where &lt;span class=&#34;math inline&#34;&gt;\(n_1\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(n_2\)&lt;/span&gt; are the size of the first and second sample, respectively. Note the - 2 due to the fact that in this case, two quantities are estimated.&lt;a href=&#34;#fnref7&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn8&#34;&gt;&lt;p&gt;The type II error is the probability of not rejecting the null hypothesis although it is in reality false.&lt;a href=&#34;#fnref8&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn9&#34;&gt;&lt;p&gt;Whether this is a good or a bad standard is a question that comes up often and is debatable. This is, however, beyond the scope of the article.&lt;a href=&#34;#fnref9&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn10&#34;&gt;&lt;p&gt;Again, &lt;em&gt;p&lt;/em&gt;-values found via a statistical table or via R must be coherent.&lt;a href=&#34;#fnref10&#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>How to track the performance of your blog in R?</title>
      <link>https://statsandr.com/blog/track-blog-performance-in-r/</link>
      <pubDate>Wed, 16 Dec 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/track-blog-performance-in-r/</guid>
      <description>
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/plotly-binding/plotly.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/typedarray/typedarray.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/jquery/jquery.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/crosstalk/css/crosstalk.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/crosstalk/js/crosstalk.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/plotly-htmlwidgets-css/plotly-htmlwidgets.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/plotly-main/plotly-latest.min.js&#34;&gt;&lt;/script&gt;

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#prerequisites&#34; id=&#34;toc-prerequisites&#34;&gt;Prerequisites&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#analytics&#34; id=&#34;toc-analytics&#34;&gt;Analytics&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#users-page-views-and-sessions&#34; id=&#34;toc-users-page-views-and-sessions&#34;&gt;Users, page views and sessions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sessions-over-time&#34; id=&#34;toc-sessions-over-time&#34;&gt;Sessions over time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sessions-per-channel&#34; id=&#34;toc-sessions-per-channel&#34;&gt;Sessions per channel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sessions-per-day-of-week&#34; id=&#34;toc-sessions-per-day-of-week&#34;&gt;Sessions per day of week&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sessions-per-day-and-time&#34; id=&#34;toc-sessions-per-day-and-time&#34;&gt;Sessions per day and time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sessions-per-month-and-year&#34; id=&#34;toc-sessions-per-month-and-year&#34;&gt;Sessions per month and year&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#top-performing-pages&#34; id=&#34;toc-top-performing-pages&#34;&gt;Top performing pages&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#time-normalized-page-views&#34; id=&#34;toc-time-normalized-page-views&#34;&gt;Time-normalized page views&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#page-views-by-country&#34; id=&#34;toc-page-views-by-country&#34;&gt;Page views by country&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#browser-information&#34; id=&#34;toc-browser-information&#34;&gt;Browser information&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#user-engagement-by-devices&#34; id=&#34;toc-user-engagement-by-devices&#34;&gt;User engagement by devices&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#content&#34; id=&#34;toc-content&#34;&gt;Content&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#finding-topics&#34; id=&#34;toc-finding-topics&#34;&gt;Finding topics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#content-distribution&#34; id=&#34;toc-content-distribution&#34;&gt;Content distribution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#a-small-note-about-ads&#34; id=&#34;toc-a-small-note-about-ads&#34;&gt;A small note about ads&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#future-plans&#34; id=&#34;toc-future-plans&#34;&gt;Future plans&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#thank-you-note&#34; id=&#34;toc-thank-you-note&#34;&gt;Thank you note&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/track-blog-performance-r-google-analytics.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/&#34;&gt;Stats and R&lt;/a&gt; has been launched on December 16, 2019. Since the blog is officially one year old today and after having discussed the main &lt;a href=&#34;https://statsandr.com/blog/7-benefits-of-sharing-your-code-in-a-data-science-blog/&#34;&gt;benefits of maintaining a technical blog&lt;/a&gt;, I thought it would be a good time to share some numbers and thoughts about it.&lt;/p&gt;
&lt;p&gt;In this article, I show how to &lt;strong&gt;analyze a blog and its blog posts&lt;/strong&gt; with the &lt;code&gt;{googleAnalyticsR}&lt;/code&gt; R package (see package’s &lt;a href=&#34;https://8-bit-sheep.com/googleAnalyticsR/&#34; target=&#34;_blank&#34;&gt;full documentation&lt;/a&gt;). After sharing some analytics about the blog, I will also discuss about content creation/distribution and, to a smaller extent, the future plans. This is a way to share my journey as a data science blogger and a way to give you an insight about how Stats and R is doing.&lt;/p&gt;
&lt;p&gt;I decided to share with you some numbers through the &lt;code&gt;{googleAnalyticsR}&lt;/code&gt; package instead of the regular Google Analytics dashboards for several reasons:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;There are plenty of data analysts who are much more experienced than me when it comes to analyzing Google Analytics data via their dedicated platform&lt;/li&gt;
&lt;li&gt;I recently discovered the &lt;code&gt;{googleAnalyticsR}&lt;/code&gt; package in R and I would like to present its possibilities, and perhaps convince marketing specialists familiar with R to complement their Google Analytics dashboards with some data visualizations made in R (via some &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;ggplot2 visualizations&lt;/a&gt; for instance)&lt;/li&gt;
&lt;li&gt;I would like to &lt;strong&gt;automate the process&lt;/strong&gt; such in a way that I can easily &lt;strong&gt;replicate&lt;/strong&gt; the same types of analysis across the years. This will allow to see how the blog evolves throughout the years. We know that using R is a pretty good starting point when it comes to automation and replication—especially thanks to &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown reports&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I am not an expert in the field of digital marketing, but who knows, it may still give some ideas to data analysts, SEO specialists or other bloggers on how to track the performance of their own blog or website using R. For those of you who are interested in a more condensed analysis, see my &lt;a href=&#34;https://antoinesoetewey.com/files/google-analytics-dashboard&#34;&gt;custom Google Analytics dashboard&lt;/a&gt;.&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;/p&gt;
&lt;p&gt;Before going further, I would like to remind that I am not making a living from my blog (far from it!) and it is definitely not my goal as I do not believe that I would be the same kind of writer if it was my main occupation.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;prerequisites&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Prerequisites&lt;/h1&gt;
&lt;p&gt;As for any package in R, we first need to install it—with &lt;code&gt;install.packages()&lt;/code&gt;—and load it—with &lt;code&gt;library()&lt;/code&gt;:&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;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;#39;googleAnalyticsR&amp;#39;, dependencies = TRUE)
library(googleAnalyticsR)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, we need to authorize the access of the Google Analytics account using the &lt;code&gt;ga_auth()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ga_auth()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Running this code will open a browser window on which you will be able to authorize the access. This step will save an authorization token so you only have to do it once.&lt;/p&gt;
&lt;p&gt;Make sure to run the &lt;code&gt;ga_auth()&lt;/code&gt; function in a R script and not in a &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt; document. Follow this &lt;a href=&#34;https://8-bit-sheep.com/googleAnalyticsR/articles/rmarkdown.html&#34; target=&#34;_blank&#34;&gt;procedure&lt;/a&gt; if you want to use the package and its functions in a R Markdown report or in a blog post like I did for this article.&lt;/p&gt;
&lt;p&gt;Once we have completed the Google Analytics authorization, we will need the ID of the Google Analytics account we want to access. All the available accounts linked to your email address (after authentication) are stored in &lt;code&gt;ga_account_list()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;accounts &amp;lt;- ga_account_list()

accounts&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2 × 10
##   accountId account…¹ inter…² level websi…³ type  webPr…⁴ webPr…⁵ viewId viewN…⁶
##   &amp;lt;chr&amp;gt;     &amp;lt;chr&amp;gt;     &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  
## 1 86997981  Antoine … 129397… STAN… https:… WEB   UA-869… Antoin… 13318… All We…
## 2 86997981  Antoine … 218214… STAN… https:… WEB   UA-869… statsa… 20812… All We…
## # … with abbreviated variable names ¹​accountName, ²​internalWebPropertyId,
## #   ³​websiteUrl, ⁴​webPropertyId, ⁵​webPropertyName, ⁶​viewName&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;accounts$webPropertyName&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Antoine Soetewey&amp;quot; &amp;quot;statsandr.com&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see I have two accounts linked to my Google Analytics profile: one for my personal website (&lt;a href=&#34;https://antoinesoetewey.com/&#34; target=&#34;_blank&#34;&gt;antoinesoetewey.com&lt;/a&gt;) and one for this blog.&lt;/p&gt;
&lt;p&gt;Of course, I select the account linked to this blog:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select the view ID by property name
view_id &amp;lt;- accounts$viewId[which(accounts$webPropertyName == &amp;quot;statsandr.com&amp;quot;)]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make sure to edit the code with your own property name.&lt;/p&gt;
&lt;p&gt;We are now finally ready to use our Google Analytics data in R for a better analysis!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;analytics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Analytics&lt;/h1&gt;
&lt;div id=&#34;users-page-views-and-sessions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Users, page views and sessions&lt;/h2&gt;
&lt;p&gt;Let’s start with some general numbers, such as the number of &lt;strong&gt;users, sessions and page views&lt;/strong&gt; for the entire site. Note that for the present article, we use data over the past year, so from December 16, 2019 to December 15, 2020:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# set date range
start_date &amp;lt;- as.Date(&amp;quot;2019-12-16&amp;quot;)
end_date &amp;lt;- as.Date(&amp;quot;2020-12-15&amp;quot;)

# get Google Analytics (GA) data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;users&amp;quot;, &amp;quot;sessions&amp;quot;, &amp;quot;pageviews&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

gadata&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    users sessions pageviews
## 1 321940   428217    560491&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In its first year, Stats and R has attracted &lt;strong&gt;321,940 users&lt;/strong&gt;, who generated a total of &lt;strong&gt;428,217 sessions&lt;/strong&gt; and &lt;strong&gt;560,491 page views&lt;/strong&gt; (that is an average of &lt;em&gt;1531&lt;/em&gt; page views per day).&lt;/p&gt;
&lt;p&gt;For those unfamiliar with Google Analytics data and the difference between these metrics, remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;strong&gt;user&lt;/strong&gt; is the number of new and returning people who visit your site during a set period of time&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;session&lt;/strong&gt; is a group of user interactions with your website that take place within a given time frame&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;page view&lt;/strong&gt;, as the name suggests, is defined as a view of a page on your site&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So if person A reads three blog posts then leave the site and person B reads one blog post, your about page then leave the site, Google Analytics data will show 2 users, 2 sessions and 5 page views.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sessions-over-time&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sessions over time&lt;/h2&gt;
&lt;p&gt;In addition to the rather general metrics presented above, it is also interesting to illustrate the daily number of sessions &lt;strong&gt;over time&lt;/strong&gt; in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#scatterplot&#34;&gt;scatterplot&lt;/a&gt;—together with a smoothed line—to analyze the &lt;strong&gt;evolution&lt;/strong&gt; of the blog:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get the Google Analytics (GA) data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;sessions&amp;quot;), # edit for other metrics
  dimensions = c(&amp;quot;date&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# load required libraries
library(dplyr)
library(ggplot2)

# scatter plot with a trend line
gadata %&amp;gt;%
  ggplot(aes(x = date, y = sessions)) +
  geom_point(size = 1L, color = &amp;quot;steelblue&amp;quot;) + # change size and color of points
  geom_smooth(color = &amp;quot;darkgrey&amp;quot;, alpha = 0.25) + # change color of smoothed line and transparency of confidence interval
  theme_minimal() +
  labs(
    y = &amp;quot;Sessions&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Evolution of daily sessions&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  theme(plot.margin = unit(c(5.5, 15.5, 5.5, 5.5), &amp;quot;pt&amp;quot;)) + # to avoid the plot being cut on the right edge
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-6-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;(See &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;how to draw plots with the &lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt;, or with 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; if you are not familiar with the package.)&lt;/p&gt;
&lt;p&gt;As you can see, there was a huge peak of traffic around end of April, with almost 12,000 users in a single day. Yes, you read it well and there is no bug. The blog post “&lt;a href=&#34;https://statsandr.com/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;&gt;A package to download free Springer books during Covid-19 quarantine&lt;/a&gt;” went viral and generated a massive traffic for a few days. The daily number of sessions returned to a more normal level after a couple of days. We also observe an upward trend in the last months (since end of August/beginning of September), which indicates that the blog is growing in terms of number of daily sessions.&lt;/p&gt;
&lt;p&gt;Note that I decided to focus on the number of sessions and the number of page views in this section and the following ones, but you can always change to your preferred metrics by editing &lt;code&gt;metrics = c(&#34;sessions&#34;)&lt;/code&gt; in the code. See all available metrics provided by Google Analytics in this &lt;a href=&#34;https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sessions-per-channel&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sessions per channel&lt;/h2&gt;
&lt;p&gt;Knowing &lt;strong&gt;how people come to your blog&lt;/strong&gt; is a pretty important factor. Here is how to visualize the evolution of daily sessions per channel in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#line-plot&#34;&gt;line plot&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Get the data
trend_data &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  dimensions = c(&amp;quot;date&amp;quot;),
  metrics = &amp;quot;sessions&amp;quot;,
  pivots = pivot_ga4(&amp;quot;medium&amp;quot;, &amp;quot;sessions&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# edit variable names
names(trend_data) &amp;lt;- c(&amp;quot;Date&amp;quot;, &amp;quot;Total&amp;quot;, &amp;quot;Organic&amp;quot;, &amp;quot;Referral&amp;quot;, &amp;quot;Direct&amp;quot;, &amp;quot;Email&amp;quot;, &amp;quot;Social&amp;quot;)

# Change the data into a long format
library(tidyr)
trend_long &amp;lt;- gather(trend_data, Channel, Sessions, -Date)

# Build up the line plot
ggplot(trend_long, aes(x = Date, y = Sessions, group = Channel)) +
  theme_minimal() +
  geom_line(aes(colour = Channel)) +
  labs(
    y = &amp;quot;Sessions&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Evolution of daily sessions per channel&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-7-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;!-- It is also possible, via the `{highcharter}` package, to draw a dynamic line plot. This interactive version (which works only in HTML) allows you to mouse hover the plot to see the values for any specific date and for any channel: --&gt;
&lt;p&gt;We see that a large share of the traffic is from the organic channel, which indicates that most readers visit the blog after a query on search engines (mostly Google). In my case, where most of my posts are tutorials and which help people with specific problems, it is thus not a surprise that most of my traffic comes from organic search.&lt;/p&gt;
&lt;p&gt;We also notice some small peaks of sessions generated from the referral and direct channels, which are probably happening on the date of publication of each article.&lt;/p&gt;
&lt;p&gt;We also see that there seems to be a recurrent pattern of ups and downs in the number of daily sessions. Those are weekly cycles, with less readers during the weekend and which indicates that people are working on improving their statistical or R knowledge mostly during the week (which actually makes sense!).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sessions-per-day-of-week&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sessions per day of week&lt;/h2&gt;
&lt;p&gt;As shown above, traffic seems to be different depending on the &lt;strong&gt;day of week&lt;/strong&gt;. To investigate this further, we draw a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; of the number of sessions for every day of the week:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = &amp;quot;sessions&amp;quot;,
  dimensions = c(&amp;quot;dayOfWeek&amp;quot;, &amp;quot;date&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

## Recoding gadata$dayOfWeek following GA naming conventions
gadata$dayOfWeek &amp;lt;- recode_factor(gadata$dayOfWeek,
  &amp;quot;0&amp;quot; = &amp;quot;Sunday&amp;quot;,
  &amp;quot;1&amp;quot; = &amp;quot;Monday&amp;quot;,
  &amp;quot;2&amp;quot; = &amp;quot;Tuesday&amp;quot;,
  &amp;quot;3&amp;quot; = &amp;quot;Wednesday&amp;quot;,
  &amp;quot;4&amp;quot; = &amp;quot;Thursday&amp;quot;,
  &amp;quot;5&amp;quot; = &amp;quot;Friday&amp;quot;,
  &amp;quot;6&amp;quot; = &amp;quot;Saturday&amp;quot;
)

## Reordering gadata$dayOfWeek to have Monday as first day of the week
gadata$dayOfWeek &amp;lt;- factor(gadata$dayOfWeek,
  levels = c(
    &amp;quot;Monday&amp;quot;, &amp;quot;Tuesday&amp;quot;, &amp;quot;Wednesday&amp;quot;, &amp;quot;Thursday&amp;quot;, &amp;quot;Friday&amp;quot;, &amp;quot;Saturday&amp;quot;,
    &amp;quot;Sunday&amp;quot;
  )
)

# Boxplot
gadata %&amp;gt;%
  ggplot(aes(x = dayOfWeek, y = sessions)) +
  geom_boxplot() +
  theme_minimal() +
  labs(
    y = &amp;quot;Sessions&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Sessions per day of week&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-9-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see there are some &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;, probably due (in part at least) to the article that went viral. For the sake of illustration, below the same plot after removing points considered as potential outliers according to the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#interquartile-range&#34;&gt;interquartile range (IQR)&lt;/a&gt; criterion (i.e., points above or below the whiskers), and after a couple of visual improvements:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# boxplot
gadata %&amp;gt;%
  filter(sessions &amp;lt;= 3000) %&amp;gt;% # filter out sessions &amp;gt; 3,000
  ggplot(aes(x = dayOfWeek, y = sessions, fill = dayOfWeek)) + # fill boxplot by dayOfWeek
  geom_boxplot(varwidth = TRUE) + # vary boxes width according to n obs.
  geom_jitter(alpha = 0.25, width = 0.2) + # adds random noise and limit its width
  theme_minimal() +
  labs(
    y = &amp;quot;Sessions&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Sessions per day of week&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com\nPoints &amp;gt; 3,000 excluded&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  theme(legend.position = &amp;quot;none&amp;quot;) # remove legend&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-10-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;After excluding data points above 3,000, it is now easier to see that the median number of sessions (represented by the horizontal bold line in the boxes) is the highest on Wednesdays, and lowest on Saturdays and Sundays.&lt;/p&gt;
&lt;p&gt;The difference in sessions between weekdays is, however, not as large as expected.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sessions-per-day-and-time&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sessions per day and time&lt;/h2&gt;
&lt;!-- We have seen the traffic per day of week. The example below shows a visualization of traffic, broken down this time by **day of week and hour of day** in an interactive heatmap: --&gt;
&lt;!-- With this interactive heatmap, we see again that the blog is most active during weekdays. But in addition to that, we also see that it is most active from 2 p.m. to 8 p.m and calm during the night (from 11 p.m. to 9 a.m). Moreover, it seems that, so far, the highest traffic happened on Wednesdays from 3 p.m. to 6 p.m. --&gt;
&lt;p&gt;We have seen the traffic per day of week. The example below shows a visualization of traffic, broken down this time by &lt;strong&gt;day of week and hour of day&lt;/strong&gt; in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#density-plot&#34;&gt;density plot&lt;/a&gt;. In this plot, the device type has also been added for more insights.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Get data by deviceCategory, day of week and hour
weekly_data &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;sessions&amp;quot;),
  dimensions = c(&amp;quot;deviceCategory&amp;quot;, &amp;quot;dayOfWeekName&amp;quot;, &amp;quot;hour&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

## Manipulation using dplyr
weekly_data_sessions &amp;lt;- weekly_data %&amp;gt;%
  group_by(deviceCategory, dayOfWeekName, hour)

## Reordering weekly_data_sessions$dayOfWeekName to have Monday as first day of the week
weekly_data_sessions$dayOfWeekName &amp;lt;- factor(weekly_data_sessions$dayOfWeekName,
  levels = c(
    &amp;quot;Monday&amp;quot;, &amp;quot;Tuesday&amp;quot;, &amp;quot;Wednesday&amp;quot;, &amp;quot;Thursday&amp;quot;, &amp;quot;Friday&amp;quot;, &amp;quot;Saturday&amp;quot;,
    &amp;quot;Sunday&amp;quot;
  )
)

## Plotting using ggplot2
weekly_data_sessions %&amp;gt;%
  ggplot(aes(hour, sessions, fill = deviceCategory, group = deviceCategory)) +
  geom_area(position = &amp;quot;stack&amp;quot;) +
  labs(
    title = &amp;quot;Sessions per day and time&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;,
    x = &amp;quot;Time&amp;quot;,
    y = &amp;quot;Sessions&amp;quot;,
    fill = &amp;quot;Device&amp;quot; # edit legend title
  ) +
  theme_minimal() +
  facet_wrap(~dayOfWeekName, ncol = 2, scales = &amp;quot;fixed&amp;quot;) +
  theme(
    legend.position = &amp;quot;bottom&amp;quot;, # move legend
    axis.text = element_text(size = 7) # change font of axis text
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-12-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The above plot shows that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;traffic increases in the afternoon then declines in the late evening&lt;/li&gt;
&lt;li&gt;traffic is the highest from Monday to Thursday, and lowest on Saturday and Sunday&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition to that, thanks to the additional information on the device category, we also see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the number of sessions on tablet is low (it is so low compared to desktop and mobile that it is not visible on the plot), and&lt;/li&gt;
&lt;li&gt;the number of sessions on mobile seems to be quite stable during the entire day,&lt;/li&gt;
&lt;li&gt;as opposed to sessions on desktop which are highest at the end of the day.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;sessions-per-month-and-year&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sessions per month and year&lt;/h2&gt;
&lt;p&gt;In the following code, we create a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt; of the number of &lt;strong&gt;daily sessions per month and year&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get data
df2 &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;sessions&amp;quot;),
  dimensions = c(&amp;quot;date&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# add in year month columns to dataframe
df2$month &amp;lt;- format(df2$date, &amp;quot;%m&amp;quot;)
df2$year &amp;lt;- format(df2$date, &amp;quot;%Y&amp;quot;)

# sessions by month by year using dplyr then graph using ggplot2 barplot
df2 %&amp;gt;%
  group_by(year, month) %&amp;gt;%
  summarize(sessions = sum(sessions)) %&amp;gt;%
  # print table steps by month by year
  # print(n = 100) %&amp;gt;%
  # graph data by month by year
  ggplot(aes(x = month, y = sessions, fill = year)) +
  geom_bar(position = &amp;quot;dodge&amp;quot;, stat = &amp;quot;identity&amp;quot;) +
  theme_minimal() +
  labs(
    y = &amp;quot;Sessions&amp;quot;,
    x = &amp;quot;Month&amp;quot;,
    title = &amp;quot;Sessions per month and year&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-13-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This barplot allows to easily see the evolution of the number of sessions over the months, and compare this evolution across different years.&lt;/p&gt;
&lt;p&gt;At the moment, since the blog is online only since December 2019, the year factor is not relevant. However, I still present the visualization for other users who work on older websites, and also to remind my future self to create this interesting barplot when there will be data for more than a year.&lt;/p&gt;
&lt;!-- ### Forecasting sessions --&gt;
&lt;!-- You also may be interested in forecasting in order to predict, for instance, the number of daily sessions over the next weeks or months. --&gt;
&lt;!-- The example below uses the Holt-Winters method (which uses [time-series decomposition](http://www.dartistics.com/timeseries.html#decomposition){target=&#34;_blank&#34;}) to apply some smoothing and seasonality to the data to build a forecast that includes the likely range of values for the next 4 months (again, you can change `h = 4` to change the forecasting horizon). Notice that we specified `frequency = 7` in our time series due to the fact that there is weekly cycle in our data. --&gt;
&lt;/div&gt;
&lt;div id=&#34;top-performing-pages&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Top performing pages&lt;/h2&gt;
&lt;p&gt;Another important factor when measuring the performance of your blog or website is the &lt;strong&gt;number of page views for the different pages&lt;/strong&gt;. The top performing pages in terms of page views over the year can easily be found in Google Analytics (you can access it via &lt;code&gt;Behavior &amp;gt; Site Content &amp;gt; All pages&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;For the interested reader, here is how to get the data in R (note that you can change &lt;code&gt;n = 7&lt;/code&gt; in the code to change the number of top performing pages to display):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Make the request to GA
data_fetch &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;pageviews&amp;quot;),
  dimensions = c(&amp;quot;pageTitle&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

## Create a table of the most viewed posts
library(lubridate)
library(reactable)
library(stringr)

most_viewed_posts &amp;lt;- data_fetch %&amp;gt;%
  mutate(Title = str_trunc(pageTitle, width = 40)) %&amp;gt;% # keep maximum 40 characters
  count(Title, wt = pageviews, sort = TRUE)
head(most_viewed_posts, n = 7) # edit n for more or less pages to display&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                      Title     n
## 1 A package to download free Springer b... 85684
## 2 Variable types and examples - Stats a... 44951
## 3 Descriptive statistics in R - Stats a... 43621
## 4    Outliers detection in R - Stats and R 32560
## 5 The complete guide to clustering anal... 27184
## 6 Correlation coefficient and correlati... 21581
## 7                              Stats and R 16786&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is how to visualize this table of top performing pages in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
top_n(most_viewed_posts, n = 7, n) %&amp;gt;% # edit n for more or less pages to display
  ggplot(., aes(x = reorder(Title, n), y = n)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  coord_flip() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Title&amp;quot;,
    title = &amp;quot;Top performing pages in terms of page views&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-16-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This gives me a good first overview on how posts performed in terms of page views, so in some sense, what people find useful. For instance, I never thought that the post illustrating the &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;different types of variables that exist in statistics&lt;/a&gt; (ranked #2) would be so appreciated when I wrote it.&lt;/p&gt;
&lt;p&gt;This is something I learned with this blog: at the time of writing, there are some posts which I think no one will care about (and which I mostly write as a &lt;a href=&#34;https://statsandr.com/blog/7-benefits-of-sharing-your-code-in-a-data-science-blog/#personal-note-to-remind-my-future-self&#34;&gt;personal note for myself&lt;/a&gt;), and others which I think people will find very useful. However, after a couple of weeks after publication, sometimes I realize that it is actually exactly the opposite.&lt;/p&gt;
&lt;div id=&#34;time-normalized-page-views&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Time-normalized page views&lt;/h3&gt;
&lt;p&gt;When it comes to &lt;strong&gt;comparing blog posts&lt;/strong&gt;, however, this is not as simple.&lt;/p&gt;
&lt;p&gt;Based on the above barplot and without any further analysis, I would conclude that my article about &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;variable types&lt;/a&gt; is performing much better than the one about &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers detection in R&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, if I tell you that the article on outliers detection has been published on August 11 and the one about variable types on December 30, you will agree that the comparison does not make much sense anymore since page views for these articles were counted over a different length of time. One could also argue that a recent article had less time to generate backlinks, so it is unfair to compare it with an old post which had plenty of time to be ranked high by Google.&lt;/p&gt;
&lt;!-- A potential solution would be to analyze each post individually, so that you could make a fair comparison of how each post performed in their first week or month. Nonetheless, this process requires a large amount of manual work (for example, data that need to be manually updated via copy-paste, lots of Excel sheets, etc.) and it quickly becomes tedious if you want to compare many posts, over different periods of time and for different metrics. And more importantly, we know that manual work cannot easily be replicated on other data sets without a lot of effort and time. --&gt;
&lt;p&gt;In order to make the comparison more “fair”, we would need to compare the number of page views for each post &lt;strong&gt;since their date of publication&lt;/strong&gt;. The following code does precisely this:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it pulls daily data for a bunch of pages,&lt;/li&gt;
&lt;li&gt;then tries to detect their publication date,&lt;/li&gt;
&lt;li&gt;time-normalizes the traffic for each page based on that presumed publication date,&lt;/li&gt;
&lt;li&gt;and finally, plots the daily traffic from the publication date on out, as well as overall cumulative traffic for the top &lt;em&gt;n&lt;/em&gt; pages&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# figure out when a page actually launched by finding the
# first day where the page had at least 2 unique pageviews
first_day_pageviews_min &amp;lt;- 2

# exclude pages that have total traffic (daily unique pageviews) that are relatively low
total_unique_pageviews_cutoff &amp;lt;- 500

# set how many &amp;quot;days since publication&amp;quot; we want to include in our plot
days_live_range &amp;lt;- 180

# set number of top pages to display
n &amp;lt;- 7

# Create a dimension filter object
# You need to update the &amp;quot;expressions&amp;quot; value to be a regular expression that filters to
# the appropriate set of content on your site
page_filter_object &amp;lt;- dim_filter(&amp;quot;pagePath&amp;quot;,
  operator = &amp;quot;REGEXP&amp;quot;,
  expressions = &amp;quot;/blog/.+&amp;quot;
)

# Now, put that filter object into a filter clause. The &amp;quot;operator&amp;quot; argument can be AND # or OR...but you have to have it be something, even though it doesn&amp;#39;t do anything
# when there is only a single filter object.
page_filter &amp;lt;- filter_clause_ga4(list(page_filter_object),
  operator = &amp;quot;AND&amp;quot;
)

# Pull the GA data
ga_data &amp;lt;- google_analytics(
  viewId = view_id,
  date_range = c(start_date, end_date),
  metrics = &amp;quot;uniquePageviews&amp;quot;,
  dimensions = c(&amp;quot;date&amp;quot;, &amp;quot;pagePath&amp;quot;),
  dim_filters = page_filter,
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# Find the first date for each post. This is actually a little tricky, so we&amp;#39;re going to write a
# function that takes each page as an input, filters the data to just include those
# pages, finds the first page, and then puts a &amp;quot;from day 1&amp;quot; count on that data and
# returns it.
normalize_date_start &amp;lt;- function(page) {
  # Filter all the data to just be the page being processed
  ga_data_single_page &amp;lt;- ga_data %&amp;gt;% filter(pagePath == page)

  # Find the first value in the result that is greater than first_day_pageviews_min. In many
  # cases, this will be the first row, but, if there has been testing/previews before it
  # actually goes live, some noise may sneak in where the page may have been live, technically,
  # but wasn&amp;#39;t actually being considered live.
  first_live_row &amp;lt;- min(which(ga_data_single_page$uniquePageviews &amp;gt; first_day_pageviews_min))

  # Filter the data to start with that page
  ga_data_single_page &amp;lt;- ga_data_single_page[first_live_row:nrow(ga_data_single_page), ]

  # As the content ages, there may be days that have ZERO traffic. Those days won&amp;#39;t show up as
  # rows at all in our data. So, we actually need to create a data frame that includes
  # all dates in the range from the &amp;quot;publication&amp;quot; until the last day traffic was recorded. There&amp;#39;s
  # a little trick here where we&amp;#39;re going to make a column with a sequence of *dates* (date) and,
  # with a slightly different &amp;quot;seq,&amp;quot; a &amp;quot;days_live&amp;quot; that corresponds with each date.
  normalized_results &amp;lt;- data.frame(
    date = seq.Date(
      from = min(ga_data_single_page$date),
      to = max(ga_data_single_page$date),
      by = &amp;quot;day&amp;quot;
    ),
    days_live = seq(min(ga_data_single_page$date):
    max(ga_data_single_page$date)),
    page = page
  ) %&amp;gt;%
    # Join back to the original data to get the uniquePageviews
    left_join(ga_data_single_page) %&amp;gt;%
    # Replace the &amp;quot;NAs&amp;quot; (days in the range with no uniquePageviews) with 0s (because
    # that&amp;#39;s exactly what happened on those days!)
    mutate(uniquePageviews = ifelse(is.na(uniquePageviews), 0, uniquePageviews)) %&amp;gt;%
    # We&amp;#39;re going to plot both the daily pageviews AND the cumulative total pageviews,
    # so let&amp;#39;s add the cumulative total
    mutate(cumulative_uniquePageviews = cumsum(uniquePageviews)) %&amp;gt;%
    # Grab just the columns we need for our visualization!
    select(page, days_live, uniquePageviews, cumulative_uniquePageviews)
}

# We want to run the function above on each page in our dataset. So, we need to get a list
# of those pages. We don&amp;#39;t want to include pages with low traffic overall, which we set
# earlier as the &amp;#39;total_unique_pageviews_cutoff&amp;#39; value, so let&amp;#39;s also filter our
# list to only include the ones that exceed that cutoff. We also select the top n pages
# in terms of page views to display in the visualization.
library(dplyr)
pages_list &amp;lt;- ga_data %&amp;gt;%
  group_by(pagePath) %&amp;gt;%
  summarise(total_traffic = sum(uniquePageviews)) %&amp;gt;%
  filter(total_traffic &amp;gt; total_unique_pageviews_cutoff) %&amp;gt;%
  top_n(n = n, total_traffic)

# The first little bit of magic can now occur. We&amp;#39;ll run our normalize_date_start function on
# each value in our list of pages and get a data frame back that has our time-normalized
# traffic by page!
library(purrr)
ga_data_normalized &amp;lt;- map_dfr(pages_list$pagePath, normalize_date_start)

# We specified earlier -- in the `days_live_range` object -- how many &amp;quot;days since publication&amp;quot; we
# actually want to include, so let&amp;#39;s do one final round of filtering to only include those
# rows.
ga_data_normalized &amp;lt;- ga_data_normalized %&amp;gt;% filter(days_live &amp;lt;= days_live_range)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that our data is ready, we create two visualizations:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;Number of page views by day since publication&lt;/strong&gt;: this plot shows how quickly interest in a particular piece of content drops off. If it is not declining as rapidly as the other posts, it means you are getting &lt;em&gt;sustained&lt;/em&gt; value from it&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Cumulative&lt;/em&gt; number of page views by day since publication&lt;/strong&gt;: this plot can be used to compare blog posts on the same ground since number of page views is shown based on the publication date. To see which pages have generated the most traffic over time, simply look from top to bottom (at the right edge of the plot)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Note that both plots use the &lt;code&gt;{plotly}&lt;/code&gt; package to make them interactive so that you can mouse over a line and find out exactly what page it is (together with its values). The interactivity of the plot makes it also possible to zoom in to see, for instance, the number of page views in the first days after publication (instead of the default length of 180 days),&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt; or zoom in to see only the evolution of the number of page views below/above a certain threshold.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Create first plot
library(ggplot2)

gg &amp;lt;- ggplot(ga_data_normalized, mapping = aes(x = days_live, y = uniquePageviews, color = page)) +
  geom_line() + # The main &amp;quot;plot&amp;quot; operation
  scale_y_continuous(labels = scales::comma) + # Include commas in the y-axis numbers
  labs(
    title = &amp;quot;Page views by day since publication&amp;quot;,
    x = &amp;quot;Days since publication&amp;quot;,
    y = &amp;quot;Page views&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  theme_minimal() + # minimal theme
  theme(
    legend.position = &amp;quot;none&amp;quot;, # remove legend
  )

# Output the plot, wrapped in ggplotly so we will get some interactivity in the plot
library(plotly)
ggplotly(gg, dynamicTicks = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:480px;&#34; class=&#34;plotly html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;data&#34;:[{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[152,2186,6015,7966,7139,4388,2900,2548,2649,1458,1480,1050,834,535,535,717,686,541,441,403,310,305,348,320,258,276,272,202,240,233,258,251,180,226,205,185,237,186,212,168,184,144,172,191,184,159,211,227,149,106,194,182,206,162,145,113,93,93,130,98,89,120,120,97,110,106,103,106,100,72,65,85,78,69,89,75,63,50,65,100,101,79,80,70,92,222,94,83,82,67,68,55,60,67,71,61,69,39,34,48,33,62,58,48,46,42,45,55,42,52,44,39,75,73,80,72,43,71,62,41,47,35,50,41,40,36,39,50,51,65,34,37,33,30,37,34,36,34,33,40,25,23,28,28,36,29,28,24,27,30,40,10,18,24,16,17,27,26,31,27,15,9,20,29,33,14,28,18,22,20,28,21,23,17,19,16,17,25,27,14],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;uniquePageviews:  152&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   2&lt;br /&gt;uniquePageviews: 2186&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   3&lt;br /&gt;uniquePageviews: 6015&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   4&lt;br /&gt;uniquePageviews: 7966&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   5&lt;br /&gt;uniquePageviews: 7139&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   6&lt;br /&gt;uniquePageviews: 4388&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   7&lt;br /&gt;uniquePageviews: 2900&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   8&lt;br /&gt;uniquePageviews: 2548&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   9&lt;br /&gt;uniquePageviews: 2649&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  10&lt;br /&gt;uniquePageviews: 1458&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  11&lt;br /&gt;uniquePageviews: 1480&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  12&lt;br /&gt;uniquePageviews: 1050&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  13&lt;br /&gt;uniquePageviews:  834&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  14&lt;br /&gt;uniquePageviews:  535&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  15&lt;br /&gt;uniquePageviews:  535&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  16&lt;br /&gt;uniquePageviews:  717&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  17&lt;br /&gt;uniquePageviews:  686&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  18&lt;br /&gt;uniquePageviews:  541&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  19&lt;br /&gt;uniquePageviews:  441&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  20&lt;br /&gt;uniquePageviews:  403&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  21&lt;br /&gt;uniquePageviews:  310&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  22&lt;br /&gt;uniquePageviews:  305&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  23&lt;br /&gt;uniquePageviews:  348&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  24&lt;br /&gt;uniquePageviews:  320&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  25&lt;br /&gt;uniquePageviews:  258&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  26&lt;br /&gt;uniquePageviews:  276&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  27&lt;br /&gt;uniquePageviews:  272&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  28&lt;br /&gt;uniquePageviews:  202&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  29&lt;br /&gt;uniquePageviews:  240&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  30&lt;br /&gt;uniquePageviews:  233&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  31&lt;br /&gt;uniquePageviews:  258&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  32&lt;br /&gt;uniquePageviews:  251&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  33&lt;br /&gt;uniquePageviews:  180&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  34&lt;br /&gt;uniquePageviews:  226&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  35&lt;br /&gt;uniquePageviews:  205&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  36&lt;br /&gt;uniquePageviews:  185&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  37&lt;br /&gt;uniquePageviews:  237&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  38&lt;br /&gt;uniquePageviews:  186&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  39&lt;br /&gt;uniquePageviews:  212&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  40&lt;br /&gt;uniquePageviews:  168&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  41&lt;br /&gt;uniquePageviews:  184&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  42&lt;br /&gt;uniquePageviews:  144&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  43&lt;br /&gt;uniquePageviews:  172&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  44&lt;br /&gt;uniquePageviews:  191&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  45&lt;br /&gt;uniquePageviews:  184&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  46&lt;br /&gt;uniquePageviews:  159&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  47&lt;br /&gt;uniquePageviews:  211&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  48&lt;br /&gt;uniquePageviews:  227&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  49&lt;br /&gt;uniquePageviews:  149&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  50&lt;br /&gt;uniquePageviews:  106&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  51&lt;br /&gt;uniquePageviews:  194&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  52&lt;br /&gt;uniquePageviews:  182&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  53&lt;br /&gt;uniquePageviews:  206&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  54&lt;br /&gt;uniquePageviews:  162&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  55&lt;br /&gt;uniquePageviews:  145&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  56&lt;br /&gt;uniquePageviews:  113&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  57&lt;br /&gt;uniquePageviews:   93&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  58&lt;br /&gt;uniquePageviews:   93&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  59&lt;br /&gt;uniquePageviews:  130&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  60&lt;br /&gt;uniquePageviews:   98&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  61&lt;br /&gt;uniquePageviews:   89&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  62&lt;br /&gt;uniquePageviews:  120&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  63&lt;br /&gt;uniquePageviews:  120&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  64&lt;br /&gt;uniquePageviews:   97&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  65&lt;br /&gt;uniquePageviews:  110&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  66&lt;br /&gt;uniquePageviews:  106&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  67&lt;br /&gt;uniquePageviews:  103&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  68&lt;br /&gt;uniquePageviews:  106&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  69&lt;br /&gt;uniquePageviews:  100&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  70&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  71&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  72&lt;br /&gt;uniquePageviews:   85&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  73&lt;br /&gt;uniquePageviews:   78&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  74&lt;br /&gt;uniquePageviews:   69&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  75&lt;br /&gt;uniquePageviews:   89&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  76&lt;br /&gt;uniquePageviews:   75&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  77&lt;br /&gt;uniquePageviews:   63&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  78&lt;br /&gt;uniquePageviews:   50&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  79&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  80&lt;br /&gt;uniquePageviews:  100&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  81&lt;br /&gt;uniquePageviews:  101&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  82&lt;br /&gt;uniquePageviews:   79&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  83&lt;br /&gt;uniquePageviews:   80&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  84&lt;br /&gt;uniquePageviews:   70&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  85&lt;br /&gt;uniquePageviews:   92&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  86&lt;br /&gt;uniquePageviews:  222&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  87&lt;br /&gt;uniquePageviews:   94&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  88&lt;br /&gt;uniquePageviews:   83&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  89&lt;br /&gt;uniquePageviews:   82&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  90&lt;br /&gt;uniquePageviews:   67&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  91&lt;br /&gt;uniquePageviews:   68&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  92&lt;br /&gt;uniquePageviews:   55&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  93&lt;br /&gt;uniquePageviews:   60&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  94&lt;br /&gt;uniquePageviews:   67&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  95&lt;br /&gt;uniquePageviews:   71&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  96&lt;br /&gt;uniquePageviews:   61&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  97&lt;br /&gt;uniquePageviews:   69&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  98&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  99&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 100&lt;br /&gt;uniquePageviews:   48&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 101&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 102&lt;br /&gt;uniquePageviews:   62&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 103&lt;br /&gt;uniquePageviews:   58&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 104&lt;br /&gt;uniquePageviews:   48&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 105&lt;br /&gt;uniquePageviews:   46&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 106&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 107&lt;br /&gt;uniquePageviews:   45&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 108&lt;br /&gt;uniquePageviews:   55&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 109&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 110&lt;br /&gt;uniquePageviews:   52&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 111&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 112&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 113&lt;br /&gt;uniquePageviews:   75&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 114&lt;br /&gt;uniquePageviews:   73&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 115&lt;br /&gt;uniquePageviews:   80&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 116&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 117&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 118&lt;br /&gt;uniquePageviews:   71&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 119&lt;br /&gt;uniquePageviews:   62&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 120&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 121&lt;br /&gt;uniquePageviews:   47&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 122&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 123&lt;br /&gt;uniquePageviews:   50&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 124&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 125&lt;br /&gt;uniquePageviews:   40&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 126&lt;br /&gt;uniquePageviews:   36&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 127&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 128&lt;br /&gt;uniquePageviews:   50&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 129&lt;br /&gt;uniquePageviews:   51&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 130&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 131&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 132&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 133&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 134&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 135&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 136&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 137&lt;br /&gt;uniquePageviews:   36&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 138&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 139&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 140&lt;br /&gt;uniquePageviews:   40&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 141&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 142&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 143&lt;br /&gt;uniquePageviews:   28&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 144&lt;br /&gt;uniquePageviews:   28&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 145&lt;br /&gt;uniquePageviews:   36&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 146&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 147&lt;br /&gt;uniquePageviews:   28&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 148&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 149&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 150&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 151&lt;br /&gt;uniquePageviews:   40&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 152&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 153&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 154&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 155&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 156&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 157&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 158&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 159&lt;br /&gt;uniquePageviews:   31&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 160&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 161&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 162&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 163&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 164&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 165&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 166&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 167&lt;br /&gt;uniquePageviews:   28&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 168&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 169&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 170&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 171&lt;br /&gt;uniquePageviews:   28&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 172&lt;br /&gt;uniquePageviews:   21&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 173&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 174&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 175&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 176&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 177&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 178&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 179&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 180&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(248,118,109,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;legendgroup&#34;:&#34;/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[4,0,0,1,0,0,6,2,21,262,212,77,144,120,62,47,29,26,29,38,25,20,20,21,16,14,14,22,32,25,21,15,15,23,16,25,25,19,25,11,20,43,16,8,9,12,17,11,18,19,24,16,13,14,22,13,12,14,20,14,14,16,16,13,9,22,23,20,26,26,24,18,23,26,14,31,27,21,26,17,38,36,27,34,46,44,43,15,24,43,49,78,75,68,72,58,62,61,38,55,51,51,53,42,41,42,48,67,69,54,74,79,56,91,84,54,39,45,72,73,72,63,33,61,90,75,60,82,69,52,51,73,86,74,78,60,52,57,84,73,74,72,80,71,77,96,79,63,73,65,64,75,78,98,67,86,63,55,61,84,78,77,85,70,52,57,87,94,99,90,83,53,84,129,102,81,66,74,34,61],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   2&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   3&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   4&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   5&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   6&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   7&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   8&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   9&lt;br /&gt;uniquePageviews:   21&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  10&lt;br /&gt;uniquePageviews:  262&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  11&lt;br /&gt;uniquePageviews:  212&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  12&lt;br /&gt;uniquePageviews:   77&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  13&lt;br /&gt;uniquePageviews:  144&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  14&lt;br /&gt;uniquePageviews:  120&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  15&lt;br /&gt;uniquePageviews:   62&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  16&lt;br /&gt;uniquePageviews:   47&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  17&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  18&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  19&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  20&lt;br /&gt;uniquePageviews:   38&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  21&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  22&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  23&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  24&lt;br /&gt;uniquePageviews:   21&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  25&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  26&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  27&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  28&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  29&lt;br /&gt;uniquePageviews:   32&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  30&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  31&lt;br /&gt;uniquePageviews:   21&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  32&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  33&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  34&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  35&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  36&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  37&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  38&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  39&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  40&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  41&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  42&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  43&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  44&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  45&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  46&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  47&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  48&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  49&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  50&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  51&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  52&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  53&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  54&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  55&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  56&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  57&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  58&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  59&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  60&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  61&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  62&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  63&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  64&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  65&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  66&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  67&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  68&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  69&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  70&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  71&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  72&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  73&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  74&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  75&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  76&lt;br /&gt;uniquePageviews:   31&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  77&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  78&lt;br /&gt;uniquePageviews:   21&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  79&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  80&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  81&lt;br /&gt;uniquePageviews:   38&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  82&lt;br /&gt;uniquePageviews:   36&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  83&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  84&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  85&lt;br /&gt;uniquePageviews:   46&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  86&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  87&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  88&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  89&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  90&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  91&lt;br /&gt;uniquePageviews:   49&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  92&lt;br /&gt;uniquePageviews:   78&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  93&lt;br /&gt;uniquePageviews:   75&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  94&lt;br /&gt;uniquePageviews:   68&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  95&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  96&lt;br /&gt;uniquePageviews:   58&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  97&lt;br /&gt;uniquePageviews:   62&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  98&lt;br /&gt;uniquePageviews:   61&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  99&lt;br /&gt;uniquePageviews:   38&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 100&lt;br /&gt;uniquePageviews:   55&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 101&lt;br /&gt;uniquePageviews:   51&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 102&lt;br /&gt;uniquePageviews:   51&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 103&lt;br /&gt;uniquePageviews:   53&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 104&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 105&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 106&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 107&lt;br /&gt;uniquePageviews:   48&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 108&lt;br /&gt;uniquePageviews:   67&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 109&lt;br /&gt;uniquePageviews:   69&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 110&lt;br /&gt;uniquePageviews:   54&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 111&lt;br /&gt;uniquePageviews:   74&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 112&lt;br /&gt;uniquePageviews:   79&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 113&lt;br /&gt;uniquePageviews:   56&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 114&lt;br /&gt;uniquePageviews:   91&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 115&lt;br /&gt;uniquePageviews:   84&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 116&lt;br /&gt;uniquePageviews:   54&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 117&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 118&lt;br /&gt;uniquePageviews:   45&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 119&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 120&lt;br /&gt;uniquePageviews:   73&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 121&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 122&lt;br /&gt;uniquePageviews:   63&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 123&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 124&lt;br /&gt;uniquePageviews:   61&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 125&lt;br /&gt;uniquePageviews:   90&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 126&lt;br /&gt;uniquePageviews:   75&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 127&lt;br /&gt;uniquePageviews:   60&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 128&lt;br /&gt;uniquePageviews:   82&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 129&lt;br /&gt;uniquePageviews:   69&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 130&lt;br /&gt;uniquePageviews:   52&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 131&lt;br /&gt;uniquePageviews:   51&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 132&lt;br /&gt;uniquePageviews:   73&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 133&lt;br /&gt;uniquePageviews:   86&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 134&lt;br /&gt;uniquePageviews:   74&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 135&lt;br /&gt;uniquePageviews:   78&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 136&lt;br /&gt;uniquePageviews:   60&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 137&lt;br /&gt;uniquePageviews:   52&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 138&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 139&lt;br /&gt;uniquePageviews:   84&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 140&lt;br /&gt;uniquePageviews:   73&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 141&lt;br /&gt;uniquePageviews:   74&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 142&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 143&lt;br /&gt;uniquePageviews:   80&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 144&lt;br /&gt;uniquePageviews:   71&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 145&lt;br /&gt;uniquePageviews:   77&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 146&lt;br /&gt;uniquePageviews:   96&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 147&lt;br /&gt;uniquePageviews:   79&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 148&lt;br /&gt;uniquePageviews:   63&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 149&lt;br /&gt;uniquePageviews:   73&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 150&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 151&lt;br /&gt;uniquePageviews:   64&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 152&lt;br /&gt;uniquePageviews:   75&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 153&lt;br /&gt;uniquePageviews:   78&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 154&lt;br /&gt;uniquePageviews:   98&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 155&lt;br /&gt;uniquePageviews:   67&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 156&lt;br /&gt;uniquePageviews:   86&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 157&lt;br /&gt;uniquePageviews:   63&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 158&lt;br /&gt;uniquePageviews:   55&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 159&lt;br /&gt;uniquePageviews:   61&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 160&lt;br /&gt;uniquePageviews:   84&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 161&lt;br /&gt;uniquePageviews:   78&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 162&lt;br /&gt;uniquePageviews:   77&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 163&lt;br /&gt;uniquePageviews:   85&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 164&lt;br /&gt;uniquePageviews:   70&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 165&lt;br /&gt;uniquePageviews:   52&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 166&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 167&lt;br /&gt;uniquePageviews:   87&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 168&lt;br /&gt;uniquePageviews:   94&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 169&lt;br /&gt;uniquePageviews:   99&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 170&lt;br /&gt;uniquePageviews:   90&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 171&lt;br /&gt;uniquePageviews:   83&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 172&lt;br /&gt;uniquePageviews:   53&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 173&lt;br /&gt;uniquePageviews:   84&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 174&lt;br /&gt;uniquePageviews:  129&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 175&lt;br /&gt;uniquePageviews:  102&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 176&lt;br /&gt;uniquePageviews:   81&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 177&lt;br /&gt;uniquePageviews:   66&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 178&lt;br /&gt;uniquePageviews:   74&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 179&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 180&lt;br /&gt;uniquePageviews:   61&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(196,154,0,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;legendgroup&#34;:&#34;/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[111,325,195,41,77,59,42,42,26,18,23,30,22,22,14,11,6,13,9,11,8,10,13,4,12,14,13,7,13,14,9,8,16,13,7,19,19,10,12,17,9,9,6,11,11,7,10,10,13,20,15,10,18,26,26,18,14,16,17,25,18,26,32,30,12,15,18,24,32,30,29,24,22,29,34,42,53,34,53,31,22,58,50,71,77,57,52,62,86,64,64,56,57,45,38,75,71,78,70,77,57,53,68,92,86,112,94,58,74,91,111,93,121,131,91,97,169,180,147,185,124,101,107,148,147,158,144,130,74,118,149,177,176,142,146,95,118,180,199,199,166,173,102,114,200,192,202,181,155,127,137,176,203,199,188,164,113,115,209,191,163,179,182,137,129,203,195,191,219,187,122,135,187,184,187,165,181,134,160,218],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;uniquePageviews:  111&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   2&lt;br /&gt;uniquePageviews:  325&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   3&lt;br /&gt;uniquePageviews:  195&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   4&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   5&lt;br /&gt;uniquePageviews:   77&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   6&lt;br /&gt;uniquePageviews:   59&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   7&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   8&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   9&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  10&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  11&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  12&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  13&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  14&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  15&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  16&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  17&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  18&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  19&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  20&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  21&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  22&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  23&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  24&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  25&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  26&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  27&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  28&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  29&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  30&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  31&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  32&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  33&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  34&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  35&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  36&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  37&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  38&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  39&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  40&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  41&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  42&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  43&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  44&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  45&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  46&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  47&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  48&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  49&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  50&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  51&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  52&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  53&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  54&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  55&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  56&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  57&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  58&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  59&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  60&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  61&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  62&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  63&lt;br /&gt;uniquePageviews:   32&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  64&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  65&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  66&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  67&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  68&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  69&lt;br /&gt;uniquePageviews:   32&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  70&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  71&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  72&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  73&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  74&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  75&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  76&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  77&lt;br /&gt;uniquePageviews:   53&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  78&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  79&lt;br /&gt;uniquePageviews:   53&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  80&lt;br /&gt;uniquePageviews:   31&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  81&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  82&lt;br /&gt;uniquePageviews:   58&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  83&lt;br /&gt;uniquePageviews:   50&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  84&lt;br /&gt;uniquePageviews:   71&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  85&lt;br /&gt;uniquePageviews:   77&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  86&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  87&lt;br /&gt;uniquePageviews:   52&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  88&lt;br /&gt;uniquePageviews:   62&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  89&lt;br /&gt;uniquePageviews:   86&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  90&lt;br /&gt;uniquePageviews:   64&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  91&lt;br /&gt;uniquePageviews:   64&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  92&lt;br /&gt;uniquePageviews:   56&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  93&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  94&lt;br /&gt;uniquePageviews:   45&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  95&lt;br /&gt;uniquePageviews:   38&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  96&lt;br /&gt;uniquePageviews:   75&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  97&lt;br /&gt;uniquePageviews:   71&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  98&lt;br /&gt;uniquePageviews:   78&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  99&lt;br /&gt;uniquePageviews:   70&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 100&lt;br /&gt;uniquePageviews:   77&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 101&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 102&lt;br /&gt;uniquePageviews:   53&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 103&lt;br /&gt;uniquePageviews:   68&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 104&lt;br /&gt;uniquePageviews:   92&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 105&lt;br /&gt;uniquePageviews:   86&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 106&lt;br /&gt;uniquePageviews:  112&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 107&lt;br /&gt;uniquePageviews:   94&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 108&lt;br /&gt;uniquePageviews:   58&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 109&lt;br /&gt;uniquePageviews:   74&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 110&lt;br /&gt;uniquePageviews:   91&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 111&lt;br /&gt;uniquePageviews:  111&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 112&lt;br /&gt;uniquePageviews:   93&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 113&lt;br /&gt;uniquePageviews:  121&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 114&lt;br /&gt;uniquePageviews:  131&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 115&lt;br /&gt;uniquePageviews:   91&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 116&lt;br /&gt;uniquePageviews:   97&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 117&lt;br /&gt;uniquePageviews:  169&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 118&lt;br /&gt;uniquePageviews:  180&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 119&lt;br /&gt;uniquePageviews:  147&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 120&lt;br /&gt;uniquePageviews:  185&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 121&lt;br /&gt;uniquePageviews:  124&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 122&lt;br /&gt;uniquePageviews:  101&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 123&lt;br /&gt;uniquePageviews:  107&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 124&lt;br /&gt;uniquePageviews:  148&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 125&lt;br /&gt;uniquePageviews:  147&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 126&lt;br /&gt;uniquePageviews:  158&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 127&lt;br /&gt;uniquePageviews:  144&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 128&lt;br /&gt;uniquePageviews:  130&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 129&lt;br /&gt;uniquePageviews:   74&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 130&lt;br /&gt;uniquePageviews:  118&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 131&lt;br /&gt;uniquePageviews:  149&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 132&lt;br /&gt;uniquePageviews:  177&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 133&lt;br /&gt;uniquePageviews:  176&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 134&lt;br /&gt;uniquePageviews:  142&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 135&lt;br /&gt;uniquePageviews:  146&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 136&lt;br /&gt;uniquePageviews:   95&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 137&lt;br /&gt;uniquePageviews:  118&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 138&lt;br /&gt;uniquePageviews:  180&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 139&lt;br /&gt;uniquePageviews:  199&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 140&lt;br /&gt;uniquePageviews:  199&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 141&lt;br /&gt;uniquePageviews:  166&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 142&lt;br /&gt;uniquePageviews:  173&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 143&lt;br /&gt;uniquePageviews:  102&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 144&lt;br /&gt;uniquePageviews:  114&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 145&lt;br /&gt;uniquePageviews:  200&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 146&lt;br /&gt;uniquePageviews:  192&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 147&lt;br /&gt;uniquePageviews:  202&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 148&lt;br /&gt;uniquePageviews:  181&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 149&lt;br /&gt;uniquePageviews:  155&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 150&lt;br /&gt;uniquePageviews:  127&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 151&lt;br /&gt;uniquePageviews:  137&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 152&lt;br /&gt;uniquePageviews:  176&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 153&lt;br /&gt;uniquePageviews:  203&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 154&lt;br /&gt;uniquePageviews:  199&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 155&lt;br /&gt;uniquePageviews:  188&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 156&lt;br /&gt;uniquePageviews:  164&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 157&lt;br /&gt;uniquePageviews:  113&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 158&lt;br /&gt;uniquePageviews:  115&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 159&lt;br /&gt;uniquePageviews:  209&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 160&lt;br /&gt;uniquePageviews:  191&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 161&lt;br /&gt;uniquePageviews:  163&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 162&lt;br /&gt;uniquePageviews:  179&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 163&lt;br /&gt;uniquePageviews:  182&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 164&lt;br /&gt;uniquePageviews:  137&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 165&lt;br /&gt;uniquePageviews:  129&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 166&lt;br /&gt;uniquePageviews:  203&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 167&lt;br /&gt;uniquePageviews:  195&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 168&lt;br /&gt;uniquePageviews:  191&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 169&lt;br /&gt;uniquePageviews:  219&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 170&lt;br /&gt;uniquePageviews:  187&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 171&lt;br /&gt;uniquePageviews:  122&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 172&lt;br /&gt;uniquePageviews:  135&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 173&lt;br /&gt;uniquePageviews:  187&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 174&lt;br /&gt;uniquePageviews:  184&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 175&lt;br /&gt;uniquePageviews:  187&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 176&lt;br /&gt;uniquePageviews:  165&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 177&lt;br /&gt;uniquePageviews:  181&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 178&lt;br /&gt;uniquePageviews:  134&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 179&lt;br /&gt;uniquePageviews:  160&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 180&lt;br /&gt;uniquePageviews:  218&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(83,180,0,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;legendgroup&#34;:&#34;/blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[3,0,0,0,0,1,2,73,766,88,183,96,58,25,29,24,14,22,22,17,17,15,13,8,20,18,8,26,20,9,10,17,17,34,20,18,14,25,21,21,8,14,5,17,12,20,10,16,16,13,5,12,8,17,18,17,17,13,6,6,9,4,5,8,10,11,11,16,8,9,6,10,11,6,7,7,8,5,8,4,11,9,6,10,6,13,8,10,6,10,9,11,6,22,15,11,17,27,15,16,10,15,32,23,17,14,6,17,17,24,32,24,68,34,42,44,46,43,46,29,22,13,23,26,21,31,23,26,26,23,30,23,37,48,33,31,36,41,30,43,37,29,38,51,44,85,99,111,78,38,66,42,40,35,30,25,22,41,30,43,53,44,27,25,37,46,36,24,50,35,43,82,68,68,97,107,66,67,82,75],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   2&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   3&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   4&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   5&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   6&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   7&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   8&lt;br /&gt;uniquePageviews:   73&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   9&lt;br /&gt;uniquePageviews:  766&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  10&lt;br /&gt;uniquePageviews:   88&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  11&lt;br /&gt;uniquePageviews:  183&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  12&lt;br /&gt;uniquePageviews:   96&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  13&lt;br /&gt;uniquePageviews:   58&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  14&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  15&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  16&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  17&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  18&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  19&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  20&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  21&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  22&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  23&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  24&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  25&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  26&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  27&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  28&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  29&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  30&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  31&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  32&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  33&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  34&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  35&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  36&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  37&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  38&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  39&lt;br /&gt;uniquePageviews:   21&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  40&lt;br /&gt;uniquePageviews:   21&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  41&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  42&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  43&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  44&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  45&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  46&lt;br /&gt;uniquePageviews:   20&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  47&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  48&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  49&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  50&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  51&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  52&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  53&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  54&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  55&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  56&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  57&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  58&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  59&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  60&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  61&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  62&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  63&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  64&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  65&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  66&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  67&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  68&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  69&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  70&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  71&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  72&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  73&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  74&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  75&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  76&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  77&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  78&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  79&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  80&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  81&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  82&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  83&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  84&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  85&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  86&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  87&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  88&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  89&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  90&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  91&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  92&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  93&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  94&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  95&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  96&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  97&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  98&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  99&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 100&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 101&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 102&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 103&lt;br /&gt;uniquePageviews:   32&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 104&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 105&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 106&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 107&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 108&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 109&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 110&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 111&lt;br /&gt;uniquePageviews:   32&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 112&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 113&lt;br /&gt;uniquePageviews:   68&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 114&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 115&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 116&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 117&lt;br /&gt;uniquePageviews:   46&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 118&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 119&lt;br /&gt;uniquePageviews:   46&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 120&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 121&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 122&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 123&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 124&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 125&lt;br /&gt;uniquePageviews:   21&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 126&lt;br /&gt;uniquePageviews:   31&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 127&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 128&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 129&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 130&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 131&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 132&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 133&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 134&lt;br /&gt;uniquePageviews:   48&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 135&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 136&lt;br /&gt;uniquePageviews:   31&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 137&lt;br /&gt;uniquePageviews:   36&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 138&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 139&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 140&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 141&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 142&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 143&lt;br /&gt;uniquePageviews:   38&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 144&lt;br /&gt;uniquePageviews:   51&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 145&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 146&lt;br /&gt;uniquePageviews:   85&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 147&lt;br /&gt;uniquePageviews:   99&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 148&lt;br /&gt;uniquePageviews:  111&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 149&lt;br /&gt;uniquePageviews:   78&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 150&lt;br /&gt;uniquePageviews:   38&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 151&lt;br /&gt;uniquePageviews:   66&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 152&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 153&lt;br /&gt;uniquePageviews:   40&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 154&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 155&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 156&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 157&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 158&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 159&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 160&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 161&lt;br /&gt;uniquePageviews:   53&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 162&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 163&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 164&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 165&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 166&lt;br /&gt;uniquePageviews:   46&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 167&lt;br /&gt;uniquePageviews:   36&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 168&lt;br /&gt;uniquePageviews:   24&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 169&lt;br /&gt;uniquePageviews:   50&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 170&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 171&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 172&lt;br /&gt;uniquePageviews:   82&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 173&lt;br /&gt;uniquePageviews:   68&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 174&lt;br /&gt;uniquePageviews:   68&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 175&lt;br /&gt;uniquePageviews:   97&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 176&lt;br /&gt;uniquePageviews:  107&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 177&lt;br /&gt;uniquePageviews:   66&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 178&lt;br /&gt;uniquePageviews:   67&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 179&lt;br /&gt;uniquePageviews:   82&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 180&lt;br /&gt;uniquePageviews:   75&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(0,192,148,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/descriptive-statistics-in-r/&#34;,&#34;legendgroup&#34;:&#34;/blog/descriptive-statistics-in-r/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127],&#34;y&#34;:[176,442,232,104,90,35,115,65,42,39,38,29,27,44,22,15,41,54,36,31,35,47,44,65,53,29,37,43,62,76,68,58,28,30,126,167,122,149,130,101,69,150,139,156,158,147,94,158,211,244,281,247,272,161,159,245,295,295,309,320,178,205,311,370,369,360,300,198,218,371,403,352,390,370,250,222,358,409,353,355,316,196,218,373,321,359,374,345,288,274,417,411,442,367,329,184,252,346,344,373,376,349,283,276,375,441,413,347,298,267,300,434,393,411,407,353,294,286,410,443,422,435,365,298,280,366,368],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;uniquePageviews:  176&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   2&lt;br /&gt;uniquePageviews:  442&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   3&lt;br /&gt;uniquePageviews:  232&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   4&lt;br /&gt;uniquePageviews:  104&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   5&lt;br /&gt;uniquePageviews:   90&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   6&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   7&lt;br /&gt;uniquePageviews:  115&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   8&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   9&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  10&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  11&lt;br /&gt;uniquePageviews:   38&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  12&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  13&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  14&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  15&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  16&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  17&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  18&lt;br /&gt;uniquePageviews:   54&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  19&lt;br /&gt;uniquePageviews:   36&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  20&lt;br /&gt;uniquePageviews:   31&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  21&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  22&lt;br /&gt;uniquePageviews:   47&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  23&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  24&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  25&lt;br /&gt;uniquePageviews:   53&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  26&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  27&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  28&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  29&lt;br /&gt;uniquePageviews:   62&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  30&lt;br /&gt;uniquePageviews:   76&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  31&lt;br /&gt;uniquePageviews:   68&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  32&lt;br /&gt;uniquePageviews:   58&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  33&lt;br /&gt;uniquePageviews:   28&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  34&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  35&lt;br /&gt;uniquePageviews:  126&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  36&lt;br /&gt;uniquePageviews:  167&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  37&lt;br /&gt;uniquePageviews:  122&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  38&lt;br /&gt;uniquePageviews:  149&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  39&lt;br /&gt;uniquePageviews:  130&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  40&lt;br /&gt;uniquePageviews:  101&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  41&lt;br /&gt;uniquePageviews:   69&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  42&lt;br /&gt;uniquePageviews:  150&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  43&lt;br /&gt;uniquePageviews:  139&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  44&lt;br /&gt;uniquePageviews:  156&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  45&lt;br /&gt;uniquePageviews:  158&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  46&lt;br /&gt;uniquePageviews:  147&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  47&lt;br /&gt;uniquePageviews:   94&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  48&lt;br /&gt;uniquePageviews:  158&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  49&lt;br /&gt;uniquePageviews:  211&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  50&lt;br /&gt;uniquePageviews:  244&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  51&lt;br /&gt;uniquePageviews:  281&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  52&lt;br /&gt;uniquePageviews:  247&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  53&lt;br /&gt;uniquePageviews:  272&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  54&lt;br /&gt;uniquePageviews:  161&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  55&lt;br /&gt;uniquePageviews:  159&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  56&lt;br /&gt;uniquePageviews:  245&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  57&lt;br /&gt;uniquePageviews:  295&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  58&lt;br /&gt;uniquePageviews:  295&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  59&lt;br /&gt;uniquePageviews:  309&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  60&lt;br /&gt;uniquePageviews:  320&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  61&lt;br /&gt;uniquePageviews:  178&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  62&lt;br /&gt;uniquePageviews:  205&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  63&lt;br /&gt;uniquePageviews:  311&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  64&lt;br /&gt;uniquePageviews:  370&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  65&lt;br /&gt;uniquePageviews:  369&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  66&lt;br /&gt;uniquePageviews:  360&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  67&lt;br /&gt;uniquePageviews:  300&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  68&lt;br /&gt;uniquePageviews:  198&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  69&lt;br /&gt;uniquePageviews:  218&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  70&lt;br /&gt;uniquePageviews:  371&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  71&lt;br /&gt;uniquePageviews:  403&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  72&lt;br /&gt;uniquePageviews:  352&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  73&lt;br /&gt;uniquePageviews:  390&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  74&lt;br /&gt;uniquePageviews:  370&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  75&lt;br /&gt;uniquePageviews:  250&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  76&lt;br /&gt;uniquePageviews:  222&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  77&lt;br /&gt;uniquePageviews:  358&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  78&lt;br /&gt;uniquePageviews:  409&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  79&lt;br /&gt;uniquePageviews:  353&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  80&lt;br /&gt;uniquePageviews:  355&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  81&lt;br /&gt;uniquePageviews:  316&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  82&lt;br /&gt;uniquePageviews:  196&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  83&lt;br /&gt;uniquePageviews:  218&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  84&lt;br /&gt;uniquePageviews:  373&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  85&lt;br /&gt;uniquePageviews:  321&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  86&lt;br /&gt;uniquePageviews:  359&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  87&lt;br /&gt;uniquePageviews:  374&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  88&lt;br /&gt;uniquePageviews:  345&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  89&lt;br /&gt;uniquePageviews:  288&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  90&lt;br /&gt;uniquePageviews:  274&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  91&lt;br /&gt;uniquePageviews:  417&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  92&lt;br /&gt;uniquePageviews:  411&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  93&lt;br /&gt;uniquePageviews:  442&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  94&lt;br /&gt;uniquePageviews:  367&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  95&lt;br /&gt;uniquePageviews:  329&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  96&lt;br /&gt;uniquePageviews:  184&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  97&lt;br /&gt;uniquePageviews:  252&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  98&lt;br /&gt;uniquePageviews:  346&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  99&lt;br /&gt;uniquePageviews:  344&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 100&lt;br /&gt;uniquePageviews:  373&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 101&lt;br /&gt;uniquePageviews:  376&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 102&lt;br /&gt;uniquePageviews:  349&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 103&lt;br /&gt;uniquePageviews:  283&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 104&lt;br /&gt;uniquePageviews:  276&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 105&lt;br /&gt;uniquePageviews:  375&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 106&lt;br /&gt;uniquePageviews:  441&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 107&lt;br /&gt;uniquePageviews:  413&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 108&lt;br /&gt;uniquePageviews:  347&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 109&lt;br /&gt;uniquePageviews:  298&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 110&lt;br /&gt;uniquePageviews:  267&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 111&lt;br /&gt;uniquePageviews:  300&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 112&lt;br /&gt;uniquePageviews:  434&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 113&lt;br /&gt;uniquePageviews:  393&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 114&lt;br /&gt;uniquePageviews:  411&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 115&lt;br /&gt;uniquePageviews:  407&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 116&lt;br /&gt;uniquePageviews:  353&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 117&lt;br /&gt;uniquePageviews:  294&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 118&lt;br /&gt;uniquePageviews:  286&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 119&lt;br /&gt;uniquePageviews:  410&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 120&lt;br /&gt;uniquePageviews:  443&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 121&lt;br /&gt;uniquePageviews:  422&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 122&lt;br /&gt;uniquePageviews:  435&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 123&lt;br /&gt;uniquePageviews:  365&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 124&lt;br /&gt;uniquePageviews:  298&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 125&lt;br /&gt;uniquePageviews:  280&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 126&lt;br /&gt;uniquePageviews:  366&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 127&lt;br /&gt;uniquePageviews:  368&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(0,182,235,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/outliers-detection-in-r/&#34;,&#34;legendgroup&#34;:&#34;/blog/outliers-detection-in-r/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[11,1333,466,350,498,333,338,373,398,363,539,529,730,715,592,435,385,356,411,359,411,356,316,293,248,317,291,493,238,275,247,256,248,218,234,234,217,185,197,251,226,192,202,178,164,189,331,422,447,386,311,255,229,268,226,271,259,218,180,208,301,239,214,188,174,131,136,123,153,142,104,115,105,101,124,127,125,103,130,96,92,104,138,109,120,94,76,62,89,86,93,93,278,215,72,119,111,105,90,87,51,69,95,61,95,65,72,57,59,76,63,47,72,75,42,42,63,134,83,84,72,57,66,76,61,86,65,69,67,58,82,64,48,72,63,35,46,46,57,44,42,33,26,35,53,35,34,32,34,29,30,58,37,44,45,41,35,43,39,50,40,39,41,39,52,64,37,50,50,41,34,26,33,57,44,48,38,42,40,35],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   2&lt;br /&gt;uniquePageviews: 1333&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   3&lt;br /&gt;uniquePageviews:  466&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   4&lt;br /&gt;uniquePageviews:  350&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   5&lt;br /&gt;uniquePageviews:  498&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   6&lt;br /&gt;uniquePageviews:  333&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   7&lt;br /&gt;uniquePageviews:  338&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   8&lt;br /&gt;uniquePageviews:  373&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   9&lt;br /&gt;uniquePageviews:  398&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  10&lt;br /&gt;uniquePageviews:  363&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  11&lt;br /&gt;uniquePageviews:  539&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  12&lt;br /&gt;uniquePageviews:  529&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  13&lt;br /&gt;uniquePageviews:  730&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  14&lt;br /&gt;uniquePageviews:  715&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  15&lt;br /&gt;uniquePageviews:  592&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  16&lt;br /&gt;uniquePageviews:  435&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  17&lt;br /&gt;uniquePageviews:  385&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  18&lt;br /&gt;uniquePageviews:  356&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  19&lt;br /&gt;uniquePageviews:  411&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  20&lt;br /&gt;uniquePageviews:  359&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  21&lt;br /&gt;uniquePageviews:  411&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  22&lt;br /&gt;uniquePageviews:  356&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  23&lt;br /&gt;uniquePageviews:  316&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  24&lt;br /&gt;uniquePageviews:  293&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  25&lt;br /&gt;uniquePageviews:  248&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  26&lt;br /&gt;uniquePageviews:  317&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  27&lt;br /&gt;uniquePageviews:  291&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  28&lt;br /&gt;uniquePageviews:  493&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  29&lt;br /&gt;uniquePageviews:  238&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  30&lt;br /&gt;uniquePageviews:  275&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  31&lt;br /&gt;uniquePageviews:  247&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  32&lt;br /&gt;uniquePageviews:  256&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  33&lt;br /&gt;uniquePageviews:  248&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  34&lt;br /&gt;uniquePageviews:  218&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  35&lt;br /&gt;uniquePageviews:  234&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  36&lt;br /&gt;uniquePageviews:  234&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  37&lt;br /&gt;uniquePageviews:  217&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  38&lt;br /&gt;uniquePageviews:  185&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  39&lt;br /&gt;uniquePageviews:  197&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  40&lt;br /&gt;uniquePageviews:  251&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  41&lt;br /&gt;uniquePageviews:  226&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  42&lt;br /&gt;uniquePageviews:  192&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  43&lt;br /&gt;uniquePageviews:  202&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  44&lt;br /&gt;uniquePageviews:  178&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  45&lt;br /&gt;uniquePageviews:  164&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  46&lt;br /&gt;uniquePageviews:  189&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  47&lt;br /&gt;uniquePageviews:  331&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  48&lt;br /&gt;uniquePageviews:  422&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  49&lt;br /&gt;uniquePageviews:  447&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  50&lt;br /&gt;uniquePageviews:  386&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  51&lt;br /&gt;uniquePageviews:  311&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  52&lt;br /&gt;uniquePageviews:  255&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  53&lt;br /&gt;uniquePageviews:  229&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  54&lt;br /&gt;uniquePageviews:  268&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  55&lt;br /&gt;uniquePageviews:  226&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  56&lt;br /&gt;uniquePageviews:  271&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  57&lt;br /&gt;uniquePageviews:  259&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  58&lt;br /&gt;uniquePageviews:  218&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  59&lt;br /&gt;uniquePageviews:  180&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  60&lt;br /&gt;uniquePageviews:  208&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  61&lt;br /&gt;uniquePageviews:  301&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  62&lt;br /&gt;uniquePageviews:  239&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  63&lt;br /&gt;uniquePageviews:  214&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  64&lt;br /&gt;uniquePageviews:  188&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  65&lt;br /&gt;uniquePageviews:  174&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  66&lt;br /&gt;uniquePageviews:  131&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  67&lt;br /&gt;uniquePageviews:  136&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  68&lt;br /&gt;uniquePageviews:  123&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  69&lt;br /&gt;uniquePageviews:  153&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  70&lt;br /&gt;uniquePageviews:  142&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  71&lt;br /&gt;uniquePageviews:  104&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  72&lt;br /&gt;uniquePageviews:  115&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  73&lt;br /&gt;uniquePageviews:  105&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  74&lt;br /&gt;uniquePageviews:  101&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  75&lt;br /&gt;uniquePageviews:  124&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  76&lt;br /&gt;uniquePageviews:  127&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  77&lt;br /&gt;uniquePageviews:  125&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  78&lt;br /&gt;uniquePageviews:  103&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  79&lt;br /&gt;uniquePageviews:  130&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  80&lt;br /&gt;uniquePageviews:   96&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  81&lt;br /&gt;uniquePageviews:   92&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  82&lt;br /&gt;uniquePageviews:  104&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  83&lt;br /&gt;uniquePageviews:  138&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  84&lt;br /&gt;uniquePageviews:  109&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  85&lt;br /&gt;uniquePageviews:  120&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  86&lt;br /&gt;uniquePageviews:   94&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  87&lt;br /&gt;uniquePageviews:   76&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  88&lt;br /&gt;uniquePageviews:   62&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  89&lt;br /&gt;uniquePageviews:   89&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  90&lt;br /&gt;uniquePageviews:   86&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  91&lt;br /&gt;uniquePageviews:   93&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  92&lt;br /&gt;uniquePageviews:   93&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  93&lt;br /&gt;uniquePageviews:  278&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  94&lt;br /&gt;uniquePageviews:  215&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  95&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  96&lt;br /&gt;uniquePageviews:  119&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  97&lt;br /&gt;uniquePageviews:  111&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  98&lt;br /&gt;uniquePageviews:  105&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  99&lt;br /&gt;uniquePageviews:   90&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 100&lt;br /&gt;uniquePageviews:   87&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 101&lt;br /&gt;uniquePageviews:   51&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 102&lt;br /&gt;uniquePageviews:   69&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 103&lt;br /&gt;uniquePageviews:   95&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 104&lt;br /&gt;uniquePageviews:   61&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 105&lt;br /&gt;uniquePageviews:   95&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 106&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 107&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 108&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 109&lt;br /&gt;uniquePageviews:   59&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 110&lt;br /&gt;uniquePageviews:   76&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 111&lt;br /&gt;uniquePageviews:   63&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 112&lt;br /&gt;uniquePageviews:   47&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 113&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 114&lt;br /&gt;uniquePageviews:   75&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 115&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 116&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 117&lt;br /&gt;uniquePageviews:   63&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 118&lt;br /&gt;uniquePageviews:  134&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 119&lt;br /&gt;uniquePageviews:   83&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 120&lt;br /&gt;uniquePageviews:   84&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 121&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 122&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 123&lt;br /&gt;uniquePageviews:   66&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 124&lt;br /&gt;uniquePageviews:   76&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 125&lt;br /&gt;uniquePageviews:   61&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 126&lt;br /&gt;uniquePageviews:   86&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 127&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 128&lt;br /&gt;uniquePageviews:   69&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 129&lt;br /&gt;uniquePageviews:   67&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 130&lt;br /&gt;uniquePageviews:   58&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 131&lt;br /&gt;uniquePageviews:   82&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 132&lt;br /&gt;uniquePageviews:   64&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 133&lt;br /&gt;uniquePageviews:   48&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 134&lt;br /&gt;uniquePageviews:   72&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 135&lt;br /&gt;uniquePageviews:   63&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 136&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 137&lt;br /&gt;uniquePageviews:   46&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 138&lt;br /&gt;uniquePageviews:   46&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 139&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 140&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 141&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 142&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 143&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 144&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 145&lt;br /&gt;uniquePageviews:   53&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 146&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 147&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 148&lt;br /&gt;uniquePageviews:   32&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 149&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 150&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 151&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 152&lt;br /&gt;uniquePageviews:   58&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 153&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 154&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 155&lt;br /&gt;uniquePageviews:   45&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 156&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 157&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 158&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 159&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 160&lt;br /&gt;uniquePageviews:   50&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 161&lt;br /&gt;uniquePageviews:   40&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 162&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 163&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 164&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 165&lt;br /&gt;uniquePageviews:   52&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 166&lt;br /&gt;uniquePageviews:   64&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 167&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 168&lt;br /&gt;uniquePageviews:   50&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 169&lt;br /&gt;uniquePageviews:   50&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 170&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 171&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 172&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 173&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 174&lt;br /&gt;uniquePageviews:   57&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 175&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 176&lt;br /&gt;uniquePageviews:   48&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 177&lt;br /&gt;uniquePageviews:   38&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 178&lt;br /&gt;uniquePageviews:   42&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 179&lt;br /&gt;uniquePageviews:   40&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 180&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(165,138,255,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;legendgroup&#34;:&#34;/blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[6,4,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,17,2,1,3,2,3,2,1,8,5,2,1,2,4,2,0,3,4,5,3,1,0,7,1,1,1,2,9,0,1,2,6,4,3,6,4,6,5,2,0,2,2,2,4,0,1,1,2,0,1,1,1,0,3,3,3,2,0,3,2,2,4,3,2,2,18,1,4,0,2,3,3,1,5,1,6,3,1,1,4,4,2,4,7,3,1,2,0,0,4,0,1,3,1,1,2,1,0,5,4,3,4,4,8,6,2,2,1,2,12,9,15,7,16,13,17,16,8,9,7,10,8,11,12,8,8,7,14,10,10,16,32,19,19,25,17,31,41,13,23,35,22,25,30,19,35,28,33,37,34,64,65,44,29,39,26,23,27,43,19],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   2&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   3&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   4&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   5&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   6&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   7&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   8&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   9&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  10&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  11&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  12&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  13&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  14&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  15&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  16&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  17&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  18&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  19&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  20&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  21&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  22&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  23&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  24&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  25&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  26&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  27&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  28&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  29&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  30&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  31&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  32&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  33&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  34&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  35&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  36&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  37&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  38&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  39&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  40&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  41&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  42&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  43&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  44&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  45&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  46&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  47&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  48&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  49&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  50&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  51&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  52&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  53&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  54&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  55&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  56&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  57&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  58&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  59&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  60&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  61&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  62&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  63&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  64&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  65&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  66&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  67&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  68&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  69&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  70&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  71&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  72&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  73&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  74&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  75&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  76&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  77&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  78&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  79&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  80&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  81&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  82&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  83&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  84&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  85&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  86&lt;br /&gt;uniquePageviews:   18&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  87&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  88&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  89&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  90&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  91&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  92&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  93&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  94&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  95&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  96&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  97&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  98&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  99&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 100&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 101&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 102&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 103&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 104&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 105&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 106&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 107&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 108&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 109&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 110&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 111&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 112&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 113&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 114&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 115&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 116&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 117&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 118&lt;br /&gt;uniquePageviews:    0&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 119&lt;br /&gt;uniquePageviews:    5&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 120&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 121&lt;br /&gt;uniquePageviews:    3&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 122&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 123&lt;br /&gt;uniquePageviews:    4&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 124&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 125&lt;br /&gt;uniquePageviews:    6&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 126&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 127&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 128&lt;br /&gt;uniquePageviews:    1&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 129&lt;br /&gt;uniquePageviews:    2&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 130&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 131&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 132&lt;br /&gt;uniquePageviews:   15&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 133&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 134&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 135&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 136&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 137&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 138&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 139&lt;br /&gt;uniquePageviews:    9&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 140&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 141&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 142&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 143&lt;br /&gt;uniquePageviews:   11&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 144&lt;br /&gt;uniquePageviews:   12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 145&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 146&lt;br /&gt;uniquePageviews:    8&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 147&lt;br /&gt;uniquePageviews:    7&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 148&lt;br /&gt;uniquePageviews:   14&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 149&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 150&lt;br /&gt;uniquePageviews:   10&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 151&lt;br /&gt;uniquePageviews:   16&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 152&lt;br /&gt;uniquePageviews:   32&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 153&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 154&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 155&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 156&lt;br /&gt;uniquePageviews:   17&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 157&lt;br /&gt;uniquePageviews:   31&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 158&lt;br /&gt;uniquePageviews:   41&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 159&lt;br /&gt;uniquePageviews:   13&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 160&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 161&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 162&lt;br /&gt;uniquePageviews:   22&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 163&lt;br /&gt;uniquePageviews:   25&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 164&lt;br /&gt;uniquePageviews:   30&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 165&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 166&lt;br /&gt;uniquePageviews:   35&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 167&lt;br /&gt;uniquePageviews:   28&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 168&lt;br /&gt;uniquePageviews:   33&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 169&lt;br /&gt;uniquePageviews:   37&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 170&lt;br /&gt;uniquePageviews:   34&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 171&lt;br /&gt;uniquePageviews:   64&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 172&lt;br /&gt;uniquePageviews:   65&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 173&lt;br /&gt;uniquePageviews:   44&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 174&lt;br /&gt;uniquePageviews:   29&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 175&lt;br /&gt;uniquePageviews:   39&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 176&lt;br /&gt;uniquePageviews:   26&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 177&lt;br /&gt;uniquePageviews:   23&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 178&lt;br /&gt;uniquePageviews:   27&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 179&lt;br /&gt;uniquePageviews:   43&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 180&lt;br /&gt;uniquePageviews:   19&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(251,97,215,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/variable-types-and-examples/&#34;,&#34;legendgroup&#34;:&#34;/blog/variable-types-and-examples/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null}],&#34;layout&#34;:{&#34;margin&#34;:{&#34;t&#34;:43.7625570776256,&#34;r&#34;:7.30593607305936,&#34;b&#34;:40.1826484018265,&#34;l&#34;:54.7945205479452},&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.6118721461187},&#34;title&#34;:{&#34;text&#34;:&#34;Page views by day since publication&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:17.5342465753425},&#34;x&#34;:0,&#34;xref&#34;:&#34;paper&#34;},&#34;xaxis&#34;:{&#34;domain&#34;:[0,1],&#34;automargin&#34;:true,&#34;type&#34;:&#34;linear&#34;,&#34;autorange&#34;:true,&#34;range&#34;:[-7.95,188.95],&#34;tickmode&#34;:&#34;auto&#34;,&#34;ticktext&#34;:[&#34;0&#34;,&#34;50&#34;,&#34;100&#34;,&#34;150&#34;],&#34;tickvals&#34;:[0,50,100,150],&#34;categoryorder&#34;:&#34;array&#34;,&#34;categoryarray&#34;:[&#34;0&#34;,&#34;50&#34;,&#34;100&#34;,&#34;150&#34;],&#34;nticks&#34;:null,&#34;ticks&#34;:&#34;&#34;,&#34;tickcolor&#34;:null,&#34;ticklen&#34;:3.65296803652968,&#34;tickwidth&#34;:0,&#34;showticklabels&#34;:true,&#34;tickfont&#34;:{&#34;color&#34;:&#34;rgba(77,77,77,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.689497716895},&#34;tickangle&#34;:-0,&#34;showline&#34;:false,&#34;linecolor&#34;:null,&#34;linewidth&#34;:0,&#34;showgrid&#34;:true,&#34;gridcolor&#34;:&#34;rgba(235,235,235,1)&#34;,&#34;gridwidth&#34;:0.66417600664176,&#34;zeroline&#34;:false,&#34;anchor&#34;:&#34;y&#34;,&#34;title&#34;:{&#34;text&#34;:&#34;Days since publication&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.6118721461187}},&#34;hoverformat&#34;:&#34;.2f&#34;},&#34;yaxis&#34;:{&#34;domain&#34;:[0,1],&#34;automargin&#34;:true,&#34;type&#34;:&#34;linear&#34;,&#34;autorange&#34;:true,&#34;range&#34;:[-398.3,8364.3],&#34;tickmode&#34;:&#34;auto&#34;,&#34;ticktext&#34;:[&#34;0&#34;,&#34;2,000&#34;,&#34;4,000&#34;,&#34;6,000&#34;,&#34;8,000&#34;],&#34;tickvals&#34;:[0,2000,4000,6000,8000],&#34;categoryorder&#34;:&#34;array&#34;,&#34;categoryarray&#34;:[&#34;0&#34;,&#34;2,000&#34;,&#34;4,000&#34;,&#34;6,000&#34;,&#34;8,000&#34;],&#34;nticks&#34;:null,&#34;ticks&#34;:&#34;&#34;,&#34;tickcolor&#34;:null,&#34;ticklen&#34;:3.65296803652968,&#34;tickwidth&#34;:0,&#34;showticklabels&#34;:true,&#34;tickfont&#34;:{&#34;color&#34;:&#34;rgba(77,77,77,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.689497716895},&#34;tickangle&#34;:-0,&#34;showline&#34;:false,&#34;linecolor&#34;:null,&#34;linewidth&#34;:0,&#34;showgrid&#34;:true,&#34;gridcolor&#34;:&#34;rgba(235,235,235,1)&#34;,&#34;gridwidth&#34;:0.66417600664176,&#34;zeroline&#34;:false,&#34;anchor&#34;:&#34;x&#34;,&#34;title&#34;:{&#34;text&#34;:&#34;Page views&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.6118721461187}},&#34;hoverformat&#34;:&#34;.2f&#34;},&#34;shapes&#34;:[{&#34;type&#34;:&#34;rect&#34;,&#34;fillcolor&#34;:null,&#34;line&#34;:{&#34;color&#34;:null,&#34;width&#34;:0,&#34;linetype&#34;:[]},&#34;yref&#34;:&#34;paper&#34;,&#34;xref&#34;:&#34;paper&#34;,&#34;x0&#34;:0,&#34;x1&#34;:1,&#34;y0&#34;:0,&#34;y1&#34;:1}],&#34;showlegend&#34;:false,&#34;legend&#34;:{&#34;bgcolor&#34;:null,&#34;bordercolor&#34;:null,&#34;borderwidth&#34;:0,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.689497716895}},&#34;hovermode&#34;:&#34;closest&#34;,&#34;barmode&#34;:&#34;relative&#34;},&#34;config&#34;:{&#34;doubleClick&#34;:&#34;reset&#34;,&#34;modeBarButtonsToAdd&#34;:[&#34;hoverclosest&#34;,&#34;hovercompare&#34;],&#34;showSendToCloud&#34;:false},&#34;source&#34;:&#34;A&#34;,&#34;attrs&#34;:{&#34;7bd2e06e1f9&#34;:{&#34;x&#34;:{},&#34;y&#34;:{},&#34;colour&#34;:{},&#34;type&#34;:&#34;scatter&#34;}},&#34;cur_data&#34;:&#34;7bd2e06e1f9&#34;,&#34;visdat&#34;:{&#34;7bd2e06e1f9&#34;:[&#34;function (y) &#34;,&#34;x&#34;]},&#34;highlight&#34;:{&#34;on&#34;:&#34;plotly_click&#34;,&#34;persistent&#34;:false,&#34;dynamic&#34;:false,&#34;selectize&#34;:false,&#34;opacityDim&#34;:0.2,&#34;selected&#34;:{&#34;opacity&#34;:1},&#34;debounce&#34;:0},&#34;shinyEvents&#34;:[&#34;plotly_hover&#34;,&#34;plotly_click&#34;,&#34;plotly_selected&#34;,&#34;plotly_relayout&#34;,&#34;plotly_brushed&#34;,&#34;plotly_brushing&#34;,&#34;plotly_clickannotation&#34;,&#34;plotly_doubleclick&#34;,&#34;plotly_deselect&#34;,&#34;plotly_afterplot&#34;,&#34;plotly_sunburstclick&#34;],&#34;base_url&#34;:&#34;https://plot.ly&#34;},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;The plot above shows again a huge spike for the post that went viral (orange line). If we zoom in to include only page views below 1500, comparison between posts is easier and we see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The post on the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;top 100 R resources on Coronavirus&lt;/a&gt; (purple line) generated comparatively more traffic than the other posts in the first 50 days (&lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 1 month and 3 weeks) after publication. However, traffic gradually decreased up to the point that after 180 days (&lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 6 months), it attracted less traffic than other more performing posts.&lt;/li&gt;
&lt;li&gt;The post on &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers detection in R&lt;/a&gt; (blue line) did not get a lot of attention in the first weeks after its publication. However, it gradually generated more and more traffic up to the point that, after 60 days (&lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 2 months) after publication, it actually generated more traffic than any other post (and by a relatively large margin).&lt;/li&gt;
&lt;li&gt;The post on &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation coefficient and correlation test in R&lt;/a&gt; (green line) took approximately 100 days (&lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 3 months and 1 week) to take off, but after that it generated quite a lot of traffic. This is interesting to keep in mind when analyzing recent posts, because they may actually follow the same trend in the long run.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Create second plot: cumulative
gg &amp;lt;- ggplot(ga_data_normalized, mapping = aes(x = days_live, y = cumulative_uniquePageviews, color = page)) +
  geom_line() + # The main &amp;quot;plot&amp;quot; operation
  scale_y_continuous(labels = scales::comma) + # Include commas in the y-axis numbers
  labs(
    title = &amp;quot;Cumulative page views by day since publication&amp;quot;,
    x = &amp;quot;Days since publication&amp;quot;,
    y = &amp;quot;Cumulative page views&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  theme_minimal() + # minimal theme
  theme(
    legend.position = &amp;quot;none&amp;quot;, # remove legend
  )

# Output the plot, wrapped in ggplotly so we will get some interactivity in the plot
ggplotly(gg, dynamicTicks = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;htmlwidget-2&#34; style=&#34;width:100%;height:480px;&#34; class=&#34;plotly html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-2&#34;&gt;{&#34;x&#34;:{&#34;data&#34;:[{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[152,2338,8353,16319,23458,27846,30746,33294,35943,37401,38881,39931,40765,41300,41835,42552,43238,43779,44220,44623,44933,45238,45586,45906,46164,46440,46712,46914,47154,47387,47645,47896,48076,48302,48507,48692,48929,49115,49327,49495,49679,49823,49995,50186,50370,50529,50740,50967,51116,51222,51416,51598,51804,51966,52111,52224,52317,52410,52540,52638,52727,52847,52967,53064,53174,53280,53383,53489,53589,53661,53726,53811,53889,53958,54047,54122,54185,54235,54300,54400,54501,54580,54660,54730,54822,55044,55138,55221,55303,55370,55438,55493,55553,55620,55691,55752,55821,55860,55894,55942,55975,56037,56095,56143,56189,56231,56276,56331,56373,56425,56469,56508,56583,56656,56736,56808,56851,56922,56984,57025,57072,57107,57157,57198,57238,57274,57313,57363,57414,57479,57513,57550,57583,57613,57650,57684,57720,57754,57787,57827,57852,57875,57903,57931,57967,57996,58024,58048,58075,58105,58145,58155,58173,58197,58213,58230,58257,58283,58314,58341,58356,58365,58385,58414,58447,58461,58489,58507,58529,58549,58577,58598,58621,58638,58657,58673,58690,58715,58742,58756],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;cumulative_uniquePageviews:   152&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   2&lt;br /&gt;cumulative_uniquePageviews:  2338&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   3&lt;br /&gt;cumulative_uniquePageviews:  8353&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   4&lt;br /&gt;cumulative_uniquePageviews: 16319&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   5&lt;br /&gt;cumulative_uniquePageviews: 23458&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   6&lt;br /&gt;cumulative_uniquePageviews: 27846&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   7&lt;br /&gt;cumulative_uniquePageviews: 30746&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   8&lt;br /&gt;cumulative_uniquePageviews: 33294&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:   9&lt;br /&gt;cumulative_uniquePageviews: 35943&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  10&lt;br /&gt;cumulative_uniquePageviews: 37401&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  11&lt;br /&gt;cumulative_uniquePageviews: 38881&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  12&lt;br /&gt;cumulative_uniquePageviews: 39931&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  13&lt;br /&gt;cumulative_uniquePageviews: 40765&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  14&lt;br /&gt;cumulative_uniquePageviews: 41300&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  15&lt;br /&gt;cumulative_uniquePageviews: 41835&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  16&lt;br /&gt;cumulative_uniquePageviews: 42552&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  17&lt;br /&gt;cumulative_uniquePageviews: 43238&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  18&lt;br /&gt;cumulative_uniquePageviews: 43779&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  19&lt;br /&gt;cumulative_uniquePageviews: 44220&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  20&lt;br /&gt;cumulative_uniquePageviews: 44623&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  21&lt;br /&gt;cumulative_uniquePageviews: 44933&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  22&lt;br /&gt;cumulative_uniquePageviews: 45238&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  23&lt;br /&gt;cumulative_uniquePageviews: 45586&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  24&lt;br /&gt;cumulative_uniquePageviews: 45906&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  25&lt;br /&gt;cumulative_uniquePageviews: 46164&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  26&lt;br /&gt;cumulative_uniquePageviews: 46440&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  27&lt;br /&gt;cumulative_uniquePageviews: 46712&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  28&lt;br /&gt;cumulative_uniquePageviews: 46914&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  29&lt;br /&gt;cumulative_uniquePageviews: 47154&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  30&lt;br /&gt;cumulative_uniquePageviews: 47387&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  31&lt;br /&gt;cumulative_uniquePageviews: 47645&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  32&lt;br /&gt;cumulative_uniquePageviews: 47896&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  33&lt;br /&gt;cumulative_uniquePageviews: 48076&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  34&lt;br /&gt;cumulative_uniquePageviews: 48302&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  35&lt;br /&gt;cumulative_uniquePageviews: 48507&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  36&lt;br /&gt;cumulative_uniquePageviews: 48692&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  37&lt;br /&gt;cumulative_uniquePageviews: 48929&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  38&lt;br /&gt;cumulative_uniquePageviews: 49115&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  39&lt;br /&gt;cumulative_uniquePageviews: 49327&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  40&lt;br /&gt;cumulative_uniquePageviews: 49495&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  41&lt;br /&gt;cumulative_uniquePageviews: 49679&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  42&lt;br /&gt;cumulative_uniquePageviews: 49823&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  43&lt;br /&gt;cumulative_uniquePageviews: 49995&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  44&lt;br /&gt;cumulative_uniquePageviews: 50186&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  45&lt;br /&gt;cumulative_uniquePageviews: 50370&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  46&lt;br /&gt;cumulative_uniquePageviews: 50529&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  47&lt;br /&gt;cumulative_uniquePageviews: 50740&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  48&lt;br /&gt;cumulative_uniquePageviews: 50967&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  49&lt;br /&gt;cumulative_uniquePageviews: 51116&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  50&lt;br /&gt;cumulative_uniquePageviews: 51222&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  51&lt;br /&gt;cumulative_uniquePageviews: 51416&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  52&lt;br /&gt;cumulative_uniquePageviews: 51598&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  53&lt;br /&gt;cumulative_uniquePageviews: 51804&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  54&lt;br /&gt;cumulative_uniquePageviews: 51966&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  55&lt;br /&gt;cumulative_uniquePageviews: 52111&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  56&lt;br /&gt;cumulative_uniquePageviews: 52224&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  57&lt;br /&gt;cumulative_uniquePageviews: 52317&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  58&lt;br /&gt;cumulative_uniquePageviews: 52410&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  59&lt;br /&gt;cumulative_uniquePageviews: 52540&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  60&lt;br /&gt;cumulative_uniquePageviews: 52638&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  61&lt;br /&gt;cumulative_uniquePageviews: 52727&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  62&lt;br /&gt;cumulative_uniquePageviews: 52847&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  63&lt;br /&gt;cumulative_uniquePageviews: 52967&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  64&lt;br /&gt;cumulative_uniquePageviews: 53064&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  65&lt;br /&gt;cumulative_uniquePageviews: 53174&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  66&lt;br /&gt;cumulative_uniquePageviews: 53280&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  67&lt;br /&gt;cumulative_uniquePageviews: 53383&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  68&lt;br /&gt;cumulative_uniquePageviews: 53489&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  69&lt;br /&gt;cumulative_uniquePageviews: 53589&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  70&lt;br /&gt;cumulative_uniquePageviews: 53661&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  71&lt;br /&gt;cumulative_uniquePageviews: 53726&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  72&lt;br /&gt;cumulative_uniquePageviews: 53811&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  73&lt;br /&gt;cumulative_uniquePageviews: 53889&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  74&lt;br /&gt;cumulative_uniquePageviews: 53958&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  75&lt;br /&gt;cumulative_uniquePageviews: 54047&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  76&lt;br /&gt;cumulative_uniquePageviews: 54122&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  77&lt;br /&gt;cumulative_uniquePageviews: 54185&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  78&lt;br /&gt;cumulative_uniquePageviews: 54235&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  79&lt;br /&gt;cumulative_uniquePageviews: 54300&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  80&lt;br /&gt;cumulative_uniquePageviews: 54400&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  81&lt;br /&gt;cumulative_uniquePageviews: 54501&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  82&lt;br /&gt;cumulative_uniquePageviews: 54580&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  83&lt;br /&gt;cumulative_uniquePageviews: 54660&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  84&lt;br /&gt;cumulative_uniquePageviews: 54730&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  85&lt;br /&gt;cumulative_uniquePageviews: 54822&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  86&lt;br /&gt;cumulative_uniquePageviews: 55044&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  87&lt;br /&gt;cumulative_uniquePageviews: 55138&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  88&lt;br /&gt;cumulative_uniquePageviews: 55221&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  89&lt;br /&gt;cumulative_uniquePageviews: 55303&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  90&lt;br /&gt;cumulative_uniquePageviews: 55370&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  91&lt;br /&gt;cumulative_uniquePageviews: 55438&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  92&lt;br /&gt;cumulative_uniquePageviews: 55493&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  93&lt;br /&gt;cumulative_uniquePageviews: 55553&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  94&lt;br /&gt;cumulative_uniquePageviews: 55620&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  95&lt;br /&gt;cumulative_uniquePageviews: 55691&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  96&lt;br /&gt;cumulative_uniquePageviews: 55752&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  97&lt;br /&gt;cumulative_uniquePageviews: 55821&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  98&lt;br /&gt;cumulative_uniquePageviews: 55860&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live:  99&lt;br /&gt;cumulative_uniquePageviews: 55894&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 100&lt;br /&gt;cumulative_uniquePageviews: 55942&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 101&lt;br /&gt;cumulative_uniquePageviews: 55975&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 102&lt;br /&gt;cumulative_uniquePageviews: 56037&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 103&lt;br /&gt;cumulative_uniquePageviews: 56095&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 104&lt;br /&gt;cumulative_uniquePageviews: 56143&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 105&lt;br /&gt;cumulative_uniquePageviews: 56189&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 106&lt;br /&gt;cumulative_uniquePageviews: 56231&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 107&lt;br /&gt;cumulative_uniquePageviews: 56276&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 108&lt;br /&gt;cumulative_uniquePageviews: 56331&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 109&lt;br /&gt;cumulative_uniquePageviews: 56373&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 110&lt;br /&gt;cumulative_uniquePageviews: 56425&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 111&lt;br /&gt;cumulative_uniquePageviews: 56469&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 112&lt;br /&gt;cumulative_uniquePageviews: 56508&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 113&lt;br /&gt;cumulative_uniquePageviews: 56583&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 114&lt;br /&gt;cumulative_uniquePageviews: 56656&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 115&lt;br /&gt;cumulative_uniquePageviews: 56736&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 116&lt;br /&gt;cumulative_uniquePageviews: 56808&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 117&lt;br /&gt;cumulative_uniquePageviews: 56851&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 118&lt;br /&gt;cumulative_uniquePageviews: 56922&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 119&lt;br /&gt;cumulative_uniquePageviews: 56984&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 120&lt;br /&gt;cumulative_uniquePageviews: 57025&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 121&lt;br /&gt;cumulative_uniquePageviews: 57072&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 122&lt;br /&gt;cumulative_uniquePageviews: 57107&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 123&lt;br /&gt;cumulative_uniquePageviews: 57157&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 124&lt;br /&gt;cumulative_uniquePageviews: 57198&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 125&lt;br /&gt;cumulative_uniquePageviews: 57238&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 126&lt;br /&gt;cumulative_uniquePageviews: 57274&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 127&lt;br /&gt;cumulative_uniquePageviews: 57313&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 128&lt;br /&gt;cumulative_uniquePageviews: 57363&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 129&lt;br /&gt;cumulative_uniquePageviews: 57414&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 130&lt;br /&gt;cumulative_uniquePageviews: 57479&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 131&lt;br /&gt;cumulative_uniquePageviews: 57513&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 132&lt;br /&gt;cumulative_uniquePageviews: 57550&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 133&lt;br /&gt;cumulative_uniquePageviews: 57583&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 134&lt;br /&gt;cumulative_uniquePageviews: 57613&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 135&lt;br /&gt;cumulative_uniquePageviews: 57650&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 136&lt;br /&gt;cumulative_uniquePageviews: 57684&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 137&lt;br /&gt;cumulative_uniquePageviews: 57720&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 138&lt;br /&gt;cumulative_uniquePageviews: 57754&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 139&lt;br /&gt;cumulative_uniquePageviews: 57787&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 140&lt;br /&gt;cumulative_uniquePageviews: 57827&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 141&lt;br /&gt;cumulative_uniquePageviews: 57852&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 142&lt;br /&gt;cumulative_uniquePageviews: 57875&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 143&lt;br /&gt;cumulative_uniquePageviews: 57903&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 144&lt;br /&gt;cumulative_uniquePageviews: 57931&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 145&lt;br /&gt;cumulative_uniquePageviews: 57967&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 146&lt;br /&gt;cumulative_uniquePageviews: 57996&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 147&lt;br /&gt;cumulative_uniquePageviews: 58024&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 148&lt;br /&gt;cumulative_uniquePageviews: 58048&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 149&lt;br /&gt;cumulative_uniquePageviews: 58075&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 150&lt;br /&gt;cumulative_uniquePageviews: 58105&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 151&lt;br /&gt;cumulative_uniquePageviews: 58145&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 152&lt;br /&gt;cumulative_uniquePageviews: 58155&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 153&lt;br /&gt;cumulative_uniquePageviews: 58173&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 154&lt;br /&gt;cumulative_uniquePageviews: 58197&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 155&lt;br /&gt;cumulative_uniquePageviews: 58213&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 156&lt;br /&gt;cumulative_uniquePageviews: 58230&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 157&lt;br /&gt;cumulative_uniquePageviews: 58257&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 158&lt;br /&gt;cumulative_uniquePageviews: 58283&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 159&lt;br /&gt;cumulative_uniquePageviews: 58314&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 160&lt;br /&gt;cumulative_uniquePageviews: 58341&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 161&lt;br /&gt;cumulative_uniquePageviews: 58356&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 162&lt;br /&gt;cumulative_uniquePageviews: 58365&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 163&lt;br /&gt;cumulative_uniquePageviews: 58385&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 164&lt;br /&gt;cumulative_uniquePageviews: 58414&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 165&lt;br /&gt;cumulative_uniquePageviews: 58447&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 166&lt;br /&gt;cumulative_uniquePageviews: 58461&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 167&lt;br /&gt;cumulative_uniquePageviews: 58489&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 168&lt;br /&gt;cumulative_uniquePageviews: 58507&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 169&lt;br /&gt;cumulative_uniquePageviews: 58529&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 170&lt;br /&gt;cumulative_uniquePageviews: 58549&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 171&lt;br /&gt;cumulative_uniquePageviews: 58577&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 172&lt;br /&gt;cumulative_uniquePageviews: 58598&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 173&lt;br /&gt;cumulative_uniquePageviews: 58621&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 174&lt;br /&gt;cumulative_uniquePageviews: 58638&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 175&lt;br /&gt;cumulative_uniquePageviews: 58657&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 176&lt;br /&gt;cumulative_uniquePageviews: 58673&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 177&lt;br /&gt;cumulative_uniquePageviews: 58690&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 178&lt;br /&gt;cumulative_uniquePageviews: 58715&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 179&lt;br /&gt;cumulative_uniquePageviews: 58742&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;days_live: 180&lt;br /&gt;cumulative_uniquePageviews: 58756&lt;br /&gt;page: /blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(248,118,109,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;legendgroup&#34;:&#34;/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[4,4,4,5,5,5,11,13,34,296,508,585,729,849,911,958,987,1013,1042,1080,1105,1125,1145,1166,1182,1196,1210,1232,1264,1289,1310,1325,1340,1363,1379,1404,1429,1448,1473,1484,1504,1547,1563,1571,1580,1592,1609,1620,1638,1657,1681,1697,1710,1724,1746,1759,1771,1785,1805,1819,1833,1849,1865,1878,1887,1909,1932,1952,1978,2004,2028,2046,2069,2095,2109,2140,2167,2188,2214,2231,2269,2305,2332,2366,2412,2456,2499,2514,2538,2581,2630,2708,2783,2851,2923,2981,3043,3104,3142,3197,3248,3299,3352,3394,3435,3477,3525,3592,3661,3715,3789,3868,3924,4015,4099,4153,4192,4237,4309,4382,4454,4517,4550,4611,4701,4776,4836,4918,4987,5039,5090,5163,5249,5323,5401,5461,5513,5570,5654,5727,5801,5873,5953,6024,6101,6197,6276,6339,6412,6477,6541,6616,6694,6792,6859,6945,7008,7063,7124,7208,7286,7363,7448,7518,7570,7627,7714,7808,7907,7997,8080,8133,8217,8346,8448,8529,8595,8669,8703,8764],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;cumulative_uniquePageviews:     4&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   2&lt;br /&gt;cumulative_uniquePageviews:     4&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   3&lt;br /&gt;cumulative_uniquePageviews:     4&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   4&lt;br /&gt;cumulative_uniquePageviews:     5&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   5&lt;br /&gt;cumulative_uniquePageviews:     5&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   6&lt;br /&gt;cumulative_uniquePageviews:     5&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   7&lt;br /&gt;cumulative_uniquePageviews:    11&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   8&lt;br /&gt;cumulative_uniquePageviews:    13&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:   9&lt;br /&gt;cumulative_uniquePageviews:    34&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  10&lt;br /&gt;cumulative_uniquePageviews:   296&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  11&lt;br /&gt;cumulative_uniquePageviews:   508&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  12&lt;br /&gt;cumulative_uniquePageviews:   585&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  13&lt;br /&gt;cumulative_uniquePageviews:   729&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  14&lt;br /&gt;cumulative_uniquePageviews:   849&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  15&lt;br /&gt;cumulative_uniquePageviews:   911&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  16&lt;br /&gt;cumulative_uniquePageviews:   958&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  17&lt;br /&gt;cumulative_uniquePageviews:   987&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  18&lt;br /&gt;cumulative_uniquePageviews:  1013&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  19&lt;br /&gt;cumulative_uniquePageviews:  1042&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  20&lt;br /&gt;cumulative_uniquePageviews:  1080&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  21&lt;br /&gt;cumulative_uniquePageviews:  1105&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  22&lt;br /&gt;cumulative_uniquePageviews:  1125&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  23&lt;br /&gt;cumulative_uniquePageviews:  1145&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  24&lt;br /&gt;cumulative_uniquePageviews:  1166&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  25&lt;br /&gt;cumulative_uniquePageviews:  1182&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  26&lt;br /&gt;cumulative_uniquePageviews:  1196&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  27&lt;br /&gt;cumulative_uniquePageviews:  1210&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  28&lt;br /&gt;cumulative_uniquePageviews:  1232&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  29&lt;br /&gt;cumulative_uniquePageviews:  1264&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  30&lt;br /&gt;cumulative_uniquePageviews:  1289&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  31&lt;br /&gt;cumulative_uniquePageviews:  1310&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  32&lt;br /&gt;cumulative_uniquePageviews:  1325&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  33&lt;br /&gt;cumulative_uniquePageviews:  1340&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  34&lt;br /&gt;cumulative_uniquePageviews:  1363&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  35&lt;br /&gt;cumulative_uniquePageviews:  1379&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  36&lt;br /&gt;cumulative_uniquePageviews:  1404&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  37&lt;br /&gt;cumulative_uniquePageviews:  1429&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  38&lt;br /&gt;cumulative_uniquePageviews:  1448&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  39&lt;br /&gt;cumulative_uniquePageviews:  1473&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  40&lt;br /&gt;cumulative_uniquePageviews:  1484&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  41&lt;br /&gt;cumulative_uniquePageviews:  1504&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  42&lt;br /&gt;cumulative_uniquePageviews:  1547&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  43&lt;br /&gt;cumulative_uniquePageviews:  1563&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  44&lt;br /&gt;cumulative_uniquePageviews:  1571&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  45&lt;br /&gt;cumulative_uniquePageviews:  1580&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  46&lt;br /&gt;cumulative_uniquePageviews:  1592&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  47&lt;br /&gt;cumulative_uniquePageviews:  1609&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  48&lt;br /&gt;cumulative_uniquePageviews:  1620&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  49&lt;br /&gt;cumulative_uniquePageviews:  1638&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  50&lt;br /&gt;cumulative_uniquePageviews:  1657&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  51&lt;br /&gt;cumulative_uniquePageviews:  1681&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  52&lt;br /&gt;cumulative_uniquePageviews:  1697&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  53&lt;br /&gt;cumulative_uniquePageviews:  1710&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  54&lt;br /&gt;cumulative_uniquePageviews:  1724&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  55&lt;br /&gt;cumulative_uniquePageviews:  1746&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  56&lt;br /&gt;cumulative_uniquePageviews:  1759&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  57&lt;br /&gt;cumulative_uniquePageviews:  1771&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  58&lt;br /&gt;cumulative_uniquePageviews:  1785&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  59&lt;br /&gt;cumulative_uniquePageviews:  1805&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  60&lt;br /&gt;cumulative_uniquePageviews:  1819&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  61&lt;br /&gt;cumulative_uniquePageviews:  1833&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  62&lt;br /&gt;cumulative_uniquePageviews:  1849&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  63&lt;br /&gt;cumulative_uniquePageviews:  1865&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  64&lt;br /&gt;cumulative_uniquePageviews:  1878&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  65&lt;br /&gt;cumulative_uniquePageviews:  1887&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  66&lt;br /&gt;cumulative_uniquePageviews:  1909&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  67&lt;br /&gt;cumulative_uniquePageviews:  1932&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  68&lt;br /&gt;cumulative_uniquePageviews:  1952&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  69&lt;br /&gt;cumulative_uniquePageviews:  1978&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  70&lt;br /&gt;cumulative_uniquePageviews:  2004&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  71&lt;br /&gt;cumulative_uniquePageviews:  2028&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  72&lt;br /&gt;cumulative_uniquePageviews:  2046&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  73&lt;br /&gt;cumulative_uniquePageviews:  2069&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  74&lt;br /&gt;cumulative_uniquePageviews:  2095&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  75&lt;br /&gt;cumulative_uniquePageviews:  2109&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  76&lt;br /&gt;cumulative_uniquePageviews:  2140&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  77&lt;br /&gt;cumulative_uniquePageviews:  2167&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  78&lt;br /&gt;cumulative_uniquePageviews:  2188&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  79&lt;br /&gt;cumulative_uniquePageviews:  2214&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  80&lt;br /&gt;cumulative_uniquePageviews:  2231&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  81&lt;br /&gt;cumulative_uniquePageviews:  2269&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  82&lt;br /&gt;cumulative_uniquePageviews:  2305&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  83&lt;br /&gt;cumulative_uniquePageviews:  2332&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  84&lt;br /&gt;cumulative_uniquePageviews:  2366&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  85&lt;br /&gt;cumulative_uniquePageviews:  2412&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  86&lt;br /&gt;cumulative_uniquePageviews:  2456&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  87&lt;br /&gt;cumulative_uniquePageviews:  2499&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  88&lt;br /&gt;cumulative_uniquePageviews:  2514&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  89&lt;br /&gt;cumulative_uniquePageviews:  2538&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  90&lt;br /&gt;cumulative_uniquePageviews:  2581&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  91&lt;br /&gt;cumulative_uniquePageviews:  2630&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  92&lt;br /&gt;cumulative_uniquePageviews:  2708&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  93&lt;br /&gt;cumulative_uniquePageviews:  2783&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  94&lt;br /&gt;cumulative_uniquePageviews:  2851&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  95&lt;br /&gt;cumulative_uniquePageviews:  2923&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  96&lt;br /&gt;cumulative_uniquePageviews:  2981&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  97&lt;br /&gt;cumulative_uniquePageviews:  3043&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  98&lt;br /&gt;cumulative_uniquePageviews:  3104&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live:  99&lt;br /&gt;cumulative_uniquePageviews:  3142&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 100&lt;br /&gt;cumulative_uniquePageviews:  3197&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 101&lt;br /&gt;cumulative_uniquePageviews:  3248&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 102&lt;br /&gt;cumulative_uniquePageviews:  3299&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 103&lt;br /&gt;cumulative_uniquePageviews:  3352&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 104&lt;br /&gt;cumulative_uniquePageviews:  3394&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 105&lt;br /&gt;cumulative_uniquePageviews:  3435&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 106&lt;br /&gt;cumulative_uniquePageviews:  3477&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 107&lt;br /&gt;cumulative_uniquePageviews:  3525&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 108&lt;br /&gt;cumulative_uniquePageviews:  3592&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 109&lt;br /&gt;cumulative_uniquePageviews:  3661&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 110&lt;br /&gt;cumulative_uniquePageviews:  3715&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 111&lt;br /&gt;cumulative_uniquePageviews:  3789&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 112&lt;br /&gt;cumulative_uniquePageviews:  3868&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 113&lt;br /&gt;cumulative_uniquePageviews:  3924&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 114&lt;br /&gt;cumulative_uniquePageviews:  4015&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 115&lt;br /&gt;cumulative_uniquePageviews:  4099&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 116&lt;br /&gt;cumulative_uniquePageviews:  4153&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 117&lt;br /&gt;cumulative_uniquePageviews:  4192&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 118&lt;br /&gt;cumulative_uniquePageviews:  4237&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 119&lt;br /&gt;cumulative_uniquePageviews:  4309&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 120&lt;br /&gt;cumulative_uniquePageviews:  4382&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 121&lt;br /&gt;cumulative_uniquePageviews:  4454&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 122&lt;br /&gt;cumulative_uniquePageviews:  4517&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 123&lt;br /&gt;cumulative_uniquePageviews:  4550&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 124&lt;br /&gt;cumulative_uniquePageviews:  4611&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 125&lt;br /&gt;cumulative_uniquePageviews:  4701&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 126&lt;br /&gt;cumulative_uniquePageviews:  4776&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 127&lt;br /&gt;cumulative_uniquePageviews:  4836&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 128&lt;br /&gt;cumulative_uniquePageviews:  4918&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 129&lt;br /&gt;cumulative_uniquePageviews:  4987&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 130&lt;br /&gt;cumulative_uniquePageviews:  5039&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 131&lt;br /&gt;cumulative_uniquePageviews:  5090&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 132&lt;br /&gt;cumulative_uniquePageviews:  5163&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 133&lt;br /&gt;cumulative_uniquePageviews:  5249&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 134&lt;br /&gt;cumulative_uniquePageviews:  5323&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 135&lt;br /&gt;cumulative_uniquePageviews:  5401&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 136&lt;br /&gt;cumulative_uniquePageviews:  5461&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 137&lt;br /&gt;cumulative_uniquePageviews:  5513&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 138&lt;br /&gt;cumulative_uniquePageviews:  5570&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 139&lt;br /&gt;cumulative_uniquePageviews:  5654&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 140&lt;br /&gt;cumulative_uniquePageviews:  5727&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 141&lt;br /&gt;cumulative_uniquePageviews:  5801&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 142&lt;br /&gt;cumulative_uniquePageviews:  5873&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 143&lt;br /&gt;cumulative_uniquePageviews:  5953&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 144&lt;br /&gt;cumulative_uniquePageviews:  6024&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 145&lt;br /&gt;cumulative_uniquePageviews:  6101&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 146&lt;br /&gt;cumulative_uniquePageviews:  6197&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 147&lt;br /&gt;cumulative_uniquePageviews:  6276&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 148&lt;br /&gt;cumulative_uniquePageviews:  6339&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 149&lt;br /&gt;cumulative_uniquePageviews:  6412&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 150&lt;br /&gt;cumulative_uniquePageviews:  6477&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 151&lt;br /&gt;cumulative_uniquePageviews:  6541&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 152&lt;br /&gt;cumulative_uniquePageviews:  6616&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 153&lt;br /&gt;cumulative_uniquePageviews:  6694&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 154&lt;br /&gt;cumulative_uniquePageviews:  6792&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 155&lt;br /&gt;cumulative_uniquePageviews:  6859&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 156&lt;br /&gt;cumulative_uniquePageviews:  6945&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 157&lt;br /&gt;cumulative_uniquePageviews:  7008&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 158&lt;br /&gt;cumulative_uniquePageviews:  7063&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 159&lt;br /&gt;cumulative_uniquePageviews:  7124&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 160&lt;br /&gt;cumulative_uniquePageviews:  7208&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 161&lt;br /&gt;cumulative_uniquePageviews:  7286&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 162&lt;br /&gt;cumulative_uniquePageviews:  7363&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 163&lt;br /&gt;cumulative_uniquePageviews:  7448&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 164&lt;br /&gt;cumulative_uniquePageviews:  7518&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 165&lt;br /&gt;cumulative_uniquePageviews:  7570&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 166&lt;br /&gt;cumulative_uniquePageviews:  7627&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 167&lt;br /&gt;cumulative_uniquePageviews:  7714&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 168&lt;br /&gt;cumulative_uniquePageviews:  7808&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 169&lt;br /&gt;cumulative_uniquePageviews:  7907&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 170&lt;br /&gt;cumulative_uniquePageviews:  7997&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 171&lt;br /&gt;cumulative_uniquePageviews:  8080&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 172&lt;br /&gt;cumulative_uniquePageviews:  8133&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 173&lt;br /&gt;cumulative_uniquePageviews:  8217&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 174&lt;br /&gt;cumulative_uniquePageviews:  8346&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 175&lt;br /&gt;cumulative_uniquePageviews:  8448&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 176&lt;br /&gt;cumulative_uniquePageviews:  8529&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 177&lt;br /&gt;cumulative_uniquePageviews:  8595&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 178&lt;br /&gt;cumulative_uniquePageviews:  8669&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 179&lt;br /&gt;cumulative_uniquePageviews:  8703&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;days_live: 180&lt;br /&gt;cumulative_uniquePageviews:  8764&lt;br /&gt;page: /blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(196,154,0,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;legendgroup&#34;:&#34;/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[111,436,631,672,749,808,850,892,918,936,959,989,1011,1033,1047,1058,1064,1077,1086,1097,1105,1115,1128,1132,1144,1158,1171,1178,1191,1205,1214,1222,1238,1251,1258,1277,1296,1306,1318,1335,1344,1353,1359,1370,1381,1388,1398,1408,1421,1441,1456,1466,1484,1510,1536,1554,1568,1584,1601,1626,1644,1670,1702,1732,1744,1759,1777,1801,1833,1863,1892,1916,1938,1967,2001,2043,2096,2130,2183,2214,2236,2294,2344,2415,2492,2549,2601,2663,2749,2813,2877,2933,2990,3035,3073,3148,3219,3297,3367,3444,3501,3554,3622,3714,3800,3912,4006,4064,4138,4229,4340,4433,4554,4685,4776,4873,5042,5222,5369,5554,5678,5779,5886,6034,6181,6339,6483,6613,6687,6805,6954,7131,7307,7449,7595,7690,7808,7988,8187,8386,8552,8725,8827,8941,9141,9333,9535,9716,9871,9998,10135,10311,10514,10713,10901,11065,11178,11293,11502,11693,11856,12035,12217,12354,12483,12686,12881,13072,13291,13478,13600,13735,13922,14106,14293,14458,14639,14773,14933,15151],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;cumulative_uniquePageviews:   111&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   2&lt;br /&gt;cumulative_uniquePageviews:   436&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   3&lt;br /&gt;cumulative_uniquePageviews:   631&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   4&lt;br /&gt;cumulative_uniquePageviews:   672&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   5&lt;br /&gt;cumulative_uniquePageviews:   749&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   6&lt;br /&gt;cumulative_uniquePageviews:   808&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   7&lt;br /&gt;cumulative_uniquePageviews:   850&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   8&lt;br /&gt;cumulative_uniquePageviews:   892&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:   9&lt;br /&gt;cumulative_uniquePageviews:   918&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  10&lt;br /&gt;cumulative_uniquePageviews:   936&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  11&lt;br /&gt;cumulative_uniquePageviews:   959&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  12&lt;br /&gt;cumulative_uniquePageviews:   989&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  13&lt;br /&gt;cumulative_uniquePageviews:  1011&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  14&lt;br /&gt;cumulative_uniquePageviews:  1033&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  15&lt;br /&gt;cumulative_uniquePageviews:  1047&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  16&lt;br /&gt;cumulative_uniquePageviews:  1058&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  17&lt;br /&gt;cumulative_uniquePageviews:  1064&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  18&lt;br /&gt;cumulative_uniquePageviews:  1077&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  19&lt;br /&gt;cumulative_uniquePageviews:  1086&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  20&lt;br /&gt;cumulative_uniquePageviews:  1097&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  21&lt;br /&gt;cumulative_uniquePageviews:  1105&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  22&lt;br /&gt;cumulative_uniquePageviews:  1115&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  23&lt;br /&gt;cumulative_uniquePageviews:  1128&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  24&lt;br /&gt;cumulative_uniquePageviews:  1132&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  25&lt;br /&gt;cumulative_uniquePageviews:  1144&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  26&lt;br /&gt;cumulative_uniquePageviews:  1158&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  27&lt;br /&gt;cumulative_uniquePageviews:  1171&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  28&lt;br /&gt;cumulative_uniquePageviews:  1178&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  29&lt;br /&gt;cumulative_uniquePageviews:  1191&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  30&lt;br /&gt;cumulative_uniquePageviews:  1205&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  31&lt;br /&gt;cumulative_uniquePageviews:  1214&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  32&lt;br /&gt;cumulative_uniquePageviews:  1222&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  33&lt;br /&gt;cumulative_uniquePageviews:  1238&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  34&lt;br /&gt;cumulative_uniquePageviews:  1251&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  35&lt;br /&gt;cumulative_uniquePageviews:  1258&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  36&lt;br /&gt;cumulative_uniquePageviews:  1277&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  37&lt;br /&gt;cumulative_uniquePageviews:  1296&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  38&lt;br /&gt;cumulative_uniquePageviews:  1306&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  39&lt;br /&gt;cumulative_uniquePageviews:  1318&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  40&lt;br /&gt;cumulative_uniquePageviews:  1335&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  41&lt;br /&gt;cumulative_uniquePageviews:  1344&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  42&lt;br /&gt;cumulative_uniquePageviews:  1353&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  43&lt;br /&gt;cumulative_uniquePageviews:  1359&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  44&lt;br /&gt;cumulative_uniquePageviews:  1370&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  45&lt;br /&gt;cumulative_uniquePageviews:  1381&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  46&lt;br /&gt;cumulative_uniquePageviews:  1388&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  47&lt;br /&gt;cumulative_uniquePageviews:  1398&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  48&lt;br /&gt;cumulative_uniquePageviews:  1408&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  49&lt;br /&gt;cumulative_uniquePageviews:  1421&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  50&lt;br /&gt;cumulative_uniquePageviews:  1441&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  51&lt;br /&gt;cumulative_uniquePageviews:  1456&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  52&lt;br /&gt;cumulative_uniquePageviews:  1466&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  53&lt;br /&gt;cumulative_uniquePageviews:  1484&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  54&lt;br /&gt;cumulative_uniquePageviews:  1510&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  55&lt;br /&gt;cumulative_uniquePageviews:  1536&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  56&lt;br /&gt;cumulative_uniquePageviews:  1554&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  57&lt;br /&gt;cumulative_uniquePageviews:  1568&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  58&lt;br /&gt;cumulative_uniquePageviews:  1584&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  59&lt;br /&gt;cumulative_uniquePageviews:  1601&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  60&lt;br /&gt;cumulative_uniquePageviews:  1626&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  61&lt;br /&gt;cumulative_uniquePageviews:  1644&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  62&lt;br /&gt;cumulative_uniquePageviews:  1670&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  63&lt;br /&gt;cumulative_uniquePageviews:  1702&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  64&lt;br /&gt;cumulative_uniquePageviews:  1732&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  65&lt;br /&gt;cumulative_uniquePageviews:  1744&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  66&lt;br /&gt;cumulative_uniquePageviews:  1759&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  67&lt;br /&gt;cumulative_uniquePageviews:  1777&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  68&lt;br /&gt;cumulative_uniquePageviews:  1801&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  69&lt;br /&gt;cumulative_uniquePageviews:  1833&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  70&lt;br /&gt;cumulative_uniquePageviews:  1863&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  71&lt;br /&gt;cumulative_uniquePageviews:  1892&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  72&lt;br /&gt;cumulative_uniquePageviews:  1916&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  73&lt;br /&gt;cumulative_uniquePageviews:  1938&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  74&lt;br /&gt;cumulative_uniquePageviews:  1967&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  75&lt;br /&gt;cumulative_uniquePageviews:  2001&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  76&lt;br /&gt;cumulative_uniquePageviews:  2043&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  77&lt;br /&gt;cumulative_uniquePageviews:  2096&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  78&lt;br /&gt;cumulative_uniquePageviews:  2130&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  79&lt;br /&gt;cumulative_uniquePageviews:  2183&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  80&lt;br /&gt;cumulative_uniquePageviews:  2214&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  81&lt;br /&gt;cumulative_uniquePageviews:  2236&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  82&lt;br /&gt;cumulative_uniquePageviews:  2294&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  83&lt;br /&gt;cumulative_uniquePageviews:  2344&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  84&lt;br /&gt;cumulative_uniquePageviews:  2415&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  85&lt;br /&gt;cumulative_uniquePageviews:  2492&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  86&lt;br /&gt;cumulative_uniquePageviews:  2549&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  87&lt;br /&gt;cumulative_uniquePageviews:  2601&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  88&lt;br /&gt;cumulative_uniquePageviews:  2663&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  89&lt;br /&gt;cumulative_uniquePageviews:  2749&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  90&lt;br /&gt;cumulative_uniquePageviews:  2813&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  91&lt;br /&gt;cumulative_uniquePageviews:  2877&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  92&lt;br /&gt;cumulative_uniquePageviews:  2933&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  93&lt;br /&gt;cumulative_uniquePageviews:  2990&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  94&lt;br /&gt;cumulative_uniquePageviews:  3035&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  95&lt;br /&gt;cumulative_uniquePageviews:  3073&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  96&lt;br /&gt;cumulative_uniquePageviews:  3148&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  97&lt;br /&gt;cumulative_uniquePageviews:  3219&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  98&lt;br /&gt;cumulative_uniquePageviews:  3297&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live:  99&lt;br /&gt;cumulative_uniquePageviews:  3367&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 100&lt;br /&gt;cumulative_uniquePageviews:  3444&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 101&lt;br /&gt;cumulative_uniquePageviews:  3501&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 102&lt;br /&gt;cumulative_uniquePageviews:  3554&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 103&lt;br /&gt;cumulative_uniquePageviews:  3622&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 104&lt;br /&gt;cumulative_uniquePageviews:  3714&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 105&lt;br /&gt;cumulative_uniquePageviews:  3800&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 106&lt;br /&gt;cumulative_uniquePageviews:  3912&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 107&lt;br /&gt;cumulative_uniquePageviews:  4006&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 108&lt;br /&gt;cumulative_uniquePageviews:  4064&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 109&lt;br /&gt;cumulative_uniquePageviews:  4138&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 110&lt;br /&gt;cumulative_uniquePageviews:  4229&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 111&lt;br /&gt;cumulative_uniquePageviews:  4340&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 112&lt;br /&gt;cumulative_uniquePageviews:  4433&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 113&lt;br /&gt;cumulative_uniquePageviews:  4554&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 114&lt;br /&gt;cumulative_uniquePageviews:  4685&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 115&lt;br /&gt;cumulative_uniquePageviews:  4776&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 116&lt;br /&gt;cumulative_uniquePageviews:  4873&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 117&lt;br /&gt;cumulative_uniquePageviews:  5042&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 118&lt;br /&gt;cumulative_uniquePageviews:  5222&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 119&lt;br /&gt;cumulative_uniquePageviews:  5369&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 120&lt;br /&gt;cumulative_uniquePageviews:  5554&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 121&lt;br /&gt;cumulative_uniquePageviews:  5678&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 122&lt;br /&gt;cumulative_uniquePageviews:  5779&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 123&lt;br /&gt;cumulative_uniquePageviews:  5886&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 124&lt;br /&gt;cumulative_uniquePageviews:  6034&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 125&lt;br /&gt;cumulative_uniquePageviews:  6181&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 126&lt;br /&gt;cumulative_uniquePageviews:  6339&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 127&lt;br /&gt;cumulative_uniquePageviews:  6483&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 128&lt;br /&gt;cumulative_uniquePageviews:  6613&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 129&lt;br /&gt;cumulative_uniquePageviews:  6687&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 130&lt;br /&gt;cumulative_uniquePageviews:  6805&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 131&lt;br /&gt;cumulative_uniquePageviews:  6954&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 132&lt;br /&gt;cumulative_uniquePageviews:  7131&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 133&lt;br /&gt;cumulative_uniquePageviews:  7307&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 134&lt;br /&gt;cumulative_uniquePageviews:  7449&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 135&lt;br /&gt;cumulative_uniquePageviews:  7595&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 136&lt;br /&gt;cumulative_uniquePageviews:  7690&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 137&lt;br /&gt;cumulative_uniquePageviews:  7808&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 138&lt;br /&gt;cumulative_uniquePageviews:  7988&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 139&lt;br /&gt;cumulative_uniquePageviews:  8187&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 140&lt;br /&gt;cumulative_uniquePageviews:  8386&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 141&lt;br /&gt;cumulative_uniquePageviews:  8552&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 142&lt;br /&gt;cumulative_uniquePageviews:  8725&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 143&lt;br /&gt;cumulative_uniquePageviews:  8827&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 144&lt;br /&gt;cumulative_uniquePageviews:  8941&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 145&lt;br /&gt;cumulative_uniquePageviews:  9141&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 146&lt;br /&gt;cumulative_uniquePageviews:  9333&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 147&lt;br /&gt;cumulative_uniquePageviews:  9535&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 148&lt;br /&gt;cumulative_uniquePageviews:  9716&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 149&lt;br /&gt;cumulative_uniquePageviews:  9871&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 150&lt;br /&gt;cumulative_uniquePageviews:  9998&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 151&lt;br /&gt;cumulative_uniquePageviews: 10135&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 152&lt;br /&gt;cumulative_uniquePageviews: 10311&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 153&lt;br /&gt;cumulative_uniquePageviews: 10514&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 154&lt;br /&gt;cumulative_uniquePageviews: 10713&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 155&lt;br /&gt;cumulative_uniquePageviews: 10901&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 156&lt;br /&gt;cumulative_uniquePageviews: 11065&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 157&lt;br /&gt;cumulative_uniquePageviews: 11178&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 158&lt;br /&gt;cumulative_uniquePageviews: 11293&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 159&lt;br /&gt;cumulative_uniquePageviews: 11502&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 160&lt;br /&gt;cumulative_uniquePageviews: 11693&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 161&lt;br /&gt;cumulative_uniquePageviews: 11856&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 162&lt;br /&gt;cumulative_uniquePageviews: 12035&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 163&lt;br /&gt;cumulative_uniquePageviews: 12217&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 164&lt;br /&gt;cumulative_uniquePageviews: 12354&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 165&lt;br /&gt;cumulative_uniquePageviews: 12483&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 166&lt;br /&gt;cumulative_uniquePageviews: 12686&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 167&lt;br /&gt;cumulative_uniquePageviews: 12881&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 168&lt;br /&gt;cumulative_uniquePageviews: 13072&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 169&lt;br /&gt;cumulative_uniquePageviews: 13291&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 170&lt;br /&gt;cumulative_uniquePageviews: 13478&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 171&lt;br /&gt;cumulative_uniquePageviews: 13600&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 172&lt;br /&gt;cumulative_uniquePageviews: 13735&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 173&lt;br /&gt;cumulative_uniquePageviews: 13922&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 174&lt;br /&gt;cumulative_uniquePageviews: 14106&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 175&lt;br /&gt;cumulative_uniquePageviews: 14293&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 176&lt;br /&gt;cumulative_uniquePageviews: 14458&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 177&lt;br /&gt;cumulative_uniquePageviews: 14639&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 178&lt;br /&gt;cumulative_uniquePageviews: 14773&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 179&lt;br /&gt;cumulative_uniquePageviews: 14933&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;days_live: 180&lt;br /&gt;cumulative_uniquePageviews: 15151&lt;br /&gt;page: /blog/correlation-coefficient-and-correlation-test-in-r/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(83,180,0,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;legendgroup&#34;:&#34;/blog/correlation-coefficient-and-correlation-test-in-r/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[3,3,3,3,3,4,6,79,845,933,1116,1212,1270,1295,1324,1348,1362,1384,1406,1423,1440,1455,1468,1476,1496,1514,1522,1548,1568,1577,1587,1604,1621,1655,1675,1693,1707,1732,1753,1774,1782,1796,1801,1818,1830,1850,1860,1876,1892,1905,1910,1922,1930,1947,1965,1982,1999,2012,2018,2024,2033,2037,2042,2050,2060,2071,2082,2098,2106,2115,2121,2131,2142,2148,2155,2162,2170,2175,2183,2187,2198,2207,2213,2223,2229,2242,2250,2260,2266,2276,2285,2296,2302,2324,2339,2350,2367,2394,2409,2425,2435,2450,2482,2505,2522,2536,2542,2559,2576,2600,2632,2656,2724,2758,2800,2844,2890,2933,2979,3008,3030,3043,3066,3092,3113,3144,3167,3193,3219,3242,3272,3295,3332,3380,3413,3444,3480,3521,3551,3594,3631,3660,3698,3749,3793,3878,3977,4088,4166,4204,4270,4312,4352,4387,4417,4442,4464,4505,4535,4578,4631,4675,4702,4727,4764,4810,4846,4870,4920,4955,4998,5080,5148,5216,5313,5420,5486,5553,5635,5710],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;cumulative_uniquePageviews:     3&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   2&lt;br /&gt;cumulative_uniquePageviews:     3&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   3&lt;br /&gt;cumulative_uniquePageviews:     3&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   4&lt;br /&gt;cumulative_uniquePageviews:     3&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   5&lt;br /&gt;cumulative_uniquePageviews:     3&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   6&lt;br /&gt;cumulative_uniquePageviews:     4&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   7&lt;br /&gt;cumulative_uniquePageviews:     6&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   8&lt;br /&gt;cumulative_uniquePageviews:    79&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:   9&lt;br /&gt;cumulative_uniquePageviews:   845&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  10&lt;br /&gt;cumulative_uniquePageviews:   933&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  11&lt;br /&gt;cumulative_uniquePageviews:  1116&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  12&lt;br /&gt;cumulative_uniquePageviews:  1212&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  13&lt;br /&gt;cumulative_uniquePageviews:  1270&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  14&lt;br /&gt;cumulative_uniquePageviews:  1295&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  15&lt;br /&gt;cumulative_uniquePageviews:  1324&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  16&lt;br /&gt;cumulative_uniquePageviews:  1348&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  17&lt;br /&gt;cumulative_uniquePageviews:  1362&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  18&lt;br /&gt;cumulative_uniquePageviews:  1384&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  19&lt;br /&gt;cumulative_uniquePageviews:  1406&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  20&lt;br /&gt;cumulative_uniquePageviews:  1423&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  21&lt;br /&gt;cumulative_uniquePageviews:  1440&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  22&lt;br /&gt;cumulative_uniquePageviews:  1455&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  23&lt;br /&gt;cumulative_uniquePageviews:  1468&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  24&lt;br /&gt;cumulative_uniquePageviews:  1476&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  25&lt;br /&gt;cumulative_uniquePageviews:  1496&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  26&lt;br /&gt;cumulative_uniquePageviews:  1514&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  27&lt;br /&gt;cumulative_uniquePageviews:  1522&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  28&lt;br /&gt;cumulative_uniquePageviews:  1548&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  29&lt;br /&gt;cumulative_uniquePageviews:  1568&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  30&lt;br /&gt;cumulative_uniquePageviews:  1577&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  31&lt;br /&gt;cumulative_uniquePageviews:  1587&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  32&lt;br /&gt;cumulative_uniquePageviews:  1604&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  33&lt;br /&gt;cumulative_uniquePageviews:  1621&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  34&lt;br /&gt;cumulative_uniquePageviews:  1655&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  35&lt;br /&gt;cumulative_uniquePageviews:  1675&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  36&lt;br /&gt;cumulative_uniquePageviews:  1693&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  37&lt;br /&gt;cumulative_uniquePageviews:  1707&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  38&lt;br /&gt;cumulative_uniquePageviews:  1732&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  39&lt;br /&gt;cumulative_uniquePageviews:  1753&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  40&lt;br /&gt;cumulative_uniquePageviews:  1774&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  41&lt;br /&gt;cumulative_uniquePageviews:  1782&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  42&lt;br /&gt;cumulative_uniquePageviews:  1796&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  43&lt;br /&gt;cumulative_uniquePageviews:  1801&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  44&lt;br /&gt;cumulative_uniquePageviews:  1818&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  45&lt;br /&gt;cumulative_uniquePageviews:  1830&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  46&lt;br /&gt;cumulative_uniquePageviews:  1850&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  47&lt;br /&gt;cumulative_uniquePageviews:  1860&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  48&lt;br /&gt;cumulative_uniquePageviews:  1876&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  49&lt;br /&gt;cumulative_uniquePageviews:  1892&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  50&lt;br /&gt;cumulative_uniquePageviews:  1905&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  51&lt;br /&gt;cumulative_uniquePageviews:  1910&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  52&lt;br /&gt;cumulative_uniquePageviews:  1922&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  53&lt;br /&gt;cumulative_uniquePageviews:  1930&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  54&lt;br /&gt;cumulative_uniquePageviews:  1947&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  55&lt;br /&gt;cumulative_uniquePageviews:  1965&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  56&lt;br /&gt;cumulative_uniquePageviews:  1982&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  57&lt;br /&gt;cumulative_uniquePageviews:  1999&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  58&lt;br /&gt;cumulative_uniquePageviews:  2012&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  59&lt;br /&gt;cumulative_uniquePageviews:  2018&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  60&lt;br /&gt;cumulative_uniquePageviews:  2024&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  61&lt;br /&gt;cumulative_uniquePageviews:  2033&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  62&lt;br /&gt;cumulative_uniquePageviews:  2037&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  63&lt;br /&gt;cumulative_uniquePageviews:  2042&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  64&lt;br /&gt;cumulative_uniquePageviews:  2050&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  65&lt;br /&gt;cumulative_uniquePageviews:  2060&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  66&lt;br /&gt;cumulative_uniquePageviews:  2071&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  67&lt;br /&gt;cumulative_uniquePageviews:  2082&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  68&lt;br /&gt;cumulative_uniquePageviews:  2098&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  69&lt;br /&gt;cumulative_uniquePageviews:  2106&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  70&lt;br /&gt;cumulative_uniquePageviews:  2115&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  71&lt;br /&gt;cumulative_uniquePageviews:  2121&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  72&lt;br /&gt;cumulative_uniquePageviews:  2131&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  73&lt;br /&gt;cumulative_uniquePageviews:  2142&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  74&lt;br /&gt;cumulative_uniquePageviews:  2148&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  75&lt;br /&gt;cumulative_uniquePageviews:  2155&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  76&lt;br /&gt;cumulative_uniquePageviews:  2162&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  77&lt;br /&gt;cumulative_uniquePageviews:  2170&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  78&lt;br /&gt;cumulative_uniquePageviews:  2175&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  79&lt;br /&gt;cumulative_uniquePageviews:  2183&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  80&lt;br /&gt;cumulative_uniquePageviews:  2187&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  81&lt;br /&gt;cumulative_uniquePageviews:  2198&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  82&lt;br /&gt;cumulative_uniquePageviews:  2207&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  83&lt;br /&gt;cumulative_uniquePageviews:  2213&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  84&lt;br /&gt;cumulative_uniquePageviews:  2223&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  85&lt;br /&gt;cumulative_uniquePageviews:  2229&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  86&lt;br /&gt;cumulative_uniquePageviews:  2242&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  87&lt;br /&gt;cumulative_uniquePageviews:  2250&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  88&lt;br /&gt;cumulative_uniquePageviews:  2260&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  89&lt;br /&gt;cumulative_uniquePageviews:  2266&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  90&lt;br /&gt;cumulative_uniquePageviews:  2276&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  91&lt;br /&gt;cumulative_uniquePageviews:  2285&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  92&lt;br /&gt;cumulative_uniquePageviews:  2296&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  93&lt;br /&gt;cumulative_uniquePageviews:  2302&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  94&lt;br /&gt;cumulative_uniquePageviews:  2324&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  95&lt;br /&gt;cumulative_uniquePageviews:  2339&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  96&lt;br /&gt;cumulative_uniquePageviews:  2350&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  97&lt;br /&gt;cumulative_uniquePageviews:  2367&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  98&lt;br /&gt;cumulative_uniquePageviews:  2394&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live:  99&lt;br /&gt;cumulative_uniquePageviews:  2409&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 100&lt;br /&gt;cumulative_uniquePageviews:  2425&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 101&lt;br /&gt;cumulative_uniquePageviews:  2435&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 102&lt;br /&gt;cumulative_uniquePageviews:  2450&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 103&lt;br /&gt;cumulative_uniquePageviews:  2482&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 104&lt;br /&gt;cumulative_uniquePageviews:  2505&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 105&lt;br /&gt;cumulative_uniquePageviews:  2522&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 106&lt;br /&gt;cumulative_uniquePageviews:  2536&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 107&lt;br /&gt;cumulative_uniquePageviews:  2542&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 108&lt;br /&gt;cumulative_uniquePageviews:  2559&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 109&lt;br /&gt;cumulative_uniquePageviews:  2576&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 110&lt;br /&gt;cumulative_uniquePageviews:  2600&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 111&lt;br /&gt;cumulative_uniquePageviews:  2632&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 112&lt;br /&gt;cumulative_uniquePageviews:  2656&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 113&lt;br /&gt;cumulative_uniquePageviews:  2724&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 114&lt;br /&gt;cumulative_uniquePageviews:  2758&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 115&lt;br /&gt;cumulative_uniquePageviews:  2800&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 116&lt;br /&gt;cumulative_uniquePageviews:  2844&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 117&lt;br /&gt;cumulative_uniquePageviews:  2890&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 118&lt;br /&gt;cumulative_uniquePageviews:  2933&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 119&lt;br /&gt;cumulative_uniquePageviews:  2979&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 120&lt;br /&gt;cumulative_uniquePageviews:  3008&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 121&lt;br /&gt;cumulative_uniquePageviews:  3030&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 122&lt;br /&gt;cumulative_uniquePageviews:  3043&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 123&lt;br /&gt;cumulative_uniquePageviews:  3066&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 124&lt;br /&gt;cumulative_uniquePageviews:  3092&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 125&lt;br /&gt;cumulative_uniquePageviews:  3113&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 126&lt;br /&gt;cumulative_uniquePageviews:  3144&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 127&lt;br /&gt;cumulative_uniquePageviews:  3167&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 128&lt;br /&gt;cumulative_uniquePageviews:  3193&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 129&lt;br /&gt;cumulative_uniquePageviews:  3219&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 130&lt;br /&gt;cumulative_uniquePageviews:  3242&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 131&lt;br /&gt;cumulative_uniquePageviews:  3272&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 132&lt;br /&gt;cumulative_uniquePageviews:  3295&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 133&lt;br /&gt;cumulative_uniquePageviews:  3332&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 134&lt;br /&gt;cumulative_uniquePageviews:  3380&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 135&lt;br /&gt;cumulative_uniquePageviews:  3413&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 136&lt;br /&gt;cumulative_uniquePageviews:  3444&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 137&lt;br /&gt;cumulative_uniquePageviews:  3480&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 138&lt;br /&gt;cumulative_uniquePageviews:  3521&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 139&lt;br /&gt;cumulative_uniquePageviews:  3551&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 140&lt;br /&gt;cumulative_uniquePageviews:  3594&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 141&lt;br /&gt;cumulative_uniquePageviews:  3631&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 142&lt;br /&gt;cumulative_uniquePageviews:  3660&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 143&lt;br /&gt;cumulative_uniquePageviews:  3698&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 144&lt;br /&gt;cumulative_uniquePageviews:  3749&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 145&lt;br /&gt;cumulative_uniquePageviews:  3793&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 146&lt;br /&gt;cumulative_uniquePageviews:  3878&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 147&lt;br /&gt;cumulative_uniquePageviews:  3977&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 148&lt;br /&gt;cumulative_uniquePageviews:  4088&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 149&lt;br /&gt;cumulative_uniquePageviews:  4166&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 150&lt;br /&gt;cumulative_uniquePageviews:  4204&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 151&lt;br /&gt;cumulative_uniquePageviews:  4270&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 152&lt;br /&gt;cumulative_uniquePageviews:  4312&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 153&lt;br /&gt;cumulative_uniquePageviews:  4352&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 154&lt;br /&gt;cumulative_uniquePageviews:  4387&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 155&lt;br /&gt;cumulative_uniquePageviews:  4417&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 156&lt;br /&gt;cumulative_uniquePageviews:  4442&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 157&lt;br /&gt;cumulative_uniquePageviews:  4464&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 158&lt;br /&gt;cumulative_uniquePageviews:  4505&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 159&lt;br /&gt;cumulative_uniquePageviews:  4535&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 160&lt;br /&gt;cumulative_uniquePageviews:  4578&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 161&lt;br /&gt;cumulative_uniquePageviews:  4631&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 162&lt;br /&gt;cumulative_uniquePageviews:  4675&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 163&lt;br /&gt;cumulative_uniquePageviews:  4702&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 164&lt;br /&gt;cumulative_uniquePageviews:  4727&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 165&lt;br /&gt;cumulative_uniquePageviews:  4764&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 166&lt;br /&gt;cumulative_uniquePageviews:  4810&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 167&lt;br /&gt;cumulative_uniquePageviews:  4846&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 168&lt;br /&gt;cumulative_uniquePageviews:  4870&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 169&lt;br /&gt;cumulative_uniquePageviews:  4920&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 170&lt;br /&gt;cumulative_uniquePageviews:  4955&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 171&lt;br /&gt;cumulative_uniquePageviews:  4998&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 172&lt;br /&gt;cumulative_uniquePageviews:  5080&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 173&lt;br /&gt;cumulative_uniquePageviews:  5148&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 174&lt;br /&gt;cumulative_uniquePageviews:  5216&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 175&lt;br /&gt;cumulative_uniquePageviews:  5313&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 176&lt;br /&gt;cumulative_uniquePageviews:  5420&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 177&lt;br /&gt;cumulative_uniquePageviews:  5486&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 178&lt;br /&gt;cumulative_uniquePageviews:  5553&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 179&lt;br /&gt;cumulative_uniquePageviews:  5635&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;,&#34;days_live: 180&lt;br /&gt;cumulative_uniquePageviews:  5710&lt;br /&gt;page: /blog/descriptive-statistics-in-r/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(0,192,148,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/descriptive-statistics-in-r/&#34;,&#34;legendgroup&#34;:&#34;/blog/descriptive-statistics-in-r/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127],&#34;y&#34;:[176,618,850,954,1044,1079,1194,1259,1301,1340,1378,1407,1434,1478,1500,1515,1556,1610,1646,1677,1712,1759,1803,1868,1921,1950,1987,2030,2092,2168,2236,2294,2322,2352,2478,2645,2767,2916,3046,3147,3216,3366,3505,3661,3819,3966,4060,4218,4429,4673,4954,5201,5473,5634,5793,6038,6333,6628,6937,7257,7435,7640,7951,8321,8690,9050,9350,9548,9766,10137,10540,10892,11282,11652,11902,12124,12482,12891,13244,13599,13915,14111,14329,14702,15023,15382,15756,16101,16389,16663,17080,17491,17933,18300,18629,18813,19065,19411,19755,20128,20504,20853,21136,21412,21787,22228,22641,22988,23286,23553,23853,24287,24680,25091,25498,25851,26145,26431,26841,27284,27706,28141,28506,28804,29084,29450,29818],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;cumulative_uniquePageviews:   176&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   2&lt;br /&gt;cumulative_uniquePageviews:   618&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   3&lt;br /&gt;cumulative_uniquePageviews:   850&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   4&lt;br /&gt;cumulative_uniquePageviews:   954&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   5&lt;br /&gt;cumulative_uniquePageviews:  1044&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   6&lt;br /&gt;cumulative_uniquePageviews:  1079&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   7&lt;br /&gt;cumulative_uniquePageviews:  1194&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   8&lt;br /&gt;cumulative_uniquePageviews:  1259&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:   9&lt;br /&gt;cumulative_uniquePageviews:  1301&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  10&lt;br /&gt;cumulative_uniquePageviews:  1340&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  11&lt;br /&gt;cumulative_uniquePageviews:  1378&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  12&lt;br /&gt;cumulative_uniquePageviews:  1407&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  13&lt;br /&gt;cumulative_uniquePageviews:  1434&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  14&lt;br /&gt;cumulative_uniquePageviews:  1478&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  15&lt;br /&gt;cumulative_uniquePageviews:  1500&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  16&lt;br /&gt;cumulative_uniquePageviews:  1515&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  17&lt;br /&gt;cumulative_uniquePageviews:  1556&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  18&lt;br /&gt;cumulative_uniquePageviews:  1610&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  19&lt;br /&gt;cumulative_uniquePageviews:  1646&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  20&lt;br /&gt;cumulative_uniquePageviews:  1677&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  21&lt;br /&gt;cumulative_uniquePageviews:  1712&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  22&lt;br /&gt;cumulative_uniquePageviews:  1759&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  23&lt;br /&gt;cumulative_uniquePageviews:  1803&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  24&lt;br /&gt;cumulative_uniquePageviews:  1868&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  25&lt;br /&gt;cumulative_uniquePageviews:  1921&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  26&lt;br /&gt;cumulative_uniquePageviews:  1950&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  27&lt;br /&gt;cumulative_uniquePageviews:  1987&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  28&lt;br /&gt;cumulative_uniquePageviews:  2030&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  29&lt;br /&gt;cumulative_uniquePageviews:  2092&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  30&lt;br /&gt;cumulative_uniquePageviews:  2168&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  31&lt;br /&gt;cumulative_uniquePageviews:  2236&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  32&lt;br /&gt;cumulative_uniquePageviews:  2294&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  33&lt;br /&gt;cumulative_uniquePageviews:  2322&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  34&lt;br /&gt;cumulative_uniquePageviews:  2352&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  35&lt;br /&gt;cumulative_uniquePageviews:  2478&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  36&lt;br /&gt;cumulative_uniquePageviews:  2645&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  37&lt;br /&gt;cumulative_uniquePageviews:  2767&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  38&lt;br /&gt;cumulative_uniquePageviews:  2916&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  39&lt;br /&gt;cumulative_uniquePageviews:  3046&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  40&lt;br /&gt;cumulative_uniquePageviews:  3147&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  41&lt;br /&gt;cumulative_uniquePageviews:  3216&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  42&lt;br /&gt;cumulative_uniquePageviews:  3366&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  43&lt;br /&gt;cumulative_uniquePageviews:  3505&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  44&lt;br /&gt;cumulative_uniquePageviews:  3661&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  45&lt;br /&gt;cumulative_uniquePageviews:  3819&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  46&lt;br /&gt;cumulative_uniquePageviews:  3966&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  47&lt;br /&gt;cumulative_uniquePageviews:  4060&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  48&lt;br /&gt;cumulative_uniquePageviews:  4218&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  49&lt;br /&gt;cumulative_uniquePageviews:  4429&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  50&lt;br /&gt;cumulative_uniquePageviews:  4673&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  51&lt;br /&gt;cumulative_uniquePageviews:  4954&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  52&lt;br /&gt;cumulative_uniquePageviews:  5201&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  53&lt;br /&gt;cumulative_uniquePageviews:  5473&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  54&lt;br /&gt;cumulative_uniquePageviews:  5634&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  55&lt;br /&gt;cumulative_uniquePageviews:  5793&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  56&lt;br /&gt;cumulative_uniquePageviews:  6038&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  57&lt;br /&gt;cumulative_uniquePageviews:  6333&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  58&lt;br /&gt;cumulative_uniquePageviews:  6628&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  59&lt;br /&gt;cumulative_uniquePageviews:  6937&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  60&lt;br /&gt;cumulative_uniquePageviews:  7257&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  61&lt;br /&gt;cumulative_uniquePageviews:  7435&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  62&lt;br /&gt;cumulative_uniquePageviews:  7640&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  63&lt;br /&gt;cumulative_uniquePageviews:  7951&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  64&lt;br /&gt;cumulative_uniquePageviews:  8321&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  65&lt;br /&gt;cumulative_uniquePageviews:  8690&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  66&lt;br /&gt;cumulative_uniquePageviews:  9050&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  67&lt;br /&gt;cumulative_uniquePageviews:  9350&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  68&lt;br /&gt;cumulative_uniquePageviews:  9548&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  69&lt;br /&gt;cumulative_uniquePageviews:  9766&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  70&lt;br /&gt;cumulative_uniquePageviews: 10137&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  71&lt;br /&gt;cumulative_uniquePageviews: 10540&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  72&lt;br /&gt;cumulative_uniquePageviews: 10892&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  73&lt;br /&gt;cumulative_uniquePageviews: 11282&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  74&lt;br /&gt;cumulative_uniquePageviews: 11652&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  75&lt;br /&gt;cumulative_uniquePageviews: 11902&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  76&lt;br /&gt;cumulative_uniquePageviews: 12124&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  77&lt;br /&gt;cumulative_uniquePageviews: 12482&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  78&lt;br /&gt;cumulative_uniquePageviews: 12891&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  79&lt;br /&gt;cumulative_uniquePageviews: 13244&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  80&lt;br /&gt;cumulative_uniquePageviews: 13599&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  81&lt;br /&gt;cumulative_uniquePageviews: 13915&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  82&lt;br /&gt;cumulative_uniquePageviews: 14111&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  83&lt;br /&gt;cumulative_uniquePageviews: 14329&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  84&lt;br /&gt;cumulative_uniquePageviews: 14702&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  85&lt;br /&gt;cumulative_uniquePageviews: 15023&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  86&lt;br /&gt;cumulative_uniquePageviews: 15382&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  87&lt;br /&gt;cumulative_uniquePageviews: 15756&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  88&lt;br /&gt;cumulative_uniquePageviews: 16101&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  89&lt;br /&gt;cumulative_uniquePageviews: 16389&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  90&lt;br /&gt;cumulative_uniquePageviews: 16663&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  91&lt;br /&gt;cumulative_uniquePageviews: 17080&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  92&lt;br /&gt;cumulative_uniquePageviews: 17491&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  93&lt;br /&gt;cumulative_uniquePageviews: 17933&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  94&lt;br /&gt;cumulative_uniquePageviews: 18300&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  95&lt;br /&gt;cumulative_uniquePageviews: 18629&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  96&lt;br /&gt;cumulative_uniquePageviews: 18813&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  97&lt;br /&gt;cumulative_uniquePageviews: 19065&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  98&lt;br /&gt;cumulative_uniquePageviews: 19411&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live:  99&lt;br /&gt;cumulative_uniquePageviews: 19755&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 100&lt;br /&gt;cumulative_uniquePageviews: 20128&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 101&lt;br /&gt;cumulative_uniquePageviews: 20504&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 102&lt;br /&gt;cumulative_uniquePageviews: 20853&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 103&lt;br /&gt;cumulative_uniquePageviews: 21136&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 104&lt;br /&gt;cumulative_uniquePageviews: 21412&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 105&lt;br /&gt;cumulative_uniquePageviews: 21787&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 106&lt;br /&gt;cumulative_uniquePageviews: 22228&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 107&lt;br /&gt;cumulative_uniquePageviews: 22641&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 108&lt;br /&gt;cumulative_uniquePageviews: 22988&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 109&lt;br /&gt;cumulative_uniquePageviews: 23286&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 110&lt;br /&gt;cumulative_uniquePageviews: 23553&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 111&lt;br /&gt;cumulative_uniquePageviews: 23853&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 112&lt;br /&gt;cumulative_uniquePageviews: 24287&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 113&lt;br /&gt;cumulative_uniquePageviews: 24680&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 114&lt;br /&gt;cumulative_uniquePageviews: 25091&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 115&lt;br /&gt;cumulative_uniquePageviews: 25498&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 116&lt;br /&gt;cumulative_uniquePageviews: 25851&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 117&lt;br /&gt;cumulative_uniquePageviews: 26145&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 118&lt;br /&gt;cumulative_uniquePageviews: 26431&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 119&lt;br /&gt;cumulative_uniquePageviews: 26841&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 120&lt;br /&gt;cumulative_uniquePageviews: 27284&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 121&lt;br /&gt;cumulative_uniquePageviews: 27706&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 122&lt;br /&gt;cumulative_uniquePageviews: 28141&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 123&lt;br /&gt;cumulative_uniquePageviews: 28506&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 124&lt;br /&gt;cumulative_uniquePageviews: 28804&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 125&lt;br /&gt;cumulative_uniquePageviews: 29084&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 126&lt;br /&gt;cumulative_uniquePageviews: 29450&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;,&#34;days_live: 127&lt;br /&gt;cumulative_uniquePageviews: 29818&lt;br /&gt;page: /blog/outliers-detection-in-r/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(0,182,235,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/outliers-detection-in-r/&#34;,&#34;legendgroup&#34;:&#34;/blog/outliers-detection-in-r/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[11,1344,1810,2160,2658,2991,3329,3702,4100,4463,5002,5531,6261,6976,7568,8003,8388,8744,9155,9514,9925,10281,10597,10890,11138,11455,11746,12239,12477,12752,12999,13255,13503,13721,13955,14189,14406,14591,14788,15039,15265,15457,15659,15837,16001,16190,16521,16943,17390,17776,18087,18342,18571,18839,19065,19336,19595,19813,19993,20201,20502,20741,20955,21143,21317,21448,21584,21707,21860,22002,22106,22221,22326,22427,22551,22678,22803,22906,23036,23132,23224,23328,23466,23575,23695,23789,23865,23927,24016,24102,24195,24288,24566,24781,24853,24972,25083,25188,25278,25365,25416,25485,25580,25641,25736,25801,25873,25930,25989,26065,26128,26175,26247,26322,26364,26406,26469,26603,26686,26770,26842,26899,26965,27041,27102,27188,27253,27322,27389,27447,27529,27593,27641,27713,27776,27811,27857,27903,27960,28004,28046,28079,28105,28140,28193,28228,28262,28294,28328,28357,28387,28445,28482,28526,28571,28612,28647,28690,28729,28779,28819,28858,28899,28938,28990,29054,29091,29141,29191,29232,29266,29292,29325,29382,29426,29474,29512,29554,29594,29629],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;cumulative_uniquePageviews:    11&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   2&lt;br /&gt;cumulative_uniquePageviews:  1344&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   3&lt;br /&gt;cumulative_uniquePageviews:  1810&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   4&lt;br /&gt;cumulative_uniquePageviews:  2160&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   5&lt;br /&gt;cumulative_uniquePageviews:  2658&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   6&lt;br /&gt;cumulative_uniquePageviews:  2991&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   7&lt;br /&gt;cumulative_uniquePageviews:  3329&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   8&lt;br /&gt;cumulative_uniquePageviews:  3702&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:   9&lt;br /&gt;cumulative_uniquePageviews:  4100&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  10&lt;br /&gt;cumulative_uniquePageviews:  4463&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  11&lt;br /&gt;cumulative_uniquePageviews:  5002&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  12&lt;br /&gt;cumulative_uniquePageviews:  5531&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  13&lt;br /&gt;cumulative_uniquePageviews:  6261&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  14&lt;br /&gt;cumulative_uniquePageviews:  6976&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  15&lt;br /&gt;cumulative_uniquePageviews:  7568&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  16&lt;br /&gt;cumulative_uniquePageviews:  8003&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  17&lt;br /&gt;cumulative_uniquePageviews:  8388&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  18&lt;br /&gt;cumulative_uniquePageviews:  8744&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  19&lt;br /&gt;cumulative_uniquePageviews:  9155&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  20&lt;br /&gt;cumulative_uniquePageviews:  9514&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  21&lt;br /&gt;cumulative_uniquePageviews:  9925&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  22&lt;br /&gt;cumulative_uniquePageviews: 10281&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  23&lt;br /&gt;cumulative_uniquePageviews: 10597&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  24&lt;br /&gt;cumulative_uniquePageviews: 10890&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  25&lt;br /&gt;cumulative_uniquePageviews: 11138&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  26&lt;br /&gt;cumulative_uniquePageviews: 11455&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  27&lt;br /&gt;cumulative_uniquePageviews: 11746&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  28&lt;br /&gt;cumulative_uniquePageviews: 12239&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  29&lt;br /&gt;cumulative_uniquePageviews: 12477&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  30&lt;br /&gt;cumulative_uniquePageviews: 12752&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  31&lt;br /&gt;cumulative_uniquePageviews: 12999&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  32&lt;br /&gt;cumulative_uniquePageviews: 13255&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  33&lt;br /&gt;cumulative_uniquePageviews: 13503&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  34&lt;br /&gt;cumulative_uniquePageviews: 13721&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  35&lt;br /&gt;cumulative_uniquePageviews: 13955&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  36&lt;br /&gt;cumulative_uniquePageviews: 14189&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  37&lt;br /&gt;cumulative_uniquePageviews: 14406&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  38&lt;br /&gt;cumulative_uniquePageviews: 14591&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  39&lt;br /&gt;cumulative_uniquePageviews: 14788&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  40&lt;br /&gt;cumulative_uniquePageviews: 15039&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  41&lt;br /&gt;cumulative_uniquePageviews: 15265&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  42&lt;br /&gt;cumulative_uniquePageviews: 15457&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  43&lt;br /&gt;cumulative_uniquePageviews: 15659&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  44&lt;br /&gt;cumulative_uniquePageviews: 15837&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  45&lt;br /&gt;cumulative_uniquePageviews: 16001&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  46&lt;br /&gt;cumulative_uniquePageviews: 16190&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  47&lt;br /&gt;cumulative_uniquePageviews: 16521&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  48&lt;br /&gt;cumulative_uniquePageviews: 16943&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  49&lt;br /&gt;cumulative_uniquePageviews: 17390&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  50&lt;br /&gt;cumulative_uniquePageviews: 17776&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  51&lt;br /&gt;cumulative_uniquePageviews: 18087&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  52&lt;br /&gt;cumulative_uniquePageviews: 18342&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  53&lt;br /&gt;cumulative_uniquePageviews: 18571&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  54&lt;br /&gt;cumulative_uniquePageviews: 18839&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  55&lt;br /&gt;cumulative_uniquePageviews: 19065&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  56&lt;br /&gt;cumulative_uniquePageviews: 19336&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  57&lt;br /&gt;cumulative_uniquePageviews: 19595&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  58&lt;br /&gt;cumulative_uniquePageviews: 19813&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  59&lt;br /&gt;cumulative_uniquePageviews: 19993&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  60&lt;br /&gt;cumulative_uniquePageviews: 20201&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  61&lt;br /&gt;cumulative_uniquePageviews: 20502&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  62&lt;br /&gt;cumulative_uniquePageviews: 20741&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  63&lt;br /&gt;cumulative_uniquePageviews: 20955&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  64&lt;br /&gt;cumulative_uniquePageviews: 21143&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  65&lt;br /&gt;cumulative_uniquePageviews: 21317&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  66&lt;br /&gt;cumulative_uniquePageviews: 21448&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  67&lt;br /&gt;cumulative_uniquePageviews: 21584&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  68&lt;br /&gt;cumulative_uniquePageviews: 21707&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  69&lt;br /&gt;cumulative_uniquePageviews: 21860&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  70&lt;br /&gt;cumulative_uniquePageviews: 22002&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  71&lt;br /&gt;cumulative_uniquePageviews: 22106&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  72&lt;br /&gt;cumulative_uniquePageviews: 22221&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  73&lt;br /&gt;cumulative_uniquePageviews: 22326&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  74&lt;br /&gt;cumulative_uniquePageviews: 22427&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  75&lt;br /&gt;cumulative_uniquePageviews: 22551&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  76&lt;br /&gt;cumulative_uniquePageviews: 22678&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  77&lt;br /&gt;cumulative_uniquePageviews: 22803&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  78&lt;br /&gt;cumulative_uniquePageviews: 22906&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  79&lt;br /&gt;cumulative_uniquePageviews: 23036&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  80&lt;br /&gt;cumulative_uniquePageviews: 23132&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  81&lt;br /&gt;cumulative_uniquePageviews: 23224&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  82&lt;br /&gt;cumulative_uniquePageviews: 23328&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  83&lt;br /&gt;cumulative_uniquePageviews: 23466&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  84&lt;br /&gt;cumulative_uniquePageviews: 23575&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  85&lt;br /&gt;cumulative_uniquePageviews: 23695&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  86&lt;br /&gt;cumulative_uniquePageviews: 23789&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  87&lt;br /&gt;cumulative_uniquePageviews: 23865&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  88&lt;br /&gt;cumulative_uniquePageviews: 23927&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  89&lt;br /&gt;cumulative_uniquePageviews: 24016&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  90&lt;br /&gt;cumulative_uniquePageviews: 24102&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  91&lt;br /&gt;cumulative_uniquePageviews: 24195&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  92&lt;br /&gt;cumulative_uniquePageviews: 24288&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  93&lt;br /&gt;cumulative_uniquePageviews: 24566&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  94&lt;br /&gt;cumulative_uniquePageviews: 24781&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  95&lt;br /&gt;cumulative_uniquePageviews: 24853&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  96&lt;br /&gt;cumulative_uniquePageviews: 24972&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  97&lt;br /&gt;cumulative_uniquePageviews: 25083&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  98&lt;br /&gt;cumulative_uniquePageviews: 25188&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live:  99&lt;br /&gt;cumulative_uniquePageviews: 25278&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 100&lt;br /&gt;cumulative_uniquePageviews: 25365&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 101&lt;br /&gt;cumulative_uniquePageviews: 25416&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 102&lt;br /&gt;cumulative_uniquePageviews: 25485&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 103&lt;br /&gt;cumulative_uniquePageviews: 25580&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 104&lt;br /&gt;cumulative_uniquePageviews: 25641&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 105&lt;br /&gt;cumulative_uniquePageviews: 25736&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 106&lt;br /&gt;cumulative_uniquePageviews: 25801&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 107&lt;br /&gt;cumulative_uniquePageviews: 25873&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 108&lt;br /&gt;cumulative_uniquePageviews: 25930&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 109&lt;br /&gt;cumulative_uniquePageviews: 25989&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 110&lt;br /&gt;cumulative_uniquePageviews: 26065&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 111&lt;br /&gt;cumulative_uniquePageviews: 26128&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 112&lt;br /&gt;cumulative_uniquePageviews: 26175&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 113&lt;br /&gt;cumulative_uniquePageviews: 26247&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 114&lt;br /&gt;cumulative_uniquePageviews: 26322&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 115&lt;br /&gt;cumulative_uniquePageviews: 26364&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 116&lt;br /&gt;cumulative_uniquePageviews: 26406&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 117&lt;br /&gt;cumulative_uniquePageviews: 26469&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 118&lt;br /&gt;cumulative_uniquePageviews: 26603&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 119&lt;br /&gt;cumulative_uniquePageviews: 26686&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 120&lt;br /&gt;cumulative_uniquePageviews: 26770&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 121&lt;br /&gt;cumulative_uniquePageviews: 26842&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 122&lt;br /&gt;cumulative_uniquePageviews: 26899&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 123&lt;br /&gt;cumulative_uniquePageviews: 26965&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 124&lt;br /&gt;cumulative_uniquePageviews: 27041&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 125&lt;br /&gt;cumulative_uniquePageviews: 27102&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 126&lt;br /&gt;cumulative_uniquePageviews: 27188&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 127&lt;br /&gt;cumulative_uniquePageviews: 27253&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 128&lt;br /&gt;cumulative_uniquePageviews: 27322&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 129&lt;br /&gt;cumulative_uniquePageviews: 27389&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 130&lt;br /&gt;cumulative_uniquePageviews: 27447&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 131&lt;br /&gt;cumulative_uniquePageviews: 27529&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 132&lt;br /&gt;cumulative_uniquePageviews: 27593&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 133&lt;br /&gt;cumulative_uniquePageviews: 27641&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 134&lt;br /&gt;cumulative_uniquePageviews: 27713&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 135&lt;br /&gt;cumulative_uniquePageviews: 27776&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 136&lt;br /&gt;cumulative_uniquePageviews: 27811&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 137&lt;br /&gt;cumulative_uniquePageviews: 27857&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 138&lt;br /&gt;cumulative_uniquePageviews: 27903&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 139&lt;br /&gt;cumulative_uniquePageviews: 27960&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 140&lt;br /&gt;cumulative_uniquePageviews: 28004&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 141&lt;br /&gt;cumulative_uniquePageviews: 28046&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 142&lt;br /&gt;cumulative_uniquePageviews: 28079&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 143&lt;br /&gt;cumulative_uniquePageviews: 28105&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 144&lt;br /&gt;cumulative_uniquePageviews: 28140&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 145&lt;br /&gt;cumulative_uniquePageviews: 28193&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 146&lt;br /&gt;cumulative_uniquePageviews: 28228&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 147&lt;br /&gt;cumulative_uniquePageviews: 28262&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 148&lt;br /&gt;cumulative_uniquePageviews: 28294&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 149&lt;br /&gt;cumulative_uniquePageviews: 28328&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 150&lt;br /&gt;cumulative_uniquePageviews: 28357&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 151&lt;br /&gt;cumulative_uniquePageviews: 28387&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 152&lt;br /&gt;cumulative_uniquePageviews: 28445&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 153&lt;br /&gt;cumulative_uniquePageviews: 28482&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 154&lt;br /&gt;cumulative_uniquePageviews: 28526&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 155&lt;br /&gt;cumulative_uniquePageviews: 28571&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 156&lt;br /&gt;cumulative_uniquePageviews: 28612&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 157&lt;br /&gt;cumulative_uniquePageviews: 28647&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 158&lt;br /&gt;cumulative_uniquePageviews: 28690&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 159&lt;br /&gt;cumulative_uniquePageviews: 28729&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 160&lt;br /&gt;cumulative_uniquePageviews: 28779&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 161&lt;br /&gt;cumulative_uniquePageviews: 28819&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 162&lt;br /&gt;cumulative_uniquePageviews: 28858&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 163&lt;br /&gt;cumulative_uniquePageviews: 28899&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 164&lt;br /&gt;cumulative_uniquePageviews: 28938&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 165&lt;br /&gt;cumulative_uniquePageviews: 28990&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 166&lt;br /&gt;cumulative_uniquePageviews: 29054&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 167&lt;br /&gt;cumulative_uniquePageviews: 29091&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 168&lt;br /&gt;cumulative_uniquePageviews: 29141&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 169&lt;br /&gt;cumulative_uniquePageviews: 29191&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 170&lt;br /&gt;cumulative_uniquePageviews: 29232&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 171&lt;br /&gt;cumulative_uniquePageviews: 29266&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 172&lt;br /&gt;cumulative_uniquePageviews: 29292&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 173&lt;br /&gt;cumulative_uniquePageviews: 29325&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 174&lt;br /&gt;cumulative_uniquePageviews: 29382&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 175&lt;br /&gt;cumulative_uniquePageviews: 29426&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 176&lt;br /&gt;cumulative_uniquePageviews: 29474&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 177&lt;br /&gt;cumulative_uniquePageviews: 29512&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 178&lt;br /&gt;cumulative_uniquePageviews: 29554&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 179&lt;br /&gt;cumulative_uniquePageviews: 29594&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;days_live: 180&lt;br /&gt;cumulative_uniquePageviews: 29629&lt;br /&gt;page: /blog/top-r-resources-on-covid-19-coronavirus/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(165,138,255,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;legendgroup&#34;:&#34;/blog/top-r-resources-on-covid-19-coronavirus/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180],&#34;y&#34;:[6,10,10,11,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,14,31,33,34,37,39,42,44,45,53,58,60,61,63,67,69,69,72,76,81,84,85,85,92,93,94,95,97,106,106,107,109,115,119,122,128,132,138,143,145,145,147,149,151,155,155,156,157,159,159,160,161,162,162,165,168,171,173,173,176,178,180,184,187,189,191,209,210,214,214,216,219,222,223,228,229,235,238,239,240,244,248,250,254,261,264,265,267,267,267,271,271,272,275,276,277,279,280,280,285,289,292,296,300,308,314,316,318,319,321,333,342,357,364,380,393,410,426,434,443,450,460,468,479,491,499,507,514,528,538,548,564,596,615,634,659,676,707,748,761,784,819,841,866,896,915,950,978,1011,1048,1082,1146,1211,1255,1284,1323,1349,1372,1399,1442,1461],&#34;text&#34;:[&#34;days_live:   1&lt;br /&gt;cumulative_uniquePageviews:     6&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   2&lt;br /&gt;cumulative_uniquePageviews:    10&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   3&lt;br /&gt;cumulative_uniquePageviews:    10&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   4&lt;br /&gt;cumulative_uniquePageviews:    11&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   5&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   6&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   7&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   8&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:   9&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  10&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  11&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  12&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  13&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  14&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  15&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  16&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  17&lt;br /&gt;cumulative_uniquePageviews:    12&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  18&lt;br /&gt;cumulative_uniquePageviews:    13&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  19&lt;br /&gt;cumulative_uniquePageviews:    13&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  20&lt;br /&gt;cumulative_uniquePageviews:    14&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  21&lt;br /&gt;cumulative_uniquePageviews:    31&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  22&lt;br /&gt;cumulative_uniquePageviews:    33&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  23&lt;br /&gt;cumulative_uniquePageviews:    34&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  24&lt;br /&gt;cumulative_uniquePageviews:    37&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  25&lt;br /&gt;cumulative_uniquePageviews:    39&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  26&lt;br /&gt;cumulative_uniquePageviews:    42&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  27&lt;br /&gt;cumulative_uniquePageviews:    44&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  28&lt;br /&gt;cumulative_uniquePageviews:    45&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  29&lt;br /&gt;cumulative_uniquePageviews:    53&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  30&lt;br /&gt;cumulative_uniquePageviews:    58&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  31&lt;br /&gt;cumulative_uniquePageviews:    60&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  32&lt;br /&gt;cumulative_uniquePageviews:    61&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  33&lt;br /&gt;cumulative_uniquePageviews:    63&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  34&lt;br /&gt;cumulative_uniquePageviews:    67&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  35&lt;br /&gt;cumulative_uniquePageviews:    69&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  36&lt;br /&gt;cumulative_uniquePageviews:    69&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  37&lt;br /&gt;cumulative_uniquePageviews:    72&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  38&lt;br /&gt;cumulative_uniquePageviews:    76&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  39&lt;br /&gt;cumulative_uniquePageviews:    81&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  40&lt;br /&gt;cumulative_uniquePageviews:    84&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  41&lt;br /&gt;cumulative_uniquePageviews:    85&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  42&lt;br /&gt;cumulative_uniquePageviews:    85&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  43&lt;br /&gt;cumulative_uniquePageviews:    92&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  44&lt;br /&gt;cumulative_uniquePageviews:    93&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  45&lt;br /&gt;cumulative_uniquePageviews:    94&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  46&lt;br /&gt;cumulative_uniquePageviews:    95&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  47&lt;br /&gt;cumulative_uniquePageviews:    97&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  48&lt;br /&gt;cumulative_uniquePageviews:   106&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  49&lt;br /&gt;cumulative_uniquePageviews:   106&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  50&lt;br /&gt;cumulative_uniquePageviews:   107&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  51&lt;br /&gt;cumulative_uniquePageviews:   109&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  52&lt;br /&gt;cumulative_uniquePageviews:   115&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  53&lt;br /&gt;cumulative_uniquePageviews:   119&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  54&lt;br /&gt;cumulative_uniquePageviews:   122&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  55&lt;br /&gt;cumulative_uniquePageviews:   128&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  56&lt;br /&gt;cumulative_uniquePageviews:   132&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  57&lt;br /&gt;cumulative_uniquePageviews:   138&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  58&lt;br /&gt;cumulative_uniquePageviews:   143&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  59&lt;br /&gt;cumulative_uniquePageviews:   145&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  60&lt;br /&gt;cumulative_uniquePageviews:   145&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  61&lt;br /&gt;cumulative_uniquePageviews:   147&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  62&lt;br /&gt;cumulative_uniquePageviews:   149&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  63&lt;br /&gt;cumulative_uniquePageviews:   151&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  64&lt;br /&gt;cumulative_uniquePageviews:   155&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  65&lt;br /&gt;cumulative_uniquePageviews:   155&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  66&lt;br /&gt;cumulative_uniquePageviews:   156&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  67&lt;br /&gt;cumulative_uniquePageviews:   157&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  68&lt;br /&gt;cumulative_uniquePageviews:   159&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  69&lt;br /&gt;cumulative_uniquePageviews:   159&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  70&lt;br /&gt;cumulative_uniquePageviews:   160&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  71&lt;br /&gt;cumulative_uniquePageviews:   161&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  72&lt;br /&gt;cumulative_uniquePageviews:   162&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  73&lt;br /&gt;cumulative_uniquePageviews:   162&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  74&lt;br /&gt;cumulative_uniquePageviews:   165&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  75&lt;br /&gt;cumulative_uniquePageviews:   168&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  76&lt;br /&gt;cumulative_uniquePageviews:   171&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  77&lt;br /&gt;cumulative_uniquePageviews:   173&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  78&lt;br /&gt;cumulative_uniquePageviews:   173&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  79&lt;br /&gt;cumulative_uniquePageviews:   176&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  80&lt;br /&gt;cumulative_uniquePageviews:   178&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  81&lt;br /&gt;cumulative_uniquePageviews:   180&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  82&lt;br /&gt;cumulative_uniquePageviews:   184&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  83&lt;br /&gt;cumulative_uniquePageviews:   187&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  84&lt;br /&gt;cumulative_uniquePageviews:   189&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  85&lt;br /&gt;cumulative_uniquePageviews:   191&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  86&lt;br /&gt;cumulative_uniquePageviews:   209&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  87&lt;br /&gt;cumulative_uniquePageviews:   210&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  88&lt;br /&gt;cumulative_uniquePageviews:   214&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  89&lt;br /&gt;cumulative_uniquePageviews:   214&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  90&lt;br /&gt;cumulative_uniquePageviews:   216&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  91&lt;br /&gt;cumulative_uniquePageviews:   219&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  92&lt;br /&gt;cumulative_uniquePageviews:   222&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  93&lt;br /&gt;cumulative_uniquePageviews:   223&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  94&lt;br /&gt;cumulative_uniquePageviews:   228&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  95&lt;br /&gt;cumulative_uniquePageviews:   229&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  96&lt;br /&gt;cumulative_uniquePageviews:   235&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  97&lt;br /&gt;cumulative_uniquePageviews:   238&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  98&lt;br /&gt;cumulative_uniquePageviews:   239&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live:  99&lt;br /&gt;cumulative_uniquePageviews:   240&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 100&lt;br /&gt;cumulative_uniquePageviews:   244&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 101&lt;br /&gt;cumulative_uniquePageviews:   248&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 102&lt;br /&gt;cumulative_uniquePageviews:   250&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 103&lt;br /&gt;cumulative_uniquePageviews:   254&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 104&lt;br /&gt;cumulative_uniquePageviews:   261&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 105&lt;br /&gt;cumulative_uniquePageviews:   264&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 106&lt;br /&gt;cumulative_uniquePageviews:   265&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 107&lt;br /&gt;cumulative_uniquePageviews:   267&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 108&lt;br /&gt;cumulative_uniquePageviews:   267&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 109&lt;br /&gt;cumulative_uniquePageviews:   267&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 110&lt;br /&gt;cumulative_uniquePageviews:   271&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 111&lt;br /&gt;cumulative_uniquePageviews:   271&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 112&lt;br /&gt;cumulative_uniquePageviews:   272&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 113&lt;br /&gt;cumulative_uniquePageviews:   275&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 114&lt;br /&gt;cumulative_uniquePageviews:   276&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 115&lt;br /&gt;cumulative_uniquePageviews:   277&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 116&lt;br /&gt;cumulative_uniquePageviews:   279&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 117&lt;br /&gt;cumulative_uniquePageviews:   280&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 118&lt;br /&gt;cumulative_uniquePageviews:   280&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 119&lt;br /&gt;cumulative_uniquePageviews:   285&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 120&lt;br /&gt;cumulative_uniquePageviews:   289&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 121&lt;br /&gt;cumulative_uniquePageviews:   292&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 122&lt;br /&gt;cumulative_uniquePageviews:   296&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 123&lt;br /&gt;cumulative_uniquePageviews:   300&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 124&lt;br /&gt;cumulative_uniquePageviews:   308&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 125&lt;br /&gt;cumulative_uniquePageviews:   314&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 126&lt;br /&gt;cumulative_uniquePageviews:   316&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 127&lt;br /&gt;cumulative_uniquePageviews:   318&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 128&lt;br /&gt;cumulative_uniquePageviews:   319&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 129&lt;br /&gt;cumulative_uniquePageviews:   321&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 130&lt;br /&gt;cumulative_uniquePageviews:   333&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 131&lt;br /&gt;cumulative_uniquePageviews:   342&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 132&lt;br /&gt;cumulative_uniquePageviews:   357&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 133&lt;br /&gt;cumulative_uniquePageviews:   364&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 134&lt;br /&gt;cumulative_uniquePageviews:   380&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 135&lt;br /&gt;cumulative_uniquePageviews:   393&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 136&lt;br /&gt;cumulative_uniquePageviews:   410&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 137&lt;br /&gt;cumulative_uniquePageviews:   426&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 138&lt;br /&gt;cumulative_uniquePageviews:   434&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 139&lt;br /&gt;cumulative_uniquePageviews:   443&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 140&lt;br /&gt;cumulative_uniquePageviews:   450&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 141&lt;br /&gt;cumulative_uniquePageviews:   460&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 142&lt;br /&gt;cumulative_uniquePageviews:   468&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 143&lt;br /&gt;cumulative_uniquePageviews:   479&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 144&lt;br /&gt;cumulative_uniquePageviews:   491&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 145&lt;br /&gt;cumulative_uniquePageviews:   499&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 146&lt;br /&gt;cumulative_uniquePageviews:   507&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 147&lt;br /&gt;cumulative_uniquePageviews:   514&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 148&lt;br /&gt;cumulative_uniquePageviews:   528&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 149&lt;br /&gt;cumulative_uniquePageviews:   538&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 150&lt;br /&gt;cumulative_uniquePageviews:   548&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 151&lt;br /&gt;cumulative_uniquePageviews:   564&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 152&lt;br /&gt;cumulative_uniquePageviews:   596&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 153&lt;br /&gt;cumulative_uniquePageviews:   615&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 154&lt;br /&gt;cumulative_uniquePageviews:   634&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 155&lt;br /&gt;cumulative_uniquePageviews:   659&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 156&lt;br /&gt;cumulative_uniquePageviews:   676&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 157&lt;br /&gt;cumulative_uniquePageviews:   707&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 158&lt;br /&gt;cumulative_uniquePageviews:   748&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 159&lt;br /&gt;cumulative_uniquePageviews:   761&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 160&lt;br /&gt;cumulative_uniquePageviews:   784&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 161&lt;br /&gt;cumulative_uniquePageviews:   819&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 162&lt;br /&gt;cumulative_uniquePageviews:   841&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 163&lt;br /&gt;cumulative_uniquePageviews:   866&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 164&lt;br /&gt;cumulative_uniquePageviews:   896&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 165&lt;br /&gt;cumulative_uniquePageviews:   915&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 166&lt;br /&gt;cumulative_uniquePageviews:   950&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 167&lt;br /&gt;cumulative_uniquePageviews:   978&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 168&lt;br /&gt;cumulative_uniquePageviews:  1011&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 169&lt;br /&gt;cumulative_uniquePageviews:  1048&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 170&lt;br /&gt;cumulative_uniquePageviews:  1082&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 171&lt;br /&gt;cumulative_uniquePageviews:  1146&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 172&lt;br /&gt;cumulative_uniquePageviews:  1211&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 173&lt;br /&gt;cumulative_uniquePageviews:  1255&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 174&lt;br /&gt;cumulative_uniquePageviews:  1284&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 175&lt;br /&gt;cumulative_uniquePageviews:  1323&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 176&lt;br /&gt;cumulative_uniquePageviews:  1349&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 177&lt;br /&gt;cumulative_uniquePageviews:  1372&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 178&lt;br /&gt;cumulative_uniquePageviews:  1399&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 179&lt;br /&gt;cumulative_uniquePageviews:  1442&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;,&#34;days_live: 180&lt;br /&gt;cumulative_uniquePageviews:  1461&lt;br /&gt;page: /blog/variable-types-and-examples/&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;lines&#34;,&#34;line&#34;:{&#34;width&#34;:1.88976377952756,&#34;color&#34;:&#34;rgba(251,97,215,1)&#34;,&#34;dash&#34;:&#34;solid&#34;},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;/blog/variable-types-and-examples/&#34;,&#34;legendgroup&#34;:&#34;/blog/variable-types-and-examples/&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null}],&#34;layout&#34;:{&#34;margin&#34;:{&#34;t&#34;:43.7625570776256,&#34;r&#34;:7.30593607305936,&#34;b&#34;:40.1826484018265,&#34;l&#34;:60.6392694063927},&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.6118721461187},&#34;title&#34;:{&#34;text&#34;:&#34;Cumulative page views by day since publication&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:17.5342465753425},&#34;x&#34;:0,&#34;xref&#34;:&#34;paper&#34;},&#34;xaxis&#34;:{&#34;domain&#34;:[0,1],&#34;automargin&#34;:true,&#34;type&#34;:&#34;linear&#34;,&#34;autorange&#34;:true,&#34;range&#34;:[-7.95,188.95],&#34;tickmode&#34;:&#34;auto&#34;,&#34;ticktext&#34;:[&#34;0&#34;,&#34;50&#34;,&#34;100&#34;,&#34;150&#34;],&#34;tickvals&#34;:[0,50,100,150],&#34;categoryorder&#34;:&#34;array&#34;,&#34;categoryarray&#34;:[&#34;0&#34;,&#34;50&#34;,&#34;100&#34;,&#34;150&#34;],&#34;nticks&#34;:null,&#34;ticks&#34;:&#34;&#34;,&#34;tickcolor&#34;:null,&#34;ticklen&#34;:3.65296803652968,&#34;tickwidth&#34;:0,&#34;showticklabels&#34;:true,&#34;tickfont&#34;:{&#34;color&#34;:&#34;rgba(77,77,77,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.689497716895},&#34;tickangle&#34;:-0,&#34;showline&#34;:false,&#34;linecolor&#34;:null,&#34;linewidth&#34;:0,&#34;showgrid&#34;:true,&#34;gridcolor&#34;:&#34;rgba(235,235,235,1)&#34;,&#34;gridwidth&#34;:0.66417600664176,&#34;zeroline&#34;:false,&#34;anchor&#34;:&#34;y&#34;,&#34;title&#34;:{&#34;text&#34;:&#34;Days since publication&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.6118721461187}},&#34;hoverformat&#34;:&#34;.2f&#34;},&#34;yaxis&#34;:{&#34;domain&#34;:[0,1],&#34;automargin&#34;:true,&#34;type&#34;:&#34;linear&#34;,&#34;autorange&#34;:true,&#34;range&#34;:[-2934.65,61693.65],&#34;tickmode&#34;:&#34;auto&#34;,&#34;ticktext&#34;:[&#34;0&#34;,&#34;20,000&#34;,&#34;40,000&#34;,&#34;60,000&#34;],&#34;tickvals&#34;:[0,20000,40000,60000],&#34;categoryorder&#34;:&#34;array&#34;,&#34;categoryarray&#34;:[&#34;0&#34;,&#34;20,000&#34;,&#34;40,000&#34;,&#34;60,000&#34;],&#34;nticks&#34;:null,&#34;ticks&#34;:&#34;&#34;,&#34;tickcolor&#34;:null,&#34;ticklen&#34;:3.65296803652968,&#34;tickwidth&#34;:0,&#34;showticklabels&#34;:true,&#34;tickfont&#34;:{&#34;color&#34;:&#34;rgba(77,77,77,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.689497716895},&#34;tickangle&#34;:-0,&#34;showline&#34;:false,&#34;linecolor&#34;:null,&#34;linewidth&#34;:0,&#34;showgrid&#34;:true,&#34;gridcolor&#34;:&#34;rgba(235,235,235,1)&#34;,&#34;gridwidth&#34;:0.66417600664176,&#34;zeroline&#34;:false,&#34;anchor&#34;:&#34;x&#34;,&#34;title&#34;:{&#34;text&#34;:&#34;Cumulative page views&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.6118721461187}},&#34;hoverformat&#34;:&#34;.2f&#34;},&#34;shapes&#34;:[{&#34;type&#34;:&#34;rect&#34;,&#34;fillcolor&#34;:null,&#34;line&#34;:{&#34;color&#34;:null,&#34;width&#34;:0,&#34;linetype&#34;:[]},&#34;yref&#34;:&#34;paper&#34;,&#34;xref&#34;:&#34;paper&#34;,&#34;x0&#34;:0,&#34;x1&#34;:1,&#34;y0&#34;:0,&#34;y1&#34;:1}],&#34;showlegend&#34;:false,&#34;legend&#34;:{&#34;bgcolor&#34;:null,&#34;bordercolor&#34;:null,&#34;borderwidth&#34;:0,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.689497716895}},&#34;hovermode&#34;:&#34;closest&#34;,&#34;barmode&#34;:&#34;relative&#34;},&#34;config&#34;:{&#34;doubleClick&#34;:&#34;reset&#34;,&#34;modeBarButtonsToAdd&#34;:[&#34;hoverclosest&#34;,&#34;hovercompare&#34;],&#34;showSendToCloud&#34;:false},&#34;source&#34;:&#34;A&#34;,&#34;attrs&#34;:{&#34;7bd25534b44f&#34;:{&#34;x&#34;:{},&#34;y&#34;:{},&#34;colour&#34;:{},&#34;type&#34;:&#34;scatter&#34;}},&#34;cur_data&#34;:&#34;7bd25534b44f&#34;,&#34;visdat&#34;:{&#34;7bd25534b44f&#34;:[&#34;function (y) &#34;,&#34;x&#34;]},&#34;highlight&#34;:{&#34;on&#34;:&#34;plotly_click&#34;,&#34;persistent&#34;:false,&#34;dynamic&#34;:false,&#34;selectize&#34;:false,&#34;opacityDim&#34;:0.2,&#34;selected&#34;:{&#34;opacity&#34;:1},&#34;debounce&#34;:0},&#34;shinyEvents&#34;:[&#34;plotly_hover&#34;,&#34;plotly_click&#34;,&#34;plotly_selected&#34;,&#34;plotly_relayout&#34;,&#34;plotly_brushed&#34;,&#34;plotly_brushing&#34;,&#34;plotly_clickannotation&#34;,&#34;plotly_doubleclick&#34;,&#34;plotly_deselect&#34;,&#34;plotly_afterplot&#34;,&#34;plotly_sunburstclick&#34;],&#34;base_url&#34;:&#34;https://plot.ly&#34;},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;Compared to the previous plot, this one shows the &lt;em&gt;cumulative&lt;/em&gt; number of page views since the date of publication of the post.&lt;/p&gt;
&lt;p&gt;Without taking into consideration the post that went viral and which, by the way, does not really generate much traffic anymore (which makes sense since the incredible campaign from Springer to offer their books for free during the COVID-19 quarantine has ended), we see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The post on &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers detection&lt;/a&gt; has surpassed the post on &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;top R resources on Coronavirus&lt;/a&gt; in terms of cumulative number of page views after around 120 days (&lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 4 months) after publication, which indicates that people are looking at this specific problem. I remember that I wrote this post because, at that time, I had to deal with the problems of outliers in R and I did not found a neat solution online. So I guess, the fact that resources on a specific topic are missing helps to attract visitors looking for an answer to their question.&lt;/li&gt;
&lt;li&gt;Among the remaining posts, the ranking of the most performing ones in terms of cumulative number of page views within 180 days (&lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 6 months) after publication is the following:
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;Correlation coefficient and correlation test in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/&#34;&gt;Clustering analysis by hand and in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;Descriptive statistics in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;Variable types and examples&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The analyses so far give you already a good understanding of the performance of your blog. However, for the interested readers, we show other important metrics in the following sections.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;page-views-by-country&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Page views by country&lt;/h2&gt;
&lt;p&gt;In the following we are interested in seeing &lt;strong&gt;where the traffic comes from&lt;/strong&gt;. This is particularly interesting to get to know your audience, and even more important if you are running a business or an ecommerce.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get GA data
data_fetch &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = &amp;quot;pageviews&amp;quot;,
  dimensions = &amp;quot;country&amp;quot;,
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# table
countries &amp;lt;- data_fetch %&amp;gt;%
  mutate(Country = str_trunc(country, width = 40)) %&amp;gt;% # keep maximum 40 characters
  count(Country, wt = pageviews, sort = TRUE)
head(countries, n = 10) # edit n for more or less countries to display&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##           Country      n
## 1   United States 131306
## 2           India  38800
## 3         Belgium  32983
## 4  United Kingdom  25833
## 5          Brazil  18961
## 6         Germany  17851
## 7           Spain  17355
## 8          Canada  13880
## 9          Mexico  12882
## 10    Philippines  12540&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To visualize this table of top countries in terms of page views in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
top_n(countries, n = 10, n) %&amp;gt;% # edit n for more or less countries to display
  ggplot(., aes(x = reorder(Country, n), y = n)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  coord_flip() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Country&amp;quot;,
    title = &amp;quot;Top performing countries in terms of page views&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  theme(plot.margin = unit(c(5.5, 7.5, 5.5, 5.5), &amp;quot;pt&amp;quot;)) # to avoid the plot being cut on the right edge&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-21-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We see that readers from the US take the largest share of the number of page views (by quite a lot actually!), and Belgium (my country) comes in third place in terms of number of page views.&lt;/p&gt;
&lt;p&gt;Given that the US population is much larger than the Belgian population (&lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 331 million people compared to &lt;span class=&#34;math inline&#34;&gt;\(\approx\)&lt;/span&gt; 11.5 million people, respectively), the above result is not really surprising. Again, for a better comparison, it would be interesting to take into consideration the size of the population when comparing countries.&lt;/p&gt;
&lt;p&gt;Indeed, it could be that a large share of the traffic comes from a country with a large population, but that the number of page views per person (or per 100,000 inhabitants) is higher for another country. This information about top performing countries in terms of page views &lt;em&gt;per person&lt;/em&gt; could give you insights on &lt;strong&gt;which country do the most avid readers come from&lt;/strong&gt;. This is beyond the scope of this article, but you can see examples of plots which include the information on the population size in these &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium-is-it-over-yet/&#34;&gt;COVID-19 visualizations&lt;/a&gt;. I recommend to apply the same methodology to the above plot for a better comparison.&lt;/p&gt;
&lt;p&gt;If you are thinking about doing the extra step of including population size when comparing countries, I believe that it would be even better to take into account the information on computer access in each country as well. If we take India as example: at the time of writing this article, its population amounts to almost 1.4 &lt;em&gt;billion&lt;/em&gt;. However, the percentage of Indian people having access to a computer is undoubtedly lower than in US or Belgium (again, at least at the moment). It would therefore make more sense to compare countries by comparing the number of page views &lt;em&gt;per people having access to a computer&lt;/em&gt;.&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;browser-information&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Browser information&lt;/h2&gt;
&lt;p&gt;For more technical aspects, you could also be interested in the number of &lt;strong&gt;page views by browser&lt;/strong&gt;. This can be visualized with the following barplot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# get data
browser_info &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;pageviews&amp;quot;),
  dimensions = c(&amp;quot;browser&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# table
browser &amp;lt;- browser_info %&amp;gt;%
  mutate(Browser = str_trunc(browser, width = 40)) %&amp;gt;% # keep maximum 40 characters
  count(Browser, wt = pageviews, sort = TRUE)

# plot
top_n(browser, n = 10, n) %&amp;gt;% # edit n for more or less browser to display
  ggplot(., aes(x = reorder(Browser, n), y = n)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal() +
  coord_flip() +
  labs(
    y = &amp;quot;Page views&amp;quot;,
    x = &amp;quot;Browser&amp;quot;,
    title = &amp;quot;Which browsers are our visitors using?&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-22-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Most visits were, as expected, from &lt;em&gt;Chrome&lt;/em&gt;, &lt;em&gt;Safari&lt;/em&gt; and &lt;em&gt;Firefox&lt;/em&gt; browsers.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;user-engagement-by-devices&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;User engagement by devices&lt;/h2&gt;
&lt;p&gt;One may also be interested in checking &lt;strong&gt;how users are engaged&lt;/strong&gt; on different types of devices. To do so, we plot 3 charts describing:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;How many sessions&lt;/strong&gt; were made from the different types of devices&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;average time on page&lt;/strong&gt; (in seconds) by type of device&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;number of page views per session&lt;/strong&gt; by device type&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# GA data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;sessions&amp;quot;, &amp;quot;avgTimeOnPage&amp;quot;),
  dimensions = c(&amp;quot;date&amp;quot;, &amp;quot;deviceCategory&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# plot sessions by deviceCategory
gadata %&amp;gt;%
  ggplot(aes(deviceCategory, sessions)) +
  geom_bar(aes(fill = deviceCategory), stat = &amp;quot;identity&amp;quot;) +
  theme_minimal() +
  labs(
    y = &amp;quot;Sessions&amp;quot;,
    x = &amp;quot;&amp;quot;,
    title = &amp;quot;Sessions per device&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;,
    fill = &amp;quot;Device&amp;quot; # edit legend title
  ) +
  scale_y_continuous(labels = scales::comma) # better y labels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-23-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the above plot, we see that the majority of readers visited the blog from a desktop, and a small number of readers from a tablet.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# add median of average time on page per device
gadata &amp;lt;- gadata %&amp;gt;%
  group_by(deviceCategory) %&amp;gt;%
  mutate(med = median(avgTimeOnPage))

# plot avgTimeOnPage by deviceCategory
ggplot(gadata) +
  aes(x = avgTimeOnPage, fill = deviceCategory) +
  geom_histogram(bins = 30L) +
  scale_fill_hue() +
  theme_minimal() +
  theme(legend.position = &amp;quot;none&amp;quot;) +
  facet_wrap(vars(deviceCategory)) +
  labs(
    y = &amp;quot;Frequency&amp;quot;,
    x = &amp;quot;Average time on page (in seconds)&amp;quot;,
    title = &amp;quot;Average time on page per device&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  geom_vline(aes(xintercept = med, group = deviceCategory),
    color = &amp;quot;darkgrey&amp;quot;,
    linetype = &amp;quot;dashed&amp;quot;
  ) +
  geom_text(
    aes(
      x = med, y = 25,
      label = paste0(&amp;quot;Median = &amp;quot;, round(med), &amp;quot; seconds&amp;quot;)
    ),
    angle = 90,
    vjust = 2,
    color = &amp;quot;darkgrey&amp;quot;,
    size = 3
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-24-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the above plot, we see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;some readers on tablet have a very low average time spent on each page (see the peak around 0 second in the tablet facet)&lt;/li&gt;
&lt;li&gt;distributions of the average time on page for readers on desktop and mobile were quite similar, with an average time on page mostly between 100 seconds (= 1 minute 40 seconds) and 400 seconds (= 6 minutes 40 seconds)&lt;/li&gt;
&lt;li&gt;quite surprisingly, the median of the average time spent on page is slightly higher for visitors on mobile than on desktop (see the dashed vertical lines representing the medians in the desktop and mobile facets). This indicates that, although more people visit the blog from desktop, it seems that &lt;strong&gt;people on mobile spend more time per page&lt;/strong&gt;. I find this result quite surprising given that most of my articles include R code and require a computer to run the code. Therefore, I expected that people would spend more time on desktop than on mobile because on mobile they would quickly scan the article, while on desktop they would read the article carefully and try to reproduce the code on their computer.&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Given this result, it would be interesting to also illustrate the &lt;strong&gt;number of page views during a session&lt;/strong&gt;, represented by device type.&lt;/p&gt;
&lt;p&gt;Indeed, it may be the case that visitors on mobile spend, on average, more time on each page &lt;em&gt;but people on desktop visit more pages per session&lt;/em&gt;. We verify this via a density plot, and for better readability we exclude data points above 2.5 page views/session and we exclude visits from a tablet:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# GA data
gadata &amp;lt;- google_analytics(view_id,
  date_range = c(start_date, end_date),
  metrics = c(&amp;quot;pageviewsPerSession&amp;quot;),
  dimensions = c(&amp;quot;date&amp;quot;, &amp;quot;deviceCategory&amp;quot;),
  anti_sample = TRUE # slows down the request but ensures data isn&amp;#39;t sampled
)

# add median of number of page views/session
gadata &amp;lt;- gadata %&amp;gt;%
  group_by(deviceCategory) %&amp;gt;%
  mutate(med = median(pageviewsPerSession))

## Reordering gadata$deviceCategory
gadata$deviceCategory &amp;lt;- factor(gadata$deviceCategory,
  levels = c(&amp;quot;mobile&amp;quot;, &amp;quot;desktop&amp;quot;, &amp;quot;tablet&amp;quot;)
)

# plot pageviewsPerSession by deviceCategory
gadata %&amp;gt;%
  filter(pageviewsPerSession &amp;lt;= 2.5 &amp;amp; deviceCategory != &amp;quot;tablet&amp;quot;) %&amp;gt;% # filter out pageviewsPerSession &amp;gt; 2.5 and visits from tablet
  ggplot(aes(x = pageviewsPerSession, fill = deviceCategory, color = deviceCategory)) +
  geom_density(alpha = 0.5) +
  scale_fill_hue() +
  theme_minimal() +
  labs(
    y = &amp;quot;Frequency&amp;quot;,
    x = &amp;quot;Page views per session&amp;quot;,
    title = &amp;quot;Page views/session by device&amp;quot;,
    subtitle = paste0(format(start_date, &amp;quot;%b %d, %Y&amp;quot;), &amp;quot; to &amp;quot;, format(end_date, &amp;quot;%b %d, %Y&amp;quot;)),
    caption = &amp;quot;Data: Google Analytics data of statsandr.com\nPoints &amp;gt; 2.5 excluded&amp;quot;,
    color = &amp;quot;Device&amp;quot;, # edit legend title
    fill = &amp;quot;Device&amp;quot; # edit legend title
  ) +
  scale_y_continuous(labels = scales::comma) + # better y labels
  geom_vline(aes(xintercept = med, group = deviceCategory, color = deviceCategory),
    linetype = &amp;quot;dashed&amp;quot;,
    show.legend = FALSE # remove legend
  ) +
  geom_text(
    aes(
      x = med, y = 2.75,
      label = paste0(&amp;quot;Median = &amp;quot;, round(med, 2), &amp;quot; page views/session&amp;quot;),
      color = deviceCategory
    ),
    angle = 90,
    vjust = 2,
    size = 3,
    show.legend = FALSE # remove legend
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-12-16-track-blog-performance-in-r_files/figure-html/unnamed-chunk-25-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This last plot confirms our thoughts, that is, although people on mobile seem to spend more time on each page, &lt;strong&gt;people on desktop tend to visit more pages per session&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;(One may wonder why I chose to compare medians instead of means. The main reason is that not all distributions considered here are &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;bell-shaped&lt;/a&gt; (especially for data on tablet) and there are many &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;. In these cases, the mean is usually not the most appropriate &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; and the median is a more robust way to represent such data. For the interested reader, see a note on the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#mean-vs.-median&#34;&gt;difference between mean and median&lt;/a&gt;, and the context in which each measure is more appropriate.)&lt;/p&gt;
&lt;!-- ## Map --&gt;
&lt;!-- If you are interested to see where you visitors come from in a specific country, the code below may be of interest. For this example, I plot the number of sessions for each province in Belgium. You can change the country in the code `bel_level_2 &lt;- getData(&#34;GADM&#34;, country = &#34;BEL&#34;, level = 2)`. --&gt;
&lt;!-- We see that, at the regional level, most sessions come from Wallonia. At the province level, we see that most sessions come from the Walloon Brabant and Brussels. Moreover, the Luxembourg province has a small number of sessions. --&gt;
&lt;!-- Be careful that these figures **do not take into account the population** of each region or province. The comparisons are, therefore, not made on the same ground. A larger population will by nature have more sessions, all else being equal. A fair comparison between provinces or regions would require to take into account its population. This can be done by computing the number of sessions per 100,000 inhabitants for instance. See an example of such comparisons with the [number of COVID-19 hospitalizations per 100,000 inhabitants in Belgium](/blog/covid-19-in-belgium-is-it-over-yet/). --&gt;
&lt;p&gt;This is the end of the analytics section. Of course, many more visualizations and data analyses are possible, depending on the site that is tracked and the marketing expertise of the analyst. This was an overview of what is possible, and I hope it will give you some ideas to explore your Google Analytics data further. Next year, I may also include forecasts and make annual comparisons. See also some examples of other analyses in this &lt;a href=&#34;https://github.com/SDITools/ga-and-r-examples&#34; target=&#34;_blank&#34;&gt;GitHub repository&lt;/a&gt; and this &lt;a href=&#34;http://www.dartistics.com/googleanalytics/index.html&#34; target=&#34;_blank&#34;&gt;website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As a side note, I would like to add the following: even if tracking the performance of your blog is important to understand how you attract visitors and how they engage with your site, I also believe that &lt;strong&gt;looking at your Google Analytics stats too often is not optimal&lt;/strong&gt;, nor sane.&lt;/p&gt;
&lt;p&gt;Talking about personal experience: at the beginning of the blog I used to look very often at the number of visitors in real-time and the audience. I was kind of obsessed to know how many people were right now on my blog and I was constantly checking if it performed better than the day before in terms of number of visitors. I remember that I was spending so much time looking at these metrics in the first weeks that I felt I was wasting my time. And the time I was wasting looking at my Google Analytics stats was lost not creating good quality content for the blog, working on my thesis/classes, or other projects.&lt;/p&gt;
&lt;p&gt;So when I realized that, I deleted the Google Analytics app from my smartphone and forced myself not to look at my stats more than once a month (just to make sure there is no critical issues that need to be fixed). From that moment onward, I stopped wasting my time on things I cannot control, and I got more satisfaction from writing articles because I was writing them for myself, not for the sake of seeing people reading them. This change was like a relief, and I am now more satisfied with my work on this blog compared to the first weeks or months.&lt;/p&gt;
&lt;p&gt;Everyone is different and unique so I am not saying that you should do the same. However, if you feel that you look too much at your stats and sometimes lose motivation in writing, perhaps this is one potential solution.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;content&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Content&lt;/h1&gt;
&lt;p&gt;Now that we have seen how we can analyze Google Analytics data and track the performance of a website or blog in details, I would like to share some thoughts about content creation, content distribution and the future plans.&lt;/p&gt;
&lt;div id=&#34;finding-topics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Finding topics&lt;/h2&gt;
&lt;p&gt;One of the biggest challenges I face with my blog is &lt;strong&gt;creating proper content&lt;/strong&gt;. In the best case scenario, I would like to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create &lt;strong&gt;useful&lt;/strong&gt; content&lt;/li&gt;
&lt;li&gt;about subjects I am really &lt;strong&gt;familiar&lt;/strong&gt; with,&lt;/li&gt;
&lt;li&gt;which I &lt;strong&gt;enjoy&lt;/strong&gt; and&lt;/li&gt;
&lt;li&gt;which &lt;strong&gt;fit into the blog&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By sharing only articles about topics I am familiar with, the writing process is easier and quicker. Indeed, most of the articles I wrote cover topics I teach at university, so a large part of the preliminary research is already done when I decide to write about it. Also (and this is not negligible), questions and incomprehension from students allow me to see the points I should focus on when writing about it, and how to present it to make it accessible and comprehensible to most people.&lt;/p&gt;
&lt;p&gt;Moreover, by making my thoughts public, I often have the chance to confront them with other points of view, which allows me to study the topic even further. This in turn accelerates the writing process even more when writing about a related topic.&lt;/p&gt;
&lt;p&gt;I also tend to write only about things I enjoy or I am interested in. I prefer quality over quantity, so writing an article from A to Z takes quite a long time depending on the depth of the subject. Since it takes time (even without taking into account the time spent after publication) and I have a full-time job, I really focus on topics I enjoy in order to keep seeing this blog as a source of pleasure, and not as a work or an obligation.&lt;/p&gt;
&lt;p&gt;The fact that I write only about things I am familiar with, which I enjoy and when I have some free time (which mostly depend on the ongoing projects related to my PhD thesis) makes it hard for me to follow a defined pace for posts. This is why my writing schedule has been a bit inconsistent during this first year and is likely to be similar in the future as I do not want to be in the position to force myself to write.&lt;a href=&#34;#fn7&#34; class=&#34;footnote-ref&#34; id=&#34;fnref7&#34;&gt;&lt;sup&gt;7&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;content-distribution&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Content distribution&lt;/h2&gt;
&lt;p&gt;Even if we all agree that bloggers should &lt;a href=&#34;https://statsandr.com/blog/7-benefits-of-sharing-your-code-in-a-data-science-blog/&#34;&gt;write for themselves first&lt;/a&gt; and not for the sake of having lots of readers, it is still appreciated when your content is being read by others.&lt;/p&gt;
&lt;p&gt;So although I do not like abusive self-promotion and I do not feel comfortable sharing my blog posts to all existing Facebook, LinkedIn and Reddit groups, somehow people need to &lt;strong&gt;get informed that you have written something&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;For this reason, I created a &lt;a href=&#34;https://twitter.com/statsandr&#34; target=&#34;_blank&#34;&gt;Twitter account&lt;/a&gt; where I share new posts immediately after publishing them on the blog. In addition to posting them on Twitter, I also share the link by email to people who subscribed to the &lt;a href=&#34;https://statsandr.com/subscribe/&#34;&gt;newsletter&lt;/a&gt; of the blog.&lt;/p&gt;
&lt;p&gt;I also managed to get my content published on &lt;a href=&#34;https://antoinesoetewey.medium.com/&#34; target=&#34;_blank&#34;&gt;Medium&lt;/a&gt; through the Towards Data Science publication, &lt;a href=&#34;https://www.r-bloggers.com/author/r-on-stats-and-r/&#34; target=&#34;_blank&#34;&gt;R-bloggers&lt;/a&gt; and &lt;a href=&#34;https://rweekly.org/&#34; target=&#34;_blank&#34;&gt;R Weekly&lt;/a&gt;. A non-negligible part of my audience comes from these referral, especially during the couple of days after publication.&lt;/p&gt;
&lt;p&gt;By distributing the content this way, I do not feel pushy (something I want to avoid at all costs!) because people decided by themselves to receive the content I publish (e.g., they subscribed to the newsletter, they followed the blog on Twitter, they chose to read blog aggregators, etc.). So in some sense, I do not distribute my content “without their prior consent” and they can always choose not to see my posts anymore.&lt;/p&gt;
&lt;p&gt;However, as you can see from the &lt;a href=&#34;https://statsandr.com/blog/track-blog-performance-in-r/#sessions-per-channel&#34;&gt;plot of the number of session per channel&lt;/a&gt;, you see that most readers come from the organic channel, so from search engines. And for this channel, apart from creating quality content (and some basic knowledge in SEO), I do not have any control on how well it is presented nor distributed to people. For this channel, it is basically search engine algorithms which decide to promote my content or not, and if they do, how well it is promoted. The only control I have regarding ranking factors is simply to &lt;strong&gt;create quality content&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;So even if I believe that having a content distribution strategy definitely helps in reaching more people and growing your blog, it does not make everything. Creating quality content is, in my view of a beginner in SEO and marketing, the best strategy for my posts to be read.&lt;/p&gt;
&lt;p&gt;For this very specific reason, now that I feel I have settled a decent distribution strategy, I no longer spend my energy and time on this matter.&lt;/p&gt;
&lt;p&gt;So I just simply try to enjoy writing on my blog, and the rest will eventually follow. If not, I am still learning a lot from this blog anyway so I do not see it as wasted time.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;a-small-note-about-ads&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;A small note about ads&lt;/h2&gt;
&lt;p&gt;I know that an easy way to get money out of your blog is to run ads and I understand that people do it if it is profitable. However, I often find ads too intrusive or annoying and I personally do not like to read blog posts which include many ads.&lt;/p&gt;
&lt;p&gt;To keep the reading process as enjoyable as possible, as you can see, I do not display any advertising on my blog. As long as the costs of running this website and the related open source projects (e.g., my &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny apps&lt;/a&gt;, etc.) are not too high, I do not expect to include ads.&lt;/p&gt;
&lt;p&gt;If in the future costs were to increase, I will still try to avoid putting ads as much as possible and I will try to rely on &lt;a href=&#34;https://statsandr.com/support/#github-sponsor-program-paypal-or-buy-me-a-book&#34;&gt;sponsorship programs &amp;amp; donations&lt;/a&gt; and on &lt;a href=&#34;https://statsandr.com/support/#recommendations&#34;&gt;paid side projects&lt;/a&gt; for people who need help for their statistical analyses.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;future-plans&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Future plans&lt;/h1&gt;
&lt;p&gt;After exactly one year of blogging, I am asking myself the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What do I want &lt;a href=&#34;https://statsandr.com/&#34;&gt;statsandr.com&lt;/a&gt; to be?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As already said, as long as I enjoy writing stuff I am passionate about on this blog, I will continue. This is very important to me.&lt;/p&gt;
&lt;p&gt;In addition to that, I would like it to be a place to &lt;strong&gt;share knowledge&lt;/strong&gt;. The field of statistics and R (and data science in general) is evolving at an extremely fast pace—and more and more people have many interesting things to say.&lt;/p&gt;
&lt;p&gt;Moreover, I learned a lot since the launch this blog. But &lt;strong&gt;I learned even more when working in collaboration&lt;/strong&gt; with someone else (see for instance these &lt;a href=&#34;https://statsandr.com/tags/collaboration/&#34;&gt;collaborations&lt;/a&gt;). I see so many learning opportunities when collaborating that I would love to see this blog as a place to share knowledge, but &lt;em&gt;not only my knowledge&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;To be more precise, I would love to hear about other researchers, statisticians, R lovers, data scientists, authors, etc. who want to collaborate with me. This could lead, in the end, to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;a href=&#34;https://statsandr.com/contribute/&#34;&gt;guest post&lt;/a&gt; if you have a good idea on what you want to write about but need a way to share it (and since you have access to my Google Analytics data in the past year through this article you have a good idea of the number of visitors who will see your content),&lt;/li&gt;
&lt;li&gt;a piece of content written together if you believe our skills and knowledge are complementary (see all &lt;a href=&#34;https://statsandr.com/blog/&#34;&gt;articles&lt;/a&gt; for an overview of what I like to write about),&lt;/li&gt;
&lt;li&gt;a piece of code, a R package, a &lt;a href=&#34;https://statsandr.com/tags/visualization/&#34;&gt;visualization&lt;/a&gt; or a &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny app&lt;/a&gt; you want to create together (or just share),&lt;/li&gt;
&lt;li&gt;a book or a course on &lt;a href=&#34;https://statsandr.com/tags/statistics/&#34;&gt;statistics&lt;/a&gt; and/or &lt;a href=&#34;https://statsandr.com/tags/r/&#34;&gt;R&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;or anything else you have in mind (I am open to new ideas and challenges).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With this article, you see the figures and the audience of the blog. With all my &lt;a href=&#34;https://statsandr.com/blog/&#34;&gt;articles&lt;/a&gt;, you can see my strengths and weaknesses.&lt;/p&gt;
&lt;p&gt;So I will finish this section by saying that, if anyone is willing to &lt;strong&gt;work on something together&lt;/strong&gt; (which does not need to be huge), you can always &lt;a href=&#34;https://statsandr.com/contact/&#34;&gt;contact me&lt;/a&gt; or leave a comment at the end of this post. I am looking forward to hearing from you.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;thank-you-note&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Thank you note&lt;/h1&gt;
&lt;p&gt;Last but not least, I also wanted to leave a short thank you note to the Towards Data Science, R-bloggers and R Weekly teams that have cross-posted most of my articles in their respective publications and therefore allowed me to share my thoughts to a larger—and very knowledgeable—audience.&lt;/p&gt;
&lt;p&gt;Also, I would like to thank all active readers for their comments, constructive feedback and support so far. I am looking forward to sharing more quality content through this blog and I hope it will keep being useful to many of you, in parallel to being useful to me.&lt;/p&gt;
&lt;p&gt;A special thanks to &lt;a href=&#34;https://code.markedmondson.me/&#34; target=&#34;_blank&#34;&gt;Mark Edmondson&lt;/a&gt;, the author of the &lt;code&gt;{googleAnalyticsR}&lt;/code&gt; package and all people who wrote &lt;a href=&#34;https://8-bit-sheep.com/googleAnalyticsR/#tutorials&#34; target=&#34;_blank&#34;&gt;tutorials&lt;/a&gt; using the package, which were used as inspiration for this blog post. More broadly, thanks also to the open source community which is of great help in learning R.&lt;/p&gt;
&lt;p&gt;Thanks for reading. I hope that you learned how to track the performance of your website or blog in R using the &lt;code&gt;{googleAnalyticsR}&lt;/code&gt; package. See you next year for a second &lt;a href=&#34;https://statsandr.com/tags/review/&#34;&gt;review&lt;/a&gt;, and in the meantime, if you maintain a blog I would be really happy to hear how you track its performance. Feel free to let me know via the comments below!&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;Thanks to the &lt;a href=&#34;https://blog.rstudio.com/2021/01/06/google-analytics-part2/&#34; target=&#34;_blank&#34;&gt;RStudio blog&lt;/a&gt; for the inspiration.&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;See more ways to &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;install and load R packages&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;li id=&#34;fn3&#34;&gt;&lt;p&gt;Many thanks to &lt;a href=&#34;http://www.dartistics.com/googleanalytics/int-time-normalized.html&#34; target=&#34;_blank&#34;&gt;dartistics.com&lt;/a&gt; for the code. Note that for better readability of the plots, I slightly edited the code: (i) to display only the top &lt;em&gt;n&lt;/em&gt; pages in terms of traffic instead of all pages, (ii) to change the theme to &lt;code&gt;theme_minimal()&lt;/code&gt; and (iii) to make the axis ticks dynamic when zooming in or out (in the &lt;code&gt;ggplotly()&lt;/code&gt; function).&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Note that the default period of 180 days can also be changed in the code.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;This may require some assumptions if the percentage of people having access to a computer is not readily available. I believe, however, that it would still be more appropriate than just taking into account the population size—especially when comparing developed with developing countries.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;At least that is what I do when I read blogs on mobile versus reading them on desktop.&lt;a href=&#34;#fnref6&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn7&#34;&gt;&lt;p&gt;Note, however, that research has shown that scheduling time for writing is a good way to productive writing (&lt;a href=&#34;https://www.apa.org/pubs/books/4441031&#34; target=&#34;_blank&#34;&gt;Silvia, 2019&lt;/a&gt;). This is why, unlike for my blog, I have set regular writing periods in my calendar (and I try to stick to it no matter how busy I am at that time) dedicated to my PhD thesis.&lt;a href=&#34;#fnref7&#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>ANOVA in R</title>
      <link>https://statsandr.com/blog/anova-in-r/</link>
      <pubDate>Mon, 12 Oct 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/anova-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#aim-and-hypotheses-of-anova&#34; id=&#34;toc-aim-and-hypotheses-of-anova&#34;&gt;Aim and hypotheses of ANOVA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#underlying-assumptions-of-anova&#34; id=&#34;toc-underlying-assumptions-of-anova&#34;&gt;Underlying assumptions of ANOVA&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#variable-type&#34; id=&#34;toc-variable-type&#34;&gt;Variable type&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#independence&#34; id=&#34;toc-independence&#34;&gt;Independence&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#normality&#34; id=&#34;toc-normality&#34;&gt;Normality&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#equality-of-variances---homogeneity&#34; id=&#34;toc-equality-of-variances---homogeneity&#34;&gt;Equality of variances - homogeneity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#another-method-to-test-normality-and-homogeneity&#34; id=&#34;toc-another-method-to-test-normality-and-homogeneity&#34;&gt;Another method to test normality and homogeneity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#outliers&#34; id=&#34;toc-outliers&#34;&gt;Outliers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#anova&#34; id=&#34;toc-anova&#34;&gt;ANOVA&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#preliminary-analyses&#34; id=&#34;toc-preliminary-analyses&#34;&gt;Preliminary analyses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#anova-in-r&#34; id=&#34;toc-anova-in-r&#34;&gt;ANOVA in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interpretations-of-anova-results&#34; id=&#34;toc-interpretations-of-anova-results&#34;&gt;Interpretations of ANOVA results&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#whats-next&#34; id=&#34;toc-whats-next&#34;&gt;What’s next?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#post-hoc-test&#34; id=&#34;toc-post-hoc-test&#34;&gt;Post-hoc test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#issue-of-multiple-testing&#34; id=&#34;toc-issue-of-multiple-testing&#34;&gt;Issue of multiple testing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#post-hoc-tests-in-r-and-their-interpretation&#34; id=&#34;toc-post-hoc-tests-in-r-and-their-interpretation&#34;&gt;Post-hoc tests in R and their interpretation&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#tukey-hsd-test&#34; id=&#34;toc-tukey-hsd-test&#34;&gt;Tukey HSD test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#dunnetts-test&#34; id=&#34;toc-dunnetts-test&#34;&gt;Dunnett’s test&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#other-p-values-adjustment-methods&#34; id=&#34;toc-other-p-values-adjustment-methods&#34;&gt;Other &lt;em&gt;p&lt;/em&gt;-values adjustment methods&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualization-of-anova-and-post-hoc-tests-on-the-same-plot&#34; id=&#34;toc-visualization-of-anova-and-post-hoc-tests-on-the-same-plot&#34;&gt;Visualization of ANOVA and post-hoc tests on the same plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#summary&#34; id=&#34;toc-summary&#34;&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/anova-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;ANOVA (ANalysis Of VAriance) is a &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt; to determine whether two or more population means are different. In other words, it is used to &lt;strong&gt;compare two or more groups&lt;/strong&gt; to see if they are significantly &lt;strong&gt;different&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In practice, however, the:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;&lt;strong&gt;Student t-test&lt;/strong&gt;&lt;/a&gt; is used to compare &lt;strong&gt;2 groups&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ANOVA&lt;/strong&gt; generalizes the t-test beyond 2 groups, so it is used to compare &lt;strong&gt;3 or more groups&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that there are several versions of the ANOVA (e.g., one-way ANOVA, &lt;a href=&#34;https://statsandr.com/blog/two-way-anova-in-r/&#34;&gt;two-way ANOVA&lt;/a&gt;, mixed ANOVA, repeated measures ANOVA, etc.). In this article, we present the simplest form only—the &lt;strong&gt;one-way ANOVA&lt;/strong&gt;&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;—and we refer to it as ANOVA in the remaining of the article.&lt;/p&gt;
&lt;p&gt;Although ANOVA is used to make inference about &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#mean&#34;&gt;means&lt;/a&gt; of different groups, the method is called “analysis of &lt;em&gt;&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#variance&#34;&gt;variance&lt;/a&gt;&lt;/em&gt;”. It is called like this because it compares the “between” variance (the variance between the different groups) and the variance “within” (the variance within each group). If the between variance is significantly larger than the within variance, the group means are declared to be different. Otherwise, we cannot conclude one way or the other. The two variances are compared to each other by taking the ratio (&lt;span class=&#34;math inline&#34;&gt;\(\frac{variance_{between}}{variance_{within}}\)&lt;/span&gt;) and then by comparing this ratio to a threshold from the Fisher &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;probability distribution&lt;/a&gt; (a threshold based on a specific significance level, usually 5%).&lt;/p&gt;
&lt;p&gt;This is enough theory regarding the ANOVA method for now. In the remaining of this article, we discuss about it from a more practical point of view, and in particular we will cover the following points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the aim of the ANOVA, when it should be used and the null/alternative hypothesis&lt;/li&gt;
&lt;li&gt;the underlying assumptions of the ANOVA and how to check them&lt;/li&gt;
&lt;li&gt;how to perform the ANOVA in R&lt;/li&gt;
&lt;li&gt;how to interpret results of the ANOVA&lt;/li&gt;
&lt;li&gt;understand the notion of post-hoc test and interpret the results&lt;/li&gt;
&lt;li&gt;how to visualize results of ANOVA and post-hoc tests&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;Data for the present article is the &lt;code&gt;penguins&lt;/code&gt; dataset (an alternative to the well-known &lt;code&gt;iris&lt;/code&gt; dataset), accessible via the &lt;a href=&#34;https://github.com/allisonhorst/palmerpenguins&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{palmerpenguins}&lt;/code&gt; package&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;palmerpenguins&amp;quot;)
library(palmerpenguins)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The dataset contains data for 344 penguins of 3 different species (Adelie, Chinstrap and Gentoo). The dataset contains 8 variables, but we focus only on the flipper length and the species for this article, so we keep only those 2 variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tidyverse)

dat &amp;lt;- penguins %&amp;gt;%
  select(species, flipper_length_mm)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(If you are unfamiliar with the pipe operator (&lt;code&gt;%&amp;gt;%&lt;/code&gt;), you can also &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/#subset-a-data-frame&#34;&gt;select variables&lt;/a&gt; with &lt;code&gt;penguins[, c(&#34;species&#34;, &#34;flipper_length_mm&#34;)]&lt;/code&gt;. Learn more ways to select variables in the article about &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;data manipulation&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;Below some basic &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; and a plot (made 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;) of our dataset before we proceed to the goal of the ANOVA:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       species    flipper_length_mm
##  Adelie   :152   Min.   :172.0    
##  Chinstrap: 68   1st Qu.:190.0    
##  Gentoo   :124   Median :197.0    
##                  Mean   :200.9    
##                  3rd Qu.:213.0    
##                  Max.   :231.0    
##                  NA&amp;#39;s   :2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Flipper length varies from 172 to 231 mm, with a mean of 200.9 mm. There are respectively 152, 68 and 124 penguins of the species Adelie, Chinstrap and Gentoo.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)

ggplot(dat) +
  aes(x = species, y = flipper_length_mm, color = species) +
  geom_jitter() +
  theme(legend.position = &amp;quot;none&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Here, the &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factor&lt;/a&gt; is the &lt;code&gt;species&lt;/code&gt; variable which contains 3 modalities or groups (Adelie, Chinstrap and Gentoo).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;aim-and-hypotheses-of-anova&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Aim and hypotheses of ANOVA&lt;/h1&gt;
&lt;p&gt;As mentioned in the introduction, the ANOVA is used to compare groups (in practice, 3 or more groups). More generally, it is used to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;study whether measurements are similar across different modalities (also called levels or treatments in the context of ANOVA) of a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;categorical&lt;/a&gt; variable&lt;/li&gt;
&lt;li&gt;compare the impact of the different levels of a categorical variable on a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative&lt;/a&gt; variable&lt;/li&gt;
&lt;li&gt;explain a quantitative variable based on a qualitative variable&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this context and as an example, we are going to use an ANOVA to help us answer the question: “&lt;strong&gt;Is the length of the flippers different between the 3 species of penguins?&lt;/strong&gt;”.&lt;/p&gt;
&lt;p&gt;The null and alternative hypothesis of an ANOVA are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu_{Adelie} = \mu_{Chinstrap} = \mu_{Gentoo}\)&lt;/span&gt; (&lt;span class=&#34;math inline&#34;&gt;\(\Rightarrow\)&lt;/span&gt; the 3 species are equal in terms of flipper length)&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;em&gt;at least&lt;/em&gt; one mean is different (&lt;span class=&#34;math inline&#34;&gt;\(\Rightarrow\)&lt;/span&gt; at least one species is different from the other 2 species in terms of flipper length)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Be careful that the alternative hypothesis is &lt;strong&gt;&lt;em&gt;not&lt;/em&gt;&lt;/strong&gt; that all means are different. The opposite of all means being equal (&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;) is that &lt;em&gt;at least&lt;/em&gt; one mean is different from the others (&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;In this sense, if the null hypothesis is rejected, it means that at least one species is different from the other 2, but not necessarily that all 3 species are different from each other. It could be that flipper length for the species Gentoo is different than for the species Chinstrap and Adelie, but flipper length is similar between Chinstrap and Adelie. Other types of test (known as post-hoc tests and covered in this &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#post-hoc-test&#34;&gt;section&lt;/a&gt;) must be performed to test whether all 3 species differ.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;underlying-assumptions-of-anova&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Underlying assumptions of ANOVA&lt;/h1&gt;
&lt;p&gt;As for many &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt;, there are some assumptions that need to be met in order to be able to interpret the results. When one or several assumptions are not met, although it is technically possible to perform these tests, it would be incorrect to interpret the results and trust the conclusions.&lt;/p&gt;
&lt;p&gt;Below are the assumptions of the ANOVA, how to test them and which other tests exist if an assumption is not met:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Variable type&lt;/strong&gt;: ANOVA requires a mix of one &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;continuous quantitative&lt;/a&gt; dependent variable (which corresponds to the measurements to which the question relates) and one &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative&lt;/a&gt; independent variable (with at least 2 levels which will determine the groups to compare).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Independence&lt;/strong&gt;: the data, collected from a representative and randomly selected portion of the total &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt;, should be independent between groups and within each group. The assumption of independence is most often verified based on the design of the experiment and on the good control of experimental conditions rather than via a formal test. If you are still unsure about independence based on the experiment design, ask yourself if one observation is related to another (if one observation has an impact on another) within each group or between the groups themselves. If not, it is most likely that you have independent &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;samples&lt;/a&gt;. If observations between samples (forming the different groups to be compared) are dependent (for example, if three measurements have been collected on the &lt;strong&gt;same individuals&lt;/strong&gt; as it is often the case in medical studies when measuring a metric (i) before, (ii) during and (iii) after a treatment), the repeated measures ANOVA should be preferred in order to take into account the dependency between the samples.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normality&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;In case of small samples, residuals&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; should follow approximately a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;&lt;strong&gt;normal distribution&lt;/strong&gt;&lt;/a&gt;. The normality assumption can be tested visually thanks to a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; and a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#qq-plot&#34;&gt;QQ-plot&lt;/a&gt;, and/or formally via a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;normality test&lt;/a&gt; such as the Shapiro-Wilk or Kolmogorov-Smirnov test. If, even after a transformation of your data (e.g., logarithmic transformation, square root, Box-Cox, etc.), the residuals still do not follow approximately a normal distribution, the &lt;a href=&#34;https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/&#34;&gt;Kruskal-Wallis test&lt;/a&gt; can be applied (&lt;code&gt;kruskal.test(variable ~ group, data = dat&lt;/code&gt; in R). This non-parametric test, robust to non normal distributions, has the same goal than the ANOVA—compare 3 or more groups—but it uses sample medians instead of sample means to compare groups.&lt;/li&gt;
&lt;li&gt;In case of large samples, &lt;strong&gt;normality is not required&lt;/strong&gt; (this is a common misconception!). By the &lt;a href=&#34;https://en.wikipedia.org/wiki/Central_limit_theorem&#34; target=&#34;_blank&#34;&gt;central limit theorem&lt;/a&gt;, sample means of large samples are often well-approximated by a normal distribution even if the data are not normally distributed &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-stevens2013intermediate&#34;&gt;Stevens 2013&lt;/a&gt;)&lt;/span&gt;.&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt; It is therefore not required to test the normality assumption when the number of observations in each group/sample is large (usually &lt;span class=&#34;math inline&#34;&gt;\(n \ge 30\)&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Equality of variances&lt;/strong&gt;: the variances of the different groups should be equal in the populations (an assumption called homogeneity of the variances, or even sometimes referred as homoscedasticity, as opposed to heteroscedasticity if variances are different across groups). This assumption can be tested graphically (by comparing the dispersion in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; or &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#dotplot&#34;&gt;dotplot&lt;/a&gt; for instance), or more formally via the Levene’s test (&lt;code&gt;leveneTest(variable ~ group)&lt;/code&gt; from the &lt;code&gt;{car}&lt;/code&gt; package) or Bartlett’s test, among others. If the hypothesis of equal variances is rejected, another version of the ANOVA can be used: the Welch ANOVA (&lt;code&gt;oneway.test(variable ~ group, var.equal = FALSE)&lt;/code&gt;). Note that the Welch ANOVA does not require homogeneity of the variances, but the distributions should still follow approximately a normal distribution. Note that the &lt;a href=&#34;https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/&#34;&gt;Kruskal-Wallis test&lt;/a&gt; does not require the assumptions of normality nor homoscedasticity of the variances.&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Outliers&lt;/strong&gt;: An &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outlier&lt;/a&gt; is a value or an observation that is distant from the other observations. There should be &lt;strong&gt;no significant outliers in the different groups&lt;/strong&gt;, or the conclusions of your ANOVA may be flawed. There are several methods to &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;detect outliers&lt;/a&gt; in your data but in order to deal with them, it is your choice to either:
&lt;ul&gt;
&lt;li&gt;use the non-parametric version (i.e., the Kruskal-Wallis test)&lt;/li&gt;
&lt;li&gt;transform your data (logarithmic or Box-Cox transformation, among others)&lt;/li&gt;
&lt;li&gt;or remove them (be careful)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Choosing the appropriate test depending on whether assumptions are met may be confusing so here is a brief summary:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Check that your observations are independent.&lt;/li&gt;
&lt;li&gt;Sample sizes:
&lt;ul&gt;
&lt;li&gt;In case of small samples, test the normality of residuals:
&lt;ul&gt;
&lt;li&gt;If normality is assumed, test the homogeneity of the variances:
&lt;ul&gt;
&lt;li&gt;If variances are equal, use &lt;strong&gt;ANOVA&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If variances are not equal, use the &lt;strong&gt;Welch ANOVA&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;If normality is not assumed, use the &lt;strong&gt;Kruskal-Wallis test&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;In case of large samples normality is assumed, so test the homogeneity of the variances:
&lt;ul&gt;
&lt;li&gt;If variances are equal, use &lt;strong&gt;ANOVA&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If variances are not equal, use the &lt;strong&gt;Welch ANOVA&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now that we have seen the underlying assumptions of the ANOVA, we review them specifically for our dataset before applying the appropriate version of the test.&lt;/p&gt;
&lt;div id=&#34;variable-type&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Variable type&lt;/h2&gt;
&lt;p&gt;The dependent variable &lt;code&gt;flipper_length_mm&lt;/code&gt; is a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative&lt;/a&gt; variable and the independent variable &lt;code&gt;species&lt;/code&gt; is a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative&lt;/a&gt; one (with 3 levels corresponding to the 3 species). So we have a mix of the two types of variable and this assumption is met.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;independence&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Independence&lt;/h2&gt;
&lt;p&gt;Independence of the observations is assumed as data have been collected from a randomly selected portion of the population and measurements within and between the 3 samples are not related.&lt;/p&gt;
&lt;p&gt;The independence assumption is most often verified based on the design of the experiment and on the good control of experimental conditions, as it is the case here.&lt;/p&gt;
&lt;p&gt;If you really want to test it more formally, you can, however, test it via a statistical test—the Durbin-Watson test (in R: &lt;code&gt;durbinWatsonTest(res_lm)&lt;/code&gt; where &lt;code&gt;res_lm&lt;/code&gt; is a linear model). The null hypothesis of this test specifies an autocorrelation coefficient = 0, while the alternative hypothesis specifies an autocorrelation coefficient &lt;span class=&#34;math inline&#34;&gt;\(\ne\)&lt;/span&gt; 0.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;normality&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Normality&lt;/h2&gt;
&lt;p&gt;Since the smallest sample size per group (i.e., per species) is 68, we have large samples. Therefore, we do not need to check normality.&lt;/p&gt;
&lt;p&gt;Usually, we would directly test the homogeneity of the variances without testing normality. However, for the sake of illustration, we act as if the sample sizes were small in order to illustrate what would need to be done in that case.&lt;/p&gt;
&lt;p&gt;Remember that &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normality&lt;/a&gt; of residuals can be tested visually via a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; and a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#qq-plot&#34;&gt;QQ-plot&lt;/a&gt;, and/or formally via a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;normality test&lt;/a&gt; (Shapiro-Wilk test for instance).&lt;/p&gt;
&lt;p&gt;Before checking the normality assumption, we first need to compute the ANOVA (more on that in this &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#anova-in-r&#34;&gt;section&lt;/a&gt;). We then save the results in &lt;code&gt;res_aov&lt;/code&gt; :&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;res_aov &amp;lt;- aov(flipper_length_mm ~ species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can now check normality visually:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;par(mfrow = c(1, 2)) # combine plots

# histogram
hist(res_aov$residuals)

# QQ-plot
library(car)
qqPlot(res_aov$residuals,
  id = FALSE # id = FALSE to remove point identification
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-6-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the histogram and QQ-plot above, we can already see that the normality assumption seems to be met. Indeed, the histogram roughly form a bell curve, indicating that the residuals follow a normal distribution. Furthermore, points in the QQ-plots roughly follow the straight line and most of them are within the confidence bands, also indicating that residuals follow approximately a normal distribution.&lt;/p&gt;
&lt;p&gt;Some researchers stop here and assume that normality is met, while others also test the assumption via a formal &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;normality test&lt;/a&gt;. It is your choice to test it (i) only visually, (ii) only via a normality test, or (iii) both visually AND via a normality test. Bear in mind, however, the two following points:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;ANOVA is quite robust to small deviations from normality. This means that it is not an issue (from the perspective of the interpretation of the ANOVA results) if a small number of points deviates slightly from the normality,&lt;/li&gt;
&lt;li&gt;normality tests are sometimes quite conservative, meaning that the null hypothesis of normality may be rejected due to a limited deviation from normality. This is especially the case with large samples as power of the test increases with the sample size.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In practice, I tend to prefer the (i) visual approach only, but again, this is a matter of personal choice and also depends on the context of the analysis.&lt;/p&gt;
&lt;p&gt;Still for the sake of illustration, we also now test the normality assumption via a normality test. You can use the Shapiro-Wilk test or the Kolmogorov-Smirnov test, among others.&lt;/p&gt;
&lt;p&gt;Remember that the null and alternative hypothesis of these tests are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: data come from a normal distribution&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: data do &lt;strong&gt;&lt;em&gt;not&lt;/em&gt;&lt;/strong&gt; come from a normal distribution&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In R, we can test normality of the residuals with the Shapiro-Wilk test thanks to the &lt;code&gt;shapiro.test()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;shapiro.test(res_aov$residuals)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Shapiro-Wilk normality test
## 
## data:  res_aov$residuals
## W = 0.99452, p-value = 0.2609&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;P&lt;/em&gt;-value of the Shapiro-Wilk test on the residuals is larger than the usual significance level of &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 5\%\)&lt;/span&gt;, so we do not reject the hypothesis that residuals follow a normal distribution (&lt;em&gt;p&lt;/em&gt;-value = 0.261).&lt;/p&gt;
&lt;p&gt;This result is in line with the visual approach. In our case, the normality assumption is thus met both visually and formally.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Side note: Remind that the p-value is the &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/&#34;&gt;probability&lt;/a&gt; of having observations as extreme as the ones we have observed in the sample(s) given that the null hypothesis is true. If the p-value &lt;span class=&#34;math inline&#34;&gt;\(&amp;lt; \alpha\)&lt;/span&gt; (indicating that it is not likely to observe the data we have in the sample given that the null hypothesis is true), the null hypothesis is rejected, otherwise the null hypothesis is not rejected. See more about &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;p-value and significance level&lt;/a&gt; if you are unfamiliar with those important statistical concepts.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Remember that if the normality assumption was not reached, some transformation(s) would need to be applied on the raw data in the hope that residuals would better fit a normal distribution, or you would need to use the non-parametric version of the ANOVA—the &lt;a href=&#34;https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/&#34;&gt;Kruskal-Wallis test&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As pointed out by a reader (see comments at the very end of the article), the normality assumption can also be tested on the “raw” data (i.e., the observations) instead of the residuals. However, if you test the normality assumption on the raw data, it must be tested for &lt;em&gt;each group separately&lt;/em&gt; as the ANOVA requires normality in &lt;em&gt;each group&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Testing normality on all residuals or on the observations per group is equivalent, and will give similar results. Indeed, saying “The distribution of Y within each group is normally distributed” is the same as saying “The residuals are normally distributed”.&lt;/p&gt;
&lt;p&gt;Remember that residuals are the distance between the actual value of Y and the mean value of Y for a specific value of X, so the grouping variable is induced in the computation of the residuals.&lt;/p&gt;
&lt;p&gt;So in summary, in ANOVA you actually have two options for testing normality:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Checking normality separately for each group on the “raw” data (Y values)&lt;/li&gt;
&lt;li&gt;Checking normality on all residuals (but not per group)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In practice, you will see that it is often easier to just use the residuals and check them all together, especially if you have many groups or few observations per group.&lt;/p&gt;
&lt;p&gt;If you are still not convinced: remember that an ANOVA is a special case of a linear model. Suppose your independent variable is a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;continuous variable&lt;/a&gt; (instead of a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;categorical variable&lt;/a&gt;), the only option you have left is to check normality on the residuals, which is precisely what is done for testing normality in &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt; models.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;equality-of-variances---homogeneity&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Equality of variances - homogeneity&lt;/h2&gt;
&lt;p&gt;Assuming residuals follow a normal distribution, it is now time to check whether the variances are equal across species or not. The result will have an impact on whether we use the ANOVA or the Welch ANOVA.&lt;/p&gt;
&lt;p&gt;This can again be verified visually—via a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; or &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#dotplot&#34;&gt;dotplot&lt;/a&gt;—or more formally via a statistical test (Levene’s test, among others).&lt;/p&gt;
&lt;p&gt;Visually, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Boxplot
boxplot(flipper_length_mm ~ species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-8-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Dotplot
library(&amp;quot;lattice&amp;quot;)

dotplot(flipper_length_mm ~ species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-8-2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Both the boxplot and the dotplot show a similar variance for the different species. In the boxplot, this can be seen by the fact that the boxes and the whiskers have a comparable size for all species.&lt;/p&gt;
&lt;p&gt;There are a couple of &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt; as shown by the points outside the whiskers, but this does not change the fact that the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#dispersion&#34;&gt;dispersion&lt;/a&gt; is more or less the same between the different species.&lt;/p&gt;
&lt;p&gt;In the dotplot, this can be seen by the fact that points for all 3 species have more or less the same &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#range&#34;&gt;range&lt;/a&gt;, a sign of the dispersion and thus the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#variance&#34;&gt;variance&lt;/a&gt; being similar.&lt;/p&gt;
&lt;p&gt;Like the normality assumption, if you feel that the visual approach is not sufficient, you can formally test for equality of the variances with a Levene’s or Bartlett’s test. Notice that the Levene’s test is less sensitive to departures from normal distribution than the Bartlett’s test.&lt;/p&gt;
&lt;p&gt;The null and alternative hypothesis for both tests are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: variances are equal&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: at least one variance is different&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In R, the Levene’s test can be performed thanks to the &lt;code&gt;leveneTest()&lt;/code&gt; function from the &lt;code&gt;{car}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Levene&amp;#39;s test
library(car)

leveneTest(flipper_length_mm ~ species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Levene&amp;#39;s Test for Homogeneity of Variance (center = median)
##        Df F value Pr(&amp;gt;F)
## group   2  0.3306 0.7188
##       339&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value being larger than the significance level of 0.05, we do not reject the null hypothesis, so we cannot reject the hypothesis that variances are equal between species (&lt;em&gt;p&lt;/em&gt;-value = 0.719).&lt;/p&gt;
&lt;p&gt;This result is also in line with the visual approach, so the homogeneity of variances is met both visually and formally.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;another-method-to-test-normality-and-homogeneity&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Another method to test normality and homogeneity&lt;/h2&gt;
&lt;p&gt;For your information, it is also possible to test the homogeneity of the variances and the normality of the residuals visually (and both at the same time) via the &lt;code&gt;plot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;par(mfrow = c(1, 2)) # combine plots

# 1. Homogeneity of variances
plot(res_aov, which = 3)

# 2. Normality
plot(res_aov, which = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-10-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Plot on the left hand side shows that there is no evident relationships between residuals and fitted values (the mean of each group), so homogeneity of variances is assumed. If homogeneity of variances was violated, the red line would not be flat (horizontal).&lt;/p&gt;
&lt;p&gt;Plot on the right hand side shows that residuals follow approximately a normal distribution, so normality is assumed. If normality was violated, points would consistently deviate from the dashed line.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;outliers&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Outliers&lt;/h2&gt;
&lt;p&gt;There are several techniques to &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;detect outliers&lt;/a&gt;. In this article, we focus on the most simple one (yet very efficient)—the visual approach via a boxplot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(flipper_length_mm ~ species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-11-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;There is one outlier in the group &lt;code&gt;Adelie&lt;/code&gt;, as defined by the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#interquartile-range&#34;&gt;interquartile range&lt;/a&gt; criterion. This point is, however, not seen as a significant outlier so we can assume that the assumption of no significant outliers is met.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;anova&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;ANOVA&lt;/h1&gt;
&lt;p&gt;We showed that all assumptions of the ANOVA are met.&lt;/p&gt;
&lt;p&gt;We can thus proceed to the implementation of the ANOVA in R, but first, let’s do some preliminary analyses to better understand the research question.&lt;/p&gt;
&lt;div id=&#34;preliminary-analyses&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Preliminary analyses&lt;/h2&gt;
&lt;p&gt;A good practice before actually performing the ANOVA in R is to &lt;strong&gt;visualize the data&lt;/strong&gt; in relation to the research question. The best way to do so is to draw and compare boxplots of the quantitative variable &lt;code&gt;flipper_length_mm&lt;/code&gt; for each species.&lt;/p&gt;
&lt;p&gt;This can be done with the &lt;code&gt;boxplot()&lt;/code&gt; function in base R (same code than the visual check of equal variances):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(flipper_length_mm ~ species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-12-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Or 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;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)

ggplot(dat) +
  aes(x = species, y = flipper_length_mm) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-13-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The boxplots above show that, at least for our sample, penguins of the species &lt;code&gt;Gentoo&lt;/code&gt; seem to have the biggest flipper, and &lt;code&gt;Adelie&lt;/code&gt; species the smallest flipper.&lt;/p&gt;
&lt;p&gt;Besides a boxplot for each species, it is also a good practice to compute some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;&lt;strong&gt;descriptive statistics&lt;/strong&gt;&lt;/a&gt; such as the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#mean&#34;&gt;mean&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#standard-deviation-and-variance&#34;&gt;standard deviation&lt;/a&gt; by species.&lt;/p&gt;
&lt;p&gt;This can be done, for instance, with the &lt;code&gt;aggregate()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aggregate(flipper_length_mm ~ species,
  data = dat,
  function(x) round(c(mean = mean(x), sd = sd(x)), 2)
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     species flipper_length_mm.mean flipper_length_mm.sd
## 1    Adelie                 189.95                 6.54
## 2 Chinstrap                 195.82                 7.13
## 3    Gentoo                 217.19                 6.48&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or with the &lt;code&gt;summarise()&lt;/code&gt; and &lt;code&gt;group_by()&lt;/code&gt; functions from the &lt;code&gt;{dplyr}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(dplyr)

group_by(dat, species) %&amp;gt;%
  summarise(
    mean = mean(flipper_length_mm, na.rm = TRUE),
    sd = sd(flipper_length_mm, na.rm = TRUE)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 3
##   species    mean    sd
##   &amp;lt;fct&amp;gt;     &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1 Adelie     190.  6.54
## 2 Chinstrap  196.  7.13
## 3 Gentoo     217.  6.48&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Mean is also the lowest for &lt;code&gt;Adelie&lt;/code&gt; and highest for &lt;code&gt;Gentoo&lt;/code&gt;. Boxplots and descriptive statistics are, however, not enough to conclude that flippers are significantly different in the 3 populations of penguins.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;anova-in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;ANOVA in R&lt;/h2&gt;
&lt;p&gt;As you guessed by now, only the ANOVA can help us to make inference about the population given the sample at hand, and help us to answer the initial research question “Is the length of the flippers different between the 3 species of penguins?”.&lt;/p&gt;
&lt;p&gt;ANOVA in R can be done in several ways, of which two are presented below:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;With the &lt;code&gt;oneway.test()&lt;/code&gt; function:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 1st method:
oneway.test(flipper_length_mm ~ species,
  data = dat,
  var.equal = TRUE # assuming equal variances
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	One-way analysis of means
## 
## data:  flipper_length_mm and species
## F = 594.8, num df = 2, denom df = 339, p-value &amp;lt; 2.2e-16&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;With the &lt;code&gt;summary()&lt;/code&gt; and &lt;code&gt;aov()&lt;/code&gt; functions:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 2nd method:
res_aov &amp;lt;- aov(flipper_length_mm ~ species,
  data = dat
)

summary(res_aov)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##              Df Sum Sq Mean Sq F value Pr(&amp;gt;F)    
## species       2  52473   26237   594.8 &amp;lt;2e-16 ***
## Residuals   339  14953      44                   
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 2 observations deleted due to missingness&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see from the two outputs above, the test statistic (&lt;code&gt;F =&lt;/code&gt; in the first method and &lt;code&gt;F value&lt;/code&gt; in the second one) and the &lt;em&gt;p&lt;/em&gt;-value (&lt;code&gt;p-value&lt;/code&gt; in the first method and &lt;code&gt;Pr(&amp;gt;F)&lt;/code&gt; in the second one) are exactly the same for both methods, which means that in case of equal variances, results and conclusions will be unchanged.&lt;/p&gt;
&lt;p&gt;The advantage of the first method is that it is easy to switch from the ANOVA (used when variances are equal) to the Welch ANOVA (used when variances are &lt;strong&gt;un&lt;/strong&gt;equal). This can be done by replacing &lt;code&gt;var.equal = TRUE&lt;/code&gt; by &lt;code&gt;var.equal = FALSE&lt;/code&gt;, as presented below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;oneway.test(flipper_length_mm ~ species,
  data = dat,
  var.equal = FALSE # assuming unequal variances
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	One-way analysis of means (not assuming equal variances)
## 
## data:  flipper_length_mm and species
## F = 614.01, num df = 2.00, denom df = 172.76, p-value &amp;lt; 2.2e-16&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The advantage of the second method, however, is that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the full ANOVA table (with degrees of freedom, mean squares, etc.) is printed, which may be of interest in some (theoritical) cases&lt;/li&gt;
&lt;li&gt;results of the ANOVA (&lt;code&gt;res_aov&lt;/code&gt;) can be saved for later use (especially useful for &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#post-hoc-test&#34;&gt;post-hoc tests&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;interpretations-of-anova-results&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Interpretations of ANOVA results&lt;/h2&gt;
&lt;p&gt;Given that the &lt;em&gt;p&lt;/em&gt;-value is smaller than 0.05, we reject the null hypothesis, so we reject the hypothesis that all means are equal. Therefore, we can conclude that &lt;strong&gt;at least one species is different than the others in terms of flippers length&lt;/strong&gt; (&lt;em&gt;p&lt;/em&gt;-value &amp;lt; 2.2e-16).&lt;/p&gt;
&lt;p&gt;(&lt;em&gt;For the sake of illustration&lt;/em&gt;, if the &lt;em&gt;p&lt;/em&gt;-value was larger than 0.05: we cannot reject the null hypothesis that all means are equal, so we cannot reject the hypothesis that the 3 considered species of penguins are equal in terms of flippers length.)&lt;/p&gt;
&lt;p&gt;A nice and easy way to report results of an ANOVA in R is with the &lt;code&gt;report()&lt;/code&gt; function from the &lt;code&gt;{report}&lt;/code&gt; package:&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(res_aov)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## The ANOVA (formula: flipper_length_mm ~ species) suggests that:
## 
##   - The main effect of species is statistically significant and large (F(2, 339)
## = 594.80, p &amp;lt; .001; Eta2 = 0.78, 95% CI [0.75, 1.00])
## 
## Effect sizes were labelled following Field&amp;#39;s (2013) recommendations.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, the function interprets the results for you and indicates a large and significant main effect of the species on the flipper length (&lt;em&gt;p&lt;/em&gt;-value &amp;lt; .001).&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 &lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/&#34;&gt;tips and tricks in R&lt;/a&gt; if you find this one useful.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;whats-next&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What’s next?&lt;/h2&gt;
&lt;p&gt;If the &lt;strong&gt;null hypothesis is not rejected&lt;/strong&gt; (&lt;em&gt;p&lt;/em&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(\ge\)&lt;/span&gt; 0.05), it means that we do not reject the hypothesis that all groups are equal. The ANOVA more or less stops here.&lt;/p&gt;
&lt;p&gt;Other types of analyses can be performed of course, but—given the data at hand—we could not prove that at least one group was different so we usually do not go further with the ANOVA.&lt;/p&gt;
&lt;p&gt;On the contrary, if the &lt;strong&gt;null hypothesis is rejected&lt;/strong&gt; (as it is our case since the &lt;em&gt;p&lt;/em&gt;-value &amp;lt; 0.05), we proved that at least one group is different. We can decide to stop here if we are only interested to test whether all species are equal in terms of flippers length.&lt;/p&gt;
&lt;p&gt;But most of the time, when we showed thanks to an ANOVA that at least one group is different, we are also interested in knowing &lt;strong&gt;which&lt;/strong&gt; one(s) is(are) different. Results of an ANOVA, however, do &lt;strong&gt;&lt;em&gt;NOT&lt;/em&gt;&lt;/strong&gt; tell us which group(s) is(are) different from the others.&lt;/p&gt;
&lt;p&gt;To test this, we need to use other types of test, referred as post-hoc tests (in Latin, “after this”, so after obtaining statistically significant ANOVA results) or multiple pairwise-comparison tests.&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This family of statistical tests is the topic of the following sections.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;post-hoc-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Post-hoc test&lt;/h1&gt;
&lt;div id=&#34;issue-of-multiple-testing&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Issue of multiple testing&lt;/h2&gt;
&lt;p&gt;In order to see which group(s) is(are) different from the others, we need to &lt;strong&gt;compare groups 2 by 2&lt;/strong&gt;. In practice, since there are 3 species, we are going to compare species 2 by 2 as follows:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Chinstrap versus Adelie&lt;/li&gt;
&lt;li&gt;Gentoo vs. Adelie&lt;/li&gt;
&lt;li&gt;Gentoo vs. Chinstrap&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In theory, we could compare species thanks to 3 &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-tests&lt;/a&gt; since we need to compare 2 groups and a t-test is used precisely in that case.&lt;/p&gt;
&lt;p&gt;However, if several t-tests are performed, the issue of &lt;strong&gt;multiple testing&lt;/strong&gt; (also referred as multiplicity) arises. In short, when several &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt; are performed, some will have &lt;em&gt;p&lt;/em&gt;-values less than &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; purely by chance, even if all null hypotheses are in fact true.&lt;/p&gt;
&lt;p&gt;To demonstrate the problem, consider our case where we have 3 hypotheses to test and a desired significance level of 0.05.&lt;/p&gt;
&lt;p&gt;The probability of observing at least one significant result (at least one &lt;em&gt;p&lt;/em&gt;-value &amp;lt; 0.05) just due to chance is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{equation}
\begin{split}
P(\text{at least 1 sig. result}) &amp;amp; = 1 - P(\text{no sig. results}) \\
&amp;amp; = 1 - (1 - 0.05)^3 \\
&amp;amp; = 0.142625
\end{split}
\end{equation}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;So, with as few as 3 tests being considered, we already have a 14.26% chance of observing at least one significant result, even if all of the tests are actually not significant.&lt;/p&gt;
&lt;p&gt;And as the number of groups increases, the number of comparisons increases as well, so the probability of having a significant result simply due to chance keeps increasing.&lt;/p&gt;
&lt;p&gt;For example, with 10 groups we need to make 45 comparisons and the probability of having at least one significant result by chance becomes &lt;span class=&#34;math inline&#34;&gt;\(1 - (1 - 0.05)^{45} = 90\%\)&lt;/span&gt;. So it is very likely to observe a significant result just by chance when comparing 10 groups, and when we have 14 groups or more we are almost certain (99%) to have a false positive!&lt;/p&gt;
&lt;p&gt;Post-hoc tests take into account that multiple tests are done and deal with the problem by adjusting &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; in some way, so that the probability of observing at least one significant result due to chance remains below our desired significance level.&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;post-hoc-tests-in-r-and-their-interpretation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Post-hoc tests in R and their interpretation&lt;/h2&gt;
&lt;p&gt;Post-hoc tests are a family of statistical tests so there are several of them. The most common ones are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tukey HSD&lt;/strong&gt;, used to compare &lt;strong&gt;all groups&lt;/strong&gt; to each other (so all possible comparisons of 2 groups).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dunnett&lt;/strong&gt;, used to make comparisons with a &lt;strong&gt;reference group&lt;/strong&gt;. For example, consider 2 treatment groups and one control group. If you only want to compare the 2 treatment groups with respect to the control group, and you do not want to compare the 2 treatment groups to each other, the Dunnett’s test is preferred.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bonferroni correction&lt;/strong&gt; if one has a set of planned comparisons to do.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The Bonferroni correction is simple: you simply divide the desired global &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; level by the number of comparisons.&lt;/p&gt;
&lt;p&gt;In our example, we have 3 comparisons so if we want to keep a global &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;, we have &lt;span class=&#34;math inline&#34;&gt;\(\alpha&amp;#39; = \frac{0.05}{3} = 0.0167\)&lt;/span&gt;. We can then simply perform a Student’s t-test for each comparison, and compare the obtained &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values with this new &lt;span class=&#34;math inline&#34;&gt;\(\alpha&amp;#39;\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The other two post-hoc tests are presented in the next sections.&lt;/p&gt;
&lt;p&gt;Note that variances are assumed to be equal for all three methods (unless you use the Welch’s t-test instead of the Student’s t-test with the Bonferroni correction). If variances are not equal, you can use the Games-Howell test, among others.&lt;/p&gt;
&lt;div id=&#34;tukey-hsd-test&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Tukey HSD test&lt;/h3&gt;
&lt;p&gt;In our case, since there is no “reference” species and we are interested in comparing all species, we are going to use the Tukey HSD test.&lt;/p&gt;
&lt;p&gt;In R, the Tukey HSD test is done as follows. This is where the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#anova-in-r&#34;&gt;second method&lt;/a&gt; to perform the ANOVA comes handy because the results (&lt;code&gt;res_aov&lt;/code&gt;) are reused for the post-hoc test:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(multcomp)

# Tukey HSD test:
post_test &amp;lt;- glht(res_aov,
  linfct = mcp(species = &amp;quot;Tukey&amp;quot;)
)

summary(post_test)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	 Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: aov(formula = flipper_length_mm ~ species, data = dat)
## 
## Linear Hypotheses:
##                         Estimate Std. Error t value Pr(&amp;gt;|t|)    
## Chinstrap - Adelie == 0   5.8699     0.9699   6.052 1.03e-08 ***
## Gentoo - Adelie == 0     27.2333     0.8067  33.760  &amp;lt; 1e-08 ***
## Gentoo - Chinstrap == 0  21.3635     1.0036  21.286  &amp;lt; 1e-08 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## (Adjusted p values reported -- single-step method)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the output of the Tukey HSD test, we are interested in the table displayed after &lt;code&gt;Linear Hypotheses:&lt;/code&gt;, and more precisely, in the first and last column of the table. The first column shows the comparisons which have been made; the last column (&lt;code&gt;Pr(&amp;gt;|t|)&lt;/code&gt;) shows the adjusted&lt;a href=&#34;#fn7&#34; class=&#34;footnote-ref&#34; id=&#34;fnref7&#34;&gt;&lt;sup&gt;7&lt;/sup&gt;&lt;/a&gt; &lt;em&gt;p&lt;/em&gt;-values for each comparison (with the null hypothesis being the two groups are equal and the alternative hypothesis being the two groups are different).&lt;/p&gt;
&lt;p&gt;It is these adjusted &lt;em&gt;p&lt;/em&gt;-values that are used to test whether two groups are significantly different or not, and we can be confident that the entire set of comparisons collectively has an error rate of 0.05.&lt;/p&gt;
&lt;p&gt;In our example, we tested:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Chinstrap versus Adelie (line &lt;code&gt;Chinstrap - Adelie == 0&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Gentoo vs. Adelie (line &lt;code&gt;Gentoo - Adelie == 0&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Gentoo vs. Chinstrap (line &lt;code&gt;Gentoo - Chinstrap == 0&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;All three ajusted &lt;em&gt;p&lt;/em&gt;-values are smaller than 0.05, so we reject the null hypothesis for all comparisons, which means that &lt;strong&gt;all species are significantly different&lt;/strong&gt; in terms of flippers length.&lt;/p&gt;
&lt;p&gt;The results of the post-hoc test can be visualized with the &lt;code&gt;plot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;par(mar = c(3, 8, 3, 3))
plot(post_test)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-21-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We see that the confidence intervals do not cross the zero line, which indicate that all groups are significantly different.&lt;/p&gt;
&lt;p&gt;Note that the Tukey HSD test can also be done in R with the &lt;code&gt;TukeyHSD()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;TukeyHSD(res_aov)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = flipper_length_mm ~ species, data = dat)
## 
## $species
##                       diff       lwr       upr p adj
## Chinstrap-Adelie  5.869887  3.586583  8.153191     0
## Gentoo-Adelie    27.233349 25.334376 29.132323     0
## Gentoo-Chinstrap 21.363462 19.000841 23.726084     0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this code, it is the column &lt;code&gt;p adj&lt;/code&gt; (also the last column) which is of interest. Notice that the conclusions are the same than above: all species are significantly different in terms of flippers length.&lt;/p&gt;
&lt;p&gt;The results can also be visualized with the &lt;code&gt;plot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(TukeyHSD(res_aov))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-23-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dunnetts-test&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Dunnett’s test&lt;/h3&gt;
&lt;p&gt;We have seen in this &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#issue-of-multiple-testing&#34;&gt;section&lt;/a&gt; that as the number of groups increases, the number of comparisons also increases. And as the number of &lt;strong&gt;comparisons increases&lt;/strong&gt;, the post-hoc analysis must lower the individual significance level even further, which leads to &lt;strong&gt;lower statistical power&lt;/strong&gt; (so a difference between group means in the population is less likely to be detected).&lt;/p&gt;
&lt;p&gt;One method to mitigate this and increase the statistical power is by reducing the number of comparisons. This reduction allows the post-hoc procedure to use a larger individual error rate to achieve the desired global error rate.&lt;/p&gt;
&lt;p&gt;While comparing all possible groups with a Tukey HSD test is a common approach, many studies have a control group and several treatment groups. For these studies, you may need to compare the treatment groups only to the control group, which reduces the number of comparisons.&lt;/p&gt;
&lt;p&gt;Dunnett’s test does precisely this—it only compares a group taken as reference to all other groups, but it does not compare all groups to each others.&lt;/p&gt;
&lt;p&gt;So to recap:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the Tukey HSD test allows to compares &lt;strong&gt;all&lt;/strong&gt; groups but at the cost of &lt;strong&gt;less power&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;the Dunnett’s test allows to only make &lt;strong&gt;comparisons with a reference group&lt;/strong&gt;, but with the benefit of &lt;strong&gt;more power&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now, again for the sake of illustration, consider that the species &lt;code&gt;Adelie&lt;/code&gt; is the reference species and we are only interested in comparing the reference species against the other 2 species. In that scenario, we would use the Dunnett’s test.&lt;/p&gt;
&lt;p&gt;In R, the Dunnett’s test is done as follows (the only difference with the code for the Tukey HSD test is in the line &lt;code&gt;linfct = mcp(species = &#34;Dunnett&#34;)&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(multcomp)

# Dunnett&amp;#39;s test:
post_test &amp;lt;- glht(res_aov,
  linfct = mcp(species = &amp;quot;Dunnett&amp;quot;)
)

summary(post_test)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	 Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Dunnett Contrasts
## 
## 
## Fit: aov(formula = flipper_length_mm ~ species, data = dat)
## 
## Linear Hypotheses:
##                         Estimate Std. Error t value Pr(&amp;gt;|t|)    
## Chinstrap - Adelie == 0   5.8699     0.9699   6.052 7.59e-09 ***
## Gentoo - Adelie == 0     27.2333     0.8067  33.760  &amp;lt; 1e-10 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## (Adjusted p values reported -- single-step method)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The interpretation is the same as for the Tukey HSD test’s except that in the Dunett’s test we only compare:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Chinstrap versus Adelie (line &lt;code&gt;Chinstrap - Adelie == 0&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Gentoo vs. Adelie (line &lt;code&gt;Gentoo - Adelie == 0&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Both adjusted &lt;em&gt;p&lt;/em&gt;-values (displayed in the last column) are below 0.05, so we reject the null hypothesis for both comparisons.&lt;/p&gt;
&lt;p&gt;This means that both the &lt;strong&gt;species Chinstrap and Gentoo are significantly different from the reference species Adelie&lt;/strong&gt; in terms of flippers length. (Nothing can be said about the comparison between Chinstrap and Gentoo though.)&lt;/p&gt;
&lt;p&gt;Again, the results of the post-hoc test can be visualized with the &lt;code&gt;plot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;par(mar = c(3, 8, 3, 3))
plot(post_test)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-25-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We see that the confidence intervals do not cross the zero line, which indicate that both the species Gentoo and Chinstrap are significantly different from the reference species Adelie.&lt;/p&gt;
&lt;p&gt;Note that in R, by default, the reference category for a &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factor variable&lt;/a&gt; is the first category in alphabetical order. This is the reason that, by default, the reference species is Adelie.&lt;/p&gt;
&lt;p&gt;The reference category can be changed with the &lt;code&gt;relevel()&lt;/code&gt; function (or with the &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#reordering-factors&#34;&gt;&lt;code&gt;{questionr}&lt;/code&gt; addin&lt;/a&gt;). Considering that we want Gentoo as the reference category instead of Adelie:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change reference category:
dat$species &amp;lt;- relevel(dat$species, ref = &amp;quot;Gentoo&amp;quot;)

# Check that Gentoo is the reference category:
levels(dat$species)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Gentoo&amp;quot;    &amp;quot;Adelie&amp;quot;    &amp;quot;Chinstrap&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Gentoo now being the first category of the three, it is indeed considered as the reference level.&lt;/p&gt;
&lt;p&gt;In order to perform the Dunnett’s test with the new reference we first need to rerun the ANOVA to take into account the new reference:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;res_aov2 &amp;lt;- aov(flipper_length_mm ~ species,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can then run the Dunett’s test with the new results of the ANOVA:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Dunnett&amp;#39;s test:
post_test &amp;lt;- glht(res_aov2,
  linfct = mcp(species = &amp;quot;Dunnett&amp;quot;)
)

summary(post_test)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	 Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Dunnett Contrasts
## 
## 
## Fit: aov(formula = flipper_length_mm ~ species, data = dat)
## 
## Linear Hypotheses:
##                         Estimate Std. Error t value Pr(&amp;gt;|t|)    
## Adelie - Gentoo == 0    -27.2333     0.8067  -33.76   &amp;lt;1e-10 ***
## Chinstrap - Gentoo == 0 -21.3635     1.0036  -21.29   &amp;lt;1e-10 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## (Adjusted p values reported -- single-step method)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;par(mar = c(3, 8, 3, 3))
plot(post_test)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-28-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the results above we conclude that Adelie and Chinstrap species are significantly different from Gentoo species in terms of flippers length (adjusted &lt;em&gt;p&lt;/em&gt;-values &amp;lt; 1e-10).&lt;/p&gt;
&lt;p&gt;Note that even if your study does not have a reference group which you can compare to the other groups, it is still often better to do multiple comparisons determined by some research questions than to do all-pairwise tests. By reducing the number of post-hoc comparisons to what is necessary only, and no more, you maximize the statistical power.&lt;a href=&#34;#fn8&#34; class=&#34;footnote-ref&#34; id=&#34;fnref8&#34;&gt;&lt;sup&gt;8&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;other-p-values-adjustment-methods&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Other &lt;em&gt;p&lt;/em&gt;-values adjustment methods&lt;/h2&gt;
&lt;p&gt;For the interested readers, note that you can use other &lt;em&gt;p&lt;/em&gt;-values adjustment methods by using the &lt;code&gt;pairwise.t.test()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pairwise.t.test(dat$flipper_length_mm, dat$species,
  p.adjust.method = &amp;quot;holm&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Pairwise comparisons using t tests with pooled SD 
## 
## data:  dat$flipper_length_mm and dat$species 
## 
##           Gentoo  Adelie 
## Adelie    &amp;lt; 2e-16 -      
## Chinstrap &amp;lt; 2e-16 3.8e-09
## 
## P value adjustment method: holm&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default, the Holm method is applied but other methods exist. See &lt;code&gt;?p.adjust&lt;/code&gt; for all available options.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization-of-anova-and-post-hoc-tests-on-the-same-plot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Visualization of ANOVA and post-hoc tests on the same plot&lt;/h1&gt;
&lt;p&gt;If you are interested in including results of ANOVA and post-hoc tests on the same plot (directly on the boxplots), here are two pieces of code which may be of interest to you.&lt;/p&gt;
&lt;p&gt;The first one is edited by me based on the code found in this &lt;a href=&#34;http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Edit from here
x &amp;lt;- which(names(dat) == &amp;quot;species&amp;quot;) # name of grouping variable
y &amp;lt;- which(
  names(dat) == &amp;quot;flipper_length_mm&amp;quot; # names of variables to test
)
method1 &amp;lt;- &amp;quot;anova&amp;quot; # one of &amp;quot;anova&amp;quot; or &amp;quot;kruskal.test&amp;quot;
method2 &amp;lt;- &amp;quot;t.test&amp;quot; # one of &amp;quot;wilcox.test&amp;quot; or &amp;quot;t.test&amp;quot;
my_comparisons &amp;lt;- list(c(&amp;quot;Chinstrap&amp;quot;, &amp;quot;Adelie&amp;quot;), c(&amp;quot;Gentoo&amp;quot;, &amp;quot;Adelie&amp;quot;), c(&amp;quot;Gentoo&amp;quot;, &amp;quot;Chinstrap&amp;quot;)) # comparisons for post-hoc tests
# Edit until here


# Edit at your own risk
library(ggpubr)
for (i in y) {
  for (j in x) {
    p &amp;lt;- ggboxplot(dat,
      x = colnames(dat[j]), y = colnames(dat[i]),
      color = colnames(dat[j]),
      legend = &amp;quot;none&amp;quot;,
      palette = &amp;quot;npg&amp;quot;,
      add = &amp;quot;jitter&amp;quot;
    )
    print(
      p + stat_compare_means(aes(label = paste0(after_stat(method), &amp;quot;, p-value = &amp;quot;, after_stat(p.format))),
        method = method1, label.y = max(dat[, i], na.rm = TRUE)
      )
      + stat_compare_means(comparisons = my_comparisons, method = method2, label = &amp;quot;p.format&amp;quot;) # remove if p-value of ANOVA or Kruskal-Wallis test &amp;gt;= alpha
    )
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-30-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;And the second method is from the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggstatsplot)

ggbetweenstats(
  data = dat,
  x = species,
  y = flipper_length_mm,
  type = &amp;quot;parametric&amp;quot;, # ANOVA or Kruskal-Wallis
  var.equal = TRUE, # ANOVA or Welch ANOVA
  plot.type = &amp;quot;box&amp;quot;,
  pairwise.comparisons = TRUE,
  pairwise.display = &amp;quot;significant&amp;quot;,
  centrality.plotting = FALSE,
  bf.message = FALSE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-10-12-anova-in-r_files/figure-html/unnamed-chunk-31-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see on the above plot, boxplots by species are presented together with &lt;em&gt;p&lt;/em&gt;-values of the ANOVA (after &lt;code&gt;p =&lt;/code&gt; in the subtitle of the plot) and &lt;em&gt;p&lt;/em&gt;-values of the post-hoc tests (above each comparison).&lt;/p&gt;
&lt;p&gt;Besides the fact that these methods can be used to combine a visual representation and statistical results on the same plot, they also have the advantage that you can perform multiple ANOVA tests at once. See more information in this &lt;a href=&#34;https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Summary&lt;/h1&gt;
&lt;p&gt;In this article, we reviewed the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#aim-and-hypotheses-of-anova&#34;&gt;goals and hypotheses&lt;/a&gt; of an ANOVA, what are the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#underlying-assumptions-of-anova&#34;&gt;assumptions&lt;/a&gt; which need to be verified before being able to trust the results (namely, independence, normality and homogeneity), we then showed &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#anova-in-r&#34;&gt;how to do an ANOVA in R&lt;/a&gt; and how to &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#interpretations-of-anova-results&#34;&gt;interpret the results&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;An article about ANOVA would not be complete without discussing about &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#post-hoc-test&#34;&gt;post-hoc tests&lt;/a&gt;, and in particular, the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#tukey-hsd-test&#34;&gt;Tukey HSD&lt;/a&gt;—to compare all groups—and the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#dunnetts-test&#34;&gt;Dunnett’s&lt;/a&gt; test—to compare a reference group to all other groups.&lt;/p&gt;
&lt;p&gt;Last but not least, we showed how to &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#visualization-of-anova-and-post-hoc-tests&#34;&gt;visualize&lt;/a&gt; the data and the results of the ANOVA and post-hoc tests in the same plot.&lt;/p&gt;
&lt;p&gt;Thanks for reading. See this &lt;a href=&#34;https://statsandr.com/blog/how-to-one-way-anova-by-hand/&#34;&gt;tutorial&lt;/a&gt; if you would like to learn how to do an ANOVA by hand.&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;p&gt;&lt;em&gt;(Note that this article is available for download on my &lt;a href=&#34;https://statsandr.gumroad.com/&#34;&gt;Gumroad page&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-hsu1996multiple&#34; class=&#34;csl-entry&#34;&gt;
Hsu, Jason. 1996. &lt;em&gt;Multiple Comparisons: Theory and Methods&lt;/em&gt;. CRC Press.
&lt;/div&gt;
&lt;div id=&#34;ref-stevens2013intermediate&#34; class=&#34;csl-entry&#34;&gt;
Stevens, James P. 2013. &lt;em&gt;Intermediate Statistics: A Modern Approach&lt;/em&gt;. Routledge.
&lt;/div&gt;
&lt;/div&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;Note that it is called &lt;em&gt;one-way&lt;/em&gt; or &lt;em&gt;one-factor&lt;/em&gt; ANOVA because the means relate to the different modalities of a single independent variable, or factor.&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;Residuals (denoted &lt;span class=&#34;math inline&#34;&gt;\(\epsilon\)&lt;/span&gt;) are the differences between the observed values of the dependent variable (&lt;span class=&#34;math inline&#34;&gt;\(y\)&lt;/span&gt;) and the predicted values (&lt;span class=&#34;math inline&#34;&gt;\(\hat{y}\)&lt;/span&gt;). In the context of ANOVA, residuals correspond to the differences between the observed values and the mean of all values for that group.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;&lt;span class=&#34;citation&#34;&gt;Stevens (&lt;a href=&#34;#ref-stevens2013intermediate&#34;&gt;2013&lt;/a&gt;)&lt;/span&gt; wrote, in p. 57, “Numerous studies have examined the effect of violations of assumptions in ANOVA, and an excellent summary of this literature has been provided by Glass, Peckham, and Sanders (1972). Their review indicates that non normality has only a slight effect on the type I error rate, even for very skewed or kurtotic distributions. For example, the actual &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;s for some very non-normal populations were only .055 or .06: very minor deviations from the nominal level of .05. […] The basic reason is the &lt;em&gt;Central Limit Theorem&lt;/em&gt;, which states that the sum of independent observations having any distribution whatsoever approaches a normal distribution as the number of observations increases. To be somewhat more specific, Bock (1975) notes,”even for distributions which depart markedly from normality, sums of 50 or more observations approximate to normality. For moderately non-normal distributions the approximation is good with as few as 10 to 20 observations” (p. 111). Now since the sums of independent observations approach normality rapidly, so do the means, and the sampling distribution of &lt;em&gt;F&lt;/em&gt; is based on means. Thus the sampling distribution of &lt;em&gt;F&lt;/em&gt; is only slightly affected, and therefore the critical values when sampling from normal and non-normal distributions will not differ by much. Lack of normality due to skewness also has only a slight effect on power (a few hundredths).”&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;As long as you use the Kruskal-Wallis test to, &lt;em&gt;in fine&lt;/em&gt;, compare groups, homoscedasticity is not required. If you wish to compare medians, the Kruskal-Wallis test requires homoscedasticity. See more information about the difference in this &lt;a href=&#34;https://influentialpoints.com/Training/Kruskal-Wallis_ANOVA_use_and_misuse.htm&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;Note that, as discussed in the comments at the end of the article, post-hoc tests can under some circumstances be done directly (without an ANOVA). See the comments or &lt;span class=&#34;citation&#34;&gt;Hsu (&lt;a href=&#34;#ref-hsu1996multiple&#34;&gt;1996&lt;/a&gt;)&lt;/span&gt; for more details.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;Note that you could in principle apply the Bonferroni correction to all tests. For example, in the example above, with 3 tests and a global desired significance level of &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; = 0.05, we would only reject a null hypothesis if the &lt;em&gt;p&lt;/em&gt;-value is less than &lt;span class=&#34;math inline&#34;&gt;\(\frac{0.05}{3}\)&lt;/span&gt; = 0.0167. This method is, however, known to be quite conservative, leading to a potentially high rate of false negatives.&lt;a href=&#34;#fnref6&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn7&#34;&gt;&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-values are adjusted to keep the global significance level to the desired level.&lt;a href=&#34;#fnref7&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn8&#34;&gt;&lt;p&gt;Thanks Michael Friendly for this suggestion.&lt;a href=&#34;#fnref8&#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>Graphics in R with ggplot2</title>
      <link>https://statsandr.com/blog/graphics-in-r-with-ggplot2/</link>
      <pubDate>Fri, 21 Aug 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/graphics-in-r-with-ggplot2/</guid>
      <description>
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/htmltools-fill/fill.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/plotly-binding/plotly.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/typedarray/typedarray.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/jquery/jquery.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/crosstalk/css/crosstalk.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/crosstalk/js/crosstalk.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/plotly-htmlwidgets-css/plotly-htmlwidgets.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/plotly-main/plotly-latest.min.js&#34;&gt;&lt;/script&gt;

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#basic-principles-of-ggplot2&#34; id=&#34;toc-basic-principles-of-ggplot2&#34;&gt;Basic principles of &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#create-plots-with-ggplot2&#34; id=&#34;toc-create-plots-with-ggplot2&#34;&gt;Create plots with &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#scatter-plot&#34; id=&#34;toc-scatter-plot&#34;&gt;Scatter plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#line-plot&#34; id=&#34;toc-line-plot&#34;&gt;Line plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-line-and-points&#34; id=&#34;toc-combination-of-line-and-points&#34;&gt;Combination of line and points&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#histogram&#34; id=&#34;toc-histogram&#34;&gt;Histogram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#density-plot&#34; id=&#34;toc-density-plot&#34;&gt;Density plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-histogram-and-densities&#34; id=&#34;toc-combination-of-histogram-and-densities&#34;&gt;Combination of histogram and densities&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#dotplot&#34; id=&#34;toc-dotplot&#34;&gt;Dotplot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#boxplot&#34; id=&#34;toc-boxplot&#34;&gt;Boxplot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#barplot&#34; id=&#34;toc-barplot&#34;&gt;Barplot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#raincloud-plot&#34; id=&#34;toc-raincloud-plot&#34;&gt;Raincloud plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#further-personalization&#34; id=&#34;toc-further-personalization&#34;&gt;Further personalization&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#title-and-axis-labels&#34; id=&#34;toc-title-and-axis-labels&#34;&gt;Title and axis labels&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#axis-ticks&#34; id=&#34;toc-axis-ticks&#34;&gt;Axis ticks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#log-transformations&#34; id=&#34;toc-log-transformations&#34;&gt;Log transformations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#limits&#34; id=&#34;toc-limits&#34;&gt;Limits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scales-for-better-axis-formats&#34; id=&#34;toc-scales-for-better-axis-formats&#34;&gt;Scales for better axis formats&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#legend&#34; id=&#34;toc-legend&#34;&gt;Legend&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#shape-color-size-and-transparency&#34; id=&#34;toc-shape-color-size-and-transparency&#34;&gt;Shape, color, size and transparency&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#text-and-labels&#34; id=&#34;toc-text-and-labels&#34;&gt;Text and labels&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#smooth-and-regression-lines&#34; id=&#34;toc-smooth-and-regression-lines&#34;&gt;Smooth and regression lines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#facets&#34; id=&#34;toc-facets&#34;&gt;Facets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#themes&#34; id=&#34;toc-themes&#34;&gt;Themes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interactive-plot-with-plotly&#34; id=&#34;toc-interactive-plot-with-plotly&#34;&gt;Interactive plot with &lt;code&gt;{plotly}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combine-plots-with-patchwork&#34; id=&#34;toc-combine-plots-with-patchwork&#34;&gt;Combine plots with &lt;code&gt;{patchwork}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#flip-coordinates&#34; id=&#34;toc-flip-coordinates&#34;&gt;Flip coordinates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#save-plot&#34; id=&#34;toc-save-plot&#34;&gt;Save plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#managing-dates&#34; id=&#34;toc-managing-dates&#34;&gt;Managing dates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#highlight-data-with-gghighlight&#34; id=&#34;toc-highlight-data-with-gghighlight&#34;&gt;Highlight data with &lt;code&gt;{gghighlight}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#tip&#34; id=&#34;toc-tip&#34;&gt;Tip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#to-go-further&#34; id=&#34;toc-to-go-further&#34;&gt;To go further&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;center&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/graphics-in-r-with-ggplot2.png&#34; style=&#34;width:50.0%&#34; /&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that this article is inspired from the lecture notes of Prof. Anouar El Ghouch and my personal notes as teaching assistant for his course entitled “Statistics and data sciences with R: Advanced programming” given at UCLouvain.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;R is known to be a really powerful programming language when it comes to graphics and visualizations (in addition to &lt;a href=&#34;https://statsandr.com/tags/statistics/&#34;&gt;statistics&lt;/a&gt; and data science of course!).&lt;/p&gt;
&lt;p&gt;To keep it short, graphics in R can be done in three ways, via the:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;{graphics}&lt;/code&gt; package (the base graphics in R, loaded by default)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{lattice}&lt;/code&gt; package which adds more functionalities to the base package&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; package (which needs to be &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;installed and loaded&lt;/a&gt; beforehand)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The &lt;code&gt;{graphics}&lt;/code&gt; package comes with a large choice of plots (such as &lt;code&gt;plot&lt;/code&gt;, &lt;code&gt;hist&lt;/code&gt;, &lt;code&gt;barplot&lt;/code&gt;, &lt;code&gt;boxplot&lt;/code&gt;, &lt;code&gt;pie&lt;/code&gt;, &lt;code&gt;mosaicplot&lt;/code&gt;, etc.) and additional related features (e.g., &lt;code&gt;abline&lt;/code&gt;, &lt;code&gt;lines&lt;/code&gt;, &lt;code&gt;legend&lt;/code&gt;, &lt;code&gt;mtext&lt;/code&gt;, &lt;code&gt;rect&lt;/code&gt;, etc.). It is often the preferred way to draw plots for most R users, and in particular for beginners to intermediate users.&lt;/p&gt;
&lt;p&gt;Since its creation in 2005 by Hadley Wickham, &lt;strong&gt;&lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/strong&gt; has grown in use to become one of the most popular R packages and the &lt;strong&gt;most popular package for graphics and data visualizations&lt;/strong&gt;. The &lt;code&gt;{ggplot2}&lt;/code&gt; package is a much more modern approach to creating professional-quality graphics. More information about the package can be found at &lt;a href=&#34;https://ggplot2.tidyverse.org/&#34; target=&#34;_blank&#34;&gt;ggplot2.tidyverse.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this article, we will see how to create common plots such as scatter plots, line plots, histograms, boxplots, barplots, density plots in R with this package. If you are unfamiliar with any of these types of graph, you will find more information about each one (when to use it, its purpose, what does it show, etc.) in my article about &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics in R&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;To illustrate plots with the &lt;code&gt;{ggplot2}&lt;/code&gt; package we will use the &lt;code&gt;mpg&lt;/code&gt; dataset available in the package.&lt;/p&gt;
&lt;p&gt;The dataset contains observations collected by the US Environmental Protection Agency on fuel economy from 1999 to 2008 for 38 popular models of cars (run &lt;code&gt;?mpg&lt;/code&gt; for more information about the data):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)
dat &amp;lt;- ggplot2::mpg&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Before going further, let’s transform the &lt;code&gt;cyl&lt;/code&gt;, &lt;code&gt;drv&lt;/code&gt;, &lt;code&gt;fl&lt;/code&gt;, &lt;code&gt;year&lt;/code&gt; and &lt;code&gt;class&lt;/code&gt; variables in &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factor&lt;/a&gt; with the &lt;code&gt;transform()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- transform(dat,
  cyl = factor(cyl),
  drv = factor(drv),
  fl = factor(fl),
  year = factor(year),
  class = factor(class)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the interested reader, see more &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;data manipulation techniques in R&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;basic-principles-of-ggplot2&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Basic principles of &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;{ggplot2}&lt;/code&gt; package is based on the principles of “The Grammar of Graphics” (hence “gg” in the name of &lt;code&gt;{ggplot2}&lt;/code&gt;), that is, a coherent system for describing and building graphs. The main idea is to &lt;strong&gt;design a graphic as a succession of layers&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The main layers are:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The &lt;strong&gt;dataset&lt;/strong&gt; that contains the variables that we want to represent. This is done with the &lt;code&gt;ggplot()&lt;/code&gt; function and comes first.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;variable(s)&lt;/strong&gt; to represent on the x and/or y-axis, and the aesthetic elements (such as color, size, fill, shape and transparency) of the objects to be represented. This is done with the &lt;code&gt;aes()&lt;/code&gt; function (abbreviation of aesthetic).&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;type of graphical representation&lt;/strong&gt; (scatter plot, line plot, barplot, histogram, boxplot, etc.). This is done with the functions &lt;code&gt;geom_point()&lt;/code&gt;, &lt;code&gt;geom_line()&lt;/code&gt;, &lt;code&gt;geom_bar()&lt;/code&gt;, &lt;code&gt;geom_histogram()&lt;/code&gt;, &lt;code&gt;geom_boxplot()&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;If needed, additional layers (such as labels, annotations, scales, axis ticks, legends, themes, facets, etc.) can be added to personalize the plot.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To create a plot, we thus first need to specify the data in the &lt;code&gt;ggplot()&lt;/code&gt; function and then add the required layers such as the variables, the aesthetic elements and the type of plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(data) +
  aes(x = var_x, y = var_y) +
  geom_x()&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;data&lt;/code&gt; in &lt;code&gt;ggplot()&lt;/code&gt; is the name of the data frame which contains the variables &lt;code&gt;var_x&lt;/code&gt; and &lt;code&gt;var_y&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;+&lt;/code&gt; symbol is used to indicate the different layers that will be added to the plot. Make sure to write the &lt;code&gt;+&lt;/code&gt; &lt;em&gt;symbol at the end of the line&lt;/em&gt; of code and not at the beginning of the line, otherwise &lt;a href=&#34;https://statsandr.com/blog/top-10-errors-in-r/#forgetting-the-sign-in-ggplot2&#34;&gt;R throws an error&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The layer &lt;code&gt;aes()&lt;/code&gt; indicates what variables will be used in the plot and more generally, the aesthetic elements of the plot.&lt;/li&gt;
&lt;li&gt;Finally, &lt;code&gt;x&lt;/code&gt; in &lt;code&gt;geom_x()&lt;/code&gt; represents the type of plot.&lt;/li&gt;
&lt;li&gt;Other layers are usually not required unless we want to personalize the plot further.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that it is a good practice to write one line of code per layer to improve code readability.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;create-plots-with-ggplot2&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Create plots with &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;In the following sections we will show how to draw the following plots:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;scatter plot&lt;/li&gt;
&lt;li&gt;line plot&lt;/li&gt;
&lt;li&gt;histogram&lt;/li&gt;
&lt;li&gt;density plot&lt;/li&gt;
&lt;li&gt;dotplot&lt;/li&gt;
&lt;li&gt;boxplot&lt;/li&gt;
&lt;li&gt;barplot&lt;/li&gt;
&lt;li&gt;raincloud plot&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In order to focus on the construction of the different plots and the use of &lt;code&gt;{ggplot2}&lt;/code&gt;, we will restrict ourselves to drawing basic (yet beautiful) plots without unnecessary layers. For the sake of completeness, we will briefly discuss and illustrate different layers to further personalize a plot at the end of the article (see this &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/#further-personalization&#34;&gt;section&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Note that if you still struggle to create plots with &lt;code&gt;{ggplot2}&lt;/code&gt; after reading this tutorial, you may find the &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#esquisse&#34;&gt;{esquisse} addin&lt;/a&gt; useful. This addin allows you to &lt;strong&gt;interactively&lt;/strong&gt; (that is, by dragging and dropping variables) create plots with the &lt;code&gt;{ggplot2}&lt;/code&gt; package. Give it a try!&lt;/p&gt;
&lt;div id=&#34;scatter-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scatter plot&lt;/h2&gt;
&lt;p&gt;We start by creating a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#scatterplot&#34;&gt;scatter plot&lt;/a&gt; using &lt;code&gt;geom_point&lt;/code&gt;. Remember that a scatter plot is used to visualize the relation between two &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative variables&lt;/a&gt;.&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;We start by specifying the data:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) # data&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_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;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Then we add the variables to be represented with the &lt;code&gt;aes()&lt;/code&gt; function:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) + # data
  aes(x = displ, y = hwy) # variables&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_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;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Finally, we indicate the type of plot:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) + # data
  aes(x = displ, y = hwy) + # variables
  geom_point() # type of plot&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-6-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You will also sometimes see the aesthetic elements (&lt;code&gt;aes()&lt;/code&gt; with the variables) inside the &lt;code&gt;ggplot()&lt;/code&gt; function in addition to the dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mpg, aes(x = displ, y = hwy)) +
  geom_point()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-7-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This second method gives the exact same plot than the first method. I tend to prefer the first method over the second for better readability, but this is more a matter of taste so the choice is up to you.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Line plot&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#line-plot&#34;&gt;Line plots&lt;/a&gt;, particularly useful in time series or finance, can be created similarly but by using &lt;code&gt;geom_line()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = displ, y = hwy) +
  geom_line()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-8-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;(Note that this might not be the most appropriate plot since there are multiple points for each value of &lt;code&gt;displ&lt;/code&gt;, but this is just an example to show how to create a line plot.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-line-and-points&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Combination of line and points&lt;/h2&gt;
&lt;p&gt;An advantage of &lt;code&gt;{ggplot2}&lt;/code&gt; is the ability to combine several types of plots and its flexibility in designing it. For instance, we can add a line to a scatter plot by simply adding a layer to the initial scatter plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = displ, y = hwy) +
  geom_point() +
  geom_line() # add line&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-9-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Histogram&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; (useful to visualize distributions and detect potential &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;) can be plotted using &lt;code&gt;geom_histogram()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = hwy) +
  geom_histogram()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-10-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;By default, the number of bins is equal to 30. You can change this value using the &lt;code&gt;bins&lt;/code&gt; argument inside the &lt;code&gt;geom_histogram()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = hwy) +
  geom_histogram(bins = round(sqrt(nrow(dat))))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-11-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Here I specify the number of bins to be equal to the square root of the number of observations (following the square-root rule) but you can specify any integer number.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;density-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Density plot&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#density-plot&#34;&gt;Density plots&lt;/a&gt; can be created using &lt;code&gt;geom_density()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = hwy) +
  geom_density()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-12-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-histogram-and-densities&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Combination of histogram and densities&lt;/h2&gt;
&lt;p&gt;We can also superimpose a histogram and a density curve on the same plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = hwy, y = after_stat(density)) +
  geom_histogram() +
  geom_density()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-13-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Or superimpose several densities:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = hwy, color = drv, fill = drv) +
  geom_density(alpha = 0.25) # add transparency&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-14-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The argument &lt;code&gt;alpha = 0.25&lt;/code&gt; has been added for some transparency. More information about this argument can be found in this &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/#further-personalization&#34;&gt;section&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dotplot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Dotplot&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#dotplot&#34;&gt;dotplot&lt;/a&gt; in &lt;code&gt;{ggplot2}&lt;/code&gt; can be built with &lt;code&gt;geom_dotplot()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Dotplot for one variable
ggplot(dat) +
  aes(x = &amp;quot;&amp;quot;, y = hwy) +
  geom_dotplot(binaxis = &amp;quot;y&amp;quot;, stackdir = &amp;quot;center&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-15-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Dotplot by factor
ggplot(dat) +
  aes(x = drv, y = hwy) +
  geom_dotplot(
    binaxis = &amp;quot;y&amp;quot;, stackdir = &amp;quot;center&amp;quot;,
    dotsize = 0.75 # decrease dot size
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-15-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Dotplots are more appropriate with small samples (because the plot may be hard to read with too many points). For large samples, a boxplot may be used.&lt;/p&gt;
&lt;p&gt;For the interested reader, see many personalization that is possible with a dotplot in this &lt;a href=&#34;http://www.sthda.com/english/wiki/ggplot2-dot-plot-quick-start-guide-r-software-and-data-visualization&#34; target=&#34;_blank&#34;&gt;tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;boxplot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Boxplot&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; (also very useful to visualize distributions and detect potential &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;) can be plotted using &lt;code&gt;geom_boxplot()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Boxplot for one variable
ggplot(dat) +
  aes(x = &amp;quot;&amp;quot;, y = hwy) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-16-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Boxplot by factor
ggplot(dat) +
  aes(x = drv, y = hwy) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-16-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It is also possible to plot the points on the boxplot with &lt;code&gt;geom_jitter()&lt;/code&gt;, and to vary the width of the boxes according to the size (i.e., the number of observations) of each level with &lt;code&gt;varwidth = TRUE&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = drv, y = hwy) +
  geom_boxplot(varwidth = TRUE) + # vary boxes width according to n obs.
  geom_jitter(alpha = 0.25, width = 0.2) # adds random noise and limit its width&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-17-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;geom_jitter()&lt;/code&gt; layer adds some random variation to each point in order to prevent them from overlapping (an issue known as overplotting).&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; Moreover, the &lt;code&gt;alpha&lt;/code&gt; argument adds some transparency to the points (see more in this &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/#further-personalization&#34;&gt;section&lt;/a&gt;) to keep the focus on the boxes and not on the points.&lt;/p&gt;
&lt;p&gt;Finally, it is also possible to divide boxplots into several panels according to the levels of a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative variable&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = drv, y = hwy) +
  geom_boxplot(varwidth = TRUE) + # vary boxes width according to n obs.
  geom_jitter(alpha = 0.25, width = 0.2) + # adds random noise and limit its width
  facet_wrap(~year) # divide into 2 panels&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-18-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For a visually more appealing plot, it is also possible to use some colors for the boxes depending on the x variable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = drv, y = hwy, fill = drv) + # add color to boxes with fill
  geom_boxplot(varwidth = TRUE) + # vary boxes width according to n obs.
  geom_jitter(alpha = 0.25, width = 0.2) + # adds random noise and limit its width
  facet_wrap(~year) + # divide into 2 panels
  theme(legend.position = &amp;quot;none&amp;quot;) # remove legend&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-19-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In that case, it best to remove the legend as it becomes redundant. See more information about the legend in this &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/#legend&#34;&gt;section&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are unhappy with the default colors provided in &lt;code&gt;{ggplot2}&lt;/code&gt;, you can change them manually with the &lt;code&gt;scale_fill_manual()&lt;/code&gt; layer:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = drv, y = hwy, fill = drv) + # add color to boxes with fill
  geom_boxplot(varwidth = TRUE) + # vary boxes width according to n obs.
  geom_jitter(alpha = 0.25, width = 0.2) + # adds random noise and limit its width
  facet_wrap(~year) + # divide into 2 panels
  theme(legend.position = &amp;quot;none&amp;quot;) + # remove legend
  scale_fill_manual(values = c(&amp;quot;darkred&amp;quot;, &amp;quot;darkgreen&amp;quot;, &amp;quot;steelblue&amp;quot;)) # change fill color manually&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-20-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;barplot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Barplot&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt; (useful to visualize qualitative variables) can be plotted using &lt;code&gt;geom_bar()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = drv) +
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-21-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Bars’ heights correspond to the observed frequencies (i.e., the number of observations) for each level of the variable of interest (&lt;code&gt;drv&lt;/code&gt; in our case).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: by default, the order of the bars follows the initial order (by alphabetical order or numerical order if you did not change it). If you want to order the levels by frequency (largest first), use the &lt;code&gt;fct_infreq()&lt;/code&gt; function from the &lt;code&gt;{forcats}&lt;/code&gt; package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(forcats)

ggplot(dat) +
  aes(x = fct_infreq(drv)) + # order by frequency
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-22-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you want to order levels in an increasing order (i.e., category with the smallest frequency first), use the &lt;code&gt;fct_rev()&lt;/code&gt; in addition to the &lt;code&gt;fct_infreq()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = fct_rev(fct_infreq(drv))) + # order by frequency
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-23-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;(Label for the x-axis can then easily be edited with the &lt;code&gt;labs()&lt;/code&gt; function. See &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/#title-and-axis-labels&#34;&gt;below&lt;/a&gt; for more information.)&lt;/p&gt;
&lt;p&gt;Again, for a more appealing plot, we can add some colors to the bars with the &lt;code&gt;fill&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = drv, fill = drv) + # add colors to bars
  geom_bar() +
  theme(legend.position = &amp;quot;none&amp;quot;) # remove legend&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-24-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We can also create a barplot with two qualitative variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = drv, fill = year) + # fill by years
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-25-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In order to compare proportions across groups, it is best to make each bar the same height using &lt;code&gt;position = &#34;fill&#34;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  geom_bar(aes(x = drv, fill = year), position = &amp;quot;fill&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-26-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To draw the bars next to each other for each group, use &lt;code&gt;position = &#34;dodge&#34;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  geom_bar(aes(x = drv, fill = year), position = &amp;quot;dodge&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-27-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;raincloud-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Raincloud plot&lt;/h2&gt;
&lt;p&gt;A raincloud plot is a graph that combines 3 visualizations:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;a density plot,&lt;/li&gt;
&lt;li&gt;a boxplot,&lt;/li&gt;
&lt;li&gt;and the raw data in the form of a dotplot or jittered points.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The advantage of this plot is that it illustrates, &lt;strong&gt;all at once&lt;/strong&gt;, the distribution (with the density curve), the summary measures (first, second and third &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#first-and-third-quartile&#34;&gt;quartiles&lt;/a&gt;, and maximum/mininum without &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt; thanks to the boxplot) and the number of observations (either via a dotplot or via jittered points).&lt;/p&gt;
&lt;p&gt;Let’s illustrate the raincloud plot, first with jittered points (more appropriate with large samples):&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;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tidyverse)
library(ggdist)

# density plot:
dat %&amp;gt;%
  ggplot(aes(x = drv, y = hwy, fill = drv)) +
  stat_halfeye(
    adjust = 0.5, # set the smoothing parameter
    width = 0.5, # set the height of the curves
    justification = -0.2, # move curves to the right
    .width = 0, point_colour = NA # remove interval present by default
  ) +
  # boxplot:
  geom_boxplot(
    width = 0.12, # width of boxes
    outlier.color = NA, # remove color of outliers
    alpha = 0.5 # add transparency
  ) +
  # jittered points:
  geom_point(aes(colour = drv), # add color on points
    size = 1.3, # size of points
    alpha = .3, # add transparency
    position = position_jitter( # obtain shifted points
      seed = 1, # set seed for same random representation
      width = .09 # manage the width of the offset
    )
  ) +
  # further personalization:
  coord_flip() + # rotate plot
  theme(legend.position = &amp;quot;none&amp;quot;) # remove legend&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-28-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now the same chart but with dotplots this time (more appropriate with small &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;samples&lt;/a&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# density plot:
dat %&amp;gt;%
  sample_n(100) %&amp;gt;% # random sample of size 100
  ggplot(aes(x = drv, y = hwy, fill = drv)) +
  stat_halfeye(
    adjust = 0.5, # set the smoothing parameter
    width = 0.5, # set the height of the curves
    justification = -0.2, # move curves to the right
    .width = 0, point_colour = NA # remove interval present by default
  ) +
  # boxplot:
  geom_boxplot(
    width = 0.12, # width of boxes
    outlier.color = NA, # remove color of outliers
    alpha = 0.5 # add transparency
  ) +
  # dotplot:
  stat_dots(
    dotsize = 0.5, # size of points
    side = &amp;quot;left&amp;quot;, # place points on opposite side of density curve
    justification = 1.1, # move points away from boxplot
    binwidth = 1 # group points together
  ) +
  # further personalization:
  coord_flip() + # rotate plot
  theme(legend.position = &amp;quot;none&amp;quot;) # remove legend&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-29-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The code is much longer compared to the other plots, but the only line(s) to edit to adapt to your dataset is the aesthetics (&lt;code&gt;aes()&lt;/code&gt;). The rest is mainly adjustments that should not be changed.&lt;/p&gt;
&lt;p&gt;You may have notice that at the end of the code, there are some personalization which allow to improve the plot even further. The most common personalization are presented in the next section.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;further-personalization&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Further personalization&lt;/h2&gt;
&lt;div id=&#34;title-and-axis-labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title and axis labels&lt;/h3&gt;
&lt;p&gt;The first things to personalize in a plot is the labels to make the plot more informative to the audience. We can easily add a title, subtitle, caption and edit axis labels with the &lt;code&gt;labs()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p &amp;lt;- ggplot(dat) +
  aes(x = displ, y = hwy) +
  geom_point()

p + labs(
  title = &amp;quot;Fuel efficiency for 38 popular models of car&amp;quot;,
  subtitle = &amp;quot;Period 1999-2008&amp;quot;,
  caption = &amp;quot;Data: ggplot2::mpg. See more at statsandr.com&amp;quot;,
  x = &amp;quot;Engine displacement (litres)&amp;quot;,
  y = &amp;quot;Highway miles per gallon (mpg)&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-30-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see in the above code, you can save one or more layers of the plot in an object for later use.&lt;/p&gt;
&lt;p&gt;This way, you can save your “main” plot, and add more layers of personalization until you get the desired output. Here we saved the main scatter plot in an object called &lt;code&gt;p&lt;/code&gt; and we will refer to it for the subsequent personalization.&lt;/p&gt;
&lt;p&gt;You can also edit the alignment, the size and the shape of the title and subtitle via the &lt;code&gt;theme()&lt;/code&gt; layer and the &lt;code&gt;element_text()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + labs(
  title = &amp;quot;Fuel efficiency for 38 popular models of car&amp;quot;,
  subtitle = &amp;quot;Period 1999-2008&amp;quot;,
  caption = &amp;quot;Data: ggplot2::mpg. See more at statsandr.com&amp;quot;,
  x = &amp;quot;Engine displacement (litres)&amp;quot;,
  y = &amp;quot;Highway miles per gallon (mpg)&amp;quot;
) +
  theme(
    plot.title = element_text(
      hjust = 0.5, # center
      size = 12,
      color = &amp;quot;steelblue&amp;quot;,
      face = &amp;quot;bold&amp;quot;
    ),
    plot.subtitle = element_text(
      hjust = 0.5, # center
      size = 10,
      color = &amp;quot;gray&amp;quot;,
      face = &amp;quot;italic&amp;quot;
    )
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-31-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If the title or subtitle is long and you want to divide it into multiple lines, use &lt;code&gt;\n&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + labs(
  title = &amp;quot;Fuel efficiency for 38 popular \n models of car&amp;quot;,
  subtitle = &amp;quot;Period 1999-2008&amp;quot;,
  caption = &amp;quot;Data: ggplot2::mpg. See more at statsandr.com&amp;quot;,
  x = &amp;quot;Engine displacement (litres)&amp;quot;,
  y = &amp;quot;Highway miles per gallon (mpg)&amp;quot;
) +
  theme(
    plot.title = element_text(
      hjust = 0.5, # center
      size = 12,
      color = &amp;quot;steelblue&amp;quot;,
      face = &amp;quot;bold&amp;quot;
    ),
    plot.subtitle = element_text(
      hjust = 0.5, # center
      size = 10,
      color = &amp;quot;gray&amp;quot;,
      face = &amp;quot;italic&amp;quot;
    )
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-32-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-ticks&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Axis ticks&lt;/h3&gt;
&lt;p&gt;Axis ticks can be adjusted using &lt;code&gt;scale_x_continuous()&lt;/code&gt; and &lt;code&gt;scale_y_continuous()&lt;/code&gt; for the x and y-axis, respectively:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Adjust ticks
p + scale_x_continuous(breaks = seq(from = 1, to = 7, by = 0.5)) + # x-axis
  scale_y_continuous(breaks = seq(from = 10, to = 45, by = 5)) # y-axis&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-33-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;log-transformations&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Log transformations&lt;/h3&gt;
&lt;p&gt;In some cases, it is useful to plot the log transformation of the variables. This can be done with the &lt;code&gt;scale_x_log10()&lt;/code&gt; and &lt;code&gt;scale_y_log10()&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + scale_x_log10() +
  scale_y_log10()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-34-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;limits&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Limits&lt;/h3&gt;
&lt;p&gt;The most convenient way to control the limits of the plot is to use again the &lt;code&gt;scale_x_continuous()&lt;/code&gt; and &lt;code&gt;scale_y_continuous()&lt;/code&gt; functions in addition to the &lt;code&gt;limits&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + scale_x_continuous(limits = c(3, 6)) +
  scale_y_continuous(limits = c(20, 30))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-35-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It is also possible to simply take a subset of the dataset with the &lt;code&gt;subset()&lt;/code&gt; or &lt;code&gt;filter()&lt;/code&gt; function. See how to &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/#subset-a-data-frame&#34;&gt;subset a dataset&lt;/a&gt; if you need a reminder.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scales-for-better-axis-formats&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scales for better axis formats&lt;/h3&gt;
&lt;p&gt;Depending on your data, it is possible to format axes in a certain way with the &lt;code&gt;{scales}&lt;/code&gt; package. The format I use the most is &lt;code&gt;comma&lt;/code&gt; which formats large numbers in a more-readable way.&lt;/p&gt;
&lt;p&gt;For this example, we multiply both variables by 10000 to have larger numbers and then we apply the format to the y-axis (only to the y-axis so we can see the difference with the x-axis which is not formatted):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = displ * 10000, y = hwy * 10000) +
  geom_point() +
  scale_y_continuous(labels = scales::comma) # format y-axis&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-36-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, numbers on the y-axis are displayed as 200,000, 300,000, etc. instead of 200000, 300000, etc., which makes it more readable.&lt;/p&gt;
&lt;p&gt;Another common format is &lt;code&gt;percent&lt;/code&gt; to display numbers as percentages:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = displ, y = hwy / 100) +
  geom_point() +
  scale_y_continuous(labels = scales::percent) # format y-axis&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-37-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;These two formats make large numbers and percentages easier to read. Other formats are possible such as using dollar signs, dates etc. See more information in the &lt;a href=&#34;https://scales.r-lib.org/&#34; target=&#34;_blank&#34;&gt;package’s documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;legend&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Legend&lt;/h3&gt;
&lt;p&gt;By default, the legend is located to the right side of the plot (when there is a legend to be displayed of course).&lt;/p&gt;
&lt;p&gt;To control the position of the legend, we need to use the &lt;code&gt;theme()&lt;/code&gt; function in addition to the &lt;code&gt;legend.position&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + aes(color = class) +
  theme(legend.position = &amp;quot;top&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-38-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Replace &lt;code&gt;&#34;top&#34;&lt;/code&gt; by &lt;code&gt;&#34;left&#34;&lt;/code&gt; or &lt;code&gt;&#34;bottom&#34;&lt;/code&gt; to change its position and by &lt;code&gt;&#34;none&#34;&lt;/code&gt; to remove it.&lt;/p&gt;
&lt;p&gt;The title of the legend can be edited with the &lt;code&gt;labs()&lt;/code&gt; layer:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + aes(color = class) +
  labs(color = &amp;quot;Car&amp;#39;s class&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-39-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that the argument inside &lt;code&gt;labs()&lt;/code&gt; must match the one inside the &lt;code&gt;aes()&lt;/code&gt; layer (in this case: &lt;code&gt;color&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;The title of the legend can also be removed with &lt;code&gt;legend.title = element_blank()&lt;/code&gt; inside the &lt;code&gt;theme()&lt;/code&gt; layer:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + aes(color = class) +
  theme(
    legend.title = element_blank(),
    legend.position = &amp;quot;bottom&amp;quot;
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-40-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The legend now appears at the bottom of the plot, without the legend title.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;shape-color-size-and-transparency&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Shape, color, size and transparency&lt;/h3&gt;
&lt;p&gt;There are a very large number of options to improve the quality of the plot or to add additional information. These include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;shape,&lt;/li&gt;
&lt;li&gt;size,&lt;/li&gt;
&lt;li&gt;color, and&lt;/li&gt;
&lt;li&gt;alpha (transparency).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can for instance change the shape of all points in a scatter plot by adding &lt;code&gt;shape&lt;/code&gt; to &lt;code&gt;geom_point()&lt;/code&gt;, or vary the shape according to the values taken by another variable (in that case, the &lt;code&gt;shape&lt;/code&gt; argument must be inside &lt;code&gt;aes()&lt;/code&gt;):&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change shape of all points
ggplot(dat) +
  aes(x = displ, y = hwy) +
  geom_point(shape = 4)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-41-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change shape of points based on a categorical variable
ggplot(dat) +
  aes(x = displ, y = hwy, shape = drv) +
  geom_point()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-41-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Following the same principle, we can modify the color, size and transparency of the points based on a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative&lt;/a&gt; or &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative&lt;/a&gt; variable. Here are some examples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p &amp;lt;- ggplot(dat) +
  aes(x = displ, y = hwy) +
  geom_point()

# Change color for all points
p + geom_point(color = &amp;quot;steelblue&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-42-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change color based on a qualitative variable
p + aes(color = drv)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-42-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change color based on a quantitative variable
p + aes(color = cty)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-42-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change color based on a criterion (median of cty variable)
p + aes(color = cty &amp;gt; median(cty))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-42-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change size of all points
p + geom_point(size = 4)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-42-5.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change size of points based on a quantitative variable
p + aes(size = cty)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-42-6.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change transparency based on a quantitative variable
p + aes(alpha = cty)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-42-7.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We can of course mix several options (shape, color, size, alpha) to build more complex graphics:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + geom_point(size = 0.5) +
  aes(color = drv, shape = year, alpha = cty)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-43-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you are unhappy with the default colors, you can change them manually with the &lt;code&gt;scale_colour_manual()&lt;/code&gt; layer (for qualitative variables) and the &lt;code&gt;scale_colour_gradient2()&lt;/code&gt; layer (for quantitative variables):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change color based on a qualitative variable
p + aes(color = drv) +
  scale_colour_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-44-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Change color based on a quantitative variable
p + aes(color = cty) +
  scale_colour_gradient2(
    low = &amp;quot;green&amp;quot;,
    mid = &amp;quot;gray&amp;quot;,
    high = &amp;quot;red&amp;quot;,
    midpoint = median(dat$cty)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-44-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For your information, you can emulate &lt;code&gt;{ggplot2}&lt;/code&gt; default color palette for a desired number of colors and produce a character vector of HEX colors. For example, with 4 colors:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(scales)
show_col(hue_pal()(4))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-45-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;text-and-labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Text and labels&lt;/h3&gt;
&lt;p&gt;To add a label on a point (for example the row number), we can use the &lt;code&gt;geom_text()&lt;/code&gt; and &lt;code&gt;aes()&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + geom_text(aes(label = rownames(dat)),
  check_overlap = TRUE,
  size = 2,
  vjust = -1
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-46-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To add text on the plot, we use the &lt;code&gt;annotate()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + annotate(&amp;quot;text&amp;quot;,
  x = 6,
  y = 40,
  label = &amp;quot;hwy and displ are \n negatively correlated \n (rho = -0.77, p-value &amp;lt; 0.001)&amp;quot;,
  size = 3
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-47-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Read the article on &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation coefficient and correlation test in R&lt;/a&gt; to see how I computed the correlation coefficient (rho) and the &lt;em&gt;p&lt;/em&gt;-value of the correlation test.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;smooth-and-regression-lines&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Smooth and regression lines&lt;/h3&gt;
&lt;p&gt;In a scatter plot, it is possible to add a smooth line fitted to the data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + geom_smooth()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-48-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the context of simple &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt;, it is often the case that the regression line is displayed on the plot.&lt;/p&gt;
&lt;p&gt;This can be done by adding &lt;code&gt;method = lm&lt;/code&gt; (&lt;code&gt;lm&lt;/code&gt; stands for linear model) in the &lt;code&gt;geom_smooth()&lt;/code&gt; layer:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + geom_smooth(method = lm)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-49-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It is also possible to draw a regression line for each level of a categorical variable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + aes(color = drv, shape = drv) +
  geom_smooth(method = lm, se = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-50-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;se = FALSE&lt;/code&gt; argument removes the confidence interval around the regression lines.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;facets&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Facets&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;facet_grid&lt;/code&gt; allows you to divide the same graphic into several panels according to the values of one or two qualitative variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# According to one variable
p + facet_grid(. ~ drv)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-51-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# According to 2 variables
p + facet_grid(drv ~ year)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-51-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It is then possible to add a regression line to each facet:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + facet_grid(. ~ drv) +
  geom_smooth(method = lm)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-52-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;facet_wrap()&lt;/code&gt; can also be used, as illustrated in this &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/#boxplot&#34;&gt;section&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;themes&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Themes&lt;/h3&gt;
&lt;p&gt;Several functions are available in the &lt;code&gt;{ggplot2}&lt;/code&gt; package to change the theme of the plot.&lt;/p&gt;
&lt;p&gt;The most common themes after the default theme (i.e., &lt;code&gt;theme_gray()&lt;/code&gt;) are the black and white (&lt;code&gt;theme_bw()&lt;/code&gt;), minimal (&lt;code&gt;theme_minimal()&lt;/code&gt;) and classic (&lt;code&gt;theme_classic()&lt;/code&gt;) themes:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Black and white theme
p + theme_bw()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-53-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Minimal theme
p + theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-53-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Classic theme
p + theme_classic()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-53-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;I tend to use the minimal theme for most of my &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt; reports as it brings out the patterns and points and not the layout of the plot, but again this is a matter of personal taste. See more themes at &lt;a href=&#34;https://ggplot2.tidyverse.org/reference/ggtheme.html&#34; target=&#34;_blank&#34;&gt;ggplot2.tidyverse.org/reference/ggtheme.html&lt;/a&gt; and in the &lt;code&gt;{ggthemes}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;In order to avoid having to change the theme for each plot you create, you can change the theme for the current R session using the &lt;code&gt;theme_set()&lt;/code&gt; function as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;theme_set(theme_minimal())&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;interactive-plot-with-plotly&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Interactive plot with &lt;code&gt;{plotly}&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;You can easily make your plots created with &lt;code&gt;{ggplot2}&lt;/code&gt; interactive with the &lt;code&gt;{plotly}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(plotly)
ggplotly(p + aes(color = year))&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;plotly html-widget html-fill-item&#34; id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:480px;&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;data&#34;:[{&#34;x&#34;:[1.8,1.8,2.7999999999999998,2.7999999999999998,1.8,1.8,2.7999999999999998,2.7999999999999998,2.7999999999999998,5.7000000000000002,5.7000000000000002,5.7000000000000002,5.7000000000000002,6.5,2.3999999999999999,3.1000000000000001,2.3999999999999999,3,3.2999999999999998,3.2999999999999998,3.7999999999999998,3.7999999999999998,3.8999999999999999,3.8999999999999999,5.2000000000000002,5.2000000000000002,3.8999999999999999,5.2000000000000002,5.9000000000000004,5.2000000000000002,5.2000000000000002,5.9000000000000004,4.5999999999999996,5.4000000000000004,4,4,4,5,4.2000000000000002,4.2000000000000002,4.5999999999999996,4.5999999999999996,5.4000000000000004,3.7999999999999998,3.7999999999999998,4.5999999999999996,4.5999999999999996,1.6000000000000001,1.6000000000000001,1.6000000000000001,1.6000000000000001,1.6000000000000001,2.3999999999999999,2.3999999999999999,2.5,2.5,2,2,4,4.7000000000000002,4,4.5999999999999996,5.4000000000000004,5.4000000000000004,4,5,2.3999999999999999,2.3999999999999999,3,3,3.2999999999999998,3.2999999999999998,3.1000000000000001,3.7999999999999998,3.7999999999999998,2.5,2.5,2.2000000000000002,2.2000000000000002,2.5,2.5,2.7000000000000002,2.7000000000000002,3.3999999999999999,3.3999999999999999,2.2000000000000002,2.2000000000000002,3,3,2.2000000000000002,2.2000000000000002,3,3,1.8,1.8,1.8,4.7000000000000002,2.7000000000000002,2.7000000000000002,3.3999999999999999,3.3999999999999999,2,2,2.7999999999999998,1.8999999999999999,2,2,2.7999999999999998,2.7999999999999998,1.8999999999999999,1.8999999999999999,2,2,1.8,1.8,2.7999999999999998,2.7999999999999998],&#34;y&#34;:[29,29,26,26,26,25,25,25,24,17,26,23,15,17,27,26,24,24,22,22,22,21,17,17,17,15,17,16,15,15,16,15,17,17,17,19,17,17,17,17,16,16,15,26,25,21,22,33,32,32,29,32,26,27,26,26,26,29,20,17,15,15,17,16,17,17,29,27,26,25,17,17,26,26,27,25,24,26,26,26,26,20,20,19,17,29,27,26,26,27,29,26,26,30,33,35,15,20,20,17,19,29,26,24,44,29,26,23,24,44,41,29,26,29,29,26,26],&#34;text&#34;:[&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 25&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 25&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 25&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 24&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.7&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.7&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.7&lt;br /&gt;hwy: 23&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.7&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 6.5&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 27&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.1&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 24&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.0&lt;br /&gt;hwy: 24&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 22&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 22&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.8&lt;br /&gt;hwy: 22&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.8&lt;br /&gt;hwy: 21&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.9&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.9&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.2&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.2&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.9&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.2&lt;br /&gt;hwy: 16&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.9&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.2&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.2&lt;br /&gt;hwy: 16&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.9&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.4&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 19&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.0&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.2&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.2&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 16&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 16&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.4&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.8&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.8&lt;br /&gt;hwy: 25&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 21&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 22&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.6&lt;br /&gt;hwy: 33&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.6&lt;br /&gt;hwy: 32&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.6&lt;br /&gt;hwy: 32&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.6&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.6&lt;br /&gt;hwy: 32&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 27&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 20&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.4&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.4&lt;br /&gt;hwy: 16&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 5.0&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 27&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.0&lt;br /&gt;hwy: 25&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.1&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.8&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.8&lt;br /&gt;hwy: 27&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 25&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 24&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.2&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.2&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.7&lt;br /&gt;hwy: 20&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.7&lt;br /&gt;hwy: 20&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.4&lt;br /&gt;hwy: 19&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.4&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.2&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.2&lt;br /&gt;hwy: 27&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.2&lt;br /&gt;hwy: 27&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.2&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 30&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 33&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 35&#34;,&#34;year: 1999&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 15&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.7&lt;br /&gt;hwy: 20&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.7&lt;br /&gt;hwy: 20&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.4&lt;br /&gt;hwy: 17&#34;,&#34;year: 1999&lt;br /&gt;displ: 3.4&lt;br /&gt;hwy: 19&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 24&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.9&lt;br /&gt;hwy: 44&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 23&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 24&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.9&lt;br /&gt;hwy: 44&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.9&lt;br /&gt;hwy: 41&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 29&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 26&#34;,&#34;year: 1999&lt;br /&gt;displ: 2.8&lt;br /&gt;hwy: 26&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;markers&#34;,&#34;marker&#34;:{&#34;autocolorscale&#34;:false,&#34;color&#34;:&#34;rgba(248,118,109,1)&#34;,&#34;opacity&#34;:1,&#34;size&#34;:5.6692913385826778,&#34;symbol&#34;:&#34;circle&#34;,&#34;line&#34;:{&#34;width&#34;:1.8897637795275593,&#34;color&#34;:&#34;rgba(248,118,109,1)&#34;}},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;1999&#34;,&#34;legendgroup&#34;:&#34;1999&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null},{&#34;x&#34;:[2,2,3.1000000000000001,2,2,3.1000000000000001,3.1000000000000001,3.1000000000000001,4.2000000000000002,5.2999999999999998,5.2999999999999998,5.2999999999999998,6,6.2000000000000002,6.2000000000000002,7,5.2999999999999998,5.2999999999999998,2.3999999999999999,3.5,3.6000000000000001,3.2999999999999998,3.2999999999999998,3.2999999999999998,3.7999999999999998,4,3.7000000000000002,3.7000000000000002,4.7000000000000002,4.7000000000000002,4.7000000000000002,4.7000000000000002,4.7000000000000002,4.7000000000000002,5.7000000000000002,4.7000000000000002,4.7000000000000002,4.7000000000000002,4.7000000000000002,4.7000000000000002,4.7000000000000002,5.7000000000000002,5.4000000000000004,4,4.5999999999999996,4.5999999999999996,5.4000000000000004,4,4,4.5999999999999996,4.5999999999999996,5.4000000000000004,1.8,1.8,1.8,2,2.3999999999999999,2.3999999999999999,3.2999999999999998,2,2,2.7000000000000002,2.7000000000000002,2.7000000000000002,3,3.7000000000000002,4.7000000000000002,4.7000000000000002,5.7000000000000002,6.0999999999999996,4.2000000000000002,4.4000000000000004,5.4000000000000004,4,4.5999999999999996,2.5,2.5,3.5,3.5,3.5,4,5.5999999999999996,3.7999999999999998,5.2999999999999998,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,4,4.7000000000000002,2.3999999999999999,2.3999999999999999,3.5,2.3999999999999999,2.3999999999999999,3.2999999999999998,1.8,1.8,5.7000000000000002,2.7000000000000002,4,4,2,2,2,2,2.5,2.5,2.5,2.5,2,2,3.6000000000000001],&#34;y&#34;:[31,30,27,28,27,25,25,25,23,20,15,20,17,26,25,24,19,14,30,29,26,24,24,17,23,23,19,18,19,19,12,17,12,17,18,16,12,17,17,16,12,17,18,19,19,17,17,26,24,23,22,20,34,36,36,29,30,31,28,28,27,24,24,24,22,19,12,19,18,14,18,18,18,19,19,31,32,27,26,25,20,18,28,25,27,25,26,23,25,27,25,27,20,17,31,31,28,31,31,27,37,35,18,22,18,20,29,29,29,29,29,29,28,29,28,29,26],&#34;text&#34;:[&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 31&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 30&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.1&lt;br /&gt;hwy: 27&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 28&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 27&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.1&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.1&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.1&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.2&lt;br /&gt;hwy: 23&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.3&lt;br /&gt;hwy: 20&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.3&lt;br /&gt;hwy: 15&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.3&lt;br /&gt;hwy: 20&#34;,&#34;year: 2008&lt;br /&gt;displ: 6.0&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 6.2&lt;br /&gt;hwy: 26&#34;,&#34;year: 2008&lt;br /&gt;displ: 6.2&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 7.0&lt;br /&gt;hwy: 24&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.3&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.3&lt;br /&gt;hwy: 14&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 30&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.5&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.6&lt;br /&gt;hwy: 26&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 24&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 24&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.8&lt;br /&gt;hwy: 23&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 23&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.7&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.7&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 12&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 12&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.7&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 16&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 12&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 16&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 12&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.7&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.4&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.4&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 26&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 24&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 23&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 22&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.4&lt;br /&gt;hwy: 20&#34;,&#34;year: 2008&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 34&#34;,&#34;year: 2008&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 36&#34;,&#34;year: 2008&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 36&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 30&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 31&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 28&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 28&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 27&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.7&lt;br /&gt;hwy: 24&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.7&lt;br /&gt;hwy: 24&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.7&lt;br /&gt;hwy: 24&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.0&lt;br /&gt;hwy: 22&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.7&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 12&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.7&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 6.1&lt;br /&gt;hwy: 14&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.2&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.4&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.4&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.6&lt;br /&gt;hwy: 19&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 31&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 32&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.5&lt;br /&gt;hwy: 27&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.5&lt;br /&gt;hwy: 26&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.5&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 20&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.6&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.8&lt;br /&gt;hwy: 28&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.3&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 27&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 26&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 23&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 27&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 25&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 27&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 20&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.7&lt;br /&gt;hwy: 17&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 31&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 31&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.5&lt;br /&gt;hwy: 28&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 31&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.4&lt;br /&gt;hwy: 31&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.3&lt;br /&gt;hwy: 27&#34;,&#34;year: 2008&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 37&#34;,&#34;year: 2008&lt;br /&gt;displ: 1.8&lt;br /&gt;hwy: 35&#34;,&#34;year: 2008&lt;br /&gt;displ: 5.7&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.7&lt;br /&gt;hwy: 22&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 18&#34;,&#34;year: 2008&lt;br /&gt;displ: 4.0&lt;br /&gt;hwy: 20&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 28&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.5&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 28&#34;,&#34;year: 2008&lt;br /&gt;displ: 2.0&lt;br /&gt;hwy: 29&#34;,&#34;year: 2008&lt;br /&gt;displ: 3.6&lt;br /&gt;hwy: 26&#34;],&#34;type&#34;:&#34;scatter&#34;,&#34;mode&#34;:&#34;markers&#34;,&#34;marker&#34;:{&#34;autocolorscale&#34;:false,&#34;color&#34;:&#34;rgba(0,191,196,1)&#34;,&#34;opacity&#34;:1,&#34;size&#34;:5.6692913385826778,&#34;symbol&#34;:&#34;circle&#34;,&#34;line&#34;:{&#34;width&#34;:1.8897637795275593,&#34;color&#34;:&#34;rgba(0,191,196,1)&#34;}},&#34;hoveron&#34;:&#34;points&#34;,&#34;name&#34;:&#34;2008&#34;,&#34;legendgroup&#34;:&#34;2008&#34;,&#34;showlegend&#34;:true,&#34;xaxis&#34;:&#34;x&#34;,&#34;yaxis&#34;:&#34;y&#34;,&#34;hoverinfo&#34;:&#34;text&#34;,&#34;frame&#34;:null}],&#34;layout&#34;:{&#34;margin&#34;:{&#34;t&#34;:23.305936073059364,&#34;r&#34;:7.3059360730593621,&#34;b&#34;:37.260273972602747,&#34;l&#34;:37.260273972602747},&#34;plot_bgcolor&#34;:&#34;rgba(235,235,235,1)&#34;,&#34;paper_bgcolor&#34;:&#34;rgba(255,255,255,1)&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.611872146118724},&#34;xaxis&#34;:{&#34;domain&#34;:[0,1],&#34;automargin&#34;:true,&#34;type&#34;:&#34;linear&#34;,&#34;autorange&#34;:false,&#34;range&#34;:[1.3300000000000001,7.2699999999999996],&#34;tickmode&#34;:&#34;array&#34;,&#34;ticktext&#34;:[&#34;2&#34;,&#34;3&#34;,&#34;4&#34;,&#34;5&#34;,&#34;6&#34;,&#34;7&#34;],&#34;tickvals&#34;:[2,3,4,5,6,7],&#34;categoryorder&#34;:&#34;array&#34;,&#34;categoryarray&#34;:[&#34;2&#34;,&#34;3&#34;,&#34;4&#34;,&#34;5&#34;,&#34;6&#34;,&#34;7&#34;],&#34;nticks&#34;:null,&#34;ticks&#34;:&#34;outside&#34;,&#34;tickcolor&#34;:&#34;rgba(51,51,51,1)&#34;,&#34;ticklen&#34;:3.6529680365296811,&#34;tickwidth&#34;:0.66417600664176002,&#34;showticklabels&#34;:true,&#34;tickfont&#34;:{&#34;color&#34;:&#34;rgba(77,77,77,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.68949771689498},&#34;tickangle&#34;:-0,&#34;showline&#34;:false,&#34;linecolor&#34;:null,&#34;linewidth&#34;:0,&#34;showgrid&#34;:true,&#34;gridcolor&#34;:&#34;rgba(255,255,255,1)&#34;,&#34;gridwidth&#34;:0.66417600664176002,&#34;zeroline&#34;:false,&#34;anchor&#34;:&#34;y&#34;,&#34;title&#34;:{&#34;text&#34;:&#34;displ&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.611872146118724}},&#34;hoverformat&#34;:&#34;.2f&#34;},&#34;yaxis&#34;:{&#34;domain&#34;:[0,1],&#34;automargin&#34;:true,&#34;type&#34;:&#34;linear&#34;,&#34;autorange&#34;:false,&#34;range&#34;:[10.4,45.600000000000001],&#34;tickmode&#34;:&#34;array&#34;,&#34;ticktext&#34;:[&#34;20&#34;,&#34;30&#34;,&#34;40&#34;],&#34;tickvals&#34;:[20,30,40],&#34;categoryorder&#34;:&#34;array&#34;,&#34;categoryarray&#34;:[&#34;20&#34;,&#34;30&#34;,&#34;40&#34;],&#34;nticks&#34;:null,&#34;ticks&#34;:&#34;outside&#34;,&#34;tickcolor&#34;:&#34;rgba(51,51,51,1)&#34;,&#34;ticklen&#34;:3.6529680365296811,&#34;tickwidth&#34;:0.66417600664176002,&#34;showticklabels&#34;:true,&#34;tickfont&#34;:{&#34;color&#34;:&#34;rgba(77,77,77,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.68949771689498},&#34;tickangle&#34;:-0,&#34;showline&#34;:false,&#34;linecolor&#34;:null,&#34;linewidth&#34;:0,&#34;showgrid&#34;:true,&#34;gridcolor&#34;:&#34;rgba(255,255,255,1)&#34;,&#34;gridwidth&#34;:0.66417600664176002,&#34;zeroline&#34;:false,&#34;anchor&#34;:&#34;x&#34;,&#34;title&#34;:{&#34;text&#34;:&#34;hwy&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.611872146118724}},&#34;hoverformat&#34;:&#34;.2f&#34;},&#34;shapes&#34;:[],&#34;showlegend&#34;:true,&#34;legend&#34;:{&#34;bgcolor&#34;:&#34;rgba(255,255,255,1)&#34;,&#34;bordercolor&#34;:&#34;transparent&#34;,&#34;borderwidth&#34;:1.8897637795275593,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:11.68949771689498},&#34;title&#34;:{&#34;text&#34;:&#34;year&#34;,&#34;font&#34;:{&#34;color&#34;:&#34;rgba(0,0,0,1)&#34;,&#34;family&#34;:&#34;&#34;,&#34;size&#34;:14.611872146118724}}},&#34;hovermode&#34;:&#34;closest&#34;,&#34;barmode&#34;:&#34;relative&#34;},&#34;config&#34;:{&#34;doubleClick&#34;:&#34;reset&#34;,&#34;modeBarButtonsToAdd&#34;:[&#34;hoverclosest&#34;,&#34;hovercompare&#34;],&#34;showSendToCloud&#34;:false},&#34;source&#34;:&#34;A&#34;,&#34;attrs&#34;:{&#34;aece6d48ddbc&#34;:{&#34;colour&#34;:{},&#34;x&#34;:{},&#34;y&#34;:{},&#34;type&#34;:&#34;scatter&#34;}},&#34;cur_data&#34;:&#34;aece6d48ddbc&#34;,&#34;visdat&#34;:{&#34;aece6d48ddbc&#34;:[&#34;function (y) &#34;,&#34;x&#34;]},&#34;highlight&#34;:{&#34;on&#34;:&#34;plotly_click&#34;,&#34;persistent&#34;:false,&#34;dynamic&#34;:false,&#34;selectize&#34;:false,&#34;opacityDim&#34;:0.20000000000000001,&#34;selected&#34;:{&#34;opacity&#34;:1},&#34;debounce&#34;:0},&#34;shinyEvents&#34;:[&#34;plotly_hover&#34;,&#34;plotly_click&#34;,&#34;plotly_selected&#34;,&#34;plotly_relayout&#34;,&#34;plotly_brushed&#34;,&#34;plotly_brushing&#34;,&#34;plotly_clickannotation&#34;,&#34;plotly_doubleclick&#34;,&#34;plotly_deselect&#34;,&#34;plotly_afterplot&#34;,&#34;plotly_sunburstclick&#34;],&#34;base_url&#34;:&#34;https://plot.ly&#34;},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;You can now hover over a point to display more information about that point. There is also the possibility to zoom in and out, to download the plot, to select some observations, etc. More information about &lt;code&gt;{plotly}&lt;/code&gt; for R can be found &lt;a href=&#34;https://plotly.com/r/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;combine-plots-with-patchwork&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Combine plots with &lt;code&gt;{patchwork}&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;There are several ways to combine plots made in &lt;code&gt;{ggplot2}&lt;/code&gt;. In my opinion, the most convenient way is with the &lt;code&gt;{patchwork}&lt;/code&gt; package using symbols such as &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt; and parentheses.&lt;/p&gt;
&lt;p&gt;We first need to create some plots and save them:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p_a &amp;lt;- ggplot(dat) +
  aes(x = displ, y = hwy) +
  geom_point()

p_b &amp;lt;- ggplot(dat) +
  aes(x = hwy) +
  geom_histogram()

p_c &amp;lt;- ggplot(dat) +
  aes(x = drv, y = hwy) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we have 3 plots saved in our environment, we can combine them. To have plots &lt;strong&gt;next to each other&lt;/strong&gt; simply use the &lt;code&gt;+&lt;/code&gt; symbol:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(patchwork)
p_a + p_b + p_c&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-57-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To display them &lt;strong&gt;above each other&lt;/strong&gt; simply use the &lt;code&gt;/&lt;/code&gt; symbol:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p_a / p_b / p_c&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-58-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;And finally, to combine them &lt;strong&gt;above and next&lt;/strong&gt; to each other, mix &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt; and parentheses:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p_a + p_b / p_c&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-59-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;(p_a + p_b) / p_c&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-59-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;See more ways to combine plots with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;grid.arrange()&lt;/code&gt; from the &lt;code&gt;{gridExtra}&lt;/code&gt; package&lt;/li&gt;
&lt;li&gt;&lt;code&gt;plot_grid()&lt;/code&gt; from the &lt;code&gt;{cowplot}&lt;/code&gt; package&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;flip-coordinates&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Flip coordinates&lt;/h3&gt;
&lt;p&gt;Flipping coordinates of your plot is useful to create horizontal boxplots, or when labels of a variable are so long that they overlap each other on the x-axis. See with and without flipping coordinates below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# without flipping coordinates
p1 &amp;lt;- ggplot(dat) +
  aes(x = class, y = hwy) +
  geom_boxplot()

# with flipping coordinates
p2 &amp;lt;- ggplot(dat) +
  aes(x = class, y = hwy) +
  geom_boxplot() +
  coord_flip()

library(patchwork)
p1 + p2 # left: without flipping, right: with flipping&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-60-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This can be done with many types of plot, not only with boxplots. For instance, if a categorical variable has many levels or the labels are long, it is usually best to flip the coordinates for a better visual:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = class) +
  geom_bar() +
  coord_flip()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-61-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;save-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Save plot&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ggsave()&lt;/code&gt; function will save the most recent plot in your current &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/#r-working-directory&#34;&gt;working directory&lt;/a&gt; unless you specify a path to another folder:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = displ, y = hwy) +
  geom_point()

ggsave(&amp;quot;plot1.pdf&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also specify the width, height and resolution (&lt;code&gt;dpi&lt;/code&gt;) as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggsave(&amp;quot;plot1.pdf&amp;quot;,
  width = 12,
  height = 12,
  units = &amp;quot;cm&amp;quot;,
  dpi = 300
)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;managing-dates&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Managing dates&lt;/h3&gt;
&lt;p&gt;If the time variable in your dataset is in date format, the &lt;code&gt;{ggplot2}&lt;/code&gt; package recognizes the date format and automatically uses a specific type for the axis ticks.&lt;/p&gt;
&lt;p&gt;There is no time variable with a date format in our dataset, so let’s create a new variable of this type thanks to the &lt;code&gt;as.Date()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$date &amp;lt;- as.Date(&amp;quot;2020-08-21&amp;quot;) - 0:(nrow(dat) - 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See the first 6 observations of this date variable and its class:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(dat$date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-08-21&amp;quot; &amp;quot;2020-08-20&amp;quot; &amp;quot;2020-08-19&amp;quot; &amp;quot;2020-08-18&amp;quot; &amp;quot;2020-08-17&amp;quot;
## [6] &amp;quot;2020-08-16&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(dat$date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  Date[1:234], format: &amp;quot;2020-08-21&amp;quot; &amp;quot;2020-08-20&amp;quot; &amp;quot;2020-08-19&amp;quot; &amp;quot;2020-08-18&amp;quot; &amp;quot;2020-08-17&amp;quot; ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The new variable &lt;code&gt;date&lt;/code&gt; is correctly specified in a date format.&lt;/p&gt;
&lt;p&gt;Most of the time, with a time variable, we want to create a line plot with the date on the X-axis and another continuous variable on the Y-axis, like the following plot for example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p &amp;lt;- ggplot(dat) +
  aes(x = date, y = hwy) +
  geom_line()
p&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-66-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As soon as the time variable is recognized as a date, we can use the &lt;code&gt;scale_x_date()&lt;/code&gt; layer to change the format displayed on the X-axis. The following table shows the most frequent date formats:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/date%20formats%20in%20R.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Source: www.statmethods.net&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Source: www.statmethods.net&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Run &lt;code&gt;?strptime()&lt;/code&gt; to see many more date formats available in R.&lt;/p&gt;
&lt;p&gt;For this example, let’s add the year in addition to the unabbreviated month:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + scale_x_date(date_labels = &amp;quot;%B %Y&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-67-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It also possible to control the breaks to display on the X-axis with the &lt;code&gt;date_breaks&lt;/code&gt; argument. For this example, let’s say we want to display the day as number and the abbreviated month for each interval of 10 days:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + scale_x_date(date_breaks = &amp;quot;10 days&amp;quot;, date_labels = &amp;quot;%d %b&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-68-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If labels displayed on the X-axis are unreadable because they overlap each other, you can rotate them with the &lt;code&gt;theme()&lt;/code&gt; layer and the &lt;code&gt;angle&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + scale_x_date(date_breaks = &amp;quot;10 days&amp;quot;, date_labels = &amp;quot;%d %b&amp;quot;) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-69-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;highlight-data-with-gghighlight&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Highlight data with &lt;code&gt;{gghighlight}&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;{gghighlight}&lt;/code&gt; package allows, as its name suggests, to highlight some data directly on your ggplot. The highlighted data (that you define) are shown in bright color and the rest in gray.&lt;/p&gt;
&lt;p&gt;Below example of how it works for a scatter plot, boxplot, barplot and histogram.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(gghighlight)

# scatter plot
ggplot(mpg, aes(x = displ, y = hwy, color = cyl)) +
  geom_point() +
  gghighlight(cyl == &amp;quot;8&amp;quot;) +
  theme(legend.position = &amp;quot;none&amp;quot;) # remove legend&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-70-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# boxplot
ggplot(dat) +
  aes(x = drv, y = hwy, fill = drv) +
  geom_boxplot() +
  gghighlight(drv %in% c(&amp;quot;r&amp;quot;, &amp;quot;4&amp;quot;)) +
  theme(legend.position = &amp;quot;none&amp;quot;) # remove legend&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-70-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# barplot
ggplot(dat) +
  aes(x = drv, fill = drv) +
  geom_bar() +
  gghighlight(drv == &amp;quot;f&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-70-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the &lt;code&gt;gghighlight()&lt;/code&gt; layer accepts different types of conditions, but also several of them at the same time:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# histogram
ggplot(dat) +
  aes(x = hwy, fill = year) +
  geom_histogram() +
  gghighlight(displ &amp;gt; 2 &amp;amp; year == &amp;quot;1999&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-71-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;tip&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Tip&lt;/h1&gt;
&lt;p&gt;I recently learned a tip very useful when drawing plots with &lt;code&gt;{ggplot2}&lt;/code&gt;. If like me, you often comment and uncomment some lines of code in your plot, you know that you cannot transform the last line into a comment without removing the &lt;code&gt;+&lt;/code&gt; sign in the line just above.&lt;/p&gt;
&lt;p&gt;Adding a line &lt;code&gt;NULL&lt;/code&gt; at the end of your plots will avoid an &lt;a href=&#34;https://statsandr.com/blog/top-10-errors-in-r/#forgetting-the-sign-in-ggplot2&#34;&gt;error&lt;/a&gt; if you forget to remove the &lt;code&gt;+&lt;/code&gt; sign in the last line of your code. See with this basic example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = date, y = hwy) +
  geom_line() + # I do not have to remove the + sign
  # theme_minimal() + # this line is a comment
  NULL # adding this line doesn&amp;#39;t change anything to the plot&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-21-graphics-in-r-with-ggplot2_files/figure-html/unnamed-chunk-72-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This trick saves me a lot of time as I do not need to worry about making sure to remove the last &lt;code&gt;+&lt;/code&gt; sign after commenting some lines of code in my plots.&lt;/p&gt;
&lt;p&gt;If you find this trick useful, you may like these 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;/div&gt;
&lt;div id=&#34;to-go-further&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;To go further&lt;/h1&gt;
&lt;p&gt;By now you have seen that &lt;code&gt;{ggplot2}&lt;/code&gt; is a very powerful and complete package to create plots in R. This article illustrated only the tip of the iceberg, and you will find many tutorials on how to create more advanced plots and visualizations with &lt;code&gt;{ggplot2}&lt;/code&gt; online. If you want to learn more than what is described in the present article, I highly recommend starting with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the chapters &lt;a href=&#34;https://r4ds.had.co.nz/data-visualisation.html&#34; target=&#34;_blank&#34;&gt;Data visualisation&lt;/a&gt; and &lt;a href=&#34;https://r4ds.had.co.nz/graphics-for-communication.html&#34; target=&#34;_blank&#34;&gt;Graphics for communication&lt;/a&gt; from the book &lt;a href=&#34;https://r4ds.had.co.nz/&#34; target=&#34;_blank&#34;&gt;R for Data Science&lt;/a&gt; from Garrett Grolemund and Hadley Wickham&lt;/li&gt;
&lt;li&gt;the book &lt;a href=&#34;https://ggplot2-book.org/&#34; target=&#34;_blank&#34;&gt;ggplot2: Elegant Graphics for Data Analysis&lt;/a&gt; from Hadley Wickham&lt;/li&gt;
&lt;li&gt;the book &lt;a href=&#34;https://r-graphics.org/&#34; target=&#34;_blank&#34;&gt;R Graphics Cookbook&lt;/a&gt; from Winston Chang&lt;/li&gt;
&lt;li&gt;the &lt;a href=&#34;https://exts.ggplot2.tidyverse.org/gallery/&#34; target=&#34;_blank&#34;&gt;ggplot2 extensions guide&lt;/a&gt; which lists many of the packages that extend &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the &lt;a href=&#34;https://statsandr.com/blog/files/ggplot2-cheatsheet.pdf&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; cheat sheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;this &lt;a href=&#34;https://pkg.garrickadenbuie.com/gentle-ggplot2/#1&#34;&gt;presentation&lt;/a&gt; by Garrick Aden-Buie&lt;/li&gt;
&lt;li&gt;a detailed tutorial by &lt;a href=&#34;https://cedricscherer.netlify.app/2019/08/05/a-ggplot2-tutorial-for-beautiful-plotting-in-r/&#34;&gt;Cédric Scherer&lt;/a&gt;&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 this article helped you to create your first plots with the &lt;code&gt;{ggplot2}&lt;/code&gt; package. As a reminder, for simple graphs, it is sometimes easier to draw them via the &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#esquisse&#34;&gt;{esquisse} addin&lt;/a&gt;. After some time, you will quickly learn how to create them by yourselves and in no time you will be able to build complex and sophisticated data visualizations.&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;Use the &lt;code&gt;geom_jitter()&lt;/code&gt; layer with caution because, although it makes a plot more revealing at large scales, it also makes it slightly less accurate at small scales since some randomness is added to the points.&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;Code inspired from Claire Della Vedova (&lt;a href=&#34;https://delladata.fr/raincloud-plot/&#34; target=&#34;_blank&#34;&gt;DellaData&lt;/a&gt;) and &lt;a href=&#34;https://www.cedricscherer.com/2021/06/06/visualizing-distributions-with-raincloud-plots-and-how-to-create-them-with-ggplot2/&#34; target=&#34;_blank&#34;&gt;Cédric Scherer&lt;/a&gt;. Thanks to both of them for this nice plot!&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;There are (at the time of writing) 26 shapes accepted in the &lt;code&gt;shape&lt;/code&gt; argument. See this &lt;a href=&#34;https://ggplot2.tidyverse.org/reference/aes_linetype_size_shape.html&#34; target=&#34;_blank&#34;&gt;documentation&lt;/a&gt; for all available shapes.&lt;a href=&#34;#fnref3&#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>Mortgage calculator in R Shiny</title>
      <link>https://statsandr.com/blog/mortgage-calculator-r-shiny/</link>
      <pubDate>Fri, 14 Aug 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/mortgage-calculator-r-shiny/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#mortgage-calculator&#34; id=&#34;toc-mortgage-calculator&#34;&gt;Mortgage calculator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-use-the-mortgage-calculator&#34; id=&#34;toc-how-to-use-the-mortgage-calculator&#34;&gt;How to use the mortgage calculator?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#code-of-the-app&#34; id=&#34;toc-code-of-the-app&#34;&gt;Code of the app&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/2020-08-14-mortgage-calculator-in-r-shiny_files/mortgage-calculator-r-shiny-app.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;I recently moved out and bought my first apartment. Of course, I could not pay it entirely with my own savings, so I had to borrow money from the bank. I visited a couple of banks operating in my country and asked for a mortgage.&lt;/p&gt;
&lt;p&gt;If you already bought your house or apartment in the past, you know how it goes: the bank analyzes your financial and personal situation and make an offer based on your propensity to repay the bank. You then either accept the offer if you are satisfied with the rate and conditions, or visit another bank if you believe you could receive a better offer. Mortgages and loans are more complicated than that of course, but let’s keep it simple here.&lt;/p&gt;
&lt;p&gt;As I kind of like to control and keep a close eye on my &lt;a href=&#34;https://statsandr.com/blog/practical-guide-on-optimal-asset-allocation/&#34;&gt;personal finances&lt;/a&gt; (sometimes a bit too close I must admit), I knew precisely how much I could spend for my monthly mortgage repayment while still being able to cover my living expenses. However, I had no clue how much I could borrow in total for my new apartment given these housing repayments.&lt;/p&gt;
&lt;p&gt;I knew I was not the first person in this case, so I looked online if I could find a R script which would answer my question (and potentially also give me the total cost of the housing loan, including the loan amount and the accumulated interests). I finally found a R script created a while ago by Prof. Thomas Girke.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;mortgage-calculator&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Mortgage calculator&lt;/h1&gt;
&lt;p&gt;The function in the script was functional and solved my main issue, but I wanted to be able to play more easily with the different settings such as the amount, the duration and the interest rate of the loan.&lt;/p&gt;
&lt;p&gt;For this reason, I created a &lt;strong&gt;R Shiny app&lt;/strong&gt; which is &lt;strong&gt;available here:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://antoinesoetewey.shinyapps.io/mortgage-calculator/&#34; target=&#34;_blank&#34;&gt;Mortgage calculator&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-08-14-mortgage-calculator-in-r-shiny_files/mortgage-calculator-r-shiny.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Mortgage calculator in R Shiny&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Mortgage calculator in R Shiny&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the meantime, I received an Excel file from a friend working in a Belgian bank which does precisely the same task. I am not an actuary nor an expert in mortgage loan, so with his file I was able to cross check the results and edit the code accordingly.&lt;/p&gt;
&lt;p&gt;The app greatly helped me to know the maximum amount I could borrow from the bank by playing with the three main settings of a mortgage, so it gave me a precise price limit when looking for apartments online.&lt;/p&gt;
&lt;p&gt;Note that the app can of course be used for any loan, not only for mortgage.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-use-the-mortgage-calculator&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to use the mortgage calculator?&lt;/h1&gt;
&lt;p&gt;First, you can find the mortgage calculator &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/mortgage-calculator/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I try to keep all my &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny apps&lt;/a&gt; easy to use for everyone. However, here is how to use it in case it is not intuitive enough:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Enter the amount of the loan (i.e., the amount you would like to borrow, do not include downpayment)&lt;/li&gt;
&lt;li&gt;Enter the annual interest rate in %&lt;/li&gt;
&lt;li&gt;Enter the duration of the loan in years&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;On the right panel (or bottom if you use the app on mobile) you will see:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a summary repeating the settings you entered,&lt;/li&gt;
&lt;li&gt;the total cost of the loan (principal and interests included), and more importantly&lt;/li&gt;
&lt;li&gt;the amount of the monthly payments&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A plot representing the percentage attributed to the repayment of the interests and the capital is also displayed. You see that (especially in the first years of the loan), the higher the interest rate and the duration of the loan, the higher the percentage of the monthly repayments is attributed to the repayments of the interests.&lt;/p&gt;
&lt;p&gt;Finally, the amortization table showing the remaining balance month by month is displayed after the summary and the plot. You can copy, export (in PDF, CSV or Excel) or print this amortization table for further use.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;code-of-the-app&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Code of the app&lt;/h1&gt;
&lt;p&gt;Here is the entire code (or see the last version on &lt;a href=&#34;https://github.com/AntoineSoetewey/mortgage-calculator&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;) in case you would like to enhance it (feel free to send me your app if you happen to improve it!).&lt;/p&gt;
&lt;script src=&#34;https://gist.github.com/AntoineSoetewey/c4cf29983f7b0695e492d53795355c4c.js&#34;&gt;&lt;/script&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 &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/mortgage-calculator/&#34; target=&#34;_blank&#34;&gt;mortgage calculator&lt;/a&gt; helped you to play with the different settings of a mortgage, and who knows, helped you to decide which house or apartment to buy.&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;p&gt;&lt;em&gt;Disclosure: Note that this application does not include investment advice or recommendations, nor a financial analysis. This application is intended for information only and you invest at your own risks. I cannot be held liable for any decision made based on the information contained in this application, nor for its use by third parties.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Outliers detection in R</title>
      <link>https://statsandr.com/blog/outliers-detection-in-r/</link>
      <pubDate>Tue, 11 Aug 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/outliers-detection-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#descriptive-statistics&#34; id=&#34;toc-descriptive-statistics&#34;&gt;Descriptive statistics&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#minimum-and-maximum&#34; id=&#34;toc-minimum-and-maximum&#34;&gt;Minimum and maximum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#histogram&#34; id=&#34;toc-histogram&#34;&gt;Histogram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#boxplot&#34; id=&#34;toc-boxplot&#34;&gt;Boxplot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#percentiles&#34; id=&#34;toc-percentiles&#34;&gt;Percentiles&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#z-scores&#34; id=&#34;toc-z-scores&#34;&gt;Z-scores&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hampel-filter&#34; id=&#34;toc-hampel-filter&#34;&gt;Hampel filter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#statistical-tests&#34; id=&#34;toc-statistical-tests&#34;&gt;Statistical tests&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#grubbss-test&#34; id=&#34;toc-grubbss-test&#34;&gt;Grubbs’s test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#dixons-test&#34; id=&#34;toc-dixons-test&#34;&gt;Dixon’s test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#rosners-test&#34; id=&#34;toc-rosners-test&#34;&gt;Rosner’s test&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#additional-remarks&#34; id=&#34;toc-additional-remarks&#34;&gt;Additional remarks&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/outliers-detection-in-R.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;An &lt;strong&gt;outlier&lt;/strong&gt; is a value or an &lt;strong&gt;observation that is distant from other observations&lt;/strong&gt;, that is to say, a data point that differs significantly from other data points. &lt;span class=&#34;citation&#34;&gt;Enderlein (&lt;a href=&#34;#ref-enderlein1987hawkins&#34;&gt;1987&lt;/a&gt;)&lt;/span&gt; goes even further as the author considers outliers as values that deviate so much from other observations one might suppose a different underlying sampling mechanism.&lt;/p&gt;
&lt;p&gt;An observation must always be compared to other observations made on the same phenomenon before actually calling it an outlier. Indeed, someone who is 200 cm tall (6’7” in US) will most likely be considered as an outlier compared to the general population, but that same person may not be considered as an outlier if we measured the height of basketball players.&lt;/p&gt;
&lt;p&gt;An outlier may be due to the variability inherent in the observed phenomenon. For example, it is often the case that there are outliers when collecting data on salaries, as some people make much more money than the rest.&lt;/p&gt;
&lt;p&gt;Outliers can also arise due to an experimental, measurement or encoding error. For instance, a human weighting 786 kg (1733 pounds) is clearly an error when encoding the weight of the subject. Her or his weight is most probably 78.6 kg (173 pounds) or 7.86 kg (17 pounds) depending on whether weights of adults or babies have been measured.&lt;/p&gt;
&lt;p&gt;For this reason, it sometimes makes sense to formally distinguish two classes of outliers: (i) extreme values and (ii) mistakes. Extreme values are statistically and philosophically more interesting, because they are possible but unlikely responses.&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;/p&gt;
&lt;p&gt;In this article, I present several approaches to detect outliers in R, from simple techniques such as &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; (including minimum, maximum, histogram, boxplot and percentiles) to more formal techniques such as the Hampel filter, the Grubbs, the Dixon and the Rosner tests for outliers.&lt;/p&gt;
&lt;p&gt;Although there is no strict or unique rule whether outliers should be removed or not from the dataset before doing statistical analyses, it is quite common to, at least, remove or impute outliers that are due to an experimental or measurement error (like the weight of 786 kg (1733 pounds) for a human). Some &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt; require the absence of outliers in order to draw sound conclusions, but removing outliers is not recommended in all cases and must be done with caution.&lt;/p&gt;
&lt;p&gt;This article will not tell you whether you should remove outliers or not (nor if you should impute them with the median, mean, mode or any other value), but it will help you to detect them in order to, as a first step, verify them. After their verification, it is then your choice to exclude or include them for your analyses (and this usually requires a thoughtful reflection on the researcher’s side).&lt;/p&gt;
&lt;p&gt;Removing or keeping outliers mostly depend on three factors:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The domain/context of your analyses and the research question. In some domains, it is common to remove outliers as they often occur due to a malfunctioning process. In other fields, outliers are kept because they contain valuable information. It also happens that analyses are performed twice, once with and once without outliers to evaluate their impact on the conclusions. If results change drastically due to some influential values, this should caution the researcher to make overambitious claims.&lt;/li&gt;
&lt;li&gt;Whether the tests you are going to apply are robust to the presence of outliers or not. For instance, the slope of a simple &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt; may significantly varies with just one outlier, whereas non-parametric tests such as the &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Wilcoxon test&lt;/a&gt; are usually robust to outliers.&lt;/li&gt;
&lt;li&gt;How distant are the outliers from other observations? Some observations considered as outliers (according to the techniques presented below) are actually not really extreme compared to all other observations, while other potential outliers may be really distant from the rest of the observations.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The dataset &lt;code&gt;mpg&lt;/code&gt; from the &lt;code&gt;{ggplot2}&lt;/code&gt; package will be used to illustrate the different approaches of outliers detection in R, and in particular we will focus on the variable &lt;code&gt;hwy&lt;/code&gt; (highway miles per gallon). We will also use some simulated data for the presentation of the outlier tests.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;descriptive-statistics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Descriptive statistics&lt;/h1&gt;
&lt;p&gt;Several methods using descriptive statistics exist. We present the most common ones below.&lt;/p&gt;
&lt;div id=&#34;minimum-and-maximum&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Minimum and maximum&lt;/h2&gt;
&lt;p&gt;The first step to detect outliers in R is to start with some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt;, and in particular with the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#minimum-and-maximum&#34;&gt;minimum and maximum&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In R, this can easily be done with the &lt;code&gt;summary()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- ggplot2::mpg
summary(dat$hwy)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   12.00   18.00   24.00   23.44   27.00   44.00&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where the minimum and maximum are respectively the first and last values in the output above.&lt;/p&gt;
&lt;p&gt;Alternatively, they can also be computed with the &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt;, or &lt;code&gt;range()&lt;/code&gt; functions:&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;pre class=&#34;r&#34;&gt;&lt;code&gt;min(dat$hwy)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;max(dat$hwy)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 44&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;range(dat$hwy)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12 44&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Some clear encoding mistake like a weight of 786 kg (1733 pounds) for a human will already be easily detected by this very simple technique.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Histogram&lt;/h2&gt;
&lt;p&gt;Another basic way to detect outliers is to draw a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; of the data.&lt;/p&gt;
&lt;p&gt;Using R base (with the number of bins corresponding to the square root of the number of observations in order to have more bins than the default option):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hist(dat$hwy,
  xlab = &amp;quot;hwy&amp;quot;,
  main = &amp;quot;Histogram of hwy&amp;quot;,
  breaks = sqrt(length(dat$hwy)) # set number of bins
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;or using &lt;code&gt;ggplot2&lt;/code&gt; (learn how to create plots with this package via 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; or via this &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;tutorial&lt;/a&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)

ggplot(dat) +
  aes(x = hwy) +
  geom_histogram(
    bins = round(sqrt(length(dat$hwy))), # set number of bins
    fill = &amp;quot;steelblue&amp;quot;, color = &amp;quot;black&amp;quot;
  ) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the histograms, we see that there seems to be a couple of observations larger than all other observations (see the bars on the right side of the plot).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;boxplot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Boxplot&lt;/h2&gt;
&lt;p&gt;In addition to histograms, &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplots&lt;/a&gt; are also useful to detect potential outliers.&lt;/p&gt;
&lt;p&gt;Using R base:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(dat$hwy,
  ylab = &amp;quot;hwy&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-5-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;or using &lt;code&gt;ggplot2&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = &amp;quot;&amp;quot;, y = hwy) +
  geom_boxplot(fill = &amp;quot;steelblue&amp;quot;) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-6-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;A boxplot helps to visualize a quantitative variable by displaying five common location summary (minimum, median, first and third quartiles and maximum) and any observation that was classified as a suspected outlier using the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#interquartile-range&#34;&gt;interquartile range (IQR)&lt;/a&gt; criterion.&lt;/p&gt;
&lt;p&gt;The IQR criterion means that all observations above &lt;span class=&#34;math inline&#34;&gt;\(q_{0.75} + 1.5 \cdot IQR\)&lt;/span&gt; or below &lt;span class=&#34;math inline&#34;&gt;\(q_{0.25} - 1.5 \cdot IQR\)&lt;/span&gt; (where &lt;span class=&#34;math inline&#34;&gt;\(q_{0.25}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(q_{0.75}\)&lt;/span&gt; correspond to first and third quartile respectively, and IQR is the difference between the third and first quartile) are considered as potential outliers by R.&lt;/p&gt;
&lt;p&gt;In other words, all observations outside of the following interval will be considered as potential outliers:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[I = [q_{0.25} - 1.5 \cdot IQR; q_{0.75} + 1.5 \cdot IQR]\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Observations considered as potential outliers by the IQR criterion are displayed as points in the boxplot. Based on this criterion, there are 2 potential outliers (see the 2 points above the vertical line, at the top of the boxplot).&lt;/p&gt;
&lt;p&gt;Remember that it is not because an observation is considered as a potential outlier by the IQR criterion that you should remove it. Removing or keeping an outlier depends on:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the context of your analysis,&lt;/li&gt;
&lt;li&gt;whether the tests you are going to perform on the dataset are robust to outliers or not, and&lt;/li&gt;
&lt;li&gt;how extreme is the outlier (so how far is the outlier from other observations).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It is also possible to extract the values of the potential outliers based on the IQR criterion thanks to the &lt;code&gt;boxplot.stats()$out&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot.stats(dat$hwy)$out&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 44 44 41&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, there are actually 3 points considered as potential outliers: 2 observations with a value of 44 and 1 observation with a value of 41.&lt;/p&gt;
&lt;p&gt;Thanks to the &lt;code&gt;which()&lt;/code&gt; function it is possible to extract the row number corresponding to these outliers:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;out &amp;lt;- boxplot.stats(dat$hwy)$out
out_ind &amp;lt;- which(dat$hwy %in% c(out))
out_ind&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 213 222 223&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this information you can now easily go back to the specific rows in the dataset to verify them, or print all variables for these outliers:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[out_ind, ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 11
##   manufacturer model      displ  year   cyl trans  drv     cty   hwy fl    class
##   &amp;lt;chr&amp;gt;        &amp;lt;chr&amp;gt;      &amp;lt;dbl&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;
## 1 volkswagen   jetta        1.9  1999     4 manua… f        33    44 d     comp…
## 2 volkswagen   new beetle   1.9  1999     4 manua… f        35    44 d     subc…
## 3 volkswagen   new beetle   1.9  1999     4 auto(… f        29    41 d     subc…&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another method to display these specific rows is with the &lt;code&gt;identify_outliers()&lt;/code&gt; function from the &lt;code&gt;{rstatix}&lt;/code&gt; package:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(rstatix)

identify_outliers(
  data = dat,
  variable = &amp;quot;hwy&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 13
##   manufacturer model      displ  year   cyl trans  drv     cty   hwy fl    class
##   &amp;lt;chr&amp;gt;        &amp;lt;chr&amp;gt;      &amp;lt;dbl&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;
## 1 volkswagen   jetta        1.9  1999     4 manua… f        33    44 d     comp…
## 2 volkswagen   new beetle   1.9  1999     4 manua… f        35    44 d     subc…
## 3 volkswagen   new beetle   1.9  1999     4 auto(… f        29    41 d     subc…
## # ℹ 2 more variables: is.outlier &amp;lt;lgl&amp;gt;, is.extreme &amp;lt;lgl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is also possible to print the values of the outliers directly on the boxplot with the &lt;code&gt;mtext()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(dat$hwy,
  ylab = &amp;quot;hwy&amp;quot;,
  main = &amp;quot;Boxplot of highway miles per gallon&amp;quot;
)
mtext(paste(&amp;quot;Outliers: &amp;quot;, paste(out, collapse = &amp;quot;, &amp;quot;)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-11-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;percentiles&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Percentiles&lt;/h2&gt;
&lt;p&gt;This method of outliers detection is based on the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#a-note-on-deciles-and-percentiles&#34;&gt;percentiles&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With the percentiles method, all observations that lie outside the interval formed by the 2.5 and 97.5 percentiles will be considered as potential outliers. Other percentiles such as the 1 and 99, or the 5 and 95 percentiles can also be considered to construct the interval.&lt;/p&gt;
&lt;p&gt;The values of the lower and upper percentiles (and thus the lower and upper limits of the interval) can be computed with the &lt;code&gt;quantile()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lower_bound &amp;lt;- quantile(dat$hwy, 0.025)
lower_bound&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 2.5% 
##   14&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;upper_bound &amp;lt;- quantile(dat$hwy, 0.975)
upper_bound&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  97.5% 
## 35.175&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;According to this method, all observations below 14 and above 35.175 will be considered as potential outliers. The row numbers of the observations outside of the interval can then be extracted with the &lt;code&gt;which()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;outlier_ind &amp;lt;- which(dat$hwy &amp;lt; lower_bound | dat$hwy &amp;gt; upper_bound)
outlier_ind&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  55  60  66  70 106 107 127 197 213 222 223&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then their values of highway miles per gallon can be printed:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[outlier_ind, &amp;quot;hwy&amp;quot;]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 11 × 1
##      hwy
##    &amp;lt;int&amp;gt;
##  1    12
##  2    12
##  3    12
##  4    12
##  5    36
##  6    36
##  7    12
##  8    37
##  9    44
## 10    44
## 11    41&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, all variables for these outliers can be printed:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[outlier_ind, ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 11 × 11
##    manufacturer model      displ  year   cyl trans drv     cty   hwy fl    class
##    &amp;lt;chr&amp;gt;        &amp;lt;chr&amp;gt;      &amp;lt;dbl&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;
##  1 dodge        dakota pi…   4.7  2008     8 auto… 4         9    12 e     pick…
##  2 dodge        durango 4…   4.7  2008     8 auto… 4         9    12 e     suv  
##  3 dodge        ram 1500 …   4.7  2008     8 auto… 4         9    12 e     pick…
##  4 dodge        ram 1500 …   4.7  2008     8 manu… 4         9    12 e     pick…
##  5 honda        civic        1.8  2008     4 auto… f        25    36 r     subc…
##  6 honda        civic        1.8  2008     4 auto… f        24    36 c     subc…
##  7 jeep         grand che…   4.7  2008     8 auto… 4         9    12 e     suv  
##  8 toyota       corolla      1.8  2008     4 manu… f        28    37 r     comp…
##  9 volkswagen   jetta        1.9  1999     4 manu… f        33    44 d     comp…
## 10 volkswagen   new beetle   1.9  1999     4 manu… f        35    44 d     subc…
## 11 volkswagen   new beetle   1.9  1999     4 auto… f        29    41 d     subc…&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are 11 potential outliers according to the percentiles method. To reduce this number, you can set the percentiles to 1 and 99:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lower_bound &amp;lt;- quantile(dat$hwy, 0.01)
upper_bound &amp;lt;- quantile(dat$hwy, 0.99)

outlier_ind &amp;lt;- which(dat$hwy &amp;lt; lower_bound | dat$hwy &amp;gt; upper_bound)

dat[outlier_ind, ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 11
##   manufacturer model      displ  year   cyl trans  drv     cty   hwy fl    class
##   &amp;lt;chr&amp;gt;        &amp;lt;chr&amp;gt;      &amp;lt;dbl&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;
## 1 volkswagen   jetta        1.9  1999     4 manua… f        33    44 d     comp…
## 2 volkswagen   new beetle   1.9  1999     4 manua… f        35    44 d     subc…
## 3 volkswagen   new beetle   1.9  1999     4 auto(… f        29    41 d     subc…&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Setting the percentiles to 1 and 99 gives the same potential outliers as with the IQR criterion.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;z-scores&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Z-scores&lt;/h2&gt;
&lt;p&gt;If your data come from a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt;, you can use the z-scores, defined as&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[z_i = \frac{x_i - \overline{X}}{s_X}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(\overline{X}\)&lt;/span&gt; is the mean and &lt;span class=&#34;math inline&#34;&gt;\(s_X\)&lt;/span&gt; is the standard deviation of the random variable &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;This is referred as scaling, which can be done with the &lt;code&gt;scale()&lt;/code&gt; function in R.&lt;/p&gt;
&lt;p&gt;According to this method, any z-score:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&amp;lt; -2 or &amp;gt; 2 is considered as rare&lt;/li&gt;
&lt;li&gt;&amp;lt; -3 or &amp;gt; 3 is considered as extremely rare&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Other authors also use a z-score below -3.29 or above 3.29 to detect outliers. This value of 3.29 comes from the fact that 1 observation out of 1000 is out of this interval if the data follow a normal distribution.&lt;/p&gt;
&lt;p&gt;In our case:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$z_hwy &amp;lt;- scale(dat$hwy)

hist(dat$z_hwy)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-17-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(dat$z_hwy)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        V1          
##  Min.   :-1.92122  
##  1st Qu.:-0.91360  
##  Median : 0.09402  
##  Mean   : 0.00000  
##  3rd Qu.: 0.59782  
##  Max.   : 3.45274&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We see that there are some observations above 3.29, but none below -3.29.&lt;/p&gt;
&lt;p&gt;To identify the line in the dataset of these observations:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;which(dat$z_hwy &amp;gt; 3.29)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 213 222&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We see that observations 213 and 222 can be considered as outliers according to this method.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;hampel-filter&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Hampel filter&lt;/h1&gt;
&lt;p&gt;Another method, known as Hampel filter, consists of considering as outliers the values outside the interval (&lt;span class=&#34;math inline&#34;&gt;\(I\)&lt;/span&gt;) formed by the median, plus or minus 3 median absolute deviations (&lt;span class=&#34;math inline&#34;&gt;\(MAD\)&lt;/span&gt;):&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[I = [median - 3 \cdot MAD; median + 3 \cdot MAD]\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(MAD\)&lt;/span&gt; is the median absolute deviation and is defined as the median of the absolute deviations from the data’s median &lt;span class=&#34;math inline&#34;&gt;\(\tilde{X} = median(X)\)&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[MAD = median(|X_i - \tilde{X}|)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For this method we first set the interval limits thanks to the &lt;code&gt;median()&lt;/code&gt; and &lt;code&gt;mad()&lt;/code&gt; functions:&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lower_bound &amp;lt;- median(dat$hwy) - 3 * mad(dat$hwy, constant = 1)
lower_bound&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;upper_bound &amp;lt;- median(dat$hwy) + 3 * mad(dat$hwy, constant = 1)
upper_bound&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 39&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;According to this method, all observations below 9 and above 39 will be considered as potential outliers. The row numbers of the observations outside of the interval can then be extracted with the &lt;code&gt;which()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;outlier_ind &amp;lt;- which(dat$hwy &amp;lt; lower_bound | dat$hwy &amp;gt; upper_bound)
outlier_ind&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 213 222 223&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;According to the Hampel filter, there are 3 outliers for the &lt;code&gt;hwy&lt;/code&gt; variable.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;statistical-tests&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Statistical tests&lt;/h1&gt;
&lt;p&gt;In this section, we present 3 &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt; to detect outliers:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Grubbs’s test&lt;/li&gt;
&lt;li&gt;Dixon’s test&lt;/li&gt;
&lt;li&gt;Rosner’s test&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These 3 statistical tests are part of more formal techniques of outliers detection as they all involve the computation of a test statistic that is compared to tabulated critical values (that are based on the sample size and the desired confidence level).&lt;/p&gt;
&lt;p&gt;Note that the 3 tests are appropriate only when the data, without any outliers, are &lt;strong&gt;approximately normally distributed&lt;/strong&gt;. It is recommended to check normality visually, with a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#qq-plot&#34;&gt;QQ-plot&lt;/a&gt;, a histogram and/or a boxplot for instance. Although it can also be checked with a formal test for normality (such as the &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;Shapiro-Wilk test&lt;/a&gt; for example), the presence of one or more outliers may cause the normality test to reject normality when it is in fact a reasonable assumption for applying one of the 3 outlier tests mentioned above.&lt;/p&gt;
&lt;p&gt;We check the normality of our data thanks to a QQ-plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(car)
qqPlot(dat$hwy)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-21-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## [1] 213 222&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Too many points deviate from the Henry’s line, so based on the QQ-plot we conclude that our data do not follow a normal distribution. Therefore, we should not use one of the outlier test on these data.&lt;/p&gt;
&lt;p&gt;For the sake of completeness, here is an example of data that could be used with the three outlier tests, together with the QQ-plot of these data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat_tests &amp;lt;- c(rnorm(50), 5)

qqPlot(dat_tests)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-22-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## [1] 51 18&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hist(dat_tests)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-22-2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For the illustration of the three outlier tests in the next sections, we thus use the simulated data (&lt;code&gt;dat_tests&lt;/code&gt;) instead of the data used so far (&lt;code&gt;dat$hwy&lt;/code&gt;).&lt;/p&gt;
&lt;div id=&#34;grubbss-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Grubbs’s test&lt;/h2&gt;
&lt;p&gt;The Grubbs test allows to detect whether the highest or lowest value in a dataset is an outlier.&lt;/p&gt;
&lt;p&gt;The Grubbs test detects one outlier at a time (highest or lowest value), so the null and alternative hypotheses are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: The &lt;em&gt;highest&lt;/em&gt; value is &lt;strong&gt;not&lt;/strong&gt; an outlier&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: The &lt;em&gt;highest&lt;/em&gt; value is an outlier&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;if we want to test the highest value, or:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: The &lt;em&gt;lowest&lt;/em&gt; value is &lt;strong&gt;not&lt;/strong&gt; an outlier&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: The &lt;em&gt;lowest&lt;/em&gt; value is an outlier&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;if we want to test the lowest value.&lt;/p&gt;
&lt;p&gt;As for any &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt;, if the &lt;strong&gt;&lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;&lt;em&gt;p&lt;/em&gt;-value&lt;/a&gt; is less&lt;/strong&gt; than the chosen &lt;strong&gt;significance threshold&lt;/strong&gt; (generally &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;) then the null hypothesis is rejected and we will conclude that the &lt;strong&gt;lowest/highest value is an outlier&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;On the contrary, if the &lt;strong&gt;&lt;em&gt;p&lt;/em&gt;-value is greater or equal&lt;/strong&gt; than the significance level, the null hypothesis is not rejected, and we will conclude that, based on the data, we do not reject the hypothesis that the &lt;strong&gt;lowest/highest value is not an outlier&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Note that the Grubbs test is not appropriate for sample size of 6 or less (&lt;span class=&#34;math inline&#34;&gt;\(n \le 6\)&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;To perform the Grubbs test in R, we use the &lt;code&gt;grubbs.test()&lt;/code&gt; function from the &lt;code&gt;{outliers}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;outliers&amp;quot;)
library(outliers)

# Grubbs test
test &amp;lt;- grubbs.test(dat_tests)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Grubbs test for one outlier
## 
## data:  dat_tests
## G = 3.68326, U = 0.72325, p-value = 0.001873
## alternative hypothesis: highest value 5 is an outlier&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.002. At the 5% significance level, we reject the hypothesis that the &lt;em&gt;highest&lt;/em&gt; value 5 is &lt;strong&gt;not&lt;/strong&gt; an outlier. In other words, based on this test, we conclude that the highest value 5 is an outlier.&lt;/p&gt;
&lt;p&gt;By default, the test is performed on the highest value (as shown in the R output: &lt;code&gt;alternative hypothesis: highest value 5 is an outlier&lt;/code&gt;). If you want to do the test for the lowest value, simply add the argument &lt;code&gt;opposite = TRUE&lt;/code&gt; in the &lt;code&gt;grubbs.test()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- grubbs.test(dat_tests, opposite = TRUE)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Grubbs test for one outlier
## 
## data:  dat_tests
## G = 2.02893, U = 0.91602, p-value = 0.9981
## alternative hypothesis: lowest value -2.65645542090478 is an outlier&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The R output indicates that the test is now performed on the lowest value (see &lt;code&gt;alternative hypothesis: lowest value -2.6564554 is an outlier&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.998. At the 5% significance level, we do not reject the hypothesis that the &lt;em&gt;lowest&lt;/em&gt; value -2.66 is &lt;strong&gt;not&lt;/strong&gt; an outlier. In other words, we cannot conlude that the lowest value -2.66 is an outlier.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dixons-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Dixon’s test&lt;/h2&gt;
&lt;p&gt;Similar to the Grubbs test, Dixon test is used to test whether a single low or high value is an outlier. So if more than one outliers is suspected, the test has to be performed on these suspected outliers individually.&lt;/p&gt;
&lt;p&gt;Note that Dixon test is most useful for small sample size (usually &lt;span class=&#34;math inline&#34;&gt;\(n \le 25\)&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;To perform the Dixon’s test in R, we use the &lt;code&gt;dixon.test()&lt;/code&gt; function from the &lt;code&gt;{outliers}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;For this illustration, as the Dixon test can only be done on small samples, we take a &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/#subset-a-data-frame&#34;&gt;subset&lt;/a&gt; of our simulated data which consists of the 20 first observations and the outlier. Note that R will throw an &lt;a href=&#34;https://statsandr.com/blog/top-10-errors-in-r/&#34;&gt;error&lt;/a&gt; and accepts only a dataset consisting of 3 to 30 observations for this test.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# subset of simulated data
subdat &amp;lt;- c(dat_tests[1:20], max(dat_tests))

# Dixon test
test &amp;lt;- dixon.test(subdat)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Dixon test for outliers
## 
## data:  subdat
## Q = 0.46668, p-value = 0.06429
## alternative hypothesis: highest value 5 is an outlier&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Results of the Dixon test show that we cannot conclude that the highest value 5 is an outlier (&lt;em&gt;p&lt;/em&gt;-value = 0.064).&lt;/p&gt;
&lt;p&gt;To test for the lowest value, simply add the &lt;code&gt;opposite = TRUE&lt;/code&gt; argument to the &lt;code&gt;dixon.test()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- dixon.test(subdat,
  opposite = TRUE
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Dixon test for outliers
## 
## data:  subdat
## Q = 0.27115, p-value = 0.6872
## alternative hypothesis: lowest value -2.65645542090478 is an outlier&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Results of the test show that we cannot conclude that the lowest value -2.66 is an outlier (&lt;em&gt;p&lt;/em&gt;-value = 0.687).&lt;/p&gt;
&lt;p&gt;It is a good practice to always check the results of the statistical test for outliers against the boxplot to make sure we tested &lt;strong&gt;all&lt;/strong&gt; potential outliers:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;out &amp;lt;- boxplot.stats(subdat)$out

boxplot(subdat)
mtext(paste(&amp;quot;Outlier: &amp;quot;, paste(out, collapse = &amp;quot;, &amp;quot;)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-27-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the boxplot, we see that the Dixon test has been applied to all potential outliers.&lt;/p&gt;
&lt;p&gt;If you need to perform the test again without the highest or lowest value, this can be done by finding the row number of the maximum or minimum value, excluding this row number from the dataset and then finally apply the Dixon test on this new dataset. We illustrate the process as if we needed to perform the test again, but this time on the data excluding the highest value:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# find and exclude highest value
remove_ind &amp;lt;- which.max(subdat)
subsubdat &amp;lt;- subdat[-remove_ind]

# Dixon test on dataset without the maximum
test &amp;lt;- dixon.test(subsubdat)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Dixon test for outliers
## 
## data:  subsubdat
## Q = 0.30413, p-value = 0.5547
## alternative hypothesis: lowest value -2.65645542090478 is an outlier&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Results show that we cannot conclude that the lowest value -2.66 is an outlier (&lt;em&gt;p&lt;/em&gt;-value = 0.555).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rosners-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Rosner’s test&lt;/h2&gt;
&lt;p&gt;Rosner’s test for outliers has the advantages that:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;it is used to &lt;strong&gt;detect several outliers at once&lt;/strong&gt; (unlike Grubbs and Dixon test which must be performed iteratively to screen for multiple outliers), and&lt;/li&gt;
&lt;li&gt;it is designed to avoid the problem of masking, where an outlier that is close in value to another outlier can go undetected.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Unlike Dixon test, note that Rosner test is most appropriate when the sample size is large (&lt;span class=&#34;math inline&#34;&gt;\(n \ge 20\)&lt;/span&gt;). We therefore use again the similated dataset (i.e., &lt;code&gt;dat_tests&lt;/code&gt;), which includes 51 observations.&lt;/p&gt;
&lt;p&gt;To perform the Rosner test, we use the &lt;code&gt;rosnerTest()&lt;/code&gt; function from the &lt;code&gt;{EnvStats}&lt;/code&gt; package. This function requires at least 2 arguments: the data and the number of suspected outliers &lt;code&gt;k&lt;/code&gt; (with &lt;code&gt;k = 3&lt;/code&gt; as the default number of suspected outliers).&lt;/p&gt;
&lt;p&gt;For this example, we set the number of suspected outliers to be equal to 1, as suggested by the number of potential outliers outlined in the boxplot.&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(EnvStats)

# Rosner test
test &amp;lt;- rosnerTest(dat_tests,
  k = 1
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Results of Outlier Test
## -------------------------
## 
## Test Method:                     Rosner&amp;#39;s Test for Outliers
## 
## Hypothesized Distribution:       Normal
## 
## Data:                            dat_tests
## 
## Sample Size:                     51
## 
## Test Statistic:                  R.1 = 3.683258
## 
## Test Statistic Parameter:        k = 1
## 
## Alternative Hypothesis:          Up to 1 observations are not
##                                  from the same Distribution.
## 
## Type I Error:                    5%
## 
## Number of Outliers Detected:     1
## 
##   i     Mean.i     SD.i Value Obs.Num    R.i+1 lambda.i+1 Outlier
## 1 0 0.06306688 1.340371     5      51 3.683258   3.136165    TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The interesting results are provided in the &lt;code&gt;$all.stats&lt;/code&gt; table:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$all.stats&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   i     Mean.i     SD.i Value Obs.Num    R.i+1 lambda.i+1 Outlier
## 1 0 0.06306688 1.340371     5      51 3.683258   3.136165    TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on the results of the Rosner test, we see that there is only one outlier (as the table contains 1 line), and that it is the observation 51 (see &lt;code&gt;Obs.Num&lt;/code&gt;) with a value of 5 (see &lt;code&gt;Value&lt;/code&gt;). This finding aligns with the Grubbs test presented above, which also detected the value 5 as an outlier.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-remarks&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Additional remarks&lt;/h1&gt;
&lt;p&gt;You will find many other methods to detect outliers:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;in the &lt;code&gt;{outliers}&lt;/code&gt; packages,&lt;/li&gt;
&lt;li&gt;via the &lt;code&gt;lofactor()&lt;/code&gt; function from the &lt;code&gt;{DMwR}&lt;/code&gt; package: Local Outlier Factor (LOF) is an algorithm used to identify outliers by comparing the local density of a point with that of its neighbors,&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;outlierTest()&lt;/code&gt; from the &lt;code&gt;{car}&lt;/code&gt; package gives the most extreme observation based on the given model and allows to test whether it is an outlier,&lt;/li&gt;
&lt;li&gt;in the &lt;code&gt;{OutlierDetection}&lt;/code&gt; package, and&lt;/li&gt;
&lt;li&gt;with the &lt;code&gt;aq.plot()&lt;/code&gt; function from the &lt;code&gt;{mvoutlier}&lt;/code&gt; package (Thanks KTR for the suggestion.).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We present these methods with the initial dataset &lt;code&gt;mpg&lt;/code&gt;, using the &lt;code&gt;cyl&lt;/code&gt; and &lt;code&gt;hwy&lt;/code&gt; variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(mvoutlier)

Y &amp;lt;- as.matrix(ggplot2::mpg[, c(&amp;quot;cyl&amp;quot;, &amp;quot;hwy&amp;quot;)])
res &amp;lt;- aq.plot(Y)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-08-11-outliers-detection-in-r_files/figure-html/unnamed-chunk-31-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note also that some transformations may “naturally” eliminate outliers. The natural log or square root of a value reduces the variation caused by extreme values, so in some cases applying these transformations will help in making potential outliers less extreme.&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 helped you to detect outliers in R via several descriptive statistics (including minimum, maximum, histogram, boxplot and percentiles) or thanks to more formal techniques of outliers detection (including Hampel filter, Grubbs, Dixon and Rosner tests).&lt;/p&gt;
&lt;p&gt;It is now your turn to try to detect outliers in your data, and decide how to treat them (i.e., keeping, removing or imputing them) before conducting your analyses.&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;p&gt;&lt;em&gt;(Note that this article is available for download on my &lt;a href=&#34;https://statsandr.gumroad.com/&#34;&gt;Gumroad page&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-enderlein1987hawkins&#34; class=&#34;csl-entry&#34;&gt;
Enderlein, G. 1987. &lt;span&gt;“Hawkins, DM: Identification of Outliers. Chapman and Hall, London–New York 1980, 188 s.,&lt;span&gt;£&lt;/span&gt; 14, 50.”&lt;/span&gt; &lt;em&gt;Biometrical Journal&lt;/em&gt; 29 (2): 198–98.
&lt;/div&gt;
&lt;/div&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;Thanks Felix Kluxen for the valuable suggestion.&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 Victor for pointing out the &lt;code&gt;range()&lt;/code&gt; function.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Thanks to Marlenildo for pointing out the &lt;code&gt;identify_outliers()&lt;/code&gt; function.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;The default is 3 (according to Pearson’s rule), but another value is also possible.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;The constant in the &lt;code&gt;mad()&lt;/code&gt; function is 1.4826 by default, so it has to be set to 1 to find the median absolute deviation. See &lt;code&gt;help(mad)&lt;/code&gt; for more details. Thanks to Elisei for pointing this out to me.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;In order to avoid flawed conclusions, it is important to pre-screen the data (graphically with a boxplot for example) to make the selection of the number of potential outliers as accurate as possible prior to running Rosner’s test.&lt;a href=&#34;#fnref6&#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>Wilcoxon test in R: how to compare 2 groups under the non-normality assumption?</title>
      <link>https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/</link>
      <pubDate>Sun, 07 Jun 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#two-different-scenarios&#34; id=&#34;toc-two-different-scenarios&#34;&gt;Two different scenarios&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#independent-samples&#34; id=&#34;toc-independent-samples&#34;&gt;Independent samples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#paired-samples&#34; id=&#34;toc-paired-samples&#34;&gt;Paired samples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-plot-and-statistical-test&#34; id=&#34;toc-combination-of-plot-and-statistical-test&#34;&gt;Combination of plot and statistical test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#independent-samples-1&#34; id=&#34;toc-independent-samples-1&#34;&gt;Independent samples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#paired-samples-1&#34; id=&#34;toc-paired-samples-1&#34;&gt;Paired samples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#assumption-of-equal-variances&#34; id=&#34;toc-assumption-of-equal-variances&#34;&gt;Assumption of equal variances&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-06-07-wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption_files/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In a previous article, we showed how to &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;compare two groups under different scenarios using the Student’s t-test&lt;/a&gt;. The Student’s t-test requires that the distributions follow a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt; when in presence of small samples.&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;/p&gt;
&lt;p&gt;In this article, we show how to &lt;strong&gt;compare two groups when the normality assumption is violated&lt;/strong&gt;, using the &lt;strong&gt;Wilcoxon test&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The Wilcoxon test is a &lt;strong&gt;non-parametric test&lt;/strong&gt;, meaning that it does not rely on data belonging to any particular parametric family of probability distributions. Non-parametric tests have the same objective as their parametric counterparts. However, they have two advantages over parametric tests: they &lt;strong&gt;do not require the assumption of normality&lt;/strong&gt; of distributions and they can deal with &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A Student’s t-test for instance is only applicable if the data are Gaussian or if the sample size is large enough (usually &lt;span class=&#34;math inline&#34;&gt;\(n \ge 30\)&lt;/span&gt;, thanks to the central limit theorem). A non-parametric test should be used in other cases.&lt;/p&gt;
&lt;p&gt;One may wonder why we would not always use a non-parametric test so we do not have to bother about testing for normality. The reason is that non-parametric tests are usually less powerful than corresponding parametric tests when the normality assumption holds.&lt;/p&gt;
&lt;p&gt;Therefore, all else being equal, with a non-parametric test you are less likely to reject the &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/#step-1-stating-the-null-and-alternative-hypothesis&#34;&gt;null hypothesis&lt;/a&gt; when it is false if the data follows a normal distribution. It is thus preferred to use the parametric version of a &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt; when the assumptions are met.&lt;/p&gt;
&lt;p&gt;In the remaining of the article, we present the two scenarios of the Wilcoxon test and how to perform them in R through two examples.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;two-different-scenarios&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Two different scenarios&lt;/h1&gt;
&lt;p&gt;As for the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test&lt;/a&gt;, the Wilcoxon test is used to compare two groups and see whether they are significantly different from each other in terms of the variable of interest.&lt;/p&gt;
&lt;p&gt;The two groups to be compared are either:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;independent, or&lt;/li&gt;
&lt;li&gt;paired (i.e., dependent)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There are actually two versions of the Wilcoxon test:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The &lt;strong&gt;Mann-Whitney-Wilcoxon&lt;/strong&gt; test (also referred as Wilcoxon rank sum test or Mann-Whitney U test) is performed when the samples are &lt;strong&gt;independent&lt;/strong&gt; (so this test is the non-parametric equivalent to the Student’s t-test for independent samples).&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Wilcoxon signed-rank&lt;/strong&gt; test (also sometimes referred as Wilcoxon test for paired samples) is performed when the samples are &lt;strong&gt;paired/dependent&lt;/strong&gt; (so this test is the non-parametric equivalent to the Student’s t-test for paired samples).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Luckily, those two tests can be done in R with the same function: &lt;code&gt;wilcox.test()&lt;/code&gt;. They are presented in the following sections.&lt;/p&gt;
&lt;div id=&#34;independent-samples&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Independent samples&lt;/h2&gt;
&lt;p&gt;For the Wilcoxon test with independent samples, suppose that we want to test whether grades at the statistics exam differ between female and male students.&lt;/p&gt;
&lt;p&gt;We have collected grades for 24 students (12 girls and 12 boys):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- data.frame(
  Sex = as.factor(c(rep(&amp;quot;Girl&amp;quot;, 12), rep(&amp;quot;Boy&amp;quot;, 12))),
  Grade = c(
    19, 18, 9, 17, 8, 7, 16, 19, 20, 9, 11, 18,
    16, 5, 15, 2, 14, 15, 4, 7, 15, 6, 7, 14
  )
)

dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     Sex Grade
## 1  Girl    19
## 2  Girl    18
## 3  Girl     9
## 4  Girl    17
## 5  Girl     8
## 6  Girl     7
## 7  Girl    16
## 8  Girl    19
## 9  Girl    20
## 10 Girl     9
## 11 Girl    11
## 12 Girl    18
## 13  Boy    16
## 14  Boy     5
## 15  Boy    15
## 16  Boy     2
## 17  Boy    14
## 18  Boy    15
## 19  Boy     4
## 20  Boy     7
## 21  Boy    15
## 22  Boy     6
## 23  Boy     7
## 24  Boy    14&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here are the distributions of the grades by sex (using &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)

ggplot(dat) +
  aes(x = Sex, y = Grade) +
  geom_boxplot(fill = &amp;quot;#0c4c8a&amp;quot;) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-06-07-wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption_files/figure-html/unnamed-chunk-2-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We first check whether the 2 samples follow a normal distribution via a histogram and the Shapiro-Wilk test:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hist(subset(dat, Sex == &amp;quot;Girl&amp;quot;)$Grade,
  main = &amp;quot;Grades for girls&amp;quot;,
  xlab = &amp;quot;Grades&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-06-07-wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption_files/figure-html/unnamed-chunk-3-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hist(subset(dat, Sex == &amp;quot;Boy&amp;quot;)$Grade,
  main = &amp;quot;Grades for boys&amp;quot;,
  xlab = &amp;quot;Grades&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-06-07-wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption_files/figure-html/unnamed-chunk-3-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;shapiro.test(subset(dat, Sex == &amp;quot;Girl&amp;quot;)$Grade)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Shapiro-Wilk normality test
## 
## data:  subset(dat, Sex == &amp;quot;Girl&amp;quot;)$Grade
## W = 0.84548, p-value = 0.0323&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;shapiro.test(subset(dat, Sex == &amp;quot;Boy&amp;quot;)$Grade)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Shapiro-Wilk normality test
## 
## data:  subset(dat, Sex == &amp;quot;Boy&amp;quot;)$Grade
## W = 0.84313, p-value = 0.03023&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The histograms show that both distributions do not seem to follow a normal distribution and the &lt;em&gt;p&lt;/em&gt;-values of the Shapiro-Wilk tests confirm it (since we reject the null hypothesis of normality for both distributions at the 5% significance level).&lt;/p&gt;
&lt;p&gt;We just showed that normality assumption is violated for both groups so it is now time to see how to perform the Wilcoxon test in R.&lt;/p&gt;
&lt;p&gt;Note that in order to use the Student’s t-test (the parametric version of the Wilcoxon test), it is required that &lt;strong&gt;both samples follow a normal distribution&lt;/strong&gt; if samples are small.&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; Therefore, even if one sample follows a normal distribution (and the other does not follow a normal distribution), it is recommended to use the non-parametric test.&lt;/p&gt;
&lt;p&gt;Remember that the null and alternative hypothesis of the Wilcoxon test are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: the 2 groups are equal in terms of the variable of interest&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: the 2 groups are different in terms of the variable of interest&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Applied to our research question, we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: grades of girls and boys are equal&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: grades of girls and boys are different&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- wilcox.test(dat$Grade ~ dat$Sex)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Wilcoxon rank sum test with continuity correction
## 
## data:  dat$Grade by dat$Sex
## W = 31.5, p-value = 0.02056
## alternative hypothesis: true location shift is not equal to 0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We obtain the test statistic, the &lt;em&gt;p&lt;/em&gt;-value and a reminder of the hypothesis tested.&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.021. Therefore, at the 5% significance level, we reject the null hypothesis and we conclude that grades are significantly different between girls and boys.&lt;/p&gt;
&lt;p&gt;Given the boxplot presented above showing the grades by sex, one may see that girls seem to perform better than boys. This can be tested formally by adding the &lt;code&gt;alternative = &#34;less&#34;&lt;/code&gt; argument to the &lt;code&gt;wilcox.test()&lt;/code&gt; function:&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- wilcox.test(dat$Grade ~ dat$Sex,
  alternative = &amp;quot;less&amp;quot;
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Wilcoxon rank sum test with continuity correction
## 
## data:  dat$Grade by dat$Sex
## W = 31.5, p-value = 0.01028
## alternative hypothesis: true location shift is less than 0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.01. Therefore, at the 5% significance level, we reject the null hypothesis and we conclude that boys performed significantly worse than girls (which is equivalent than concluding that girls performed significantly better than boys).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;paired-samples&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Paired samples&lt;/h2&gt;
&lt;p&gt;For this second scenario, consider that we administered a math test in a class of 12 students at the beginning of a semester, and that we administered a similar test at the end of the semester to the exact same students. We have the following data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat2 &amp;lt;- data.frame(
  Beginning = c(16, 5, 15, 2, 14, 15, 4, 7, 15, 6, 7, 14),
  End = c(19, 18, 9, 17, 8, 7, 16, 19, 20, 9, 11, 18)
)

dat2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    Beginning End
## 1         16  19
## 2          5  18
## 3         15   9
## 4          2  17
## 5         14   8
## 6         15   7
## 7          4  16
## 8          7  19
## 9         15  20
## 10         6   9
## 11         7  11
## 12        14  18&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We transform the dataset to have it in a &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/#introduction&#34;&gt;tidy format&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat2 &amp;lt;- data.frame(
  Time = c(rep(&amp;quot;Before&amp;quot;, 12), rep(&amp;quot;After&amp;quot;, 12)),
  Grade = c(dat2$Beginning, dat2$End)
)
dat2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      Time Grade
## 1  Before    16
## 2  Before     5
## 3  Before    15
## 4  Before     2
## 5  Before    14
## 6  Before    15
## 7  Before     4
## 8  Before     7
## 9  Before    15
## 10 Before     6
## 11 Before     7
## 12 Before    14
## 13  After    19
## 14  After    18
## 15  After     9
## 16  After    17
## 17  After     8
## 18  After     7
## 19  After    16
## 20  After    19
## 21  After    20
## 22  After     9
## 23  After    11
## 24  After    18&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The distribution of the grades at the beginning and after the semester:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Reordering dat2$Time
dat2$Time &amp;lt;- factor(dat2$Time,
  levels = c(&amp;quot;Before&amp;quot;, &amp;quot;After&amp;quot;)
)

ggplot(dat2) +
  aes(x = Time, y = Grade) +
  geom_boxplot(fill = &amp;quot;#0c4c8a&amp;quot;) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-06-07-wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption_files/figure-html/unnamed-chunk-8-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;(See the &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/&#34;&gt;&lt;code&gt;{esquisse}&lt;/code&gt; and &lt;code&gt;{questionr}&lt;/code&gt; addins&lt;/a&gt; to help you reorder levels of a factor variable and to easily 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;.)&lt;/p&gt;
&lt;p&gt;In this example, it is clear that the two samples are not independent since the same 12 students took the exam before and after the semester. Supposing also that the normality assumption is violated (and given the small sample size), we thus use the Wilcoxon test for &lt;strong&gt;paired samples&lt;/strong&gt;, with the following hypotheses:&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: grades before and after the semester are equal&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: grades before and after the semester are different&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We add the &lt;code&gt;paired = TRUE&lt;/code&gt; argument to the &lt;code&gt;wilcox.test()&lt;/code&gt; function to take into consideration the dependency between the 2 samples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;before &amp;lt;- dat2$Grade[dat2$Time == &amp;quot;Before&amp;quot;]
after &amp;lt;- dat2$Grade[dat2$Time == &amp;quot;After&amp;quot;]
test &amp;lt;- wilcox.test(before, after, paired = TRUE)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Wilcoxon signed rank test with continuity correction
## 
## data:  before and after
## V = 21, p-value = 0.1692
## alternative hypothesis: true location shift is not equal to 0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We obtain the test statistic, the &lt;em&gt;p&lt;/em&gt;-value and a reminder of the hypothesis tested.&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.169. Therefore, at the 5% significance level, we do not reject the null hypothesis that the grades are similar before and after the semester.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-plot-and-statistical-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Combination of plot and statistical test&lt;/h1&gt;
&lt;p&gt;After having written this article, I discovered the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package which I believe is worth mentioning here, in particular the &lt;code&gt;ggbetweenstats()&lt;/code&gt; and &lt;code&gt;ggwithinstats()&lt;/code&gt; functions for independent and paired samples, respectively.&lt;/p&gt;
&lt;p&gt;These two functions combine a boxplot—representing the distribution for each group—and the results of the statistical test displayed in the subtitle of the plot.&lt;/p&gt;
&lt;p&gt;See examples below for independent and paired samples, using the same data than previously.&lt;/p&gt;
&lt;div id=&#34;independent-samples-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Independent samples&lt;/h2&gt;
&lt;p&gt;For independent samples, it is the &lt;code&gt;ggbetweenstats()&lt;/code&gt; function which is used:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(ggstatsplot)

# plot with statistical results
ggbetweenstats( # independent samples
  data = dat,
  x = Sex,
  y = Grade,
  plot.type = &amp;quot;box&amp;quot;, # for boxplot
  type = &amp;quot;nonparametric&amp;quot;, # for wilcoxon
  centrality.plotting = FALSE # remove median
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-06-07-wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption_files/figure-html/unnamed-chunk-10-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value (displayed after &lt;code&gt;p =&lt;/code&gt; in the subtitle of the plot) indicates that we reject the null hypothesis, and we conclude that grades are significantly different between girls and boys (&lt;em&gt;p&lt;/em&gt;-value = 0.02).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;paired-samples-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Paired samples&lt;/h2&gt;
&lt;p&gt;For paired samples, it is the &lt;code&gt;ggwithinstats()&lt;/code&gt; function which is used:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(ggstatsplot)

# plot with statistical results
ggwithinstats( # paired samples
  data = dat2,
  x = Time,
  y = Grade,
  type = &amp;quot;nonparametric&amp;quot;, # for wilcoxon
  centrality.plotting = FALSE # remove median
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-06-07-wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption_files/figure-html/unnamed-chunk-11-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value (displayed after &lt;code&gt;p =&lt;/code&gt; in the subtitle of the plot) indicates that we do not reject the null hypothesis, so we do not reject the hypothesis that grades are equal before and after the semester (&lt;em&gt;p&lt;/em&gt;-value = 0.17).&lt;/p&gt;
&lt;p&gt;The point of this section was to illustrate how to easily draw plots together with statistical results, which is exactly the aim of the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package. See more details and examples in this &lt;a href=&#34;https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;assumption-of-equal-variances&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Assumption of equal variances&lt;/h1&gt;
&lt;p&gt;As written at the beginning of the article, the Wilcoxon test does not require the assumption of normality in case of small samples.&lt;/p&gt;
&lt;p&gt;Regarding the assumption of equal variances, this assumption may or may not be needed depending on your goal. If you only want to compare the two groups, you do not have to test the equality of variances because the two distributions do not have to have the same shape. However, if your goal is to &lt;strong&gt;compare medians of the two groups&lt;/strong&gt;, then you will need to make sure that the two distributions have the same shape (and thus, the same variance).&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So results of your test of equality of variances will change your interpretation: differences in the “distributions” of two groups or differences in the “medians” of two groups.&lt;/p&gt;
&lt;p&gt;In this article I do not wish to compare medians, I only want compare the groups by determining whether there are differences in the distributions of the two groups. This is the reason I do not test for equality of variances.&lt;/p&gt;
&lt;p&gt;Note that this is equivalent when performing the &lt;a href=&#34;https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/&#34;&gt;Kruskal-Wallis test&lt;/a&gt; to compare three groups or more (i.e., the non-parametric version of the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt;): if you only want to test whether there are differences in the groups you do not need homoscedasticity, whereas if you want to compare the medians this assumption must be met.&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 helped you to compare two groups that do not follow a normal distribution in R using the Wilcoxon test. See also:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the &lt;a href=&#34;https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/&#34;&gt;one-sample Wilcoxon test&lt;/a&gt; if you have only one group and want to compare it to a default given value,&lt;/li&gt;
&lt;li&gt;the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test&lt;/a&gt; if you need to perform the parametric version of the two-sample Wilcoxon test,&lt;/li&gt;
&lt;li&gt;and the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; if you need to compare 3 groups or more.&lt;/li&gt;
&lt;/ul&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-stevens2013intermediate&#34; class=&#34;csl-entry&#34;&gt;
Stevens, James P. 2013. &lt;em&gt;Intermediate Statistics: A Modern Approach&lt;/em&gt;. Routledge.
&lt;/div&gt;
&lt;/div&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;Remember that the normality assumption can be tested via 3 complementary methods: (i) histogram, (ii) QQ-plot and (iii) normality tests (with the most common being the Shapiro-Wilk test). See &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;how to determine if a distribution follows a normal distribution&lt;/a&gt; if you need a refresh.&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;In case of large samples, &lt;strong&gt;normality is not required&lt;/strong&gt; (this is a common misconception!). By the &lt;a href=&#34;https://en.wikipedia.org/wiki/Central_limit_theorem&#34; target=&#34;_blank&#34;&gt;central limit theorem&lt;/a&gt;, sample means of large samples are often well-approximated by a normal distribution even if the data are not normally distributed &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-stevens2013intermediate&#34;&gt;Stevens 2013&lt;/a&gt;)&lt;/span&gt;.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Note that the presence of equal elements (ties) prevents an exact &lt;em&gt;p&lt;/em&gt;-value calculation. This can be tackled by computing the exact or asymptotic Wilcoxon-Mann-Whitney test with adjustment for ties, using the &lt;code&gt;wilcox_test()&lt;/code&gt; function from the &lt;code&gt;{coin}&lt;/code&gt; package: &lt;code&gt;wilcox_test(dat$Grade ~ dat$Sex, distribution = exact())&lt;/code&gt; or &lt;code&gt;wilcox_test(dat$Grade ~ dat$Sex)&lt;/code&gt;. In our case, conclusions remain unchanged.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;We add &lt;code&gt;alternative = &#34;less&#34;&lt;/code&gt; (and not &lt;code&gt;alternative = &#34;greater&#34;&lt;/code&gt;) because we want to test that grades for boys are &lt;strong&gt;less&lt;/strong&gt; than grade for girls. Using &lt;code&gt;&#34;less&#34;&lt;/code&gt; or &lt;code&gt;&#34;greater&#34;&lt;/code&gt; can be deducted from the reference level in the dataset.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;Note that for paired samples (when in presence of a small sample), normality must be checked on the &lt;em&gt;differences&lt;/em&gt; between the two paired samples, and not individually on the two samples like it is done for independent samples.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;See these three articles for a more detailed discussion on the assumption of equal variances in Wilcoxon test: &lt;a href=&#34;https://statistics.laerd.com/statistical-guides/mann-whitney-u-test-assumptions.php&#34;&gt;1&lt;/a&gt;, &lt;a href=&#34;https://influentialpoints.com/Training/Wilcoxon-Mann-Whitney_U_test_use_and_misuse.htm&#34;&gt;2&lt;/a&gt; &amp;amp; &lt;a href=&#34;https://influentialpoints.com/Training/Wilcoxon_matched_pairs_signed_rank_test_use_and_misuse.htm&#34;&gt;3&lt;/a&gt;.&lt;a href=&#34;#fnref6&#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>How to publish a Shiny app? An example with shinyapps.io</title>
      <link>https://statsandr.com/blog/how-to-publish-shiny-app-example-with-shinyapps-io/</link>
      <pubDate>Fri, 29 May 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-publish-shiny-app-example-with-shinyapps-io/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#prerequisite&#34; id=&#34;toc-prerequisite&#34;&gt;Prerequisite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-by-step-guide&#34; id=&#34;toc-step-by-step-guide&#34;&gt;Step-by-step guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#additional-notes&#34; id=&#34;toc-additional-notes&#34;&gt;Additional notes&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#settings-of-your-app&#34; id=&#34;toc-settings-of-your-app&#34;&gt;Settings of your app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#publish-your-dataset&#34; id=&#34;toc-publish-your-dataset&#34;&gt;Publish your dataset&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/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/how-to-deploy-a-shiny-app-an-example-with-shinyapps-io.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;The &lt;a href=&#34;https://statsandr.com/tags/coronavirus/&#34;&gt;COVID-19&lt;/a&gt; virus led many people to create interactive apps and dashboards. A reader recently asked me how to publish a &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny app&lt;/a&gt; she just created. Similarly to a previous article where I show &lt;a href=&#34;https://statsandr.com/blog/how-to-upload-r-code-on-github-example-with-an-r-script-on-mac-os/&#34;&gt;how to upload R code on GitHub&lt;/a&gt;, I thought it would be useful to some people to see how I publish my Shiny apps so they could do the same.&lt;/p&gt;
&lt;p&gt;Before going through the different steps required to deploy your Shiny app online, you can check the final result with my apps &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note 1: The screenshots have been taken on MacOS and I have not tested it on Windows. Do not hesitate to let me know in the comments whether it is similar or not on other operating systems.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note 2: There are other ways to publish your app (with Docker for example), but the method shown below is easy (in my opinion) and works well.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;prerequisite&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Prerequisite&lt;/h1&gt;
&lt;p&gt;I personally use the &lt;a href=&#34;https://www.shinyapps.io/&#34; target=&#34;_blank&#34;&gt;shinyapps.io&lt;/a&gt; platform to deploy my &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny apps&lt;/a&gt;. So in order to follow this guide you will first need to create an account (if you do not already have one).&lt;/p&gt;
&lt;p&gt;They offer a free plan, but you are limited to 5 active applications and a monthly usage of 25 active hours.&lt;/p&gt;
&lt;p&gt;For your information, if you make your app available to a wide audience, expect to exceed the monthly cap of active hours quite quickly. To increase the monthly limit (or to publish more than 5 apps), you will need to upgrade your plan to a paying one.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-by-step-guide&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Step-by-step guide&lt;/h1&gt;
&lt;p&gt;Below the steps to follow in pictures.&lt;/p&gt;
&lt;p&gt;Step 1: Open &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;RStudio&lt;/a&gt; and create a new Shiny app:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-1.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 2: Give it a name (without space), choose where to save it and click on the Create button:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-2.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 3: In the same way as when you open a new &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt; document, the code for a basic Shiny app is created. Run the app by clicking on the Run App button to see the result:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-3.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 4: The basic app opens, publish it:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-4.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 5: If it is your first Shiny app, the box “Publish From Account” should be empty. Click on “Add New Account” to link the shinyapps.io account you just created:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-5.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 6: Click on the first alternative (ShinyApps.io):&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-6.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 7: Click on the link to your ShinyApps account:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-7.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 8: Click on the Dashboard button to log in into your account:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-8.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 9: Click on your name and then on Tokens&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-9.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 10: If this is your first app, there should be no token already created. Create one by clicking on the Add Token button. Then Click on the Show button:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-10.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 11: Click on the Show Secret button:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-11.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 12: Now the code is complete (nothing is hidden anymore). Click on the Copy to clipboard button:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-12.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 13: Copy the code and click on the OK button:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-13.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 14: Go back to RStudio, paste the code in the console and run it:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-14.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Your computer is now authorized to deploy applications to your shinyapps.io account.&lt;/p&gt;
&lt;p&gt;Step 15: Go back to the window where you can publish your app, choose a title (without space) and click on the Publish button:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-15.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 16: After several seconds (depending on the weight of your app), the Shiny app should appear in your internet browser:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-16.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 17: You can now edit the app (or replace the entire code by another of your app), and run the app again by clicking on the Run App button. For this illustration, I just added a link for more information in the side panel:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-17.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 18: Check that the modifications have been taken into account (the link appears in the side panel as expected) and republish your app:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-18.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 19: Click on the Publish button:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Step 20: Your app is live! You can now share it and everyone with the link will be able to use it:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-20.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-notes&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Additional notes&lt;/h1&gt;
&lt;div id=&#34;settings-of-your-app&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Settings of your app&lt;/h2&gt;
&lt;p&gt;If you need to change the settings of your Shiny app, go to your shinyapps.io dashboard and click on the app you just created to access the settings:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-21.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;See the different settings in the tabs located at the top of the windows, and see the link to the app next to the URL field:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish-shiny-app-online-shinyapps-io-22.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;publish-your-dataset&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Publish your dataset&lt;/h2&gt;
&lt;p&gt;It is often the case that your Shiny app uses a dataset that is not loaded in R by default (it uses one of your dataset that is saved locally on your computer for instance).&lt;/p&gt;
&lt;p&gt;To make the app work with your data, you will also need to publish the data when publishing your app (check the checkbox corresponding to your data):&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-29-how-to-deploy-a-shiny-app-an-example-with-shinyapps-io_files/publish%20shiny%20app%20shinyapps.io.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;Publish your dataset together with the app&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you would like to have more flexibility, another way to be able to use an external dataset in your app is to host it online:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;if you have a website, you can easily publish it through your website&lt;/li&gt;
&lt;li&gt;if you do not have a website, you can host the dataset via GitHub (if you do not have an account, it is a good time to create one!)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The last step is then to import the data via that new URL (put the data import in the code of your app).&lt;/p&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 this tutorial helped you to publish your first Shiny app.&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>Correlation coefficient and correlation test in R</title>
      <link>https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/</link>
      <pubDate>Thu, 28 May 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-coefficient&#34; id=&#34;toc-correlation-coefficient&#34;&gt;Correlation coefficient&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#between-two-variables&#34; id=&#34;toc-between-two-variables&#34;&gt;Between two variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-matrix-correlations-for-all-variables&#34; id=&#34;toc-correlation-matrix-correlations-for-all-variables&#34;&gt;Correlation matrix: correlations for all variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interpretation-of-a-correlation-coefficient&#34; id=&#34;toc-interpretation-of-a-correlation-coefficient&#34;&gt;Interpretation of a correlation coefficient&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualizations&#34; id=&#34;toc-visualizations&#34;&gt;Visualizations&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#a-scatterplot-for-2-variables&#34; id=&#34;toc-a-scatterplot-for-2-variables&#34;&gt;A scatterplot for 2 variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scatterplots-for-several-pairs-of-variables&#34; id=&#34;toc-scatterplots-for-several-pairs-of-variables&#34;&gt;Scatterplots for several pairs of variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#another-simple-correlation-matrix&#34; id=&#34;toc-another-simple-correlation-matrix&#34;&gt;Another simple correlation matrix&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-test&#34; id=&#34;toc-correlation-test&#34;&gt;Correlation test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#for-2-variables&#34; id=&#34;toc-for-2-variables&#34;&gt;For 2 variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#for-several-pairs-of-variables&#34; id=&#34;toc-for-several-pairs-of-variables&#34;&gt;For several pairs of variables&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-correlation-coefficients-and-correlation-tests&#34; id=&#34;toc-combination-of-correlation-coefficients-and-correlation-tests&#34;&gt;Combination of correlation coefficients and correlation tests&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#correlograms&#34; id=&#34;toc-correlograms&#34;&gt;Correlograms&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-does-not-imply-causation&#34; id=&#34;toc-correlation-does-not-imply-causation&#34;&gt;Correlation does not imply causation&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/correlation-coefficient-and-correlation-test-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Correlations between variables play an important role in a &lt;a href=&#34;https://statsandr.com/tags/descriptive-statistics/&#34;&gt;descriptive analysis&lt;/a&gt;. A correlation measures the &lt;strong&gt;relationship between two variables&lt;/strong&gt;, that is, how they are linked to each other. In this sense, a correlation allows to know which variables evolve in the same direction, which ones evolve in the opposite direction, and which ones are independent.&lt;/p&gt;
&lt;p&gt;In this article, I show how to compute &lt;strong&gt;correlation coefficients&lt;/strong&gt;, how to perform &lt;strong&gt;correlation tests&lt;/strong&gt; and how to &lt;strong&gt;visualize relationships&lt;/strong&gt; between variables in R.&lt;/p&gt;
&lt;p&gt;Correlation is usually computed on two &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative&lt;/a&gt; variables, but it can also be computed on two &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#ordinal&#34;&gt;qualitative ordinal&lt;/a&gt; variables.&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; See the &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; if you need to study the relationship between two &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#nominal&#34;&gt;qualitative nominal&lt;/a&gt; variables.&lt;/p&gt;
&lt;p&gt;If you need to &lt;em&gt;quantify&lt;/em&gt; the relationship between two variables, I refer you to the article about &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;In this article, we use the &lt;code&gt;mtcars&lt;/code&gt; dataset (loaded by default in R):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# display first 5 observations
head(mtcars, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
## Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The variables &lt;code&gt;vs&lt;/code&gt; and &lt;code&gt;am&lt;/code&gt; are categorical variables, so they are removed for this article:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# remove vs and am variables
library(tidyverse)
dat &amp;lt;- mtcars %&amp;gt;%
  select(-vs, -am)

# display 5 first obs. of new dataset
head(dat, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                    mpg cyl disp  hp drat    wt  qsec gear carb
## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46    4    4
## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02    4    4
## Datsun 710        22.8   4  108  93 3.85 2.320 18.61    4    1
## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44    3    1
## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02    3    2&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation-coefficient&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Correlation coefficient&lt;/h1&gt;
&lt;div id=&#34;between-two-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Between two variables&lt;/h2&gt;
&lt;p&gt;The correlation between 2 variables is found with the &lt;code&gt;cor()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;Suppose we want to compute the correlation between horsepower (&lt;code&gt;hp&lt;/code&gt;) and miles per gallon (&lt;code&gt;mpg&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Pearson correlation between 2 variables
cor(dat$hp, dat$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.7761684&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the correlation between variables &lt;em&gt;X&lt;/em&gt; and &lt;em&gt;Y&lt;/em&gt; is equal to the correlation between variables &lt;em&gt;Y&lt;/em&gt; and &lt;em&gt;X&lt;/em&gt; so the order of the variables in the &lt;code&gt;cor()&lt;/code&gt; function does not matter.&lt;/p&gt;
&lt;p&gt;The Pearson correlation is computed by default with the &lt;code&gt;cor()&lt;/code&gt; function. If you want to compute the Spearman correlation, add the argument &lt;code&gt;method = &#34;spearman&#34;&lt;/code&gt; to the &lt;code&gt;cor()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Spearman correlation between 2 variables
cor(dat$hp, dat$mpg,
  method = &amp;quot;spearman&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.8946646&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The most common correlation methods (Run &lt;code&gt;?cor&lt;/code&gt; for more information about the different methods available in the &lt;code&gt;cor()&lt;/code&gt; function) are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pearson&lt;/strong&gt; correlation is often used for &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;quantitative continuous&lt;/a&gt; variables that have a linear relationship&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Spearman&lt;/strong&gt; correlation (which is actually similar to Pearson but based on the ranked values for each variable rather than on the raw data) is often used to evaluate relationships involving at least one &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#ordinal&#34;&gt;qualitative ordinal&lt;/a&gt; variable or two quantitative variables if the link is partially linear&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kendall’s tau-b&lt;/strong&gt; which is computed from the number of concordant and discordant pairs is often used for qualitative ordinal variables&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that there exists the &lt;em&gt;point-biserial correlation&lt;/em&gt; (which can be used to measure the association between a continuous variable and a nominal variable of two levels), but this correlation is not covered here.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation-matrix-correlations-for-all-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Correlation matrix: correlations for all variables&lt;/h2&gt;
&lt;p&gt;Suppose now that we want to compute correlations for several pairs of variables. We can easily do so for all possible pairs of variables in the dataset, again with the &lt;code&gt;cor()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# correlation for all variables
round(cor(dat),
  digits = 2 # rounded to 2 decimals
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        mpg   cyl  disp    hp  drat    wt  qsec  gear  carb
## mpg   1.00 -0.85 -0.85 -0.78  0.68 -0.87  0.42  0.48 -0.55
## cyl  -0.85  1.00  0.90  0.83 -0.70  0.78 -0.59 -0.49  0.53
## disp -0.85  0.90  1.00  0.79 -0.71  0.89 -0.43 -0.56  0.39
## hp   -0.78  0.83  0.79  1.00 -0.45  0.66 -0.71 -0.13  0.75
## drat  0.68 -0.70 -0.71 -0.45  1.00 -0.71  0.09  0.70 -0.09
## wt   -0.87  0.78  0.89  0.66 -0.71  1.00 -0.17 -0.58  0.43
## qsec  0.42 -0.59 -0.43 -0.71  0.09 -0.17  1.00 -0.21 -0.66
## gear  0.48 -0.49 -0.56 -0.13  0.70 -0.58 -0.21  1.00  0.27
## carb -0.55  0.53  0.39  0.75 -0.09  0.43 -0.66  0.27  1.00&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This correlation matrix gives an overview of the correlations for all combinations of two variables.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;interpretation-of-a-correlation-coefficient&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Interpretation of a correlation coefficient&lt;/h2&gt;
&lt;p&gt;First of all, correlation ranges from &lt;strong&gt;-1 to 1&lt;/strong&gt;. It gives us an indication on two things:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The direction of the relationship between the 2 variables&lt;/li&gt;
&lt;li&gt;The strength of the relationship between the 2 variables&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Regarding the direction of the relationship: On the one hand, a &lt;strong&gt;negative correlation&lt;/strong&gt; implies that the two variables under consideration vary in &lt;strong&gt;opposite directions&lt;/strong&gt;, that is, if a variable increases the other decreases and vice versa. On the other hand, a &lt;strong&gt;positive correlation&lt;/strong&gt; implies that the two variables under consideration vary in the &lt;strong&gt;same direction&lt;/strong&gt;, i.e., if a variable increases the other one increases and if one decreases the other one decreases as well.&lt;/p&gt;
&lt;p&gt;Regarding the strength of the relationship: The &lt;strong&gt;more extreme&lt;/strong&gt; the correlation coefficient (the closer to -1 or 1), the &lt;strong&gt;stronger the relationship&lt;/strong&gt;. This also means that a &lt;strong&gt;correlation close to 0&lt;/strong&gt; indicates that the two variables are &lt;strong&gt;independent&lt;/strong&gt;, that is, as one variable increases, there is no tendency in the other variable to either decrease or increase.&lt;/p&gt;
&lt;p&gt;As an illustration, the Pearson correlation between horsepower (&lt;code&gt;hp&lt;/code&gt;) and miles per gallon (&lt;code&gt;mpg&lt;/code&gt;) found above is -0.78, meaning that the 2 variables vary in opposite direction. This makes sense, cars with more horsepower tend to consume more fuel (and thus have a lower mileage per gallon). On the contrary, from the correlation matrix we see that the correlation between miles per gallon (&lt;code&gt;mpg&lt;/code&gt;) and the time to drive 1/4 of a mile (&lt;code&gt;qsec&lt;/code&gt;) is 0.42, meaning that fast cars (low &lt;code&gt;qsec&lt;/code&gt;) tend to have a worse mileage per gallon (low &lt;code&gt;mpg&lt;/code&gt;). This again makes sense as fast cars tend to consume more fuel.&lt;/p&gt;
&lt;p&gt;Note that it is a good practice to visualize the type of the relationship between the two variables &lt;em&gt;before&lt;/em&gt; interpreting the correlation coefficients. The reason is that the correlation coefficient could be biased due to an &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outlier&lt;/a&gt; or due to the type of link between the two variables.&lt;/p&gt;
&lt;p&gt;For instance, see the two Pearson correlation coefficients (denoted by &lt;code&gt;R&lt;/code&gt; in the following plots) when the outlier is excluded and included:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-6-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The Pearson correlation coefficient changes drastically due to a single point, and thus the interpretation. It goes from a negative correlation coefficient, indicating a negative relationship between the 2 variables, to a positive coefficient, indicating a positive relationship. We would have missed this insight if we had not visualized the data in a scatterplot (see how to draw a scatterplot in this &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/#visualizations&#34;&gt;section&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;A correlation coefficient may also miss a non-linear link between two variables:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-7-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The Pearson correlation coefficient is equal to 0, indicating no relationship between the two variables, because it measures the &lt;strong&gt;linear&lt;/strong&gt; relationship and it is clear from the plot that the link is non-linear.&lt;/p&gt;
&lt;p&gt;So to recap, it is a good practice to visualize the data via a scatterplot before interpreting a correlation coefficient (it does not tell the whole story) and see how the correlation coefficient changes when using the parametric (Pearson) or nonparametric version (Spearman or Kendall’s tau-b).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;visualizations&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Visualizations&lt;/h1&gt;
&lt;p&gt;The correlation matrix presented above is not easily interpretable, especially when the dataset is composed of many variables. In the following sections, we present some alternatives to the correlation matrix for better readability.&lt;/p&gt;
&lt;div id=&#34;a-scatterplot-for-2-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;A scatterplot for 2 variables&lt;/h2&gt;
&lt;p&gt;A good way to visualize a correlation between 2 variables is to draw a scatterplot of the two variables of interest. Suppose we want to examine the relationship between horsepower (&lt;code&gt;hp&lt;/code&gt;) and miles per gallon (&lt;code&gt;mpg&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# scatterplot
library(ggplot2)

ggplot(dat) +
  aes(x = hp, y = mpg) +
  geom_point(colour = &amp;quot;#0c4c8a&amp;quot;) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-8-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you are unfamiliar 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;, you can draw the scatterplot using the &lt;code&gt;plot()&lt;/code&gt; function from R base graphics:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(dat$hp, dat$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-9-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;or use the &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#esquisse&#34;&gt;esquisse addin&lt;/a&gt; to easily draw plots using the &lt;code&gt;{ggplot2}&lt;/code&gt; package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scatterplots-for-several-pairs-of-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scatterplots for several pairs of variables&lt;/h2&gt;
&lt;p&gt;Suppose that instead of visualizing the relationship between only 2 variables, we want to visualize the relationship for several pairs of variables. This is possible thanks to the &lt;code&gt;pair()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;For this illustration, we focus only on miles per gallon (&lt;code&gt;mpg&lt;/code&gt;), horsepower (&lt;code&gt;hp&lt;/code&gt;) and weight (&lt;code&gt;wt&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# multiple scatterplots
pairs(dat[, c(&amp;quot;mpg&amp;quot;, &amp;quot;hp&amp;quot;, &amp;quot;wt&amp;quot;)])&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-10-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The figure indicates that weight (&lt;code&gt;wt&lt;/code&gt;) and horsepower (&lt;code&gt;hp&lt;/code&gt;) are positively correlated, whereas miles per gallon (&lt;code&gt;mpg&lt;/code&gt;) seems to be negatively correlated with horsepower (&lt;code&gt;hp&lt;/code&gt;) and weight (&lt;code&gt;wt&lt;/code&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;another-simple-correlation-matrix&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Another simple correlation matrix&lt;/h2&gt;
&lt;p&gt;This version of the correlation matrix presents the correlation coefficients in a slightly more readable way, i.e., by coloring the coefficients based on their sign. Applied to our dataset, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# improved correlation matrix
library(corrplot)

corrplot(cor(dat),
  method = &amp;quot;number&amp;quot;,
  type = &amp;quot;upper&amp;quot; # show only upper side
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-11-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Correlation test&lt;/h1&gt;
&lt;div id=&#34;for-2-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;For 2 variables&lt;/h2&gt;
&lt;p&gt;Unlike a correlation matrix which indicates the correlation coefficients between some pairs of variables in the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt;, a correlation test is used to test whether the correlation (denoted &lt;span class=&#34;math inline&#34;&gt;\(\rho\)&lt;/span&gt;) between 2 variables is significantly different from 0 or not in the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Actually, a correlation coefficient different from 0 in the sample does not mean that the correlation is &lt;strong&gt;significantly&lt;/strong&gt; different from 0 in the population. This needs to be tested with a &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis test&lt;/a&gt;—and known as the correlation test.&lt;/p&gt;
&lt;p&gt;The null and alternative hypothesis for the correlation test are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\rho = 0\)&lt;/span&gt; (meaning that there is no linear relationship between the two variables)&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\rho \ne 0\)&lt;/span&gt; (meaning that there is a linear relationship between the two variables)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Via this correlation test, what we are actually testing is whether:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the sample contains sufficient evidence to reject the null hypothesis and conclude that the correlation coefficient does not equal 0, so the relationship exists in the population.&lt;/li&gt;
&lt;li&gt;or on the contrary, the sample does not contain enough evidence that the correlation coefficient does not equal 0, so in this case we do not reject the null hypothesis of no relationship between the variables in the population.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that there are 2 assumptions for this test to be valid:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Independence of the data&lt;/li&gt;
&lt;li&gt;For small sample sizes (usually &lt;span class=&#34;math inline&#34;&gt;\(n &amp;lt; 30\)&lt;/span&gt;), the two variables should follow a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Suppose that we want to test whether the rear axle ratio (&lt;code&gt;drat&lt;/code&gt;) is correlated with the time to drive a quarter of a mile (&lt;code&gt;qsec&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Pearson correlation test
test &amp;lt;- cor.test(dat$drat, dat$qsec)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Pearson&amp;#39;s product-moment correlation
## 
## data:  dat$drat and dat$qsec
## t = 0.50164, df = 30, p-value = 0.6196
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.265947  0.426340
## sample estimates:
##        cor 
## 0.09120476&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value of the correlation test between these 2 variables is 0.62. At the 5% significance level, we do not reject the null hypothesis of no correlation. We therefore conclude that we do not reject the hypothesis that there is no linear relationship between the 2 variables.&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;This test proves that even if the correlation coefficient is different from 0 (the correlation is 0.09 in the sample), it is actually not significantly different from 0 in the population.&lt;/p&gt;
&lt;p&gt;Note that the &lt;em&gt;p&lt;/em&gt;-value of a correlation test is based on the correlation coefficient &lt;strong&gt;and&lt;/strong&gt; the sample size. The larger the sample size and the more extreme the correlation (closer to -1 or 1), the more likely the null hypothesis of no correlation will be rejected.&lt;/p&gt;
&lt;p&gt;With a small sample size, it is thus possible to obtain a &lt;em&gt;relatively&lt;/em&gt; large correlation in the sample (based on the correlation coefficient), but still find a correlation not significantly different from 0 in the population (based on the correlation test). For this reason, it is recommended to always perform a correlation test before interpreting a correlation coefficient to avoid flawed conclusions.&lt;/p&gt;
&lt;!-- A nice and easy way to report results of a correlation test in R is with the `report()` function from the `{report}` package: --&gt;
&lt;!-- As you can see, the function interprets the test (together with the correlation coefficient and the *p*-value) for you. --&gt;
&lt;!-- Note that the `report()` function can be used for other analyses. See more examples in the package&#39;s [documentation](https://easystats.github.io/report/){target=&#34;_blank&#34;}. See also more [tips and tricks in R](/blog/tips-and-tricks-in-rstudio-and-r-markdown/) if you find this one useful. --&gt;
&lt;/div&gt;
&lt;div id=&#34;for-several-pairs-of-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;For several pairs of variables&lt;/h2&gt;
&lt;p&gt;Similar to the correlation matrix used to compute correlation for several pairs of variables, the &lt;code&gt;rcorr()&lt;/code&gt; function (from the &lt;code&gt;{Hmisc}&lt;/code&gt; package) allows to compute &lt;em&gt;p&lt;/em&gt;-values of the correlation test for several pairs of variables at once. Applied to our dataset, we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# correlation tests for whole dataset
library(Hmisc)
res &amp;lt;- rcorr(as.matrix(dat)) # rcorr() accepts matrices only

# display p-values (rounded to 3 decimals)
round(res$P, 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        mpg   cyl  disp    hp  drat    wt  qsec  gear  carb
## mpg     NA 0.000 0.000 0.000 0.000 0.000 0.017 0.005 0.001
## cyl  0.000    NA 0.000 0.000 0.000 0.000 0.000 0.004 0.002
## disp 0.000 0.000    NA 0.000 0.000 0.000 0.013 0.001 0.025
## hp   0.000 0.000 0.000    NA 0.010 0.000 0.000 0.493 0.000
## drat 0.000 0.000 0.000 0.010    NA 0.000 0.620 0.000 0.621
## wt   0.000 0.000 0.000 0.000 0.000    NA 0.339 0.000 0.015
## qsec 0.017 0.000 0.013 0.000 0.620 0.339    NA 0.243 0.000
## gear 0.005 0.004 0.001 0.493 0.000 0.000 0.243    NA 0.129
## carb 0.001 0.002 0.025 0.000 0.621 0.015 0.000 0.129    NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Only correlations with &lt;em&gt;p&lt;/em&gt;-values smaller than the significance level (usually &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;) should be interpreted.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-correlation-coefficients-and-correlation-tests&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Combination of correlation coefficients and correlation tests&lt;/h1&gt;
&lt;p&gt;Now that we covered the concepts of correlation coefficients and correlation tests, let see if we can combine the two concepts.&lt;/p&gt;
&lt;p&gt;If you need to do this for a few pairs of variables, I recommend using the &lt;code&gt;ggscatterstats()&lt;/code&gt; function from the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package. Let’s see it in practice with one pair of variables—&lt;code&gt;wt&lt;/code&gt; and &lt;code&gt;mpg&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## plot with statistical results
library(ggstatsplot)

ggscatterstats(
  data = dat,
  x = wt,
  y = mpg,
  bf.message = FALSE,
  marginal = FALSE # remove histograms
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-15-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Based on the result of the test, we conclude that there is a negative correlation between the weight and the number of miles per gallon (&lt;span class=&#34;math inline&#34;&gt;\(r = - 0.87\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001).&lt;/p&gt;
&lt;p&gt;If you need to do it for many pairs of variables, I recommend using the the &lt;code&gt;correlation&lt;/code&gt; function from the &lt;a href=&#34;https://easystats.github.io/correlation/&#34; target=&#34;_blank&#34;&gt;easystats &lt;code&gt;{correlation}&lt;/code&gt; package&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This function allows to combine correlation coefficients and correlation tests for &lt;em&gt;several pairs&lt;/em&gt; of variables, all in a single table (thanks to &lt;a href=&#34;https://github.com/AntoineSoetewey/statsandr/issues/8&#34; target=&#34;_blank&#34;&gt;krzysiektr&lt;/a&gt; for pointing it out to me):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(correlation)

correlation::correlation(dat,
  include_factors = TRUE, method = &amp;quot;auto&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Correlation Matrix (auto-method)
## 
## Parameter1 | Parameter2 |     r |         95% CI | t(30) |         p
## --------------------------------------------------------------------
## mpg        |        cyl | -0.85 | [-0.93, -0.72] | -8.92 | &amp;lt; .001***
## mpg        |       disp | -0.85 | [-0.92, -0.71] | -8.75 | &amp;lt; .001***
## mpg        |         hp | -0.78 | [-0.89, -0.59] | -6.74 | &amp;lt; .001***
## mpg        |       drat |  0.68 | [ 0.44,  0.83] |  5.10 | &amp;lt; .001***
## mpg        |         wt | -0.87 | [-0.93, -0.74] | -9.56 | &amp;lt; .001***
## mpg        |       qsec |  0.42 | [ 0.08,  0.67] |  2.53 | 0.137    
## mpg        |       gear |  0.48 | [ 0.16,  0.71] |  3.00 | 0.065    
## mpg        |       carb | -0.55 | [-0.75, -0.25] | -3.62 | 0.016*   
## cyl        |       disp |  0.90 | [ 0.81,  0.95] | 11.45 | &amp;lt; .001***
## cyl        |         hp |  0.83 | [ 0.68,  0.92] |  8.23 | &amp;lt; .001***
## cyl        |       drat | -0.70 | [-0.84, -0.46] | -5.37 | &amp;lt; .001***
## cyl        |         wt |  0.78 | [ 0.60,  0.89] |  6.88 | &amp;lt; .001***
## cyl        |       qsec | -0.59 | [-0.78, -0.31] | -4.02 | 0.007**  
## cyl        |       gear | -0.49 | [-0.72, -0.17] | -3.10 | 0.054    
## cyl        |       carb |  0.53 | [ 0.22,  0.74] |  3.40 | 0.027*   
## disp       |         hp |  0.79 | [ 0.61,  0.89] |  7.08 | &amp;lt; .001***
## disp       |       drat | -0.71 | [-0.85, -0.48] | -5.53 | &amp;lt; .001***
## disp       |         wt |  0.89 | [ 0.78,  0.94] | 10.58 | &amp;lt; .001***
## disp       |       qsec | -0.43 | [-0.68, -0.10] | -2.64 | 0.131    
## disp       |       gear | -0.56 | [-0.76, -0.26] | -3.66 | 0.015*   
## disp       |       carb |  0.39 | [ 0.05,  0.65] |  2.35 | 0.177    
## hp         |       drat | -0.45 | [-0.69, -0.12] | -2.75 | 0.110    
## hp         |         wt |  0.66 | [ 0.40,  0.82] |  4.80 | &amp;lt; .001***
## hp         |       qsec | -0.71 | [-0.85, -0.48] | -5.49 | &amp;lt; .001***
## hp         |       gear | -0.13 | [-0.45,  0.23] | -0.69 | &amp;gt; .999   
## hp         |       carb |  0.75 | [ 0.54,  0.87] |  6.21 | &amp;lt; .001***
## drat       |         wt | -0.71 | [-0.85, -0.48] | -5.56 | &amp;lt; .001***
## drat       |       qsec |  0.09 | [-0.27,  0.43] |  0.50 | &amp;gt; .999   
## drat       |       gear |  0.70 | [ 0.46,  0.84] |  5.36 | &amp;lt; .001***
## drat       |       carb | -0.09 | [-0.43,  0.27] | -0.50 | &amp;gt; .999   
## wt         |       qsec | -0.17 | [-0.49,  0.19] | -0.97 | &amp;gt; .999   
## wt         |       gear | -0.58 | [-0.77, -0.29] | -3.93 | 0.008**  
## wt         |       carb |  0.43 | [ 0.09,  0.68] |  2.59 | 0.132    
## qsec       |       gear | -0.21 | [-0.52,  0.15] | -1.19 | &amp;gt; .999   
## qsec       |       carb | -0.66 | [-0.82, -0.40] | -4.76 | &amp;lt; .001***
## gear       |       carb |  0.27 | [-0.08,  0.57] |  1.56 | 0.774    
## 
## p-value adjustment method: Holm (1979)
## Observations: 32&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, it gives, among other useful information, the correlation coefficients (column &lt;code&gt;r&lt;/code&gt;) and the result of the correlation test (column &lt;code&gt;95% CI&lt;/code&gt; for the confidence interval or &lt;code&gt;p&lt;/code&gt; for the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value) for all pairs of variables.&lt;/p&gt;
&lt;div id=&#34;correlograms&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Correlograms&lt;/h2&gt;
&lt;p&gt;The table above is very useful and informative, but let see if it is possible to combine the concepts of correlation coefficients and correlations test in one single visualization. A visualization that would be easy to read and interpret.&lt;/p&gt;
&lt;p&gt;Ideally, we would like to have a concise overview of correlations between all possible pairs of variables present in a dataset, with a clear distinction for correlations that are significantly different from 0.&lt;/p&gt;
&lt;p&gt;The figure below, known as a &lt;a href=&#34;https://statsandr.com/blog/correlogram-in-r-how-to-highlight-the-most-correlated-variables-in-a-dataset/#correlogram&#34;&gt;correlogram&lt;/a&gt; and adapted from the &lt;code&gt;corrplot()&lt;/code&gt; function, does precisely this:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# do not edit
corrplot2 &amp;lt;- function(data,
                      method = &amp;quot;pearson&amp;quot;,
                      sig.level = 0.05,
                      order = &amp;quot;original&amp;quot;,
                      diag = FALSE,
                      type = &amp;quot;upper&amp;quot;,
                      tl.srt = 90,
                      number.font = 1,
                      number.cex = 1,
                      mar = c(0, 0, 0, 0)) {
  library(corrplot)
  data_incomplete &amp;lt;- data
  data &amp;lt;- data[complete.cases(data), ]
  mat &amp;lt;- cor(data, method = method)
  cor.mtest &amp;lt;- function(mat, method) {
    mat &amp;lt;- as.matrix(mat)
    n &amp;lt;- ncol(mat)
    p.mat &amp;lt;- matrix(NA, n, n)
    diag(p.mat) &amp;lt;- 0
    for (i in 1:(n - 1)) {
      for (j in (i + 1):n) {
        tmp &amp;lt;- cor.test(mat[, i], mat[, j], method = method)
        p.mat[i, j] &amp;lt;- p.mat[j, i] &amp;lt;- tmp$p.value
      }
    }
    colnames(p.mat) &amp;lt;- rownames(p.mat) &amp;lt;- colnames(mat)
    p.mat
  }
  p.mat &amp;lt;- cor.mtest(data, method = method)
  col &amp;lt;- colorRampPalette(c(&amp;quot;#BB4444&amp;quot;, &amp;quot;#EE9988&amp;quot;, &amp;quot;#FFFFFF&amp;quot;, &amp;quot;#77AADD&amp;quot;, &amp;quot;#4477AA&amp;quot;))
  corrplot(mat,
    method = &amp;quot;color&amp;quot;, col = col(200), number.font = number.font,
    mar = mar, number.cex = number.cex,
    type = type, order = order,
    addCoef.col = &amp;quot;black&amp;quot;, # add correlation coefficient
    tl.col = &amp;quot;black&amp;quot;, tl.srt = tl.srt, # rotation of text labels
    # combine with significance level
    p.mat = p.mat, sig.level = sig.level, insig = &amp;quot;blank&amp;quot;,
    # hide correlation coefficients on the diagonal
    diag = diag
  )
}

# edit from here
corrplot2(
  data = dat,
  method = &amp;quot;pearson&amp;quot;,
  sig.level = 0.05,
  order = &amp;quot;original&amp;quot;,
  diag = FALSE,
  type = &amp;quot;upper&amp;quot;,
  tl.srt = 75
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-17-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The correlogram shows correlation coefficients for all pairs of variables (with more intense colors for more extreme correlations), and correlations not significantly different from 0 are represented by a white box.&lt;/p&gt;
&lt;p&gt;To learn more about this plot and the code used, I invite you to read the article entitled “&lt;a href=&#34;https://statsandr.com/blog/correlogram-in-r-how-to-highlight-the-most-correlated-variables-in-a-dataset/&#34;&gt;Correlogram in R: how to highlight the most correlated variables in a dataset&lt;/a&gt;”.&lt;/p&gt;
&lt;p&gt;For those of you who are still not completely satisfied, I recently found two alternatives—one with the &lt;code&gt;ggpairs()&lt;/code&gt; function from the &lt;code&gt;{GGally}&lt;/code&gt; package and one with the &lt;code&gt;ggcormat()&lt;/code&gt; function from the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;The two functions are illustrated with the variables &lt;code&gt;mpg&lt;/code&gt;, &lt;code&gt;hp&lt;/code&gt; and &lt;code&gt;wt&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(GGally)

ggpairs(dat[, c(&amp;quot;mpg&amp;quot;, &amp;quot;hp&amp;quot;, &amp;quot;wt&amp;quot;)])&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-18-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The plot above combines correlation coefficients, correlation tests (via the asterisks next to the coefficients&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;) and scatterplots for all possible pairs of variables present in a dataset.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggstatsplot)

ggcorrmat(
  data = dat[, c(&amp;quot;mpg&amp;quot;, &amp;quot;hp&amp;quot;, &amp;quot;wt&amp;quot;)],
  type = &amp;quot;parametric&amp;quot;, # parametric for Pearson, nonparametric for Spearman&amp;#39;s correlation
  colors = c(&amp;quot;darkred&amp;quot;, &amp;quot;white&amp;quot;, &amp;quot;steelblue&amp;quot;) # change default colors
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-28-correlation-coefficient-and-correlation-test-in-r_files/figure-html/unnamed-chunk-19-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The plot above also shows the correlation coefficients and if any, the non-significant correlations (by default at the 5% significance level with the Holm adjustment method) are shown by a big cross on the correlation coefficients.&lt;/p&gt;
&lt;p&gt;The advantage of these two alternatives compared to the first one is that it is directly available within a package, so you do not need to run the code of the function first in order to draw the correlogram.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation-does-not-imply-causation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Correlation does not imply causation&lt;/h1&gt;
&lt;p&gt;I am pretty sure you have already heard the statement “Correlation does not imply causation” in statistics. An article about correlation would not be complete without discussing about causation.&lt;/p&gt;
&lt;p&gt;A non-zero correlation between two variables does not necessarily mean that there is a cause and effect relationship between these two variables!&lt;/p&gt;
&lt;p&gt;Indeed, a significant correlation between two variables means that changes in one variable are associated (positively or negatively) with changes in the other variable. Nonetheless, a significant correlation &lt;em&gt;does not&lt;/em&gt; indicate that variations in one variable &lt;em&gt;cause&lt;/em&gt; the variations in the other variable.&lt;/p&gt;
&lt;p&gt;A non-zero correlation between X and Y can appear in several cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;X causes Y&lt;/li&gt;
&lt;li&gt;Y causes X&lt;/li&gt;
&lt;li&gt;a third variable causes X and Y&lt;/li&gt;
&lt;li&gt;a combination of these three reasons&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Sometimes it is quite clear that there is a causal relationship between two variables. Take for example the correlation between the price of a consumer product such as milk and its consumption. It is quite obvious that there is a causal link between the two: if the price of milk increases, it is expected that its consumption will decrease.&lt;/p&gt;
&lt;p&gt;However, this causal link is not always present even if the correlation is significant. &lt;span class=&#34;citation&#34;&gt;Maurage et al. (&lt;a href=&#34;#ref-maurage2013does&#34;&gt;2013&lt;/a&gt;)&lt;/span&gt; showed that, although there is a positive and significant correlation between chocolate consumption and the number of Nobel laureates, this correlation comes from the fact that a third variable, Gross Domestic Product (GDP), causes chocolate consumption and the number of Nobel laureates. They found that countries with higher GDP tend to have a higher level of chocolate consumption and scientific research (leading to more Nobel laureates).&lt;/p&gt;
&lt;p&gt;This example shows that one must be very cautious when interpreting correlations and avoid over-interpreting a correlation as a causal relationship.&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 helped you to compute correlation coefficients and perform correlation tests in R. If you would like to learn how to compute the coefficients by hand, see this &lt;a href=&#34;https://statsandr.com/blog/pearson-spearman-kendall-correlation-by-hand/&#34;&gt;step-by-step tutorial&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;p&gt;&lt;em&gt;(Note that this article is available for download on my &lt;a href=&#34;https://statsandr.gumroad.com/&#34;&gt;Gumroad page&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-maurage2013does&#34; class=&#34;csl-entry&#34;&gt;
Maurage, Pierre, Alexandre Heeren, and Mauro Pesenti. 2013. &lt;span&gt;“Does Chocolate Consumption Really Boost Nobel Award Chances? The Peril of over-Interpreting Correlations in Health Studies.”&lt;/span&gt; &lt;em&gt;The Journal of Nutrition&lt;/em&gt; 143 (6): 931–33.
&lt;/div&gt;
&lt;/div&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;It is true that there is the point-biserial correlation which can be used with a nominal variable (consisting of two factors). Nonetheless, this type of correlation is much less known and usually not covered in introductory statistics classes; with one continuous and one nominal variable, it is much more frequent to learn about the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test&lt;/a&gt; (for a nominal variable with 2 groups) or &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; (for a nominal variable with 3 or more groups). More information about choosing the most appropriate measure of association depending on the type of variable can be found in this &lt;a href=&#34;https://journals.sagepub.com/doi/pdf/10.1177/8756479308317006&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.&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;It is important to remember that we tested for a &lt;em&gt;linear&lt;/em&gt; relationship between the two variables since we used the Pearson’s correlation. It may be the case that there is a relationship between the two variables in the population, but this relation may not be linear.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;One asterisk means that the coefficient is significant at the 5% level, 2 is at the 1% significance level, and 3 is at the 0.1% significance level. This is usually the case in R; the more asterisks, the more it is significant.&lt;a href=&#34;#fnref3&#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>How to upload your R code on GitHub? An example with an R script on MacOS</title>
      <link>https://statsandr.com/blog/how-to-upload-r-code-on-github-example-with-an-r-script-on-mac-os/</link>
      <pubDate>Sun, 24 May 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-upload-r-code-on-github-example-with-an-r-script-on-mac-os/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#prerequisite&#34; id=&#34;toc-prerequisite&#34;&gt;Prerequisite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-by-step-guide&#34; id=&#34;toc-step-by-step-guide&#34;&gt;Step-by-step guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#additional-notes&#34; id=&#34;toc-additional-notes&#34;&gt;Additional notes&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;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;A few days ago, a colleague asked me how to upload some R code on GitHub in order to make it accessible to everyone. Due to the lockdown, I could not just go into his office and show him on his computer. So I sent him several screenshots showing, step by step, how to do so.&lt;/p&gt;
&lt;p&gt;Right before I deleted the screenshots I’d just taken, I thought that perhaps they would be useful for other persons, so I wrote this article.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note 1: The screenshots have been taken on MacOS and I have not tested it on Windows. Do not hesitate to let me know in the comments whether it is similar or not on other operating systems.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note 2: There must be other ways to do it, but the method shown below is (in my opinion) easy and works well.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;prerequisite&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Prerequisite&lt;/h1&gt;
&lt;p&gt;In order to follow this guide and upload your R code on GitHub, you will need at least:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;a href=&#34;https://github.com/&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt; account&lt;/li&gt;
&lt;li&gt;the &lt;a href=&#34;https://desktop.github.com/&#34; target=&#34;_blank&#34;&gt;GitHub Desktop&lt;/a&gt; application installed on your computer&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;step-by-step-guide&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Step-by-step guide&lt;/h1&gt;
&lt;p&gt;For this guide, I use a R script created to plot the &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium-is-it-over-yet/&#34;&gt;evolution of the hospital admissions due to COVID-19 in Belgium&lt;/a&gt;. See the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures&#34; target=&#34;_blank&#34;&gt;repository on GitHub&lt;/a&gt; in case you want to see the final result before proceeding further.&lt;/p&gt;
&lt;p&gt;You often hear&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“A picture is worth a thousand words”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So here is without further ado how to upload your R script on GitHub in images:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-1.png&#34; alt=&#34;Step 1: Go to github.com/login and sign in&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Go to github.com/login and sign in&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-2.png&#34; alt=&#34;Step 2: Go to your GitHub profile and create a new repository&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Go to your GitHub profile and create a new repository&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-3.png&#34; alt=&#34;Step 3: Set the name, description, audience and README file for the new repository&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Set the name, description, audience and README file for the new repository&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Be careful that if you choose to make it &lt;strong&gt;public&lt;/strong&gt;, it will be &lt;strong&gt;visible to everyone&lt;/strong&gt;. If you do not want to share the code, but still want it to be uploaded on GitHub, choose the private option.&lt;/p&gt;
&lt;p&gt;Initializing the repo with a README file is not mandatory, but I strongly recommend it so you will be able to add information for this repo.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-4.png&#34; alt=&#34;Step 4: You now see your new repository with only the README file&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 4: You now see your new repository with only the README file&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-5.png&#34; alt=&#34;Step 5: Open the GitHub Desktop application and sign in with your GitHub account&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 5: Open the GitHub Desktop application and sign in with your GitHub account&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-6.png&#34; alt=&#34;Step 6 a: Clone the repository you just created on github.com to your computer&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 6 a: Clone the repository you just created on github.com to your computer&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-7.png&#34; alt=&#34;Step 6 b: Clone the repository you just created on github.com to your computer&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 6 b: Clone the repository you just created on github.com to your computer&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-8.png&#34; alt=&#34;Step 6 c: Clone the repository you just created on github.com to your computer&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 6 c: Clone the repository you just created on github.com to your computer&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-9.png&#34; alt=&#34;Step 7: Your new repo appears on the GitHub Desktop application&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 7: Your new repo appears on the GitHub Desktop application&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-10.png&#34; alt=&#34;Step 8: Open an R script and write your code&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 8: Open an R script and write your code&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;(See &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;how to install R and RStudio&lt;/a&gt; if you are unfamiliar with it.)&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-11.png&#34; alt=&#34;Step 9 a: Save your R script in the corresponding folder&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 9 a: Save your R script in the corresponding folder&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can see the path to the folder in step 6 c, under “Local Path”.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-12.png&#34; alt=&#34;Step 9 b: Save your R script in the corresponding folder&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 9 b: Save your R script in the corresponding folder&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-13.png&#34; alt=&#34;Step 10: Reopen GitHub Desktop, edit the commit title (1) and click on the commit button (2)&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 10: Reopen GitHub Desktop, edit the commit title (1) and click on the commit button (2)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In step 10, make sure that the current repository (see top left) is the repo you are currently working on.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-14.png&#34; alt=&#34;Step 11: Push the commit to github.com&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 11: Push the commit to github.com&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-15.png&#34; alt=&#34;Step 12: On your GitHub profile, click on the newly created repository&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 12: On your GitHub profile, click on the newly created repository&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-16.png&#34; alt=&#34;Step 13: You now see your script which has been added to the repository&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 13: You now see your script which has been added to the repository&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Your R code is now available online via the new repository on your GitHub profile. If you need to share it, you can simply share the URL of the repo.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-notes&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Additional notes&lt;/h1&gt;
&lt;p&gt;If you need to edit your code:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Find the folder of the repo on your computer by clicking on the button “Show in Finder”:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/find%20the%20repo%20on%20your%20computer.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Find the folder of your repo on your computer&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Find the folder of your repo on your computer&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;You will be redirected to the folder of your repo on your computer. Open the R script you want to work on, edit it and save it:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-17.png&#34; alt=&#34;Open the R script, edit it and save it&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Open the R script, edit it and save it&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;After your script is saved, &lt;strong&gt;do not forget to commit the changes and push the commit&lt;/strong&gt; (see step 10 above).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In case you need to see an old version of your code, you can see all commits by clicking on the commits tab accessible via the repo on github.com:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-18.png&#34; alt=&#34;See all commits&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;See all commits&lt;/div&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 this article helped you to create a GitHub repository, and upload your R scripts so that it is available to anyone.&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>COVID-19 in Belgium: is it over yet?</title>
      <link>https://statsandr.com/blog/covid-19-in-belgium-is-it-over-yet/</link>
      <pubDate>Fri, 22 May 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/covid-19-in-belgium-is-it-over-yet/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#new-hospital-admissions&#34; id=&#34;toc-new-hospital-admissions&#34;&gt;New hospital admissions&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#overall&#34; id=&#34;toc-overall&#34;&gt;Overall&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-period&#34; id=&#34;toc-by-period&#34;&gt;By period&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#zooming-in&#34; id=&#34;toc-zooming-in&#34;&gt;Zooming in&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#patients-in-hospitals&#34; id=&#34;toc-patients-in-hospitals&#34;&gt;Patients in hospitals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#patients-in-intensive-care&#34; id=&#34;toc-patients-in-intensive-care&#34;&gt;Patients in intensive care&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#confirmed-cases&#34; id=&#34;toc-confirmed-cases&#34;&gt;Confirmed cases&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-province&#34; id=&#34;toc-by-province&#34;&gt;By province&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-age-group-and-sex&#34; id=&#34;toc-by-age-group-and-sex&#34;&gt;By age group and sex&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#static&#34; id=&#34;toc-static&#34;&gt;Static&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#dynamic&#34; id=&#34;toc-dynamic&#34;&gt;Dynamic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-age-group-sex-and-province&#34; id=&#34;toc-by-age-group-sex-and-province&#34;&gt;By age group, sex and province&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Note 1: The present article has been written on May 22, 2020 and has been updated infrequently. The current situation regarding COVID-19 in Belgium may therefore be different to what is presented below. See my &lt;a href=&#34;https://twitter.com/statsandr&#34; target=&#34;_blank&#34;&gt;Twitter&lt;/a&gt; profile for more frequent updates of the plots.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note 2: This is a joint work with Prof. &lt;a href=&#34;https://twitter.com/NikoSpeybroeck&#34; target=&#34;_blank&#34;&gt;Niko Speybroeck&lt;/a&gt;, Prof. &lt;a href=&#34;https://twitter.com/CatherineLinard&#34; target=&#34;_blank&#34;&gt;Catherine Linard&lt;/a&gt;, Prof. &lt;a href=&#34;https://twitter.com/sdellicour&#34; target=&#34;_blank&#34;&gt;Simon Dellicour&lt;/a&gt; and &lt;a href=&#34;https://twitter.com/arosas_aguirre&#34; target=&#34;_blank&#34;&gt;Angel Rosas-Aguirre&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Belgium recently started to lift its lockdown measures initially imposed to contain the spread of the Covid-19. Following this decision taken by Belgian authorities, we analyze how the situation evolved so far.&lt;/p&gt;
&lt;p&gt;Contrarily to a previous article in which I analyzed the outbreak of the &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium/&#34;&gt;Coronavirus in Belgium using the SIR model&lt;/a&gt;, in this article we focus on the evolution of the number of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;hospital admissions&lt;/li&gt;
&lt;li&gt;patients in hospitals&lt;/li&gt;
&lt;li&gt;patients in intensive care&lt;/li&gt;
&lt;li&gt;new confirmed cases&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;at the province and national level.&lt;/p&gt;
&lt;p&gt;Data is from &lt;a href=&#34;https://epistat.wiv-isp.be/covid/&#34; target=&#34;_blank&#34;&gt;Sciensano&lt;/a&gt; and all plots were created 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;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;new-hospital-admissions&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;New hospital admissions&lt;/h1&gt;
&lt;div id=&#34;overall&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Overall&lt;/h2&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalisations_COVID-19_1.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Belgian hospitalizations COVID-19&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Belgian hospitalizations COVID-19&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;From the above figure, we see that the rate of hospitalizations continue with a decreasing trend in all provinces (and in Belgium as well).&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalisations_COVID-19_1.png&#34;&gt;Download&lt;/a&gt; the figure, or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/plot_hosp_trends_divid_twographs.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update of October 27, 2020:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalizations_2710.png&#34; style=&#34;width:100.0%&#34; alt=&#34;COVID19 hospitalizations in Belgium&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;COVID19 hospitalizations in Belgium&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalizations_2710.png&#34;&gt;Download&lt;/a&gt; the figure, or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/plot_hosp_trends_divid_twographs_2710.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The detailed situation in Brabant:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalizations_splitBrabant_2710.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalizations_splitBrabant_2710.png&#34;&gt;Download&lt;/a&gt; the figure, or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/plot_hosp_trends_divid_splitBrabant_2710.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;by-period&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;By period&lt;/h3&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/EvolutionHospitalizations_red2.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Daily COVID19 hospitalizations in Belgium from March to October 2020&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Daily COVID19 hospitalizations in Belgium from March to October 2020&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/EvolutionHospitalizations_red2.png&#34;&gt;Download&lt;/a&gt; the figure, or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/EvolutionProvincesCOVID_v3.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update of November 16, 2020:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/EvolutionHospitalizations_16_11_20.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Daily COVID19 hospitalizations in Belgium by period&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Daily COVID19 hospitalizations in Belgium by period&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/EvolutionHospitalizations_16_11_20.png&#34;&gt;Download&lt;/a&gt; the figure.&lt;/p&gt;
&lt;p&gt;In the first wave, the province of Limburg recorded on average the highest number of COVID19 hospital admissions per million inhabitants. During the second wave, Liège and Hainaut struggled with the highest rates. With two exceptions (Antwerp and Limburg), last month was worse than in March-April. In three provinces (Hainaut, Namur and Liège), the number has more than doubled.&lt;/p&gt;
&lt;p&gt;During the period from June 14 to July 15, 2020, the number of COVID19 hospital admissions in Belgium fell to very low relative levels, but we have failed to maintain them. Now that hospital admissions are no longer increasing, we hope that the colors will lighten up again a bit as the end of the year approaches.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;zooming-in&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Zooming in&lt;/h2&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalisations_COVID-19_3weeks.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Hospital admissions COVID-19 - Belgium&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Hospital admissions COVID-19 - Belgium&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalisations_COVID-19_3weeks.png&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/plot_hosp_trends_divid_3weeks.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalisations_COVID-19_4weeks_limited.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalisations_COVID-19_4weeks_limited.png&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/plot_hosp_trends_divid_4weeks_limited_1.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update of February 26, 2021:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There is some ongoing debate in Belgium on whether or not to ease restrictions. On February 26, 2021, Belgian authorities will meet, discuss, debate and decide. Current levels and trends of COVID-19 hospitalizations may guide them:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/fig_trends3_1.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;There is still no strong evidence that COVID-19 hospitalization curves decrease in Belgium. The comparison between the first (in gray - dates &amp;amp; curve) and second wave (in blue - dates &amp;amp; curve) needs to be done with care, but indicates that current hospitalization levels are not as low as some may like:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/fig_trends2_2.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Zooming in provides some additional insights on the COVID-19 levels during the first and second waves at province level:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalizations_2602.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This shows that the second wave resulted in more hospitalizations than the first one in most Belgian provinces, despite the warning of a first deadly wave. It also illustrates the fact that daily hospitalizations in Belgium are currently still higher than what was observed at the end of the first wave.&lt;/p&gt;
&lt;p&gt;Put simply, the bad news is that the combination of the number of contacts and the risk of transmission by contact seems (at the moment) not sufficiently low to result in a considerable decrease of hospitalizations. Yet (put simply), the good news today is that there is already some immunity in the population and that vaccinations may increase this immunity considerably. This can help in pushing curves down. Let’s not lose hope.&lt;/p&gt;
&lt;p&gt;Download figures (&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/fig_trends3_1.png&#34;&gt;1&lt;/a&gt;, &lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/fig_trends2_2.png&#34;&gt;2&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalizations_2602.png&#34;&gt;3&lt;/a&gt;) or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/plot_hosp_trends_divid_twographs_23_02_2021_fr.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update of May 10, 2021:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/covid19-hospitalization-belgium-waves1and2.jpeg&#34; style=&#34;width:100.0%&#34; alt=&#34;COVID19 hospitalizations - Wave 1 and 2&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;COVID19 hospitalizations - Wave 1 and 2&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When looking at the above plot, bad news are that:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;current levels correspond to levels of October 2020 and&lt;/li&gt;
&lt;li&gt;current levels are still about double the target of 75 hospitalizations per day.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There are, however, three good news (compared to October 2020):&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;decreasing curve,&lt;/li&gt;
&lt;li&gt;vaccination and&lt;/li&gt;
&lt;li&gt;good weather.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Update of June 4, 2021&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/covid19-hospitalisations-belgium-june4.jpeg&#34; style=&#34;width:100.0%&#34; alt=&#34;COVID-19 hospitalizations in Belgium below 75/day&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;COVID-19 hospitalizations in Belgium below 75/day&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The good news is that the number of COVID-19 hospitalizations in Belgium is now below the well-known threshold of 75 hospitalizations per day (which is a target defined by the Belgian government). This is the way to go, and we hope this trend will continue in the coming days/weeks.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;patients-in-hospitals&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Patients in hospitals&lt;/h1&gt;
&lt;p&gt;Below the evolution of the number of patients in hospitals in Belgium:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalizations_total_2810.png&#34; style=&#34;width:100.0%&#34; alt=&#34;COVID19 patients in hospitals in Belgium&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;COVID19 patients in hospitals in Belgium&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalizations_total_2810.png&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/plot_hosp_trends_divid_twographs_total_2810.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We see that, as of October 28, 2020, the number of COVID19 patients in Belgian hospitals reached the peak of the first wave. So although patients stay shorter at the hospital during the second wave compared to the first wave, hospitals are still getting crowded.&lt;/p&gt;
&lt;p&gt;Therefore, if the number of patients in hospitals follows the same path in the coming weeks, hospitals will quickly become too crowded and will not be able to accept new patients as their maximum capacity will soon be reached (if this is not already the case…).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;patients-in-intensive-care&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Patients in intensive care&lt;/h1&gt;
&lt;p&gt;Below the evolution of COVID19 patients in intensive care in Belgium, with short-term projections and 99% confidence interval:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/covid19-patients-in-intensive-care-in-belgium.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Evolution of COVID19 patients in intensive care in Belgium&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Evolution of COVID19 patients in intensive care in Belgium&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/covid19-patients-in-intensive-care-in-belgium.png&#34;&gt;Download&lt;/a&gt; the figure.&lt;/p&gt;
&lt;p&gt;Short-term projections indicate what may have happened without the slow-down in transmission. This slow-down is positive news.&lt;/p&gt;
&lt;p&gt;The maps show total intensive care patients by province if these would have had the Belgian population. Map at the top shows maximum levels in March-April and map at the bottom shows current levels. The maps indicate high intensive care use due to COVID19. In most Belgian provinces, numbers are still higher today than March-April peak numbers.&lt;/p&gt;
&lt;p&gt;Observations are in line with other preliminary indications, such as trends of COVID19 hospitalizations (currently relatively volatile), indicating that transmission is slowing down:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/evolution-covid19-hospital-admissions-belgium.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/evolution-covid19-hospital-admissions-belgium.png&#34;&gt;Download&lt;/a&gt; the figure.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;confirmed-cases&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Confirmed cases&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Note that the reported number of new confirmed cases is probably underestimated. This number does not take into account undiagnosed (without or with few symptoms) or untested cases. Therefore, figures with number of cases should be interpreted with extreme caution.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;by-province&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;By province&lt;/h2&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/new_cases_divid.png&#34; style=&#34;width:100.0%&#34; alt=&#34;New confirmed COVID-19 cases in Belgium&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;New confirmed COVID-19 cases in Belgium&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/new_cases_divid.png&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/new_cases_divid.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;by-age-group-and-sex&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;By age group and sex&lt;/h2&gt;
&lt;div id=&#34;static&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Static&lt;/h3&gt;
&lt;p&gt;Below another visualization of the number of cases by age group and sex in Belgium, for three different periods:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot-week-limit.png&#34; style=&#34;width:100.0%&#34; alt=&#34;COVID-19 cases by age group and sex in Belgium&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;COVID-19 cases by age group and sex in Belgium&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot-week-limit.png&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/pyramid-plot-week.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This visualization shows the importance to report ages of cases and not just total number.&lt;/p&gt;
&lt;p&gt;Moreover, we see that the distribution of cases per week by age group at the beginning of September is similar than during the summer holidays, but the number of cases per week is higher. The distribution of cases per week by age group at the beginning of September is however different from the “first wave” (period from March 1, 2020 to May 31, 2020). During the fist period, majority of cases were elderly, while at the beginning of September majority of cases are young people. It would be interesting to see how the distribution of cases by age group evolves during winter.&lt;/p&gt;
&lt;p&gt;The figure above may be put in relation with the structure of the Belgian population:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot-population.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Structure of Belgian population (2019)&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Structure of Belgian population (2019)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot-population.png&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/pyramid-plot-population.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dynamic&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Dynamic&lt;/h3&gt;
&lt;p&gt;Additionally, these can be seen dynamically:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot-week-animated.gif&#34; style=&#34;width:100.0%&#34; alt=&#34;COVID-19 cases by age group and sex in Belgium - dynamic version&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;COVID-19 cases by age group and sex in Belgium - dynamic version&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot-week-animated.gif&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/pyramid-plot-week-animated.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With an update of the second wave:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot-week-animated-incidence.gif&#34; style=&#34;width:100.0%&#34; alt=&#34;Age and sex specific incidence per 100 000 of COVID19 cases in Belgium - dynamic version&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Age and sex specific incidence per 100 000 of COVID19 cases in Belgium - dynamic version&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot-week-animated-incidence.gif&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/pyramid-plot-week-animated.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;by-age-group-sex-and-province&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;By age group, sex and province&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot_facets_incidence_week.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/pyramid-plot_facets_incidence_week.png&#34;&gt;Download&lt;/a&gt; the figure or see the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures/blob/master/pyramid-plot_facets_incidence_week.R&#34; target=&#34;_blank&#34;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;/div&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;We hope that these figures will evolve in the right direction. In the meantime, take care and stay safe!&lt;/p&gt;
&lt;p&gt;If you would like to be further updated on the evolution of the COVID-19 epidemic, two options:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;visit the blog from time to time, and&lt;/li&gt;
&lt;li&gt;join Twitter and follow us: &lt;a href=&#34;https://twitter.com/statsandr&#34; target=&#34;_blank&#34;&gt;statsandr&lt;/a&gt;, &lt;a href=&#34;https://twitter.com/NikoSpeybroeck&#34; target=&#34;_blank&#34;&gt;NikoSpeybroeck&lt;/a&gt; &amp;amp; &lt;a href=&#34;https://twitter.com/arosas_aguirre&#34; target=&#34;_blank&#34;&gt;arosas_aguirre&lt;/a&gt;&lt;/li&gt;
&lt;/ol&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>One-proportion and chi-square goodness of fit test</title>
      <link>https://statsandr.com/blog/one-proportion-and-goodness-of-fit-test-in-r-and-by-hand/</link>
      <pubDate>Wed, 13 May 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/one-proportion-and-goodness-of-fit-test-in-r-and-by-hand/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-r&#34; id=&#34;toc-in-r&#34;&gt;In R&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#one-proportion-test&#34; id=&#34;toc-one-proportion-test&#34;&gt;One-proportion test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#assumption-of-prop.test-and-binom.test&#34; id=&#34;toc-assumption-of-prop.test-and-binom.test&#34;&gt;Assumption of &lt;code&gt;prop.test()&lt;/code&gt; and &lt;code&gt;binom.test()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#chi-square-goodness-of-fit-test&#34; id=&#34;toc-chi-square-goodness-of-fit-test&#34;&gt;Chi-square goodness of fit test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#assumptions&#34; id=&#34;toc-assumptions&#34;&gt;Assumptions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#does-my-distribution-follow-a-given-distribution&#34; id=&#34;toc-does-my-distribution-follow-a-given-distribution&#34;&gt;Does my distribution follow a given distribution?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#observed-frequencies&#34; id=&#34;toc-observed-frequencies&#34;&gt;Observed frequencies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#expected-frequencies&#34; id=&#34;toc-expected-frequencies&#34;&gt;Expected frequencies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#observed-vs.-expected-frequencies&#34; id=&#34;toc-observed-vs.-expected-frequencies&#34;&gt;Observed vs. expected frequencies&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand&#34; id=&#34;toc-by-hand&#34;&gt;By hand&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#one-proportion-test-1&#34; id=&#34;toc-one-proportion-test-1&#34;&gt;One-proportion test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#verification-in-r&#34; id=&#34;toc-verification-in-r&#34;&gt;Verification in R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#goodness-of-fit-test&#34; id=&#34;toc-goodness-of-fit-test&#34;&gt;Goodness of fit test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#verification-in-r-1&#34; id=&#34;toc-verification-in-r-1&#34;&gt;Verification in R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/One-proportion%20and%20goodness%20of%20fit%20test%20in%20R%20and%20by%20hand.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In a previous article, I presented the &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;Chi-square test of independence in R&lt;/a&gt; which is used to test the independence between two &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;categorical&lt;/a&gt; variables.&lt;/p&gt;
&lt;p&gt;In this article, I show how to perform, first in R and then by hand, the:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;one-proportion test (also referred as one-sample proportion test)&lt;/li&gt;
&lt;li&gt;Chi-square goodness of fit test&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first test is used to compare an observed proportion to an expected proportion, when the qualitative variable has only &lt;strong&gt;two categories&lt;/strong&gt;. The second test is used to compare multiple observed proportions to multiple expected proportions, in a situation where the qualitative variable has &lt;strong&gt;two or more categories&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Both tests allow to test the equality of proportions between the levels of the qualitative variable or to test the equality with given proportions. These given proportions could be determined arbitrarily or based on the theoretical probabilities of a known distribution.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;In R&lt;/h1&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;For this section, we use the same dataset than in the article on &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt;. It is the well-known &lt;code&gt;iris&lt;/code&gt; dataset, to which we add the variable &lt;code&gt;size&lt;/code&gt;. The variable &lt;code&gt;size&lt;/code&gt; corresponds to &lt;code&gt;small&lt;/code&gt; if the length of the petal is smaller than the median of all flowers, &lt;code&gt;big&lt;/code&gt; otherwise:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load iris dataset
dat &amp;lt;- iris

# create size variable
dat$size &amp;lt;- ifelse(dat$Sepal.Length &amp;lt; median(dat$Sepal.Length),
  &amp;quot;small&amp;quot;, &amp;quot;big&amp;quot;
)

# show first 5 observations
head(dat, n = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species  size
## 1          5.1         3.5          1.4         0.2  setosa small
## 2          4.9         3.0          1.4         0.2  setosa small
## 3          4.7         3.2          1.3         0.2  setosa small
## 4          4.6         3.1          1.5         0.2  setosa small
## 5          5.0         3.6          1.4         0.2  setosa small&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;one-proportion-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;One-proportion test&lt;/h2&gt;
&lt;p&gt;For this example, we have a sample of 150 flowers and we want to test whether the proportion of small flowers is different than the proportion of big flowers (measured by the variable &lt;code&gt;size&lt;/code&gt;). Here are the number of flowers by size, and the corresponding proportions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# barplot
library(ggplot2)
ggplot(dat) +
  aes(x = size) +
  geom_bar(fill = &amp;quot;#0c4c8a&amp;quot;) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# counts by size
table(dat$size)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##   big small 
##    77    73&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# proportions by size, rounded to 2 decimals
round(prop.table(table(dat$size)), 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##   big small 
##  0.51  0.49&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Among the 150 flowers forming our sample, 51% and 49% are big and small, respectively. To test whether the proportions are different among both sizes, we use the &lt;code&gt;prop.test()&lt;/code&gt; function which accepts the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;number of successes&lt;/li&gt;
&lt;li&gt;number of observations/trials&lt;/li&gt;
&lt;li&gt;expected probability (the one we want to test against)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The hypotheses in our example are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: proportions of big and small flowers are equal&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: proportions of big and small flowers are different&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Considering (arbitrarily) that &lt;code&gt;big&lt;/code&gt; is the success, we have:&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;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# one-proportion test
test &amp;lt;- prop.test(
  x = 77, # number of successes
  n = 150, # total number of trials (77 + 73)
  p = 0.5 # we test for equal proportion so prob = 0.5 in each group
)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  1-sample proportions test with continuity correction
## 
## data:  77 out of 150, null probability 0.5
## X-squared = 0.06, df = 1, p-value = 0.8065
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4307558 0.5952176
## sample estimates:
##         p 
## 0.5133333&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We obtain an output with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the null probability (&lt;code&gt;0.5&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the test statistic (&lt;code&gt;X-squared = 0.06&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the degrees of freedom (&lt;code&gt;df = 1&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the &lt;em&gt;p&lt;/em&gt;-value (&lt;code&gt;p-value = 0.8065&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the alternative hypothesis (&lt;code&gt;true p is not equal to 0.5&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the 95% confidence interval (which can also be extracted with &lt;code&gt;test$conf.int&lt;/code&gt;) and&lt;/li&gt;
&lt;li&gt;the proportion in the sample (&lt;code&gt;0.5133333&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.806 so, at the 5% significance level, we do not reject the null hypothesis that the proportions of small and big flowers are the same.&lt;/p&gt;
&lt;p&gt;An alternative is the &lt;code&gt;ggpiestats()&lt;/code&gt; function from the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package:&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;pre class=&#34;r&#34;&gt;&lt;code&gt;## plot with statistical results
library(ggstatsplot)
ggpiestats(
  data = dat,
  x = size,
  bf.message = FALSE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value (the value after &lt;code&gt;p =&lt;/code&gt; in the subtitle of the plot) is slightly different because Yates’ continuity correction is not applied in &lt;code&gt;ggpiestats()&lt;/code&gt; while it is applied by default in &lt;code&gt;prop.test()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The conclusion remains however the same, that is, we do not reject the null hypothesis that proportions of big and small flowers are equal.&lt;/p&gt;
&lt;div id=&#34;assumption-of-prop.test-and-binom.test&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Assumption of &lt;code&gt;prop.test()&lt;/code&gt; and &lt;code&gt;binom.test()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Note that &lt;code&gt;prop.test()&lt;/code&gt; uses a normal approximation to the binomial distribution. Therefore, one assumption of this test is that the sample size is large enough (usually, &lt;em&gt;n &amp;gt; 30&lt;/em&gt;). If the sample size is small, it is recommended to use the exact binomial test.&lt;/p&gt;
&lt;p&gt;The exact binomial test can be performed with the &lt;code&gt;binom.test()&lt;/code&gt; function and accepts the same arguments as the &lt;code&gt;prop.test()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;For this example, suppose now that we have a sample of 12 big and 3 small flowers and we want to test whether the proportions are the same among both sizes:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# barplot
barplot(c(12, 3), # observed counts
  names.arg = c(&amp;quot;big&amp;quot;, &amp;quot;small&amp;quot;), # rename labels
  ylab = &amp;quot;Frequency&amp;quot;, # y-axis label
  xlab = &amp;quot;Size&amp;quot; # x-axis label
)
abline(
  h = 15 / 2, # expected counts in each level
  lty = 2 # dashed line
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-5-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# exact binomial test
test &amp;lt;- binom.test(
  x = 12, # counts of successes
  n = 15, # total counts (12 + 3)
  p = 0.5 # expected proportion
)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Exact binomial test
## 
## data:  12 and 15
## number of successes = 12, number of trials = 15, p-value = 0.03516
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.5191089 0.9566880
## sample estimates:
## probability of success 
##                    0.8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.035 so, at the 5% significance level, we reject the null hypothesis and we conclude that the proportions of small and big flowers are significantly different. This is equivalent than concluding that the proportion of big flowers is significantly different from 0.5 (since there are only two sizes).&lt;/p&gt;
&lt;p&gt;If you want to test that the proportion of big flowers is greater than 50%, add the &lt;code&gt;alternative = &#34;greater&#34;&lt;/code&gt; argument into the &lt;code&gt;binom.test()&lt;/code&gt; function:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- binom.test(
  x = 12, # counts of successes
  n = 15, # total counts (12 + 3)
  p = 0.5, # expected proportion
  alternative = &amp;quot;greater&amp;quot; # test that prop of big flowers is &amp;gt; 0.5
)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Exact binomial test
## 
## data:  12 and 15
## number of successes = 12, number of trials = 15, p-value = 0.01758
## alternative hypothesis: true probability of success is greater than 0.5
## 95 percent confidence interval:
##  0.5602156 1.0000000
## sample estimates:
## probability of success 
##                    0.8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.018 so, at the 5% significance level, we reject the null hypothesis and we conclude that the proportion of big flowers is significantly larger than 50%.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;chi-square-goodness-of-fit-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Chi-square goodness of fit test&lt;/h2&gt;
&lt;p&gt;Suppose now that the qualitative variable has more than two levels as it is the case for the variable &lt;code&gt;Species&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# barplot
ggplot(dat) +
  aes(x = Species) +
  geom_bar(fill = &amp;quot;#0c4c8a&amp;quot;) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-7-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# counts by Species
table(dat$Species)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##     setosa versicolor  virginica 
##         50         50         50&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The variable &lt;code&gt;Species&lt;/code&gt; has 3 levels, with 50 observations in each level.&lt;/p&gt;
&lt;p&gt;Suppose for this example that we want to test whether the 3 species are equally common. If they were equally common, they would be equally distributed and the expected proportions would be &lt;span class=&#34;math inline&#34;&gt;\(\frac{1}{3}\)&lt;/span&gt; for each of the species.&lt;/p&gt;
&lt;p&gt;The hypotheses are now:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: proportions of each species are equal&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: there is at least one species with a different proportion&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This test can be done with the &lt;code&gt;chisq.test()&lt;/code&gt; function, accepting the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a numeric vector representing the observed proportions&lt;/li&gt;
&lt;li&gt;a vector of probabilities (of the same length of the observed proportions) representing the expected proportions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Applied to our research question (i.e., are the 3 species equally common?), we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# chi-square goodness of fit test
test &amp;lt;- chisq.test(table(dat$Species), # observed proportions
  p = c(1 / 3, 1 / 3, 1 / 3) # expected proportions
)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Chi-squared test for given probabilities
## 
## data:  table(dat$Species)
## X-squared = 0, df = 2, p-value = 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 1 so, at the 5% significance level, we do not reject the null hypothesis that the proportions are equal among all species.&lt;/p&gt;
&lt;p&gt;This was quite obvious even before doing the &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt; given that there are exactly 50 flowers of each species, so it was easy to see that the species are equally common. We however still did the test to show how it works in practice.&lt;/p&gt;
&lt;p&gt;Note that the alternative proposed by the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package can also be used for a Chi-square goodness of fit test:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## plot with statistical results
ggpiestats(
  data = dat,
  x = Species,
  bf.message = FALSE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-9-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;assumptions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Assumptions&lt;/h3&gt;
&lt;p&gt;One of the assumptions of the chi-square goodness of fit test is that the sample size is large enough in order for the chi-square approximation to be valid.&lt;/p&gt;
&lt;p&gt;To be more precise, there must be at least 5 &lt;em&gt;expected&lt;/em&gt; frequencies in each group of your categorical variable. This can be verified as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;chisq.test(table(dat$Species))$expected&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     setosa versicolor  virginica 
##         50         50         50&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The assumption of sufficiently large sample size is met as all expected frequencies are above 5.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;does-my-distribution-follow-a-given-distribution&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Does my distribution follow a given distribution?&lt;/h3&gt;
&lt;p&gt;In the previous section, we chose the proportions ourselves. The goodness of fit test is also particularly useful to compare observed proportions with expected proportions that are based on some known distribution.&lt;/p&gt;
&lt;p&gt;Remember the hypotheses of the test:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: there is no significant difference between the observed and the expected frequencies&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: there is a significant difference between the observed and the expected frequencies&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this example, suppose that we measured the number of girls in 100 families of 5 children. We want to test whether the (observed) distribution of number girls follows a binomial distribution.&lt;/p&gt;
&lt;div id=&#34;observed-frequencies&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Observed frequencies&lt;/h4&gt;
&lt;p&gt;Here is the distribution of the number of girls per family in our sample of 100 families of 5 children:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-11-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;And the corresponding frequencies and relative frequencies (remember that the relative frequency is the frequency divided by the total sample size):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# counts
dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Girls Frequency Relative_freq
## 1     0         5          0.05
## 2     1        12          0.12
## 3     2        28          0.28
## 4     3        33          0.33
## 5     4        17          0.17
## 6     5         5          0.05&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;expected-frequencies&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Expected frequencies&lt;/h4&gt;
&lt;p&gt;In order to compare the observed frequencies to a binomial distribution and see if both distributions match, we first need to determine the expected frequencies that would be obtained in case of a binomial distribution.&lt;/p&gt;
&lt;p&gt;The expected frequencies assuming a probability of 0.5 of having a girl (for each of the 5 children) are as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create expected frequencies for a binomial distribution
x &amp;lt;- 0:5
df &amp;lt;- data.frame(
  Girls = factor(x),
  Expected_relative_freq = dbinom(x, size = 5, prob = 0.5)
)
df$Expected_freq &amp;lt;- df$Expected_relative_freq * 100 # *100 since there are 100 families

# create barplot
p &amp;lt;- ggplot(df, aes(x = Girls, y = Expected_freq)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, fill = &amp;quot;#F8766D&amp;quot;) +
  xlab(&amp;quot;Number of girls per family&amp;quot;) +
  ylab(&amp;quot;Expected frequency&amp;quot;) +
  labs(title = &amp;quot;Binomial distribution Bi(x, n = 5, p = 0.5)&amp;quot;) +
  theme_minimal()
p&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-13-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# expected relative frequencies and (absolute) frequencies
df&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Girls Expected_relative_freq Expected_freq
## 1     0                0.03125         3.125
## 2     1                0.15625        15.625
## 3     2                0.31250        31.250
## 4     3                0.31250        31.250
## 5     4                0.15625        15.625
## 6     5                0.03125         3.125&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;observed-vs.-expected-frequencies&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Observed vs. expected frequencies&lt;/h4&gt;
&lt;p&gt;We now compare the observed frequencies to the expected frequencies to see whether the two differ significantly. If the two differ significantly, we reject the hypothesis that the number of girls per family of 5 children follows a binomial distribution. On the other hand, if the observed and expected frequencies are similar, we do not reject the hypothesis that the number of girls per family follows a binomial distribution.&lt;/p&gt;
&lt;p&gt;Visually we have:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create data
data &amp;lt;- data.frame(
  num_girls = factor(rep(c(0:5), times = 2)),
  Freq = c(dat$Freq, df$Expected_freq),
  obs_exp = c(rep(&amp;quot;observed&amp;quot;, 6), rep(&amp;quot;expected&amp;quot;, 6))
)

# create plot
ggplot() +
  geom_bar(
    data = data, aes(
      x = num_girls, y = Freq,
      fill = obs_exp
    ),
    position = &amp;quot;dodge&amp;quot;, # bar next to each other
    stat = &amp;quot;identity&amp;quot;
  ) +
  ylab(&amp;quot;Frequency&amp;quot;) +
  xlab(&amp;quot;Number of girls per family&amp;quot;) +
  theme_minimal() +
  theme(legend.title = element_blank()) # remove legend title&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-14-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We see that the observed and expected frequencies are quite similar, so we expect that the number of girls in families of 5 children follows a binomial distribution. However, only the goodness of fit test will confirm our belief:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# chi-square goodness of fit test
test &amp;lt;- chisq.test(dat$Freq, # observed frequencies
  p = df$Expected_relative_freq # expected proportions
)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Chi-squared test for given probabilities
## 
## data:  dat$Freq
## X-squared = 3.648, df = 5, p-value = 0.6011&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.601 so, at the 5% significance level, we do not reject the null hypothesis that the observed and expected frequencies are equal. This is equivalent than concluding that we cannot reject the hypothesis that the number of girls in families of 5 children follows a binomial distribution (since the expected frequencies were based on a binomial distribution).&lt;/p&gt;
&lt;p&gt;Note that the chi-square goodness of fit test can of course be performed with other types of distribution than the binomial one. For instance, if you want to test whether an observed distribution follows a Poisson distribution, this test can be used to compare the observed frequencies with the expected proportions that would be obtained in case of a Poisson distribution.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;by-hand&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;By hand&lt;/h1&gt;
&lt;p&gt;Now that we showed how to perform the one-proportion and chi-square goodness of fit test in R, in this section we show how to do these tests by hand. We first illustrate the one-proportion test then the chi-square goodness of fit test.&lt;/p&gt;
&lt;div id=&#34;one-proportion-test-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;One-proportion test&lt;/h2&gt;
&lt;p&gt;For this example, suppose that we tossed a coin 100 times and noted that it landed on heads 67 times. Following this, we want to test whether the coin is fair, that is, test whether the probability of landing on heads or tails is equal to 50%.&lt;/p&gt;
&lt;p&gt;As for many &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt;, we do it through 4 easy steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;State the null and alternative hypotheses&lt;/li&gt;
&lt;li&gt;Compute the test-statistic (also known as t-stat)&lt;/li&gt;
&lt;li&gt;Find the rejection region&lt;/li&gt;
&lt;li&gt;Conclude by comparing the test-statistic with the rejection region&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In our example, the null and alternative hypotheses are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(p_0 = 0.5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(p_0 \ne 0.5\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(p_0\)&lt;/span&gt; is the expected proportion of landing on heads.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The test statistic is:&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[z_{obs} = \frac{\hat{p} - p_0}{\sqrt{\frac{p_0(1 - p_0)}{n}}} = \frac{0.67 - 0.5}{\sqrt{\frac{0.5 \cdot (1 - 0.5)}{100}}} = 3.4\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;(See how to perform &lt;a href=&#34;https://statsandr.com/blog/a-shiny-app-for-inferential-statistics-by-hand/&#34;&gt;hypothesis tests in a Shiny app&lt;/a&gt; if you need more help in computing the test statistic.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The rejection region is found via the &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt; table. Assuming a significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;, we have:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/Screenshot%202020-05-13%20at%2012.23.38.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\pm z_{\alpha/2} = \pm z_{0.025} = \pm 1.96\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We compare the test statistic (found in step 2) with the rejection region (found in step 3) and we conclude. Visually, we have:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-16-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The test statistic lies within the rejection region (i.e., the grey shaded areas). Therefore, at the 5% significance level, we reject the null hypothesis and we conclude that the proportion of heads (and thus tails) is significantly different than 50%. In other words, still at the 5% significance level, we conclude that the coin is unfair.&lt;/p&gt;
&lt;p&gt;If you prefer to compute the &lt;em&gt;p&lt;/em&gt;-value instead of comparing the t-stat and the rejection region, you can use this &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;Shiny app to easily compute &lt;em&gt;p&lt;/em&gt;-values&lt;/a&gt; for different probability distributions. After having opened the app, set the t-stat, the corresponding alternative and you will find the &lt;em&gt;p&lt;/em&gt;-value at the top of the page.&lt;/p&gt;
&lt;div id=&#34;verification-in-r&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Verification in R&lt;/h3&gt;
&lt;p&gt;Just for the sake of illustration, here is the verification of the above example in R:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# one-proportion test
test &amp;lt;- prop.test(
  x = 67, # number of heads
  n = 100, # number of trials
  p = 0.5 # expected probability of heads
)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  1-sample proportions test with continuity correction
## 
## data:  67 out of 100, null probability 0.5
## X-squared = 10.89, df = 1, p-value = 0.0009668
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5679099 0.7588442
## sample estimates:
##    p 
## 0.67&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.001 so, at the 5% significance level, we reject the null hypothesis that the proportions of heads and tails are equal, and we conclude that the coin is biased. This is the same conclusion than the one found by hand.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;goodness-of-fit-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Goodness of fit test&lt;/h2&gt;
&lt;p&gt;We now illustrate the chi-square goodness of fit test by hand with the following example.&lt;/p&gt;
&lt;p&gt;Suppose that we toss a dice 100 times, we note how many times it lands on each face (1 to 6) and we test whether the dice is fair. Here are the observed counts by dice face:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-18-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## dice_face
##  1  2  3  4  5  6 
## 15 24 10 19 19 13&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With a fair dice, we would expect it to land &lt;span class=&#34;math inline&#34;&gt;\(\frac{100}{6} \approx 16.67\)&lt;/span&gt; times on each face (this expected value is represented by the dashed line in the above plot). Although the observed frequencies are different than the expected value of 16.67:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;##   dice_face observed_freq expected_freq
## 1         1            15         16.67
## 2         2            24         16.67
## 3         3            10         16.67
## 4         4            19         16.67
## 5         5            19         16.67
## 6         6            13         16.67&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;we need to test whether they are &lt;em&gt;significantly&lt;/em&gt; different. For this, we perform the appropriate &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis test&lt;/a&gt; following the 4 easy steps mentioned above:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;State the null and alternative hypotheses&lt;/li&gt;
&lt;li&gt;Compute the test-statistic (also known as t-stat)&lt;/li&gt;
&lt;li&gt;Find the rejection region&lt;/li&gt;
&lt;li&gt;Conclude by comparing the test-statistic with the rejection region&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The null and alternative hypotheses of the chi-square goodness of fit test are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: there is no significant difference between the observed and the expected frequencies&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: there is a significant difference between the observed and the expected frequencies&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Applied to our example, we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: all faces occur in the same proportion&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: at least one proportion is not equal to 1/6&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The test statistic is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\chi^2 = \sum_{i = 1}^k \frac{(O_i - E_i)^2}{E_i}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(O_i\)&lt;/span&gt; is the observed frequency, &lt;span class=&#34;math inline&#34;&gt;\(E_i\)&lt;/span&gt; is the expected frequency and &lt;span class=&#34;math inline&#34;&gt;\(k\)&lt;/span&gt; is the number of categories (in our case, there are 6 categories, representing the 6 dice faces).&lt;/p&gt;
&lt;p&gt;This &lt;span class=&#34;math inline&#34;&gt;\(\chi^2\)&lt;/span&gt; statistic is obtained by calculating the difference between the observed number of cases and the expected number of cases in each category. This difference is squared (to avoid negative and positive differences being compensated) and divided by the expected number of cases in that category. These values are then summed for all categories, and the total is referred to as the &lt;span class=&#34;math inline&#34;&gt;\(\chi^2\)&lt;/span&gt; statistic. Large values of this test statistic lead to the rejection of the null hypothesis, small values mean that the null hypothesis cannot be rejected.&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Given our data, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\chi^2 = \frac{(15 - 16.67)^2}{16.67} + \frac{(24 - 16.67)^2}{16.67} + \\
\frac{(10 - 16.67)^2}{16.67} +\frac{(19 - 16.67)^2}{16.67} + \\
\frac{(19 - 16.67)^2}{16.67} + \frac{(13 - 16.67)^2}{16.67}  =  7.52\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Whether the &lt;span class=&#34;math inline&#34;&gt;\(\chi^2\)&lt;/span&gt; test statistic is small or large depends on the rejection region. The rejection region is found via the &lt;span class=&#34;math inline&#34;&gt;\(\chi^2\)&lt;/span&gt; distribution table. With a degrees of freedom equals to &lt;span class=&#34;math inline&#34;&gt;\(k - 1\)&lt;/span&gt; (where &lt;span class=&#34;math inline&#34;&gt;\(k\)&lt;/span&gt; is the number of categories) and assuming a significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;, we have:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/Screenshot%202020-05-13%20at%2012.20.42.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\chi^2_{\alpha; k-1} = \chi^2_{0.05; 5} = 11.0705\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We compare the test statistic (found in step 2) with the rejection region (found in step 3) and we conclude. Visually, we have:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-13-one-proportion-and-goodness-of-fit-test-in-r-and-by-hand_files/figure-html/unnamed-chunk-20-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The test statistic does not lie within the rejection region (i.e., the grey shaded area). Therefore, at the 5% significance level, we do not reject the null hypothesis that there is no significant difference between the observed and the expected frequencies. In other words, still at the 5% significance level, we cannot reject the hypothesis that the dice is fair.&lt;/p&gt;
&lt;p&gt;Again, you can use the &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;Shiny app&lt;/a&gt; to easily compute the &lt;em&gt;p&lt;/em&gt;-value given the test statistic if you prefer this method over the comparison between the t-stat and the rejection region.&lt;/p&gt;
&lt;div id=&#34;verification-in-r-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Verification in R&lt;/h3&gt;
&lt;p&gt;Just for the sake of illustration, here is the verification of the above example in R:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# chi-square goodness of fit test
test &amp;lt;- chisq.test(dat$observed_freq, # observed frequencies for each dice face
  p = rep(1 / 6, 6) # expected probabilities for each dice face
)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Chi-squared test for given probabilities
## 
## data:  dat$observed_freq
## X-squared = 7.52, df = 5, p-value = 0.1847&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The test statistic and degrees of freedom are exactly the same than the ones found by hand. The &lt;em&gt;p&lt;/em&gt;-value is 0.185 which, still at the 5% significance level, leads to the same conclusion than by hand (i.e., failing to reject the null hypothesis).&lt;/p&gt;
&lt;/div&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 this article helped you to understand and perform the one-proportion and chi-square goodness of fit test in R and by hand. Learn more about the Chi-square test of independence &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;in R&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-by-hand/&#34;&gt;by hand&lt;/a&gt; if you want to analyze &lt;em&gt;two&lt;/em&gt; categorical variables instead of one.&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;Choosing big or small as the success event gives the exact same conclusion.&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;Note that if possible, it is best to avoid pie charts and use bar charts instead. Unfortunately, the &lt;code&gt;ggbarstats()&lt;/code&gt; function works only for the &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;independence Chi-square test&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;li id=&#34;fn3&#34;&gt;&lt;p&gt;Similarly, this argument can also be added to the &lt;code&gt;prop.test()&lt;/code&gt; function to test whether the observed proportion is larger than the expected proportion. Use &lt;code&gt;alternative = &#34;less&#34;&lt;/code&gt; if you want to test whether the observed proportion is smaller than the expected one.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Be careful that the alternative hypothesis is not that &lt;em&gt;all&lt;/em&gt; proportions are different. One different from the others is sufficient to reject the null hypothesis. It is, in some sense, similar to the alternative hypothesis of the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; which says that at least one mean is different than another.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;One assumption of this test is that &lt;span class=&#34;math inline&#34;&gt;\(n \cdot p \ge 5\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(n \cdot (1 - p) \ge 5\)&lt;/span&gt;. The assumption is met so we can use the normal approximation to the binomial distribution.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;Source: &lt;a href=&#34;http://uregina.ca/~gingrich/ch10.pdf&#34; target=&#34;_blank&#34;&gt;http://uregina.ca/~gingrich/ch10.pdf&lt;/a&gt;.&lt;a href=&#34;#fnref6&#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>A package to download free Springer books during Covid-19 quarantine</title>
      <link>https://statsandr.com/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/</link>
      <pubDate>Sun, 26 Apr 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/</guid>
      <description>
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/datatables-css/datatables-crosstalk.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/datatables-binding/datatables.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/jquery/jquery-3.6.0.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/dt-core/css/jquery.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/dt-core/css/jquery.dataTables.extra.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-core/js/jquery.dataTables.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/jszip/jszip.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/pdfmake/pdfmake.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/pdfmake/vfs_fonts.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/css/buttons.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/js/dataTables.buttons.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/js/buttons.html5.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/js/buttons.colVis.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/js/buttons.print.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/nouislider/jquery.nouislider.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/nouislider/jquery.nouislider.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/selectize/selectize.bootstrap3.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/selectize/selectize.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/crosstalk/css/crosstalk.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/crosstalk/js/crosstalk.min.js&#34;&gt;&lt;/script&gt;

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#update&#34; id=&#34;toc-update&#34;&gt;Update&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&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;#download-all-books-at-once&#34; id=&#34;toc-download-all-books-at-once&#34;&gt;Download all books at once&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#create-a-table-of-springer-books&#34; id=&#34;toc-create-a-table-of-springer-books&#34;&gt;Create a table of Springer books&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#download-only-specific-books&#34; id=&#34;toc-download-only-specific-books&#34;&gt;Download only specific books&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-title&#34; id=&#34;toc-by-title&#34;&gt;By title&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-author&#34; id=&#34;toc-by-author&#34;&gt;By author&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-subject&#34; id=&#34;toc-by-subject&#34;&gt;By subject&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#improvements&#34; id=&#34;toc-improvements&#34;&gt;Improvements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#acknowledgments&#34; id=&#34;toc-acknowledgments&#34;&gt;Acknowledgments&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/2020-04-26-a-package-to-download-free-springer-books-during-covid-19-quarantine_files/A%20package%20to%20download%20free%20Springer%20books%20during%20Covid-19%20quarantine.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;update&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Update&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;The promotion has ended so it is not possible to download the books through R. If you did not download the books in time, you can still have access to them via this &lt;a href=&#34;https://drive.google.com/drive/folders/1JC15m__PbPaowQ7k2zS1-Us72yvROCQs&#34; target=&#34;_blank&#34;&gt;link&lt;/a&gt;.&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;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;You probably already have seen that Springer released about &lt;a href=&#34;https://link.springer.com/search?facet-content-type=%22Book%22&amp;amp;package=mat-covid19_textbooks&amp;amp;%23038;facet-language=%22En%22&amp;amp;%23038;sortOrder=newestFirst&amp;amp;%23038;showAll=true&#34; target=&#34;_blank&#34;&gt;500 books&lt;/a&gt; for free following the COVID-19 pandemic. According to Springer, these textbooks will be available free of charge until at least the end of July.&lt;/p&gt;
&lt;p&gt;Following this announcement, I already downloaded a couple of statistics and R programming textbooks from their website and I will probably download a few more in the coming weeks.&lt;/p&gt;
&lt;p&gt;In this article, I present a package that saved me a lot of time and which may be of interest to many of us: the &lt;a href=&#34;https://github.com/renanxcortes/springerQuarantineBooksR&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{springerQuarantineBooksR}&lt;/code&gt; package&lt;/a&gt;, developed by &lt;a href=&#34;http://renanxcortes.github.io/&#34; target=&#34;_blank&#34;&gt;Renan Xavier Cortes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This package allows you to easily download all (or a selection of) Springer books made available free of charge during the COVID-19 quarantine.&lt;/p&gt;
&lt;p&gt;With this large collection of high quality resources and my collection of &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;top R resources about the Coronavirus&lt;/a&gt;, we do not have any excuse to not read and learn during this quarantine.&lt;/p&gt;
&lt;p&gt;In this article, I show:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how to download &lt;strong&gt;all available textbooks&lt;/strong&gt; at once and&lt;/li&gt;
&lt;li&gt;how to download a &lt;strong&gt;subset of books&lt;/strong&gt;, given a specific title, author or subject&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Without further ado, here is how the package works in practice.&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;After having installed the &lt;code&gt;{devtools}&lt;/code&gt; package, you can install the &lt;code&gt;{springerQuarantineBooksR}&lt;/code&gt; package from GitHub and load it with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;renanxcortes/springerQuarantineBooksR&amp;quot;, force = TRUE)
library(springerQuarantineBooksR)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;download-all-books-at-once&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Download all books at once&lt;/h1&gt;
&lt;p&gt;First, set the path where you would like to save all books with the &lt;code&gt;setwd()&lt;/code&gt; function then download all of them at once with the &lt;code&gt;download_springer_book_files()&lt;/code&gt; function. Note that it takes several minutes (depending on the speed of your internet connection) since all books combined amount for almost 8GB.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;setwd(&amp;quot;path_of_your_choice&amp;quot;) # where you want to save the books
download_springer_book_files() # download all of them at once&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will find all downloaded books (in PDF format) in a folder named “springer_quarantine_books”, organized by category.&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;If you want to download the EPUB version (or both the PDF and EPUB versions), add the &lt;code&gt;filetype&lt;/code&gt; argument to the function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# for EPUB version:
download_springer_book_files(filetype = &amp;quot;epub&amp;quot;)

# for both PDF and EPUB versions:
download_springer_book_files(filetype = &amp;quot;both&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default, it downloads only the English books. However, it is also possible to download all German books by adding the argument &lt;code&gt;lan = &#39;ger&#39;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;download_springer_book_files(lan = &amp;quot;ger&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that in total, there are 407 unique titles in English and 52 in German.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;create-a-table-of-springer-books&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Create a table of Springer books&lt;/h1&gt;
&lt;p&gt;Like me, if you do not know which books are offered by Springer and you do not want to download all of them, you probably may want to have an overview or a list of the released books before downloading any.&lt;/p&gt;
&lt;p&gt;For this, you can load a table containing all the titles made available by Springer into an R session with the &lt;code&gt;download_springer_table()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;springer_table &amp;lt;- springerQuarantineBooksR::download_springer_table()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This table can then be improved with the &lt;code&gt;{DT}&lt;/code&gt; package to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;keep only a minimum of information,&lt;/li&gt;
&lt;li&gt;allow searching a book by its title, author, classification or year,&lt;/li&gt;
&lt;li&gt;allow downloading the list of available books, and&lt;/li&gt;
&lt;li&gt;make the Springer links clickable for instance&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;DT&amp;quot;)
library(DT)

springer_table$open_url &amp;lt;- paste0(
  &amp;#39;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;&amp;#39;, # opening HTML tag
  springer_table$open_url, # href link
  &amp;#39;&amp;quot;&amp;gt;SpringerLink&amp;lt;/a&amp;gt;&amp;#39; # closing HTML tag
)

springer_table &amp;lt;- springer_table[, c(1:3, 19, 20)] # keep only relevant information

datatable(springer_table,
  rownames = FALSE, # remove row numbers
  filter = &amp;quot;top&amp;quot;, # add filter on top of columns
  extensions = &amp;quot;Buttons&amp;quot;, # add download buttons
  options = list(
    autoWidth = TRUE,
    dom = &amp;quot;Blfrtip&amp;quot;, # location of the download buttons
    buttons = c(&amp;quot;copy&amp;quot;, &amp;quot;csv&amp;quot;, &amp;quot;excel&amp;quot;, &amp;quot;pdf&amp;quot;, &amp;quot;print&amp;quot;), # download buttons
    pageLength = 5, # show first 5 entries, default is 10
    order = list(0, &amp;quot;asc&amp;quot;) # order the title column by ascending order
  ),
  escape = FALSE # make URLs clickable
)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:auto;&#34; class=&#34;datatables html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;filter&#34;:&#34;top&#34;,&#34;vertical&#34;:false,&#34;filterHTML&#34;:&#34;&lt;tr&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n&lt;\/tr&gt;&#34;,&#34;extensions&#34;:[&#34;Buttons&#34;],&#34;data&#34;:[[&#34;Fundamentals of Power Electronics&#34;,&#34;Handbook of the Life Course&#34;,&#34;All of Statistics&#34;,&#34;Social Anxiety and Social Phobia in Youth&#34;,&#34;Discrete Mathematics&#34;,&#34;Developmental Neurobiology&#34;,&#34;Intuitive Probability and Random Processes using MATLAB®&#34;,&#34;Handbook of Disaster Research&#34;,&#34;Handbook of the Sociology of Gender&#34;,&#34;Handbook of Sociological Theory&#34;,&#34;Acquired Brain Injury&#34;,&#34;Numerical Optimization&#34;,&#34;Ceramic Materials&#34;,&#34;Fundamentals of Biomechanics&#34;,&#34;International Handbook of Historical Archaeology&#34;,&#34;Database Marketing&#34;,&#34;Composite Materials&#34;,&#34;Time Series Analysis&#34;,&#34;Transmission Electron Microscopy&#34;,&#34;Handbook of Quantitative Criminology&#34;,&#34;Plant Physiological Ecology&#34;,&#34;Introductory Statistics with R&#34;,&#34;The Elements of Statistical Learning&#34;,&#34;Psychology, Religion, and Spirituality&#34;,&#34;Introductory Time Series with R&#34;,&#34;Child Neuropsychology&#34;,&#34;A Beginner&#39;s Guide to R&#34;,&#34;The Joy of Science&#34;,&#34;Fatigue of Structures and Materials&#34;,&#34;Essential Astrophysics&#34;,&#34;Introduction to Evolutionary Computing&#34;,&#34;Data Analysis&#34;,&#34;International Perspectives on Psychotherapy&#34;,&#34;Electrical Machines&#34;,&#34;Mechanics and Thermodynamics&#34;,&#34;Applied Behavior Analysis&#34;,&#34;Reading, Writing, and Proving&#34;,&#34;Linear and Nonlinear Programming&#34;,&#34;Introduction to Partial Differential Equations&#34;,&#34;Energy Storage&#34;,&#34;Metabolism of Human Diseases&#34;,&#34;Sensory Evaluation of Food&#34;,&#34;Fundamentals of Robotic Mechanical Systems&#34;,&#34;Integrative Human Biochemistry&#34;,&#34;Philosophy of Science for Scientists&#34;,&#34;Particles and Nuclei&#34;,&#34;Data Structures and Algorithms with Python&#34;,&#34;LGBT-Parent Families&#34;,&#34;Microeconomics&#34;,&#34;System Dynamics&#34;,&#34;Cosmology for the Curious&#34;,&#34;Methods of Mathematical Modelling&#34;,&#34;Introduction to Logic Circuits &amp; Logic Design with Verilog&#34;,&#34;Structural Analysis&#34;,&#34;Engineering Flow and Heat Exchange&#34;,&#34;Enterprise Risk Management Models&#34;,&#34;Reactive Power Control in AC Power Systems&#34;,&#34;Principles of Microeconomics&#34;,&#34;Additive Manufacturing Technologies&#34;,&#34;Fundamentals of Biomechanics&#34;,&#34;Irrigation and Drainage Engineering&#34;,&#34;LaTeX in 24 Hours&#34;,&#34;Psychology of Perception&#34;,&#34;Extragalactic Astronomy and Cosmology&#34;,&#34;Automata and Computability&#34;,&#34;The Algorithm Design Manual&#34;,&#34;Chemical Thermodynamics&#34;,&#34;Computational Physics&#34;,&#34;Introduction to Statistics and Data Analysis&#34;,&#34;Grammar for Teachers&#34;,&#34;Time Series Econometrics&#34;,&#34;Electrochemistry&#34;,&#34;Classical Fourier Analysis&#34;,&#34;Human Chromosomes&#34;,&#34;Phylogenomics&#34;,&#34;Quantum Theory for Mathematicians&#34;,&#34;Evidence-Based Critical Care&#34;,&#34;Clinical Assessment of Child and Adolescent Personality and Behavior&#34;,&#34;Design Research in Information Systems&#34;,&#34;Intermediate Physics for Medicine and Biology&#34;,&#34;Principles of Data Mining&#34;,&#34;Fundamental Astronomy&#34;,&#34;Fundamentals of Business Process Management&#34;,&#34;Brownian Motion, Martingales, and Stochastic Calculus&#34;,&#34;UML @ Classroom&#34;,&#34;Design and Analysis of Experiments&#34;,&#34;Foundations for Designing User-Centered Systems&#34;,&#34;Handbook of Consumer Finance Research&#34;,&#34;Principles of Terrestrial Ecosystem Ecology&#34;,&#34;Applied Multivariate Statistical Analysis&#34;,&#34;Strategic International Management&#34;,&#34;Computer Vision&#34;,&#34;Engineering Electromagnetics&#34;,&#34;Data Mining&#34;,&#34;International Trade Theory and Policy&#34;,&#34;Alternative Energy Sources&#34;,&#34;Introduction to Electronic Commerce and Social Commerce&#34;,&#34;Computational Geometry&#34;,&#34;Elementary Mechanics Using Python&#34;,&#34;Energy Economics&#34;,&#34;Biomedical Informatics&#34;,&#34;Acid-Base Diagrams&#34;,&#34;Brewing Science: A Multidisciplinary Approach&#34;,&#34;Learning Landscape Ecology&#34;,&#34;Probability&#34;,&#34;Modeling Life&#34;,&#34;Introduction to Plasma Physics and Controlled Fusion&#34;,&#34;Engineering Mechanics 1&#34;,&#34;Principles of Polymer Chemistry&#34;,&#34;A Primer on Scientific Programming with Python&#34;,&#34;Climate Change Science: A Modern Synthesis&#34;,&#34;Solar PV and Wind Energy Conversion Systems&#34;,&#34;Statistical Analysis and Data Display&#34;,&#34;Business Process Management Cases&#34;,&#34;Elementary Analysis&#34;,&#34;Cryptography Made Simple&#34;,&#34;Fluid Dynamics&#34;,&#34;Social Media Management&#34;,&#34;Statistics in Criminal Justice&#34;,&#34;Supply Chain Management and Advanced Planning&#34;,&#34;Probability Theory&#34;,&#34;Statistics and Data Analysis for Financial Engineering&#34;,&#34;Readings in Formal Epistemology&#34;,&#34;Differential Equations and Their Applications&#34;,&#34;Nanotechnology: Principles and Practices&#34;,&#34;Epidemiological Research: Terms and Concepts&#34;,&#34;Multinational Management&#34;,&#34;Partial Differential Equations&#34;,&#34;Bayesian and Frequentist Regression Methods&#34;,&#34;Strategic International Management&#34;,&#34;Basic Concepts in Computational Physics&#34;,&#34;Eye Tracking Methodology&#34;,&#34;Writing for Publication&#34;,&#34;Mathematical Physics&#34;,&#34;Correctional Counseling and Treatment&#34;,&#34;Thermodynamics and Energy Conversion&#34;,&#34;The Action Research Planner&#34;,&#34;Stochastic Processes and Calculus&#34;,&#34;Statistical Analysis of Clinical Data on a Pocket Calculator&#34;,&#34;Clinical Data Analysis on a Pocket Calculator&#34;,&#34;The Data Science Design Manual&#34;,&#34;An Introduction to Machine Learning&#34;,&#34;Guide to Discrete Mathematics&#34;,&#34;Petroleum Geoscience&#34;,&#34;Structure Determination by X-ray Crystallography&#34;,&#34;Introduction to Time Series and Forecasting&#34;,&#34;Principles of Mobile Communication&#34;,&#34;Cardiovascular Biomechanics&#34;,&#34;Introduction to Smooth Manifolds&#34;,&#34;Taxation in European Union&#34;,&#34;Essentials of Cerebellum and Cerebellar Disorders&#34;,&#34;Language Across the Curriculum &amp; CLIL in English as an Additional Language (EAL) Contexts&#34;,&#34;Multivariate Calculus and Geometry&#34;,&#34;Statistics and Analysis of Scientific Data&#34;,&#34;Modelling Computing Systems&#34;,&#34;Search Methodologies&#34;,&#34;Representation Theory&#34;,&#34;Linear Algebra Done Right&#34;,&#34;Stellar Structure and Evolution&#34;,&#34;Evolutionary Thinking in Medicine&#34;,&#34;Understanding Cryptography&#34;,&#34;Linear Algebra&#34;,&#34;Understanding Analysis&#34;,&#34;Linear Programming&#34;,&#34;The Nature of Scientific Knowledge&#34;,&#34;Leadership Today&#34;,&#34;Physics of Semiconductor Devices&#34;,&#34;Corporate Social Responsibility&#34;,&#34;Ordinary Differential Equations&#34;,&#34;Electronic Commerce&#34;,&#34;Ceramic Materials&#34;,&#34;Foundations of Analytical Chemistry&#34;,&#34;Life Cycle Assessment&#34;,&#34;A Clinical Guide to the Treatment of the Human Stress Response&#34;,&#34;Computational Physics&#34;,&#34;Handbook of LGBT Elders&#34;,&#34;Handbook of Cardiac Anatomy, Physiology, and Devices&#34;,&#34;Quantum Mechanics&#34;,&#34;Understanding Statistics Using R&#34;,&#34;Mass Spectrometry&#34;,&#34;Statistical Mechanics for Engineers&#34;,&#34;The Gastrointestinal System&#34;,&#34;Additive Manufacturing Technologies&#34;,&#34;Magnetic Interactions in Molecules and Solids&#34;,&#34;Survival Analysis&#34;,&#34;Foundations of Quantum Mechanics&#34;,&#34;An Introduction to Statistical Learning&#34;,&#34;Introduction to Mathematica® for Physicists&#34;,&#34;Statistical Learning from a Regression Perspective&#34;,&#34;Applied Partial Differential Equations&#34;,&#34;Principles of Astrophysics&#34;,&#34;Air Pollution and Greenhouse Gases&#34;,&#34;Polymer Synthesis: Theory and Practice&#34;,&#34;Sustainable Supply Chains&#34;,&#34;Robotics&#34;,&#34;Econometrics&#34;,&#34;The Sea Floor&#34;,&#34;SPSS for Starters and 2nd Levelers&#34;,&#34;Regression Modeling Strategies&#34;,&#34;Legal Dynamics of EU External Relations&#34;,&#34;Food Analysis Laboratory Manual&#34;,&#34;Principles of Musical Acoustics&#34;,&#34;Fundamentals of Structural Engineering&#34;,&#34;Basics of Laser Physics&#34;,&#34;Applied Quantitative Finance&#34;,&#34;Handbook of Marriage and the Family&#34;,&#34;Solid-State Physics&#34;,&#34;Electrochemical Impedance Spectroscopy and its Applications&#34;,&#34;Economics as Applied Ethics&#34;,&#34;Concise Guide to Software Engineering&#34;,&#34;Fundamentals of Multimedia&#34;,&#34;Logistics&#34;,&#34;Group Theory Applied to Chemistry&#34;,&#34;The Psychology of Social Status&#34;,&#34;A Modern Introduction to Probability and Statistics&#34;,&#34;Complex Analysis&#34;,&#34;Food Chemistry&#34;,&#34;Exam Survival Guide: Physical Chemistry&#34;,&#34;The Python Workbook&#34;,&#34;Practical Electrical Engineering&#34;,&#34;Strategic Retail Management&#34;,&#34;Food Analysis&#34;,&#34;Psychoeducational Assessment and Report Writing&#34;,&#34;Machine Learning in Medicine - a Complete Overview&#34;,&#34;Evidence-Based Interventions for Children with Challenging Behavior&#34;,&#34;Principles of Quantum Mechanics&#34;,&#34;Recommender Systems&#34;,&#34;Pharmaceutical Biotechnology&#34;,&#34;Python Programming Fundamentals&#34;,&#34;The Finite Element Method and Applications in Engineering Using ANSYS®&#34;,&#34;Group Theory&#34;,&#34;Object-Oriented Analysis, Design and Implementation&#34;,&#34;Introduction to Embedded Systems&#34;,&#34;Elementary Mechanics Using Matlab&#34;,&#34;An Introduction to Biomechanics&#34;,&#34;New Introduction to Multiple Time Series Analysis&#34;,&#34;Introduction to Data Science&#34;,&#34;Calculus With Applications&#34;,&#34;An Introduction to Soil Mechanics&#34;,&#34;Game Theory&#34;,&#34;Fundamentals of Clinical Trials&#34;,&#34;The Finite Volume Method in Computational Fluid Dynamics&#34;,&#34;The ASCRS Textbook of Colon and Rectal Surgery&#34;,&#34;Applied Predictive Modeling&#34;,&#34;Introduction to Logic Circuits &amp; Logic Design with VHDL&#34;,&#34;Sustainability Science&#34;,&#34;Physical Chemistry from a Different Angle&#34;,&#34;The Physics of Semiconductors&#34;,&#34;Energy Harvesting and Energy Efficiency&#34;,&#34;Python For ArcGIS&#34;,&#34;Statics and Mechanics of Structures&#34;,&#34;Real Analysis&#34;,&#34;MATLAB for Psychologists&#34;,&#34;Physical Asset Management&#34;,&#34;Essentials of Food Science&#34;,&#34;Quantum Mechanics&#34;,&#34;Probability Theory&#34;,&#34;Concise Guide to Databases&#34;,&#34;Digital Image Processing&#34;,&#34;Chemical and Bioprocess Engineering&#34;,&#34;Transmission Electron Microscopy&#34;,&#34;Guide to Computer Network Security&#34;,&#34;Introduction to Law&#34;,&#34;Advanced Quantum Mechanics&#34;,&#34;Bayesian Essentials with R&#34;,&#34;Applied Chemistry&#34;,&#34;Advanced Organic Chemistry&#34;,&#34;Advanced Organic Chemistry&#34;,&#34;International Humanitarian Action&#34;,&#34;Breast Cancer&#34;,&#34;Travel Marketing, Tourism Economics and the Airline Product&#34;,&#34;Electronic Commerce 2018&#34;,&#34;Disability and Vocational Rehabilitation in Rural Settings&#34;,&#34;Teaching Medicine and Medical Ethics Using Popular Culture&#34;,&#34;Market Research&#34;,&#34;Scanning Electron Microscopy and X-Ray Microanalysis&#34;,&#34;ArcGIS for Environmental and Water Issues&#34;,&#34;Physics from Symmetry&#34;,&#34;Communication and Bioethics at the End of Life&#34;,&#34;Foundations of Programming Languages&#34;,&#34;Problems in Classical Electromagnetism&#34;,&#34;Probability and Statistics for Computer Science&#34;,&#34;Empathetic Space on Screen&#34;,&#34;Political Social Work&#34;,&#34;Introductory Quantum Mechanics&#34;,&#34;Guide to Competitive Programming&#34;,&#34;Introduction to Artificial Intelligence&#34;,&#34;Bioinformatics for Evolutionary Biologists&#34;,&#34;Concepts, Methods and Practical Applications in Applied Demography&#34;,&#34;Introduction to Deep Learning&#34;,&#34;Energy and the Wealth of Nations&#34;,&#34;Lessons on Synthetic Bioarchitectures&#34;,&#34;Managing Sustainable Business&#34;,&#34;Engineering Mechanics 2&#34;,&#34;Fundamentals of Business Process Management&#34;,&#34;Clinical Methods in Medical Family Therapy&#34;,&#34;Guide to Scientific Computing in C++&#34;,&#34;Motivation and Action&#34;,&#34;Perspectives on Elderly Crime and Victimization&#34;,&#34;Knowledge Management&#34;,&#34;An Introduction to Zooarchaeology&#34;,&#34;Abstract Algebra&#34;,&#34;Criminal Justice and Mental Health&#34;,&#34;Philosophy of Race&#34;,&#34;Of Cigarettes, High Heels, and Other Interesting Things&#34;,&#34;Applied Bioinformatics&#34;,&#34;Linear Algebra and Analytic Geometry for Physical Sciences&#34;,&#34;Building Energy Modeling with OpenStudio&#34;,&#34;Customer Relationship Management&#34;,&#34;The A-Z of the PhD Trajectory&#34;,&#34;Strategic Human Resource Management and Employment Relations&#34;,&#34;Applied Linear Algebra&#34;,&#34;Witnessing Torture&#34;,&#34;Proofs from THE BOOK&#34;,&#34;Introduction to General Relativity&#34;,&#34;Introduction to Particle and Astroparticle Physics&#34;,&#34;Fundamentals of Java Programming&#34;,&#34;Optimization of Process Flowsheets through Metaheuristic Techniques&#34;,&#34;Robotics&#34;,&#34;Business Ethics - A Philosophical and Behavioral Approach&#34;,&#34;A First Introduction to Quantum Physics&#34;,&#34;Argumentation Theory: A Pragma-Dialectical Perspective&#34;,&#34;Logical Foundations of Cyber-Physical Systems&#34;,&#34;Off-Grid Electrical Systems in Developing Countries&#34;,&#34;Entertainment Science&#34;,&#34;Physics of Oscillations and Waves&#34;,&#34;Fundamentals of Solid State Engineering&#34;,&#34;Introduction to Digital Systems Design&#34;,&#34;Neural Networks and Deep Learning&#34;,&#34;Systems Programming in Unix/Linux&#34;,&#34;Analytical Corporate Finance&#34;,&#34;Fraud and Corruption&#34;,&#34;Conferencing and Presentation English for Young Academics&#34;,&#34;A Concise Guide to Market Research&#34;,&#34;Global Supply Chain and Operations Management&#34;,&#34;Introduction to Parallel Computing&#34;,&#34;Mathematical Logic&#34;,&#34;Stability and Control of Linear Systems&#34;,&#34;Introduction to Formal Philosophy&#34;,&#34;Analysis for Computer Scientists&#34;,&#34;International Business Management&#34;,&#34;Research Methods for the Digital Humanities&#34;,&#34;Introductory Computer Forensics&#34;,&#34;Control Engineering&#34;,&#34;Control Engineering: MATLAB Exercises&#34;,&#34;ENZYMES: Catalysis, Kinetics and Mechanisms&#34;,&#34;Automatic Control with Experiments&#34;,&#34;Internet of Things From Hype to Reality&#34;,&#34;Quantitative Methods for the Social Sciences&#34;,&#34;A Pythagorean Introduction to Number Theory&#34;,&#34;Philosophical and Mathematical Logic&#34;,&#34;Structural Dynamics&#34;,&#34;Plant Physiology, Development and Metabolism&#34;,&#34;Quantum Mechanics for Pedestrians 1&#34;,&#34;Quantum Mechanics for Pedestrians 2&#34;,&#34;Excel Data Analysis&#34;,&#34;Quick Start Guide to VHDL&#34;,&#34;Managing Media and Digital Organizations&#34;,&#34;Media and Digital Management&#34;,&#34;An Anthology of London in Literature, 1558-1914&#34;,&#34;Astronautics&#34;,&#34;Perceptual Organization&#34;,&#34;Research Methods for Social Justice and Equity in Education&#34;,&#34;Educational Technology&#34;,&#34;Quick Start Guide to Verilog&#34;,&#34;Spine Surgery&#34;,&#34;Introduction to Logic Circuits &amp; Logic Design with VHDL&#34;,&#34;Social Justice Theory and Practice for Social Work&#34;,&#34;School Leadership and Educational Change in Singapore&#34;,&#34;Digital Business Models&#34;,&#34;Introduction to Logic Circuits &amp; Logic Design with Verilog&#34;,&#34;Mapping Global Theatre Histories&#34;,&#34;Social Marketing in Action&#34;,&#34;Analyzing Qualitative Data with MAXQDA&#34;,&#34;Handbook of Evolutionary Research in Archaeology&#34;,&#34;Foundations of Behavioral Health&#34;,&#34;Social Psychology in Action&#34;,&#34;A Course in Rasch Measurement Theory&#34;,&#34;Multimedia Big Data Computing for IoT Applications&#34;,&#34;Policing and Minority Communities&#34;,&#34;Food Fraud Prevention&#34;,&#34;Plant Ecology&#34;],[&#34;Robert W. Erickson, Dragan Maksimovic&#34;,&#34;Jeylan T. Mortimer, Michael J. Shanahan&#34;,&#34;Larry Wasserman&#34;,&#34;Christopher Kearney&#34;,&#34;László Lovász, József Pelikán, Katalin Vesztergombi&#34;,&#34;Mahendra S. Rao, Marcus Jacobson&#34;,&#34;Steven Kay&#34;,&#34;Havidan Rodriguez, Enrico L. Quarantelli, Russell Dynes&#34;,&#34;Janet Saltzman Chafetz&#34;,&#34;Jonathan H. Turner&#34;,&#34;Jean Elbaum, Deborah Benson&#34;,&#34;Jorge Nocedal, Stephen Wright&#34;,&#34;C. Barry Carter, M. Grant Norton&#34;,&#34;Duane Knudson&#34;,&#34;Teresita Majewski, David Gaimster&#34;,&#34;Robert C. Blattberg, Byung-Do Kim, Scott A. Neslin&#34;,&#34;Krishan K. Chawla&#34;,&#34;Jonathan D. Cryer, Kung-Sik Chan&#34;,&#34;David B. Williams, C. Barry Carter&#34;,&#34;Alex R. Piquero, David Weisburd&#34;,&#34;Hans Lambers, F Stuart Chapin III, Thijs L. Pons&#34;,&#34;Peter Dalgaard&#34;,&#34;Trevor Hastie, Robert Tibshirani, Jerome Friedman&#34;,&#34;James M. Nelson&#34;,&#34;Paul S.P. Cowpertwait, Andrew V. Metcalfe&#34;,&#34;Margaret Semrud-Clikeman, Phyllis Anne Teeter Ellison&#34;,&#34;Alain Zuur, Elena N. Ieno, Erik Meesters&#34;,&#34;Richard A. Lockshin&#34;,&#34;J. Schijve&#34;,&#34;Kenneth R. Lang&#34;,&#34;A.E. Eiben, J.E. Smith&#34;,&#34;Siegmund Brandt&#34;,&#34;Stefan G. Hofmann&#34;,&#34;Slobodan N. Vukosavic&#34;,&#34;Wolfgang Demtröder&#34;,&#34;Kimberly Maich, Darren Levine, Carmen Hall&#34;,&#34;Ulrich Daepp, Pamela Gorkin&#34;,&#34;David G. Luenberger, Yinyu Ye&#34;,&#34;David Borthwick&#34;,&#34;Robert Huggins&#34;,&#34;Eckhard Lammert, Martin Zeeb&#34;,&#34;Harry T. Lawless, Hildegarde Heymann&#34;,&#34;Jorge Angeles&#34;,&#34;Andrea T. da Poian, Miguel A. R. B. Castanho&#34;,&#34;Lars-Göran Johansson&#34;,&#34;Bogdan Povh, Klaus Rith, Christoph Scholz, Frank Zetsche, Werner Rodejohann&#34;,&#34;Kent D. Lee, Steve Hubbard&#34;,&#34;Abbie E. Goldberg, Katherine R. Allen&#34;,&#34;Peter Dorman&#34;,&#34;Bilash Kanti Bala, Fatimah Mohamed Arshad, Kusairi Mohd Noh&#34;,&#34;Delia Perlov, Alex Vilenkin&#34;,&#34;Thomas Witelski, Mark Bowen&#34;,&#34;Brock J. LaMeres&#34;,&#34;O. A. Bauchau, J.I. Craig&#34;,&#34;Octave Levenspiel&#34;,&#34;David L. Olson, Desheng Dash Wu&#34;,&#34;Naser Mahdavi Tabatabaei, Ali Jafari Aghbolaghi, Nicu Bizon, Frede Blaabjerg&#34;,&#34;Martin Kolmar&#34;,&#34;Ian Gibson, David W. Rosen, Brent Stucker&#34;,&#34;Nihat Özkaya, Dawn Leger, David Goldsheyder, Margareta Nordin&#34;,&#34;Peter Waller, Muluneh Yitayew&#34;,&#34;Dilip Datta&#34;,&#34;Simon Grondin&#34;,&#34;Peter Schneider&#34;,&#34;Dexter C. Kozen&#34;,&#34;Steven S Skiena&#34;,&#34;Ernö Keszei&#34;,&#34;Philipp O.J. Scherer&#34;,&#34;Christian Heumann, Michael Schomaker,  Shalabh&#34;,&#34;Andrea DeCapua&#34;,&#34;Klaus Neusser&#34;,&#34;Christine Lefrou, Pierre Fabry, Jean-Claude Poignet&#34;,&#34;Loukas Grafakos&#34;,&#34;Orlando J. Miller, Eeva Therman&#34;,&#34;Christoph Bleidorn&#34;,&#34;Brian C. Hall&#34;,&#34;Robert C. Hyzy&#34;,&#34;Paul J. Frick, Christopher T. Barry, Randy W. Kamphaus&#34;,&#34;Alan Hevner, Samir Chatterjee&#34;,&#34;Russell K. Hobbie, Bradley J. Roth&#34;,&#34;Max Bramer&#34;,&#34;Hannu Karttunen, Pekka Kröger, Heikki Oja, Markku Poutanen, Karl Johan Donner&#34;,&#34;Marlon Dumas, Marcello La Rosa, Jan Mendling, Hajo A. Reijers&#34;,&#34;Jean-François Le Gall&#34;,&#34;Martina Seidl, Marion Scholz, Christian Huemer, Gerti Kappel&#34;,&#34;Angela Dean, Daniel Voss, Danel Draguljić&#34;,&#34;Frank E. Ritter, Gordon D. Baxter, Elizabeth F. Churchill&#34;,&#34;Jing Jian Xiao&#34;,&#34;F Stuart Chapin III, Pamela A. Matson, Peter Vitousek&#34;,&#34;Wolfgang Karl Härdle, Léopold Simar&#34;,&#34;Dirk Morschett, Hanna Schramm-Klein, Joachim Zentes&#34;,&#34;Richard Szeliski&#34;,&#34;Nathan Ida&#34;,&#34;Charu C. Aggarwal&#34;,&#34;Giancarlo Gandolfo&#34;,&#34;Efstathios E (Stathis) Michaelides&#34;,&#34;Efraim Turban, Judy Whiteside, David King, Jon Outland&#34;,&#34;Mark de Berg, Otfried Cheong, Marc van Kreveld, Mark Overmars&#34;,&#34;Anders Malthe-Sørenssen&#34;,&#34;Peter Zweifel, Aaron Praktiknjo, Georg Erdmann&#34;,&#34;Edward H. Shortliffe, James J. Cimino&#34;,&#34;Heike Kahlert, Fritz Scholz&#34;,&#34;Michael Mosher, Kenneth Trantham&#34;,&#34;Sarah E. Gergel, Monica G. Turner&#34;,&#34;Jim Pitman&#34;,&#34;Alan Garfinkel, Jane Shevtsov, Yina Guo&#34;,&#34;Francis Chen&#34;,&#34;Dietmar Gross, Werner Hauger, Jörg Schröder, Wolfgang A. Wall, Nimal Rajapakse&#34;,&#34;A. Ravve&#34;,&#34;Hans Petter Langtangen&#34;,&#34;G. Thomas Farmer, John Cook&#34;,&#34;S. Sumathi, L. Ashok Kumar, P. Surekha&#34;,&#34;Richard M. Heiberger, Burt Holland&#34;,&#34;Jan vom Brocke, Jan Mendling&#34;,&#34;Kenneth A. Ross&#34;,&#34;Nigel Smart&#34;,&#34;Michel Rieutord&#34;,&#34;Amy Van Looy&#34;,&#34;David Weisburd, Chester Britt&#34;,&#34;Hartmut Stadtler, Christoph Kilger, Herbert Meyr&#34;,&#34;Alexandr A. Borovkov&#34;,&#34;David Ruppert, David S. Matteson&#34;,&#34;Horacio Arló-Costa, Vincent F. Hendricks, Johan van Benthem&#34;,&#34;Martin Braun&#34;,&#34;Sulabha K. Kulkarni&#34;,&#34;O. S. Miettinen&#34;,&#34;Rien Segers&#34;,&#34;Jürgen Jost&#34;,&#34;Jon Wakefield&#34;,&#34;Dirk Morschett, Hanna Schramm-Klein, Joachim Zentes&#34;,&#34;Benjamin A. Stickler, Ewald Schachinger&#34;,&#34;Andrew T. Duchowski&#34;,&#34;Mary Renck Jalongo, Olivia N. Saracho&#34;,&#34;Sadri Hassani&#34;,&#34;Peter C. Kratcoski&#34;,&#34;Henning Struchtrup&#34;,&#34;Stephen Kemmis, Robin McTaggart, Rhonda Nixon&#34;,&#34;Uwe Hassler&#34;,&#34;Ton J. Cleophas, Aeilko H. Zwinderman&#34;,&#34;Ton J. Cleophas, Aeilko H. Zwinderman&#34;,&#34;Steven S. Skiena&#34;,&#34;Miroslav Kubat&#34;,&#34;Gerard O&#39;Regan&#34;,&#34;Knut Bjørlykke&#34;,&#34;Mark Ladd, Rex Palmer&#34;,&#34;Peter J. Brockwell, Richard A. Davis&#34;,&#34;Gordon L. Stüber&#34;,&#34;Peter R. Hoskins, Patricia V. Lawford, Barry J. Doyle&#34;,&#34;John Lee&#34;,&#34;Pietro Boria&#34;,&#34;Donna L. Gruol, Noriyuki Koibuchi, Mario Manto, Marco Molinari, Jeremy D. Schmahmann, Ying Shen&#34;,&#34;Angel M.Y. Lin&#34;,&#34;Seán Dineen&#34;,&#34;Massimiliano Bonamente&#34;,&#34;Faron Moller, Georg Struth&#34;,&#34;Edmund K. Burke, Graham Kendall&#34;,&#34;William Fulton, Joe Harris&#34;,&#34;Sheldon Axler&#34;,&#34;Rudolf Kippenhahn, Alfred Weigert, Achim Weiss&#34;,&#34;Alexandra Alvergne, Crispin Jenkinson, Charlotte Faurie&#34;,&#34;Christof Paar, Jan Pelzl&#34;,&#34;Jörg Liesen, Volker Mehrmann&#34;,&#34;Stephen Abbott&#34;,&#34;Robert J Vanderbei&#34;,&#34;Kevin McCain&#34;,&#34;Joan Marques, Satinder Dhiman&#34;,&#34;Massimo Rudan&#34;,&#34;John O. Okpara, Samuel O. Idowu&#34;,&#34;William A. Adkins, Mark G. Davidson&#34;,&#34;Efraim Turban, David King, Jae Kyu Lee, Ting-Peng Liang, Deborrah C. Turban&#34;,&#34;C. Barry Carter, M. Grant Norton&#34;,&#34;Miguel Valcárcel Cases, Ángela I. López-Lorente, Ma Ángeles López-Jiménez&#34;,&#34;Michael Z. Hauschild, Ralph K. Rosenbaum, Stig Irving Olsen&#34;,&#34;George S. Everly, Jr., Jeffrey M. Lating&#34;,&#34;Philipp Scherer&#34;,&#34;Debra A. Harley, Pamela B. Teaster&#34;,&#34;Paul A. Iaizzo&#34;,&#34;Daniel Bes&#34;,&#34;Randall Schumacker, Sara Tomek&#34;,&#34;Jürgen H Gross&#34;,&#34;Isamu Kusaka&#34;,&#34;Po Sing Leung&#34;,&#34;Ian Gibson, David Rosen, Brent Stucker&#34;,&#34;Coen de Graaf, Ria Broer&#34;,&#34;David G. Kleinbaum, Mitchel Klein&#34;,&#34;Travis Norsen&#34;,&#34;Gareth James, Daniela Witten, Trevor Hastie, Robert Tibshirani&#34;,&#34;Andrey Grozin&#34;,&#34;Richard A. Berk&#34;,&#34;J. David Logan&#34;,&#34;Charles Keeton&#34;,&#34;Zhongchao Tan&#34;,&#34;Dietrich Braun, Harald Cherdron, Matthias Rehahn, Helmut Ritter, Brigitte Voit&#34;,&#34;Yann Bouchery, Charles J. Corbett, Jan C. Fransoo, Tarkan Tan&#34;,&#34;Bruno Siciliano, Lorenzo Sciavicco, Luigi Villani, Giuseppe Oriolo&#34;,&#34;Badi H. Baltagi&#34;,&#34;Eugen Seibold, Wolfgang Berger&#34;,&#34;Ton J. Cleophas, Aeilko H. Zwinderman&#34;,&#34;Frank E. Harrell , Jr.&#34;,&#34;Henri de Waele&#34;,&#34;S. Suzanne Nielsen&#34;,&#34;William M. Hartmann&#34;,&#34;Jerome J. Connor, Susan Faraji&#34;,&#34;Karl F. Renk&#34;,&#34;Wolfgang Karl Härdle, Cathy Yi-Hsuan Chen, Ludger Overbeck&#34;,&#34;Gary W. Peterson, Kevin R. Bush&#34;,&#34;Harald Ibach, Hans Lüth&#34;,&#34;Andrzej Lasia&#34;,&#34;Wilfred Beckerman&#34;,&#34;Gerard O&#39;Regan&#34;,&#34;Ze-Nian Li, Mark S. Drew, Jiangchuan Liu&#34;,&#34;Harald Gleissner, J. Christian Femerling&#34;,&#34;Arnout Jozef Ceulemans&#34;,&#34;Joey T. Cheng, Jessica L. Tracy, Cameron Anderson&#34;,&#34;F.M. Dekking, C. Kraaikamp, H.P. Lopuhaä, L.E. Meester&#34;,&#34;Joseph Bak, Donald J. Newman&#34;,&#34;H.-D. Belitz, Werner Grosch, Peter Schieberle&#34;,&#34;Jochen Vogt&#34;,&#34;Ben Stephenson&#34;,&#34;Sergey N. Makarov, Reinhold Ludwig, Stephen J. Bitar&#34;,&#34;Joachim Zentes, Dirk Morschett, Hanna Schramm-Klein&#34;,&#34;S. Suzanne Nielsen&#34;,&#34;Stefan C. Dombrowski&#34;,&#34;Ton J. Cleophas, Aeilko H. Zwinderman&#34;,&#34;Kathleen Hague Armstrong, Julia A. Ogg, Ashley N. Sundman-Wheat, Audra St. John Walsh&#34;,&#34;R. Shankar&#34;,&#34;Charu C. Aggarwal&#34;,&#34;Daan J. A. Crommelin, Robert D. Sindelar, Bernd Meibohm&#34;,&#34;Kent D. Lee&#34;,&#34;Erdogan Madenci, Ibrahim Guven&#34;,&#34;Mildred S. Dresselhaus, Gene Dresselhaus, Ado Jorio&#34;,&#34;Brahma Dathan, Sarnath Ramnath&#34;,&#34;Manuel Jiménez, Rogelio Palomera, Isidoro Couvertier&#34;,&#34;Anders Malthe-Sørenssen&#34;,&#34;Jay D. Humphrey, Sherry L. O’Rourke&#34;,&#34;Helmut Lütkepohl&#34;,&#34;Laura Igual, Santi Seguí&#34;,&#34;Peter D. Lax, Maria Shea Terrell&#34;,&#34;Arnold Verruijt&#34;,&#34;Hans Peters&#34;,&#34;Lawrence M. Friedman, Curt D. Furberg, David L. DeMets, David M. Reboussin, Christopher B. Granger&#34;,&#34;F. Moukalled, L. Mangani, M. Darwish&#34;,&#34;Scott R. Steele, Tracy L. Hull, Thomas E. Read, Theodore J. Saclarides, Anthony J. Senagore, Charles B. Whitlow&#34;,&#34;Max Kuhn, Kjell Johnson&#34;,&#34;Brock J. LaMeres&#34;,&#34;Harald Heinrichs, Pim Martens, Gerd Michelsen, Arnim Wiek&#34;,&#34;Georg Job, Regina Rüffler&#34;,&#34;Marius Grundmann&#34;,&#34;Nicu Bizon, Naser Mahdavi Tabatabaei, Frede Blaabjerg, Erol Kurt&#34;,&#34;Laura Tateosian&#34;,&#34;Steen Krenk, Jan Høgsberg&#34;,&#34;Miklós Laczkovich, Vera T. Sós&#34;,&#34;Mauro Borgo, Alessandro Soranzo, Massimo Grassi&#34;,&#34;Nicholas Anthony John Hastings&#34;,&#34;Vickie A. Vaclavik, Elizabeth W. Christian&#34;,&#34;K.T. Hecht&#34;,&#34;Achim Klenke&#34;,&#34;Peter Lake, Paul Crowther&#34;,&#34;Wilhelm Burger, Mark J. Burge&#34;,&#34;Ricardo Simpson, Sudhir K. Sastry&#34;,&#34;David B. Williams, C. Barry Carter&#34;,&#34;Joseph Migga Kizza&#34;,&#34;Jaap Hage, Antonia Waltermann, Bram Akkermans&#34;,&#34;RAINER DICK&#34;,&#34;Jean-Michel Marin, Christian P. Robert&#34;,&#34;Oleg Roussak, H. D. Gesser&#34;,&#34;Francis A. Carey, Richard J. Sundberg&#34;,&#34;Francis A. Carey, Richard J. Sundberg&#34;,&#34;Hans-Joachim Heintze, Pierre Thielbörger&#34;,&#34;Umberto Veronesi, Aron Goldhirsch, Paolo Veronesi, Oreste Davide Gentilini, Maria Cristina Leonardi&#34;,&#34;Mark Anthony Camilleri&#34;,&#34;Efraim Turban, Jon Outland, David King, Jae Kyu Lee, Ting-Peng Liang, Deborrah C. Turban&#34;,&#34;Debra A. Harley, Noel A. Ysasi, Malachy L. Bishop, Allison R. Fleming&#34;,&#34;Evie Kendal, Basia Diug&#34;,&#34;Erik Mooi, Marko Sarstedt, Irma Mooi-Reci&#34;,&#34;Joseph I. Goldstein, Dale E. Newbury, Joseph R. Michael, Nicholas W.M. Ritchie, John Henry J. Scott, David C. Joy&#34;,&#34;William Bajjali&#34;,&#34;Jakob Schwichtenberg&#34;,&#34;Lori A. Roscoe, David P. Schenck&#34;,&#34;Kent D. Lee&#34;,&#34;Andrea Macchi, Giovanni Moruzzi, Francesco Pegoraro&#34;,&#34;David Forsyth&#34;,&#34;Amedeo D&#39;Adamo&#34;,&#34;Shannon R. Lane, Suzanne Pritzker&#34;,&#34;Paul R. Berman&#34;,&#34;Antti Laaksonen&#34;,&#34;Wolfgang Ertel&#34;,&#34;Bernhard Haubold, Angelika Börsch-Haubold&#34;,&#34;Richard K. Thomas&#34;,&#34;Sandro Skansi&#34;,&#34;Charles A.S. Hall, Kent Klitgaard&#34;,&#34;Eva-Kathrin Ehmoser-Sinner, Cherng-Wen Darren Tan&#34;,&#34;Gilbert G. Lenssen, N. Craig Smith&#34;,&#34;Dietmar Gross, Werner Hauger, Jörg Schröder, Wolfgang A. Wall, Javier Bonet&#34;,&#34;Marlon Dumas, Marcello La Rosa, Jan Mendling, Hajo A. Reijers&#34;,&#34;Tai Mendenhall, Angela Lamson, Jennifer Hodgson, Macaran Baird&#34;,&#34;Joe Pitt-Francis, Jonathan Whiteley&#34;,&#34;Jutta Heckhausen, Heinz Heckhausen&#34;,&#34;Peter C. Kratcoski, Maximilian Edelbacher&#34;,&#34;Klaus North, Gita Kumta&#34;,&#34;Diane Gifford-Gonzalez&#34;,&#34;Gregory T. Lee&#34;,&#34;Jada Hector, David Khey&#34;,&#34;Naomi Zack&#34;,&#34;Marcel Danesi&#34;,&#34;Paul M. Selzer, Richard J. Marhöfer, Oliver Koch&#34;,&#34;Giovanni Landi, Alessandro Zampini&#34;,&#34;Larry Brackney, Andrew Parker, Daniel Macumber, Kyle Benne&#34;,&#34;V. Kumar, Werner Reinartz&#34;,&#34;Eva O. L. Lantsoght&#34;,&#34;Ashish Malik&#34;,&#34;Peter J. Olver, Chehrzad Shakiban&#34;,&#34;Alexandra S. Moore, Elizabeth Swanson&#34;,&#34;Martin Aigner, Günter M. Ziegler&#34;,&#34;Cosimo Bambi&#34;,&#34;Alessandro De Angelis, Mário Pimenta&#34;,&#34;Mitsunori Ogihara&#34;,&#34;José María Ponce-Ortega, Luis Germán Hernández-Pérez&#34;,&#34;Matjaž Mihelj, Tadej Bajd, Aleš Ude, Jadran Lenarčič, Aleš Stanovnik, Marko Munih, Jure Rejc, Sebastjan Šlajpah&#34;,&#34;Christian A. Conrad&#34;,&#34;Pieter Kok&#34;,&#34;Frans H. van Eemeren&#34;,&#34;André Platzer&#34;,&#34;Henry Louie&#34;,&#34;Thorsten Hennig-Thurau, Mark B. Houston&#34;,&#34;Arnt Inge Vistnes&#34;,&#34;Manijeh Razeghi&#34;,&#34;Giuliano Donzellini, Luca Oneto, Domenico Ponta, Davide Anguita&#34;,&#34;Charu C. Aggarwal&#34;,&#34;K.C. Wang&#34;,&#34;Angelo Corelli&#34;,&#34;Peter C. Kratcoski, Maximilian Edelbacher&#34;,&#34;Michael Guest&#34;,&#34;Marko Sarstedt, Erik Mooi&#34;,&#34;Dmitry Ivanov, Alexander Tsipoulanidis, Jörn Schönberger&#34;,&#34;Roman Trobec, Boštjan Slivnik, Patricio Bulić, Borut Robič&#34;,&#34;Roman Kossak&#34;,&#34;Andrea Bacciotti&#34;,&#34;Sven Ove Hansson, Vincent F. Hendricks&#34;,&#34;Michael Oberguggenberger, Alexander Ostermann&#34;,&#34;Kamal Fatehi, Jeongho Choi&#34;,&#34;lewis levenberg, Tai Neilson, David Rheams&#34;,&#34;Xiaodong Lin&#34;,&#34;László Keviczky, Ruth Bars, Jenő Hetthéssy, Csilla Bányász&#34;,&#34;László Keviczky, Ruth Bars, Jenő Hetthéssy, Csilla Bányász&#34;,&#34;N.S. Punekar&#34;,&#34;Victor Manuel Hernández-Guzmán, Ramón Silva-Ortigoza&#34;,&#34;Ammar Rayes, Samer Salam&#34;,&#34;Daniel Stockemer&#34;,&#34;Ramin Takloo-Bighash&#34;,&#34;Harrie de Swart&#34;,&#34;Mario Paz, Young Hoon Kim&#34;,&#34;Satish C Bhatla, Manju A. Lal&#34;,&#34;Jochen Pade&#34;,&#34;Jochen Pade&#34;,&#34;Hector Guerrero&#34;,&#34;Brock J. LaMeres&#34;,&#34;Eli M. Noam&#34;,&#34;Eli M. Noam&#34;,&#34;Geoffrey G. Hiller, Peter L. Groves, Alan F. Dilnot&#34;,&#34;Ulrich Walter&#34;,&#34;Stephen Handel&#34;,&#34;Kamden K. Strunk, Leslie Ann Locke&#34;,&#34;Ronghuai Huang, J. Michael Spector, Junfeng Yang&#34;,&#34;Brock J. LaMeres&#34;,&#34;Bernhard Meyer, Michael Rauschmann&#34;,&#34;Brock J. LaMeres&#34;,&#34;Lynelle Watts, David Hodgson&#34;,&#34;Benjamin Wong, Salleh Hairon, Pak Tee Ng&#34;,&#34;Bernd W. Wirtz&#34;,&#34;Brock J. LaMeres&#34;,&#34;Mark Pizzato&#34;,&#34;Debra Z. Basil, Gonzalo Diaz-Meneses, Michael D. Basil&#34;,&#34;Udo Kuckartz, Stefan Rädiker&#34;,&#34;Anna Marie Prentiss&#34;,&#34;Bruce Lubotsky Levin, Ardis Hanson&#34;,&#34;Kai Sassenberg, Michael L.W. Vliek&#34;,&#34;David Andrich, Ida Marais&#34;,&#34;Sudeep Tanwar, Sudhanshu Tyagi, Neeraj Kumar&#34;,&#34;James F. Albrecht, Garth den Heyer, Perry Stanislas&#34;,&#34;John W. Spink&#34;,&#34;Ernst-Detlef Schulze, Erwin Beck, Nina Buchmann, Stephan Clemens, Klaus Müller-Hohenstein, Michael Scherer-Lorenzen&#34;],[&#34;2nd ed. 2001&#34;,&#34;2003&#34;,&#34;2004&#34;,&#34;2005&#34;,&#34;2003&#34;,&#34;4th ed. 2005&#34;,&#34;2006&#34;,&#34;2006&#34;,&#34;1999&#34;,&#34;2001&#34;,&#34;2007&#34;,&#34;2nd ed. 2006&#34;,&#34;2007&#34;,&#34;2nd ed. 2007&#34;,&#34;2009&#34;,&#34;2008&#34;,&#34;3rd ed. 2012&#34;,&#34;2nd ed. 2008&#34;,&#34;2nd ed. 2009&#34;,&#34;1st ed. 2010&#34;,&#34;2nd ed. 2008&#34;,&#34;2nd ed. 2008&#34;,&#34;2nd ed. 2009&#34;,&#34;2009&#34;,&#34;2009&#34;,&#34;2nd ed. 2009&#34;,&#34;2009&#34;,&#34;2007&#34;,&#34;2nd ed. 2009&#34;,&#34;2013&#34;,&#34;2nd ed. 2015&#34;,&#34;4th ed. 2014&#34;,&#34;1st ed. 2017&#34;,&#34;2012&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;2nd ed. 2011&#34;,&#34;4th ed. 2016&#34;,&#34;1st ed. 2016&#34;,&#34;2nd ed. 2016&#34;,&#34;2014&#34;,&#34;2nd ed. 2010&#34;,&#34;4th ed. 2014&#34;,&#34;1st ed. 2015&#34;,&#34;1st ed. 2016&#34;,&#34;7th ed. 2015&#34;,&#34;2015&#34;,&#34;2013&#34;,&#34;2014&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2015&#34;,&#34;1st ed. 2017&#34;,&#34;2009&#34;,&#34;3rd ed. 2014&#34;,&#34;2nd ed. 2017&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2017&#34;,&#34;2010&#34;,&#34;4th ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;2nd ed. 2015&#34;,&#34;1997&#34;,&#34;2nd ed. 2008&#34;,&#34;2012&#34;,&#34;3rd ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;2nd ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;2012&#34;,&#34;3rd ed. 2014&#34;,&#34;4th ed. 2001&#34;,&#34;1st ed. 2017&#34;,&#34;2013&#34;,&#34;1st ed. 2017&#34;,&#34;3rd ed. 2010&#34;,&#34;2010&#34;,&#34;5th ed. 2015&#34;,&#34;3rd ed. 2016&#34;,&#34;6th ed. 2017&#34;,&#34;2013&#34;,&#34;1st ed. 2016&#34;,&#34;2015&#34;,&#34;2nd ed. 2017&#34;,&#34;2014&#34;,&#34;2nd ed. 2016&#34;,&#34;2nd ed. 2012&#34;,&#34;4th ed. 2015&#34;,&#34;2nd ed. 2010&#34;,&#34;2011&#34;,&#34;3rd ed. 2015&#34;,&#34;2015&#34;,&#34;2nd ed. 2014&#34;,&#34;2012&#34;,&#34;4th ed. 2017&#34;,&#34;3rd ed. 2008&#34;,&#34;2015&#34;,&#34;1st ed. 2017&#34;,&#34;4th ed. 2014&#34;,&#34;2013&#34;,&#34;1st ed. 2017&#34;,&#34;2nd ed. 2017&#34;,&#34;1993&#34;,&#34;1st ed. 2017&#34;,&#34;3rd ed. 2016&#34;,&#34;2nd ed. 2013&#34;,&#34;3rd ed. 2012&#34;,&#34;5th ed. 2016&#34;,&#34;2013&#34;,&#34;2015&#34;,&#34;2nd ed. 2015&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2013&#34;,&#34;1st ed. 2016&#34;,&#34;2015&#34;,&#34;1st ed. 2016&#34;,&#34;4th ed. 2014&#34;,&#34;5th ed. 2015&#34;,&#34;2013&#34;,&#34;2nd ed. 2015&#34;,&#34;1st ed. 2016&#34;,&#34;4th ed. 1993&#34;,&#34;3rd ed. 2015&#34;,&#34;2011&#34;,&#34;1st ed. 2016&#34;,&#34;3rd ed. 2013&#34;,&#34;2013&#34;,&#34;3rd ed. 2015&#34;,&#34;2nd ed. 2016&#34;,&#34;3rd ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;2nd ed. 2013&#34;,&#34;6th ed. 2017&#34;,&#34;2014&#34;,&#34;2014&#34;,&#34;1st ed. 2016&#34;,&#34;2011&#34;,&#34;2nd ed. 2016&#34;,&#34;1st ed. 2017&#34;,&#34;2nd ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;2nd ed. 2015&#34;,&#34;5th ed. 2013&#34;,&#34;3rd ed. 2016&#34;,&#34;4th ed. 2017&#34;,&#34;1st ed. 2017&#34;,&#34;2nd ed. 2013&#34;,&#34;2nd ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;1st ed. 2016&#34;,&#34;3rd ed. 2014&#34;,&#34;2nd ed. 2017&#34;,&#34;2013&#34;,&#34;2nd ed. 2014&#34;,&#34;2004&#34;,&#34;3rd ed. 2015&#34;,&#34;2nd ed. 2012&#34;,&#34;1st ed. 2016&#34;,&#34;2010&#34;,&#34;1st ed. 2015&#34;,&#34;2nd ed. 2015&#34;,&#34;4th ed. 2014&#34;,&#34;1st ed. 2016&#34;,&#34;1st ed. 2017&#34;,&#34;2015&#34;,&#34;2013&#34;,&#34;2012&#34;,&#34;8th ed. 2015&#34;,&#34;2nd ed. 2013&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;3rd ed. 2013&#34;,&#34;2nd ed. 2013&#34;,&#34;1st ed. 2016&#34;,&#34;3rd ed. 2015&#34;,&#34;3rd ed. 2012&#34;,&#34;2013&#34;,&#34;3rd ed. 2017&#34;,&#34;1st ed. 2015&#34;,&#34;2014&#34;,&#34;2nd ed. 2015&#34;,&#34;1st ed. 2016&#34;,&#34;3rd ed. 2012&#34;,&#34;1st ed. 2017&#34;,&#34;2013&#34;,&#34;2014&#34;,&#34;2nd ed. 2016&#34;,&#34;3rd ed. 2015&#34;,&#34;2014&#34;,&#34;2014&#34;,&#34;5th ed. 2013&#34;,&#34;1st ed. 2017&#34;,&#34;2009&#34;,&#34;5th ed. 2011&#34;,&#34;4th ed. 2017&#34;,&#34;2nd ed. 2016&#34;,&#34;2nd ed. 2015&#34;,&#34;2nd ed. 2017&#34;,&#34;3rd ed. 2017&#34;,&#34;2013&#34;,&#34;2nd ed. 2016&#34;,&#34;2nd ed. 2017&#34;,&#34;3rd ed. 2017&#34;,&#34;3rd ed. 2013&#34;,&#34;4th ed. 2009&#34;,&#34;2014&#34;,&#34;2nd ed. 2017&#34;,&#34;1st ed. 2017&#34;,&#34;2nd ed. 2014&#34;,&#34;2013&#34;,&#34;2013&#34;,&#34;2014&#34;,&#34;2005&#34;,&#34;3rd ed. 2010&#34;,&#34;4th ed. 2009&#34;,&#34;1st ed. 2017&#34;,&#34;2014&#34;,&#34;1st ed. 2016&#34;,&#34;3rd ed. 2017&#34;,&#34;5th ed. 2017&#34;,&#34;2015&#34;,&#34;2015&#34;,&#34;2014&#34;,&#34;2nd ed. 1994&#34;,&#34;1st ed. 2016&#34;,&#34;4th ed. 2013&#34;,&#34;2nd ed. 2014&#34;,&#34;2nd ed. 2015&#34;,&#34;2008&#34;,&#34;2nd ed. 2015&#34;,&#34;2014&#34;,&#34;2015&#34;,&#34;2nd ed. 2015&#34;,&#34;2005&#34;,&#34;1st ed. 2017&#34;,&#34;2nd ed. 2014&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2015&#34;,&#34;5th ed. 2015&#34;,&#34;1st ed. 2016&#34;,&#34;3rd ed. 2016&#34;,&#34;2013&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2016&#34;,&#34;1st ed. 2016&#34;,&#34;3rd ed. 2016&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2015&#34;,&#34;2013&#34;,&#34;1st ed. 2015&#34;,&#34;2012&#34;,&#34;2nd ed. 2015&#34;,&#34;4th ed. 2014&#34;,&#34;2000&#34;,&#34;2nd ed. 2014&#34;,&#34;2013&#34;,&#34;2nd ed. 2016&#34;,&#34;2013&#34;,&#34;1996&#34;,&#34;4th ed. 2017&#34;,&#34;2nd ed. 2017&#34;,&#34;2nd ed. 2016&#34;,&#34;2nd ed. 2014&#34;,&#34;2nd ed. 2013&#34;,&#34;5th ed. 2007&#34;,&#34;5th ed. 2007&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2018&#34;,&#34;9th ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2018&#34;,&#34;4th ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;1st ed. 2017&#34;,&#34;2nd ed. 2017&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2017&#34;,&#34;2nd ed. 2017&#34;,&#34;1st ed. 2017&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2019&#34;,&#34;2nd ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2017&#34;,&#34;3rd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;3rd ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;3rd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;6th ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2019&#34;,&#34;2nd ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;4th ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;3rd ed. 2019&#34;,&#34;2nd ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;2nd ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2019&#34;,&#34;2nd ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;1st ed. 2018&#34;,&#34;6th ed. 2019&#34;,&#34;1st ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;2nd ed. 2018&#34;,&#34;2nd ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;3rd ed. 2018&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;2nd ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;2nd ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2020&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2020&#34;,&#34;1st ed. 2019&#34;,&#34;1st ed. 2019&#34;,&#34;2nd ed. 2019&#34;],[&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-306-48048-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-306-48247-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-21736-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-22592-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-21777-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-28117-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-24158-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-32353-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-36218-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-36274-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-37575-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-40065-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-46271-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-49312-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-72071-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-72579-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-74365-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-75959-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-76501-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-77650-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-78341-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-79054-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-84858-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-87573-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-88698-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-88963-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-93837-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4020-6099-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4020-6808-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-35963-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-44874-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-03762-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-56194-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-0400-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-27877-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-44794-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-9479-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-18842-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-48936-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-21239-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-7091-0715-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-6488-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-01851-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-3058-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-26551-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-46321-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-13072-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-4556-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-37434-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-10-2045-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-57040-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-23042-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-53883-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-90-481-2516-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4899-7454-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-53785-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-51118-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-57589-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-1120-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-44738-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-05699-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-47831-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-31791-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-54083-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4612-1844-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-84800-070-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-19864-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-61088-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-46162-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-33916-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-32862-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-30250-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-1194-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4613-0139-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-54064-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-7116-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-43341-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-0641-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-5653-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-12682-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-7307-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-53045-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-33143-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-31089-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-12742-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-52250-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-5134-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-28887-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-9504-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-45171-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-8349-6331-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-84882-935-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-07806-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-14142-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-37314-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-20951-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-50091-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-540-77974-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-19596-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-53022-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-4474-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-37902-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-46394-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-6374-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4612-4374-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-59731-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-22309-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-30319-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-2212-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-49887-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-94-007-5757-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-14941-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-2122-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-58307-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-6271-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-21936-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-09351-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-21990-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-9170-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-55309-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-5201-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-2614-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-20451-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4612-4360-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-09171-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-94-007-1171-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-23012-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-4809-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-0925-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-658-07884-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-27265-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-57883-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-31650-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-01195-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-54349-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-43715-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-4560-67-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-23428-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-94-007-1211-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-27104-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-55444-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-63913-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-44561-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-34132-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-3954-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-29854-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-55615-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-46407-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-9982-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-53919-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-24551-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-10-1802-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-6419-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-6572-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-84800-322-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-6940-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4612-0979-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-11080-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-30304-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-29716-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-04101-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-24346-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-2712-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-7630-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-33405-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-31036-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-1151-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-40975-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-3618-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-10091-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-3523-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-62872-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-56475-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-5538-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-00401-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-03623-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-19464-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-20556-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-6227-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-54398-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-15018-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-94-017-8771-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-2113-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-22951-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-6646-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-65867-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-7138-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-00894-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-44048-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-12493-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-9236-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-287-212-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-28980-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-29791-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-84628-642-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-642-20059-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-51412-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-20600-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-19425-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-54817-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-44127-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-6786-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-24331-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-50651-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-54486-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-3987-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-540-93804-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-8933-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-50319-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-57750-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-05290-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-01769-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-94-007-6863-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-0867-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-84628-168-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4419-7288-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-540-69934-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-49810-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-14240-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-21173-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-658-10183-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-45776-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-1911-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-15195-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-7807-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4757-0576-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-29659-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-6486-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-6642-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4899-7550-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-540-32899-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-24280-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-3143-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-19587-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-2623-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-540-27752-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-50017-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-7946-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-61185-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-46950-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-18539-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-16874-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-25970-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-6849-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-34195-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-94-017-7242-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-15666-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-23880-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-49875-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-18398-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-94-007-6113-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-2766-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-2197-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-14777-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-9138-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4612-1272-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-5361-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-5601-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4471-6684-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-9126-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4757-2519-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-55606-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-57252-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-25675-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-8687-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4614-4262-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-44899-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-0-387-71481-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-14454-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-48848-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-49849-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-58715-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-64786-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-65451-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-10-5218-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-6676-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-61158-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-66631-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-70920-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-70790-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-63133-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-64410-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-66772-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-68588-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-68598-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-72547-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-58487-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-67395-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-65439-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-73004-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-66219-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-73123-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-94-024-1144-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-56272-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-56509-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-68834-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-73132-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-65094-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-72682-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-59978-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-65682-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-77649-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-76442-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-78729-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-349-95348-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-68301-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-78361-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-77809-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-55381-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-77425-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-0399-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-91041-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-74965-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-57265-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-1090-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-78181-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-89491-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-91722-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-72911-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-91575-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-92207-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-95381-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-63588-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-91890-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-89292-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-72314-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-75708-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-92804-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-94463-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-92429-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-95762-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-92333-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-2475-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-56707-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-94313-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-98833-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-97298-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-02405-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-77434-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-91155-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-96622-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-96713-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-00581-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-10-8297-9\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-10-8321-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-0785-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-75804-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-99516-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-99118-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-02604-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-03255-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-94743-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-2023-1\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-00464-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-00467-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-01279-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-04516-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-71288-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-72000-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-05609-4\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-74373-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-96337-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-05900-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-6643-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-10552-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-98875-7\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-12489-2\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-3621-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-319-74746-0\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-13005-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-13605-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-12727-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-13020-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-15671-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-11117-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-18435-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-13788-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-7496-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-981-13-8759-3\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-030-19182-5\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-1-4939-9621-6\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;http://link.springer.com/openurl?genre=book&amp;isbn=978-3-662-56233-8\&#34;&gt;SpringerLink&lt;\/a&gt;&#34;],[&#34;Engineering; Circuits and Systems; Energy, general; Electronics and Microelectronics, Instrumentation; Energy Systems&#34;,&#34;Social Sciences; Sociology, general; Clinical Psychology; Population Economics&#34;,&#34;Mathematics; Computational Mathematics and Numerical Analysis; Probability Theory and Stochastic Processes; Complex Systems; Statistical Theory and Methods; Probability and Statistics in Computer Science; Statistics for Engineering, Physics, Computer Science, Chemistry and Earth Sciences&#34;,&#34;Psychology; Clinical Psychology; Personality and Social Psychology; Community and Environmental Psychology&#34;,&#34;Mathematics; Combinatorics; Number Theory&#34;,&#34;Biomedicine; Neurosciences; Anatomy; Neurobiology&#34;,&#34;Engineering; Communications Engineering, Networks; Mathematical Software; Mathematical and Computational Engineering; Signal, Image and Speech Processing; Probability Theory and Stochastic Processes; Fourier Analysis&#34;,&#34;Social Sciences; Sociology, general; Public Health; Demography&#34;,&#34;Social Sciences; Sociology, general; Social Sciences, general; Personality and Social Psychology&#34;,&#34;Social Sciences; Sociology, general; Political Science&#34;,&#34;Psychology; Neuropsychology; Rehabilitation; Behavioral Therapy; Rehabilitation Medicine&#34;,&#34;Mathematics; Optimization; Calculus of Variations and Optimal Control; Optimization; Systems Theory, Control; Computational Mathematics and Numerical Analysis; Operations Research/Decision Theory&#34;,&#34;Materials Science; Ceramics, Glass, Composites, Natural Materials; Industrial and Production Engineering; Characterization and Evaluation of Materials; Inorganic Chemistry; Nanotechnology&#34;,&#34;Biomedicine; Human Physiology; Biological and Medical Physics, Biophysics; Biomedical Engineering; Sports Medicine&#34;,&#34;Social Sciences; Archaeology; Cultural Heritage&#34;,&#34;Business and Management; Market Research/Competitive Intelligence; Marketing; Management; Innovation/Technology Management&#34;,&#34;Materials Science; Ceramics, Glass, Composites, Natural Materials; Engineering Design; Polymer Sciences; Mechanical Engineering; Civil Engineering&#34;,&#34;Mathematics; Probability Theory and Stochastic Processes; Statistical Theory and Methods; Actuarial Sciences&#34;,&#34;Materials Science; Characterization and Evaluation of Materials; Nanotechnology; Solid State Physics; Spectroscopy and Microscopy&#34;,&#34;Criminology and Criminal Justice; Criminology and Criminal Justice, general; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Methodology of the Social Sciences&#34;,&#34;Life Sciences; Plant Ecology; Plant Physiology; Plant Sciences; Ecology; Plant Anatomy/Development; Ecosystems&#34;,&#34;Mathematics; Probability Theory and Stochastic Processes; Statistics and Computing/Statistics Programs; Bioinformatics; Computer Appl. in Life Sciences&#34;,&#34;Computer Science; Data Mining and Knowledge Discovery; Probability Theory and Stochastic Processes; Statistical Theory and Methods; Computational Biology/Bioinformatics; Computer Appl. in Life Sciences&#34;,&#34;Psychology; Clinical Psychology; Religious Studies, general&#34;,&#34;Mathematics; Probability Theory and Stochastic Processes; Statistical Theory and Methods; Probability and Statistics in Computer Science; Marketing; Econometrics; Signal, Image and Speech Processing&#34;,&#34;Psychology; Child and School Psychology; Neuropsychology&#34;,&#34;Statistics; Statistics and Computing/Statistics Programs; Theoretical Ecology/Statistics; Statistics for Life Sciences, Medicine, Health Sciences&#34;,&#34;Biomedicine; Biomedicine, general; Evolutionary Biology; Microbial Genetics and Genomics; Popular Science in Nature and Environment&#34;,&#34;Engineering; Mechanical Engineering; Engineering Design; Structural Materials; Metallic Materials&#34;,&#34;Physics; Astrophysics and Astroparticles; Space Sciences (including Extraterrestrial Physics, Space Exploration and Astronautics); Astrobiology&#34;,&#34;Computer Science; Computational Intelligence; Theory of Computation; Robotics and Automation; Optimization&#34;,&#34;Physics; Mathematical Methods in Physics; Mathematical and Computational Engineering; Statistics for Engineering, Physics, Computer Science, Chemistry and Earth Sciences; Math. Applications in Chemistry; Numerical and Computational Physics, Simulation&#34;,&#34;Psychology; Clinical Psychology&#34;,&#34;Energy; Energy Systems; Power Electronics, Electrical Machines and Networks; Machinery and Machine Elements; Mechatronics; Industrial and Production Engineering&#34;,&#34;Physics; Classical Mechanics; Thermodynamics&#34;,&#34;Psychology; Child and School Psychology; Behavioral Therapy&#34;,&#34;Mathematics; Mathematical Logic and Foundations; Analysis; Number Theory&#34;,&#34;Business and Management; Operations Research/Decision Theory; Operations Research, Management Science; Mathematical Modeling and Industrial Mathematics; Engineering Economics, Organization, Logistics, Marketing&#34;,&#34;Mathematics; Partial Differential Equations; Mathematical Applications in the Physical Sciences&#34;,&#34;Energy; Energy Storage; Optical and Electronic Materials; Renewable and Green Energy; Electrochemistry&#34;,&#34;Biomedicine; Human Physiology; Metabolic Diseases; Biochemistry, general; Metabolomics&#34;,&#34;Chemistry; Food Science; Neurochemistry; Receptors&#34;,&#34;Engineering; Mechanical Engineering; Robotics and Automation&#34;,&#34;Biomedicine; Human Physiology; Medical Biochemistry; Animal Biochemistry; Medicinal Chemistry&#34;,&#34;Philosophy; Philosophy of Science; History and Philosophical Foundations of Physics; Mathematical Logic and Foundations&#34;,&#34;Physics; Quantum Physics; Elementary Particles, Quantum Field Theory&#34;,&#34;Computer Science; Data Structures; Python; Algorithm Analysis and Problem Complexity; Programming Techniques&#34;,&#34;Social Sciences; Family; Gender Studies; Public Health; Social Policy&#34;,&#34;Economics; Microeconomics; International Political Economy&#34;,&#34;Economics; Agricultural Economics; Mathematical Modeling and Industrial Mathematics; Mathematical and Computational Engineering; Industrial Organization&#34;,&#34;Physics; Cosmology; Classical and Quantum Gravitation, Relativity Theory; Particle and Nuclear Physics; History and Philosophical Foundations of Physics; Philosophy of Religion&#34;,&#34;Mathematics; Ordinary Differential Equations; Partial Differential Equations; Mathematical Applications in the Physical Sciences; Mathematical Modeling and Industrial Mathematics; Calculus of Variations and Optimal Control; Optimization&#34;,&#34;Engineering; Circuits and Systems; Processor Architectures; Logic Design&#34;,&#34;Engineering; Mechanical Engineering; Astronomy, Astrophysics and Cosmology; Aerospace Technology and Astronautics; Theoretical and Applied Mechanics&#34;,&#34;Chemistry; Industrial Chemistry/Chemical Engineering; Engineering Thermodynamics, Heat and Mass Transfer; Engineering Fluid Dynamics; Mechanical Engineering; Thermodynamics&#34;,&#34;Business and Management; Operations Management; Risk Management&#34;,&#34;Engineering; Power Electronics, Electrical Machines and Networks; Energy Systems; Control&#34;,&#34;Economics; Microeconomics; Behavioral/Experimental Economics; History of Economic Thought/Methodology; Game Theory; Institutional/Evolutionary Economics&#34;,&#34;Engineering; Engineering Design; Industrial Chemistry/Chemical Engineering; Industrial and Production Engineering; Mechanical Engineering&#34;,&#34;Biomedicine; Human Physiology; Sports Medicine; Biomedical Engineering; Biomedical Engineering/Biotechnology; Orthopedics; Rehabilitation&#34;,&#34;Earth Sciences; Hydrogeology; Water Industry/Water Technologies; Soil Science &amp; Conservation; Geoengineering, Foundations, Hydraulics&#34;,&#34;Popular Science; Popular Computer Science; Programming Techniques&#34;,&#34;Psychology; Cognitive Psychology&#34;,&#34;Physics; Astronomy, Astrophysics and Cosmology&#34;,&#34;Computer Science; Computation by Abstract Devices; Algorithm Analysis and Problem Complexity&#34;,&#34;Computer Science; Software Engineering/Programming and Operating Systems; Programming Techniques; Algorithm Analysis and Problem Complexity; Theory of Computation; Algorithms; Discrete Mathematics in Computer Science&#34;,&#34;Chemistry; Physical Chemistry; Thermodynamics; Engineering Thermodynamics, Heat and Mass Transfer; Industrial Chemistry/Chemical Engineering; Materials Science, general; Biochemistry, general&#34;,&#34;Physics; Numerical and Computational Physics, Simulation; Mathematical Applications in the Physical Sciences; Mathematical and Computational Engineering; Theoretical and Computational Chemistry&#34;,&#34;Statistics; Statistical Theory and Methods; Statistics for Business/Economics/Mathematical Finance/Insurance; Econometrics; Macroeconomics/Monetary Economics//Financial Economics&#34;,&#34;Education; Language Education; Learning and Instruction; Sociology of Education&#34;,&#34;Economics; Econometrics; Macroeconomics/Monetary Economics//Financial Economics; Statistics for Business/Economics/Mathematical Finance/Insurance&#34;,&#34;Chemistry; Electrochemistry; Energy Storage; Optical and Electronic Materials; Thermodynamics; Electrical Engineering&#34;,&#34;Mathematics; Fourier Analysis; Abstract Harmonic Analysis; Functional Analysis&#34;,&#34;Biomedicine; Human Genetics; Anatomy; Cell Biology; Life Sciences, general; Molecular Medicine&#34;,&#34;Life Sciences; Evolutionary Biology; Human Genetics; Bioinformatics; Microbial Genetics and Genomics; Animal Genetics and Genomics&#34;,&#34;Mathematics; Mathematical Physics; Mathematical Applications in the Physical Sciences; Quantum Physics; Functional Analysis; Topological Groups, Lie Groups; Mathematical Methods in Physics&#34;,&#34;Medicine &amp; Public Health; Intensive / Critical Care Medicine&#34;,&#34;Psychology; Child and School Psychology; Psychotherapy and Counseling; Education, general&#34;,&#34;Business and Management; IT in Business; Management of Computing and Information Systems; Information Systems and Communication Service; Models and Principles; Information Systems Applications (incl.Internet); e-Commerce/e-business&#34;,&#34;Physics; Biological and Medical Physics, Biophysics; Biomedical Engineering; Neurosciences; Human Physiology; Physiological, Cellular and Medical Topics&#34;,&#34;Computer Science; Information Storage and Retrieval; Database Management; Programming Techniques&#34;,&#34;Physics; Astronomy, Astrophysics and Cosmology; Geophysics/Geodesy; Popular Science in Astronomy&#34;,&#34;Computer Science; Computer Appl. in Administrative Data Processing; Business Process Management; Information Systems Applications (incl.Internet); Software Engineering&#34;,&#34;Mathematics; Probability Theory and Stochastic Processes; Quantitative Finance; Measure and Integration; Mathematical Modeling and Industrial Mathematics; Systems Theory, Control&#34;,&#34;Computer Science; Software Engineering; Management of Computing and Information Systems&#34;,&#34;Statistics; Statistical Theory and Methods; Probability Theory and Stochastic Processes; Statistics for Engineering, Physics, Computer Science, Chemistry and Earth Sciences&#34;,&#34;Computer Science; User Interfaces and Human Computer Interaction; Software Engineering&#34;,&#34;Psychology; Psychology Research; Family; Social Policy&#34;,&#34;Life Sciences; Ecology; Terrestial Ecology; Biodiversity; Ecosystems; Plant Ecology&#34;,&#34;Statistics; Statistics for Business/Economics/Mathematical Finance/Insurance; Quantitative Finance; Economic Theory/Quantitative Economics/Mathematical Methods; Statistical Theory and Methods&#34;,&#34;Business and Management; Business Strategy/Leadership; Management; Marketing&#34;,&#34;Computer Science; Image Processing and Computer Vision&#34;,&#34;Engineering; Signal, Image and Speech Processing; Information Systems and Communication Service; Communications Engineering, Networks&#34;,&#34;Computer Science; Data Mining and Knowledge Discovery; Pattern Recognition&#34;,&#34;Economics; International Economics; European Integration; Political Economy/Economic Policy&#34;,&#34;Energy; Renewable and Green Energy; Renewable and Green Energy; Sustainable Development; Energy Systems&#34;,&#34;Business and Management; e-Business/e-Commerce; Business Information Systems&#34;,&#34;Computer Science; Theory of Computation; Geometry; Math Applications in Computer Science; Earth Sciences, general; Computer Graphics; Algorithm Analysis and Problem Complexity&#34;,&#34;Physics; Classical Mechanics; Numerical and Computational Physics, Simulation; Mathematical Methods in Physics&#34;,&#34;Energy; Energy Policy, Economics and Management; Environmental Economics; Political Economy/Economic Policy; Energy Policy, Economics and Management; Industrial Organization&#34;,&#34;Medicine &amp; Public Health; Health Informatics; Biomedicine, general&#34;,&#34;Chemistry; Analytical Chemistry; Biochemistry, general; Environmental Chemistry; Inorganic Chemistry; Physical Chemistry; Geochemistry&#34;,&#34;Chemistry; Food Science; Organic Chemistry&#34;,&#34;Life Sciences; Landscape Ecology; Landscape/Regional and Urban Planning; Terrestial Ecology; Monitoring/Environmental Analysis; Theoretical Ecology/Statistics&#34;,&#34;Mathematics; Probability Theory and Stochastic Processes; Statistical Theory and Methods&#34;,&#34;Mathematics; Mathematical and Computational Biology; Mathematical Modeling and Industrial Mathematics; Ordinary Differential Equations&#34;,&#34;Physics; Plasma Physics; Nuclear Energy; Nuclear Energy; Space Sciences (including Extraterrestrial Physics, Space Exploration and Astronautics); Classical Electrodynamics&#34;,&#34;Engineering; Mechanical Engineering; Civil Engineering; Electrical Engineering; Materials Science, general; Physics, general; Mathematics, general&#34;,&#34;Chemistry; Polymer Sciences; Organic Chemistry; Physical Chemistry&#34;,&#34;Mathematics; Computational Science and Engineering; Programming Techniques; Mathematics of Computing; Numerical and Computational Physics, Simulation&#34;,&#34;Environment; Environment, general; Climate Change/Climate Change Impacts; Earth Sciences, general; Lifelong Learning/Adult Education; Geography, general; Organic Chemistry&#34;,&#34;Energy; Renewable and Green Energy; Energy Systems; Power Electronics, Electrical Machines and Networks; Energy Efficiency; Energy Harvesting&#34;,&#34;Statistics; Statistical Theory and Methods; Statistics and Computing/Statistics Programs; Statistics for Engineering, Physics, Computer Science, Chemistry and Earth Sciences&#34;,&#34;Business and Management; Business Process Management; Information Systems Applications (incl.Internet); Business Information Systems; Organization; Organizational Studies, Economic Sociology&#34;,&#34;Mathematics; Analysis; Real Functions&#34;,&#34;Computer Science; Data Structures, Cryptology and Information Theory; Mathematics of Computing; Security Science and Technology; Discrete Mathematics&#34;,&#34;Physics; Fluid- and Aerodynamics; Astrophysics and Astroparticles; Engineering Fluid Dynamics; Geophysics/Geodesy&#34;,&#34;Business and Management; Media Management; IT in Business; Marketing; e-Commerce/e-business; Human Resource Management&#34;,&#34;Criminology and Criminal Justice; Criminology and Criminal Justice, general&#34;,&#34;Business and Management; Supply Chain Management; Operations Management; IT in Business; Engineering Economics, Organization, Logistics, Marketing&#34;,&#34;Mathematics; Probability Theory and Stochastic Processes&#34;,&#34;Statistics; Statistics for Business/Economics/Mathematical Finance/Insurance; Quantitative Finance; Statistical Theory and Methods; Finance, general&#34;,&#34;Philosophy; Epistemology; Mathematical Logic and Formal Languages; Game Theory, Economics, Social and Behav. Sciences&#34;,&#34;Mathematics; Analysis&#34;,&#34;Materials Science; Nanotechnology; Nanoscale Science and Technology; Nanochemistry&#34;,&#34;Biomedicine; Biomedicine, general; Epidemiology; Public Health; Medicine/Public Health, general; Biometrics; Biostatistics&#34;,&#34;Business and Management; International Business&#34;,&#34;Mathematics; Partial Differential Equations; Theoretical, Mathematical and Computational Physics&#34;,&#34;Statistics; Statistical Theory and Methods; Statistics, general&#34;,&#34;Business and Management; Business Strategy/Leadership; Business and Management, general; Management&#34;,&#34;Physics; Numerical and Computational Physics, Simulation; Mathematical and Computational Engineering; Computational Mathematics and Numerical Analysis; Theoretical and Computational Chemistry&#34;,&#34;Computer Science; User Interfaces and Human Computer Interaction; Computer Graphics; Special Purpose and Application-Based Systems; Computer Appl. in Social and Behavioral Sciences&#34;,&#34;Education; Higher Education; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Printing and Publishing&#34;,&#34;Physics; Theoretical, Mathematical and Computational Physics; Mathematical Methods in Physics; Numerical and Computational Physics, Simulation; Applications of Mathematics&#34;,&#34;Criminology and Criminal Justice; Prison and Punishment; Psychotherapy and Counseling; Public Policy; Medicine/Public Health, general&#34;,&#34;Engineering; Engineering Thermodynamics, Heat and Mass Transfer; Thermodynamics; Industrial Chemistry/Chemical Engineering; Engineering Fluid Dynamics; Classical and Continuum Physics; Energy Systems&#34;,&#34;Education; Teaching and Teacher Education; Learning and Instruction; Assessment, Testing and Evaluation&#34;,&#34;Economics; Economic Theory/Quantitative Economics/Mathematical Methods; Statistics for Business/Economics/Mathematical Finance/Insurance; Quantitative Finance; Macroeconomics/Monetary Economics//Financial Economics; Econometrics; Game Theory, Economics, Social and Behav. Sciences&#34;,&#34;Biomedicine; Biomedicine, general; Chemistry/Food Science, general; Pharmacy; Medicine/Public Health, general; Computer Science, general; Life Sciences, general&#34;,&#34;Biomedicine; Biomedicine, general; Entomology; Pharmacy; Statistics for Life Sciences, Medicine, Health Sciences&#34;,&#34;Computer Science; Data Mining and Knowledge Discovery; Pattern Recognition; Big Data/Analytics; Visualization; Statistics and Computing/Statistics Programs&#34;,&#34;Computer Science; Data Mining and Knowledge Discovery; Big Data/Analytics; Computational Intelligence&#34;,&#34;Computer Science; Discrete Mathematics in Computer Science; Arithmetic and Logic Structures; Logics and Meanings of Programs; History of Computing; Mathematical Applications in Computer Science; Math Applications in Computer Science&#34;,&#34;Earth Sciences; Geology&#34;,&#34;Chemistry; Physical Chemistry; Crystallography and Scattering Methods; Protein Structure; Characterization and Evaluation of Materials; Geophysics/Geodesy&#34;,&#34;Statistics; Statistical Theory and Methods; Statistics for Business/Economics/Mathematical Finance/Insurance; Econometrics; Statistics for Engineering, Physics, Computer Science, Chemistry and Earth Sciences&#34;,&#34;Engineering; Communications Engineering, Networks; Signal, Image and Speech Processing; Input/Output and Data Communications&#34;,&#34;Medicine &amp; Public Health; Cardiology; Biomedical Engineering; Medical and Radiation Physics; Human Physiology&#34;,&#34;Mathematics; Differential Geometry&#34;,&#34;Law; European Law; Business Taxation/Tax Law; International Economic Law, Trade Law; Financial Law/Fiscal Law; European Integration&#34;,&#34;Biomedicine; Gene Function; Neurosciences; Behavioral Sciences; Neurology&#34;,&#34;Education; Curriculum Studies; Language Education; Learning and Instruction&#34;,&#34;Mathematics; Mathematics, general&#34;,&#34;Physics; Mathematical Methods in Physics; Statistics for Engineering, Physics, Computer Science, Chemistry and Earth Sciences; Statistics for Business/Economics/Mathematical Finance/Insurance; Mathematical and Computational Engineering; Complex Systems; Statistical Physics and Dynamical Systems&#34;,&#34;Computer Science; Logics and Meanings of Programs; Mathematical Logic and Formal Languages; Discrete Mathematics in Computer Science; Math Applications in Computer Science&#34;,&#34;Business and Management; Operations Research/Decision Theory; Operations Research, Management Science&#34;,&#34;Mathematics; Topological Groups, Lie Groups&#34;,&#34;Mathematics; Linear and Multilinear Algebras, Matrix Theory&#34;,&#34;Physics; Astrophysics and Astroparticles; Fluid- and Aerodynamics; Astronomy, Astrophysics and Cosmology; Nuclear Fusion&#34;,&#34;Medicine &amp; Public Health; Medicine/Public Health, general; Health Psychology; Anthropology; Evolutionary Biology&#34;,&#34;Computer Science; Data Structures, Cryptology and Information Theory; Programming Techniques; Communications Engineering, Networks; Circuits and Systems&#34;,&#34;Mathematics; Linear and Multilinear Algebras, Matrix Theory&#34;,&#34;Mathematics; Analysis&#34;,&#34;Business and Management; Operations Research/Decision Theory; Operations Research, Management Science; Optimization&#34;,&#34;Philosophy; Philosophy of Science; Epistemology; Science Education&#34;,&#34;Business and Management; Business Strategy/Leadership; Organization; Human Resource Development&#34;,&#34;Engineering; Circuits and Systems; Semiconductors; Electronics and Microelectronics, Instrumentation&#34;,&#34;Business and Management; Business Ethics; Public Administration; Business Strategy/Leadership&#34;,&#34;Mathematics; Ordinary Differential Equations&#34;,&#34;Business and Management; IT in Business; Operations Research/Decision Theory&#34;,&#34;Materials Science; Ceramics, Glass, Composites, Natural Materials; Inorganic Chemistry; Nanotechnology; Characterization and Evaluation of Materials; Optical and Electronic Materials&#34;,&#34;Chemistry; Analytical Chemistry; Monitoring/Environmental Analysis; Characterization and Evaluation of Materials; Biochemistry, general; Pharmacology/Toxicology&#34;,&#34;Engineering; Sustainable Development; Renewable and Green Energy; Sustainability Management&#34;,&#34;Psychology; Clinical Psychology; Psychiatry; Health Psychology&#34;,&#34;Physics; Numerical and Computational Physics, Simulation; Mathematical Applications in the Physical Sciences; Mathematical and Computational Engineering; Theoretical and Computational Chemistry&#34;,&#34;Social Sciences; Social Work; Public Health; Psychotherapy and Counseling; Social Policy&#34;,&#34;Biomedicine; Human Physiology; Cardiology; Biomedical Engineering; Angiology; Pathology; Cardiac Surgery&#34;,&#34;Physics; Quantum Physics; Quantum Field Theories, String Theory&#34;,&#34;Statistics; Statistics and Computing/Statistics Programs; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Statistics, general&#34;,&#34;Chemistry; Mass Spectrometry; Proteomics; Pharmacology/Toxicology; Monitoring/Environmental Analysis; Organic Chemistry; Forensic Science&#34;,&#34;Chemistry; Industrial Chemistry/Chemical Engineering; Theoretical and Computational Chemistry; Complex Systems; Engineering Thermodynamics, Heat and Mass Transfer; Statistical Physics and Dynamical Systems&#34;,&#34;Biomedicine; Human Physiology; Gastroenterology&#34;,&#34;Engineering; Engineering Design; Nanotechnology&#34;,&#34;Chemistry; Theoretical and Computational Chemistry; Inorganic Chemistry; Structural Materials&#34;,&#34;Statistics; Statistics for Life Sciences, Medicine, Health Sciences; Epidemiology&#34;,&#34;Physics; Quantum Physics; Philosophy of Science; History and Philosophical Foundations of Physics&#34;,&#34;Statistics; Statistical Theory and Methods; Statistics and Computing/Statistics Programs; Statistics, general&#34;,&#34;Physics; Numerical and Computational Physics, Simulation; Computer Applications in Chemistry; Particle and Nuclear Physics; Mathematical Applications in the Physical Sciences&#34;,&#34;Statistics; Statistical Theory and Methods; Probability Theory and Stochastic Processes; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Public Health; Psychological Methods/Evaluation; Methodology of the Social Sciences&#34;,&#34;Mathematics; Partial Differential Equations; Mathematical Methods in Physics; Community &amp; Population Ecology&#34;,&#34;Physics; Astronomy, Astrophysics and Cosmology; Classical and Quantum Gravitation, Relativity Theory; Classical Mechanics; Theoretical and Applied Mechanics&#34;,&#34;Engineering; Quality Control, Reliability, Safety and Risk; Atmospheric Protection/Air Quality Control/Air Pollution; Environmental Engineering/Biotechnology&#34;,&#34;Chemistry; Polymer Sciences; Organic Chemistry; Soft and Granular Matter, Complex Fluids and Microfluidics; Physical Chemistry&#34;,&#34;Business and Management; Operations Research/Decision Theory; Supply Chain Management; Procurement&#34;,&#34;Engineering; Robotics and Automation; Control, Robotics, Mechatronics; Machinery and Machine Elements&#34;,&#34;Economics; Econometrics; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Economic Theory/Quantitative Economics/Mathematical Methods; Game Theory, Economics, Social and Behav. Sciences&#34;,&#34;Earth Sciences; Oceanography; Sedimentology; Ecology; Geoecology/Natural Processes; Marine &amp; Freshwater Sciences&#34;,&#34;Biomedicine; Biomedicine, general; Computer Applications; Biometrics; Statistical Theory and Methods; Statistics and Computing/Statistics Programs&#34;,&#34;Statistics; Statistical Theory and Methods; Statistics for Life Sciences, Medicine, Health Sciences; Statistics and Computing/Statistics Programs&#34;,&#34;Law; European Law; International Relations; Sources and Subjects of International Law, International Organizations&#34;,&#34;Chemistry; Food Science; Industrial Chemistry/Chemical Engineering; Spectroscopy/Spectrometry&#34;,&#34;Physics; Acoustics; Neurobiology; Engineering Acoustics&#34;,&#34;Engineering; Light Construction, Steel Construction, Timber Construction; Building Construction and Design; Solid Construction; Structural Materials&#34;,&#34;Physics; Optics, Lasers, Photonics, Optical Devices; Microwaves, RF and Optical Engineering; Classical Electrodynamics&#34;,&#34;Statistics; Statistics for Business/Economics/Mathematical Finance/Insurance; Quantitative Finance; Risk Management; Business Finance&#34;,&#34;Social Sciences; Family; Psychology Research; Social Work&#34;,&#34;Physics; Condensed Matter Physics; Solid State Physics; Spectroscopy and Microscopy; Physical Chemistry; Engineering, general; Strongly Correlated Systems, Superconductivity&#34;,&#34;Chemistry; Electrochemistry; Spectroscopy/Spectrometry&#34;,&#34;Economics; Social Choice/Welfare Economics/Public Choice; Economic Theory/Quantitative Economics/Mathematical Methods; Public Economics; International Political Economy&#34;,&#34;Computer Science; Software Engineering; Computer Engineering; Software Management; Mathematical Software&#34;,&#34;Computer Science; Image Processing and Computer Vision; Computer Communication Networks; Information Storage and Retrieval; Database Management&#34;,&#34;Business and Management; Operations Management; Engineering Economics, Organization, Logistics, Marketing; Organization&#34;,&#34;Chemistry; Theoretical and Computational Chemistry; Crystallography and Scattering Methods; Inorganic Chemistry&#34;,&#34;Psychology; Personality and Social Psychology; Social Structure, Social Inequality; Anthropology&#34;,&#34;Mathematics; Probability Theory and Stochastic Processes; Statistics for Engineering, Physics, Computer Science, Chemistry and Earth Sciences; Mathematical and Computational Engineering&#34;,&#34;Mathematics; Analysis&#34;,&#34;Chemistry; Food Science; Agriculture; Analytical Chemistry; Biochemistry, general; Nutrition&#34;,&#34;Chemistry; Physical Chemistry; Thermodynamics; Spectroscopy/Spectrometry; Electrochemistry&#34;,&#34;Computer Science; Programming Languages, Compilers, Interpreters; Python; Computational Intelligence&#34;,&#34;Engineering; Circuits and Systems; Electronics and Microelectronics, Instrumentation; Electronic Circuits and Devices&#34;,&#34;Business and Management; Trade; Sales/Distribution; Marketing&#34;,&#34;Chemistry; Food Science; Industrial Chemistry/Chemical Engineering; Spectroscopy/Spectrometry&#34;,&#34;Psychology; Child and School Psychology; Assessment, Testing and Evaluation; Social Work; Psychological Methods/Evaluation&#34;,&#34;Biomedicine; Biomedicine, general; Medicine/Public Health, general; Statistics, general; Science, Humanities and Social Sciences, multidisciplinary&#34;,&#34;Psychology; Child and School Psychology; Assessment, Testing and Evaluation; Occupational Therapy; Family; Educational Psychology; Speech Pathology&#34;,&#34;Physics; Quantum Physics; Mathematical Methods in Physics; Theoretical, Mathematical and Computational Physics; Classical Mechanics; Elementary Particles, Quantum Field Theory&#34;,&#34;Computer Science; Data Mining and Knowledge Discovery&#34;,&#34;Biomedicine; Pharmaceutical Sciences/Technology; Biomedicine, general&#34;,&#34;Computer Science; Programming Languages, Compilers, Interpreters; Python&#34;,&#34;Engineering; Mechanical Engineering; Mathematical and Computational Engineering; Computer-Aided Engineering (CAD, CAE) and Design; Computational Science and Engineering&#34;,&#34;Physics; Condensed Matter Physics; Group Theory and Generalizations; Theoretical, Mathematical and Computational Physics; Mathematical Methods in Physics; Optical and Electronic Materials&#34;,&#34;Computer Science; Programming Techniques&#34;,&#34;Engineering; Circuits and Systems; Processor Architectures; Electronics and Microelectronics, Instrumentation&#34;,&#34;Physics; Mathematical Methods in Physics; Classical Mechanics; Numerical and Computational Physics, Simulation&#34;,&#34;Biomedicine; Human Physiology; Biomedical Engineering; Theoretical and Applied Mechanics; Biochemical Engineering&#34;,&#34;Economics; Econometrics; Statistics for Business/Economics/Mathematical Finance/Insurance; Mathematical and Computational Engineering&#34;,&#34;Computer Science; Data Mining and Knowledge Discovery; Probability and Statistics in Computer Science; Pattern Recognition; Statistics and Computing/Statistics Programs&#34;,&#34;Mathematics; Calculus&#34;,&#34;Engineering; Civil Engineering; Hydrogeology; Soil Science &amp; Conservation; Geotechnical Engineering &amp; Applied Earth Sciences&#34;,&#34;Economics; Game Theory; Game Theory, Economics, Social and Behav. Sciences; Operations Research/Decision Theory; Microeconomics&#34;,&#34;Statistics; Statistics for Life Sciences, Medicine, Health Sciences; Public Health; Epidemiology; Cancer Research; Oncology&#34;,&#34;Engineering; Engineering Fluid Dynamics; Computational Science and Engineering; Numerical and Computational Physics, Simulation; Fluid- and Aerodynamics&#34;,&#34;Medicine &amp; Public Health; Colorectal Surgery; General Surgery; Surgical Oncology&#34;,&#34;Statistics; Statistics for Life Sciences, Medicine, Health Sciences; Statistics and Computing/Statistics Programs; Statistics, general&#34;,&#34;Engineering; Circuits and Systems; Processor Architectures; Logic Design&#34;,&#34;Environment; Sustainable Development; Geoecology/Natural Processes; Social Sciences, general&#34;,&#34;Chemistry; Physical Chemistry; Thermodynamics&#34;,&#34;Physics; Semiconductors; Nanoscale Science and Technology; Electronics and Microelectronics, Instrumentation; Solid State Physics&#34;,&#34;Energy; Energy Harvesting; Nanotechnology and Microengineering; Renewable and Green Energy; Engineering Thermodynamics, Heat and Mass Transfer&#34;,&#34;Geography; Geographical Information Systems/Cartography; Programming Languages, Compilers, Interpreters; Information Systems Applications (incl.Internet); Earth Sciences, general&#34;,&#34;Engineering&#34;,&#34;Mathematics; Analysis&#34;,&#34;Psychology; Psychological Methods/Evaluation; Programming Techniques; Statistics and Computing/Statistics Programs; Psychometrics&#34;,&#34;Economics; Industrial Organization; Quality Control, Reliability, Safety and Risk; Accounting/Auditing; Operations Management&#34;,&#34;Chemistry; Food Science&#34;,&#34;Physics; Classical Mechanics&#34;,&#34;Mathematics; Probability Theory and Stochastic Processes; Measure and Integration; Dynamical Systems and Ergodic Theory; Functional Analysis; Complex Systems; Statistical Physics and Dynamical Systems&#34;,&#34;Computer Science; Database Management; Information Storage and Retrieval; Data Structures, Cryptology and Information Theory; Software Engineering/Programming and Operating Systems&#34;,&#34;Computer Science; Image Processing and Computer Vision; Signal, Image and Speech Processing; Computational Intelligence&#34;,&#34;Chemistry; Biochemical Engineering; Food Science; Engineering Thermodynamics, Heat and Mass Transfer; Mathematical Modeling and Industrial Mathematics&#34;,&#34;Physics; Spectroscopy and Microscopy; Surface and Interface Science, Thin Films; Solid State Physics; Characterization and Evaluation of Materials; Biological Microscopy&#34;,&#34;Computer Science; Information Storage and Retrieval; Data Storage Representation; Management of Computing and Information Systems; Computer Communication Networks&#34;,&#34;Law; Fundamentals of Law; Philosophy of Law&#34;,&#34;Physics; Quantum Physics; Quantum Optics; Optical and Electronic Materials; Nanoscale Science and Technology; Nanotechnology&#34;,&#34;Statistics; Statistics and Computing/Statistics Programs; Statistical Theory and Methods&#34;,&#34;Chemistry; Industrial Chemistry/Chemical Engineering; Physical Chemistry; Renewable and Green Energy; Characterization and Evaluation of Materials&#34;,&#34;Chemistry; Organic Chemistry; Physical Chemistry; Medicinal Chemistry&#34;,&#34;Chemistry; Organic Chemistry; Pharmacy; Medicinal Chemistry&#34;,&#34;Law; International Humanitarian Law, Law of Armed Conflict; Human Rights; Public Health; Natural Hazards; Anthropology&#34;,&#34;Medicine &amp; Public Health; Oncology; Imaging / Radiology; Surgery; Pathology; Human Genetics&#34;,&#34;Business and Management; Tourism Management; Marketing; Media and Communication&#34;,&#34;Business and Management; e-Business/e-Commerce; Business Information Systems; Operations Research/Decision Theory&#34;,&#34;Social Sciences; Social Work; Community and Environmental Psychology; Rehabilitation&#34;,&#34;Cultural and Media Studies; Popular Culture; Film and Television Studies; Medical Sociology; Medical Education&#34;,&#34;Business and Management; Market Research/Competitive Intelligence; Statistics for Business/Economics/Mathematical Finance/Insurance; Knowledge Management&#34;,&#34;Materials Science; Characterization and Evaluation of Materials; Spectroscopy and Microscopy; Biological Microscopy; Spectroscopy/Spectrometry; Measurement Science and Instrumentation&#34;,&#34;Geography; Geographical Information Systems/Cartography; Hydrogeology; Hydrology/Water Resources; Monitoring/Environmental Analysis; Regional/Spatial Science&#34;,&#34;Physics; Mathematical Methods in Physics; Mathematical Physics; Particle and Nuclear Physics; Topological Groups, Lie Groups&#34;,&#34;Philosophy; Bioethics; Medicine/Public Health, general; Medical Education&#34;,&#34;Computer Science; Programming Languages, Compilers, Interpreters; Control Structures and Microprogramming; Mathematical and Computational Engineering&#34;,&#34;Physics; Classical Electrodynamics; Atomic, Molecular, Optical and Plasma Physics; Microwaves, RF and Optical Engineering; Mathematical Applications in the Physical Sciences&#34;,&#34;Computer Science; Probability and Statistics in Computer Science; Statistics and Computing/Statistics Programs&#34;,&#34;Popular Science; Popular Science in Cultural and Media Studies; Film Theory; American Cinema; Film Production; Screenwriting&#34;,&#34;Social Sciences; Social Work; Social Policy; Public Policy&#34;,&#34;Physics; Quantum Physics; Elementary Particles, Quantum Field Theory; Mathematical Applications in the Physical Sciences; Classical Mechanics&#34;,&#34;Computer Science; Programming Techniques; Algorithm Analysis and Problem Complexity; Professional Computing; Algorithms; Computers and Education&#34;,&#34;Computer Science&#34;,&#34;Life Sciences; Bioinformatics; Evolutionary Biology; Computational Biology/Bioinformatics; Computer Appl. in Life Sciences&#34;,&#34;Social Sciences; Demography; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Methodology of the Social Sciences&#34;,&#34;Computer Science; Pattern Recognition; Mathematical Models of Cognitive Processes and Neural Networks; Coding and Information Theory&#34;,&#34;Energy; Energy Policy, Economics and Management; Sustainable Development; Environmental Economics; Energy Policy, Economics and Management; Data-driven Science, Modeling and Theory Building; Economic Geography&#34;,&#34;Biomedicine; Biomedical Engineering/Biotechnology; Biomedical Engineering; Systems Biology; Biomaterials; Biotechnology&#34;,&#34;Business and Management; Business Ethics; Administration, Organization and Leadership; Business Strategy/Leadership; Emerging Markets/Globalization&#34;,&#34;Engineering; Structural Materials; Mechanical Engineering&#34;,&#34;Computer Science; Computer Appl. in Administrative Data Processing; Business Process Management; Information Systems Applications (incl.Internet); Software Engineering&#34;,&#34;Psychology; Clinical Psychology; Family; General Practice / Family Medicine&#34;,&#34;Computer Science; Programming Techniques; Numeric Computing; Programming Languages, Compilers, Interpreters; Math Applications in Computer Science; Software Engineering&#34;,&#34;Psychology; Cognitive Psychology; General Psychology; Personality and Social Psychology&#34;,&#34;Criminology and Criminal Justice; Criminology and Criminal Justice, general; Geriatrics/Gerontology&#34;,&#34;Business and Management; Knowledge Management; Innovation/Technology Management; Organization; Industrial Organization&#34;,&#34;Social Sciences; Archaeology&#34;,&#34;Mathematics; Group Theory and Generalizations; Associative Rings and Algebras; Field Theory and Polynomials&#34;,&#34;Criminology and Criminal Justice; Criminology and Criminal Justice, general; Psychotherapy and Counseling&#34;,&#34;Philosophy; Critical Theory; African American Culture; Philosophy of Man; Social Philosophy; African Literature&#34;,&#34;Popular Science; Popular Science in Cultural and Media Studies; Media and Communication; Semiotics; Popular Culture; Cultural Anthropology; Sociolinguistics&#34;,&#34;Life Sciences; Bioinformatics; Computer Appl. in Life Sciences; Computational Biology/Bioinformatics; Computer Applications in Chemistry&#34;,&#34;Physics; Mathematical Methods in Physics; Linear and Multilinear Algebras, Matrix Theory; Mathematical and Computational Engineering; Geometry; Math Applications in Computer Science; Mathematical Applications in the Physical Sciences&#34;,&#34;Energy; Sustainable Architecture/Green Buildings; Mechanical Engineering; Energy Efficiency; Building Physics, HVAC; Building Construction and Design&#34;,&#34;Business and Management; Customer Relationship Management; Big Data/Analytics; Business Strategy/Leadership&#34;,&#34;Education; Research Skills; Thesis and Dissertation; Higher Education; Personal Development; Writing Skills&#34;,&#34;Business and Management; Human Resource Management; Organization; Business Strategy/Leadership&#34;,&#34;Mathematics; Linear and Multilinear Algebras, Matrix Theory; Mathematical Applications in the Physical Sciences&#34;,&#34;Literature; Contemporary Literature; Postcolonial/World Literature; Human Rights and Crime; Social Justice, Equality and Human Rights; Human Rights; Terrorism and Political Violence&#34;,&#34;Mathematics; Number Theory; Geometry; Analysis; Combinatorics; Graph Theory; Mathematics of Computing&#34;,&#34;Physics; Classical and Quantum Gravitation, Relativity Theory; Astronomy, Astrophysics and Cosmology&#34;,&#34;Physics; Astrophysics and Astroparticles; Particle and Nuclear Physics&#34;,&#34;Computer Science; Java; Programming Languages, Compilers, Interpreters; Programming Techniques&#34;,&#34;Engineering; Computational Intelligence; Industrial Chemistry/Chemical Engineering&#34;,&#34;Engineering; Control, Robotics, Mechatronics&#34;,&#34;Philosophy; Business Ethics; Business Ethics; Sociology of Work; Business Strategy/Leadership; Industrial and Organizational Psychology; Human Resource Development&#34;,&#34;Physics; Quantum Physics; Mathematical Methods in Physics; Quantum Field Theories, String Theory; Mathematical Applications in the Physical Sciences&#34;,&#34;Philosophy; Business Ethics; Political Philosophy; Social Philosophy; Moral Philosophy&#34;,&#34;Computer Science; Mathematical Logic and Formal Languages; Mathematical Logic and Foundations; Control, Robotics, Mechatronics; Quality Control, Reliability, Safety and Risk&#34;,&#34;Energy; Renewable and Green Energy; Energy Systems; Energy Policy, Economics and Management; Development and Sustainability&#34;,&#34;Business and Management; Media Management; Market Research/Competitive Intelligence; Popular Science in Business and Management; Big Data/Analytics&#34;,&#34;Physics; Classical Mechanics; Mathematical Methods in Physics; Numerical and Computational Physics, Simulation; Atmospheric Sciences; Fluid- and Aerodynamics&#34;,&#34;Engineering; Electronics and Microelectronics, Instrumentation; Optical and Electronic Materials; Solid State Physics; Spectroscopy and Microscopy; Nanotechnology&#34;,&#34;Engineering; Electrical Engineering; Logic Design; Algorithms&#34;,&#34;Computer Science; Information Systems and Communication Service; Processor Architectures&#34;,&#34;Computer Science; Programming Techniques; Programming Languages, Compilers, Interpreters; Data Structures; Operating Systems&#34;,&#34;Business and Management; Business Finance; Risk Management; Quantitative Finance; Financial Engineering; Financial Accounting&#34;,&#34;Criminology and Criminal Justice; White Collar Crime&#34;,&#34;Education; Language Education; Applied Linguistics; English&#34;,&#34;Business and Management; Marketing; Management; Statistics for Business/Economics/Mathematical Finance/Insurance&#34;,&#34;Business and Management; Operations Management; Operations Research/Decision Theory&#34;,&#34;Computer Science; Programming Techniques; Processor Architectures; Control Structures and Microprogramming; Numeric Computing&#34;,&#34;Philosophy; Philosophy of Mathematics; Mathematical Logic and Foundations; Arithmetic and Logic Structures; Logic; Applications of Mathematics&#34;,&#34;Engineering; Control; Systems Theory, Control; Ordinary Differential Equations; Engineering Mathematics&#34;,&#34;Philosophy; Analytic Philosophy; Mathematical Logic and Formal Languages; Mathematical Logic and Foundations; Theoretical, Mathematical and Computational Physics; Moral Philosophy&#34;,&#34;Computer Science; Math Applications in Computer Science; Computational Mathematics and Numerical Analysis; Mathematical and Computational Engineering; Discrete Mathematics in Computer Science&#34;,&#34;Business and Management; Cross-Cultural Management; Business Strategy/Leadership; Human Resource Management; Business Information Systems&#34;,&#34;Cultural and Media Studies; Digital/New Media; Digital Humanities; Research Methodology; Media Research; Culture and Technology&#34;,&#34;Computer Science; Security; Forensic Science; Cybercrime; Multimedia Information Systems&#34;,&#34;Engineering; Control; Systems Theory, Control; Computer Applications&#34;,&#34;Engineering; Control; Systems Theory, Control; Computer Applications&#34;,&#34;Life Sciences; Enzymology; Protein-Ligand Interactions; Biomedical Engineering/Biotechnology; Applied Microbiology; Protein Structure&#34;,&#34;Engineering; Control; Systems Theory, Control; Power Electronics, Electrical Machines and Networks; Industrial and Production Engineering&#34;,&#34;Engineering; Communications Engineering, Networks; Electronics and Microelectronics, Instrumentation; Information Systems Applications (incl.Internet); User Interfaces and Human Computer Interaction&#34;,&#34;Social Sciences; Methodology of the Social Sciences; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Statistics and Computing/Statistics Programs&#34;,&#34;Mathematics; Number Theory&#34;,&#34;Philosophy; Epistemology; Mathematical Logic and Formal Languages; Mathematical Logic and Foundations&#34;,&#34;Engineering; Civil Engineering&#34;,&#34;Life Sciences; Plant Physiology; Plant Anatomy/Development; Plant Ecology; Plant Breeding/Biotechnology; Plant Genetics and Genomics&#34;,&#34;Physics; Quantum Physics; Quantum Field Theories, String Theory; Mathematical Applications in the Physical Sciences; Quantum Information Technology, Spintronics; Mathematical Methods in Physics&#34;,&#34;Physics; Quantum Physics; Quantum Field Theories, String Theory; Mathematical Applications in the Physical Sciences; Quantum Information Technology, Spintronics&#34;,&#34;Business and Management; Operations Research/Decision Theory; Probability Theory and Stochastic Processes; Statistics for Business/Economics/Mathematical Finance/Insurance; Organization; Business Mathematics; IT in Business&#34;,&#34;Engineering; Circuits and Systems; Processor Architectures; Logic Design&#34;,&#34;Cultural and Media Studies; Media and Communication; Media Management; Culture and Technology; Cultural Management; Management&#34;,&#34;Cultural and Media Studies; Media and Communication; Media Management; Business Information Systems&#34;,&#34;Popular Science; Popular Science in Literature; British and Irish Literature; Early Modern/Renaissance Literature; Eighteenth-Century Literature; History of Britain and Ireland; Nineteenth-Century Literature&#34;,&#34;Engineering; Aerospace Technology and Astronautics; Space Sciences (including Extraterrestrial Physics, Space Exploration and Astronautics); Classical Mechanics; Classical and Quantum Gravitation, Relativity Theory&#34;,&#34;Psychology; Cognitive Psychology; Neuropsychology; Neurosciences; Audio-Visual Culture&#34;,&#34;Education; Research Methods in Education; Social Justice, Equality and Human Rights; Social Work; Teaching and Teacher Education&#34;,&#34;Education; Educational Technology; Computers and Education&#34;,&#34;Engineering; Circuits and Systems; Processor Architectures; Logic Design&#34;,&#34;Medicine &amp; Public Health; Neurosurgery; Surgical Orthopedics&#34;,&#34;Engineering; Circuits and Systems; Processor Architectures; Logic Design&#34;,&#34;Social Sciences; Social Work; Social Justice, Equality and Human Rights; Political Philosophy; Children, Youth and Family Policy&#34;,&#34;Education; Administration, Organization and Leadership; Educational Policy and Politics; Schools and Schooling&#34;,&#34;Business and Management; e-Business/e-Commerce; e-Commerce/e-business; Organization; Innovation/Technology Management; Entrepreneurship&#34;,&#34;Engineering; Circuits and Systems; Processor Architectures; Logic Design&#34;,&#34;Cultural and Media Studies; Theatre History; Performing Arts; Global/International Theatre and Performance&#34;,&#34;Business and Management; Consumer Behavior; Market Research/Competitive Intelligence; Management Education&#34;,&#34;Social Sciences; Methodology of the Social Sciences; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Research Methods in Education; Statistics and Computing/Statistics Programs; Statistics for Life Sciences, Medicine, Health Sciences; Statistics for Business/Economics/Mathematical Finance/Insurance&#34;,&#34;Social Sciences; Archaeology&#34;,&#34;Psychology; Health Psychology; Public Health; Psychiatry; Social Work&#34;,&#34;Psychology; Personality and Social Psychology; Applied Psychology; Psychological Methods/Evaluation&#34;,&#34;Education; Research Methods in Education; Methodology of the Social Sciences; Statistics for Social Science, Behavorial Science, Education, Public Policy, and Law; Assessment, Testing and Evaluation; Psychometrics; Research Skills&#34;,&#34;Engineering; Computational Intelligence; Big Data; Multimedia Information Systems; Information Systems Applications (incl.Internet)&#34;,&#34;Criminology and Criminal Justice; Policing; Ethnicity, Class, Gender and Crime&#34;,&#34;Life Sciences; Food Microbiology; Food Science; Criminal Law; Medicine/Public Health, general&#34;,&#34;Life Sciences; Plant Ecology; Plant Physiology; Plant Biochemistry; Plant Genetics and Genomics; Climate Change&#34;]],&#34;container&#34;:&#34;&lt;table class=\&#34;display\&#34;&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th&gt;book_title&lt;\/th&gt;\n      &lt;th&gt;author&lt;\/th&gt;\n      &lt;th&gt;edition&lt;\/th&gt;\n      &lt;th&gt;open_url&lt;\/th&gt;\n      &lt;th&gt;subject_classification&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n&lt;\/table&gt;&#34;,&#34;options&#34;:{&#34;autoWidth&#34;:true,&#34;dom&#34;:&#34;Blfrtip&#34;,&#34;buttons&#34;:[&#34;copy&#34;,&#34;csv&#34;,&#34;excel&#34;,&#34;pdf&#34;,&#34;print&#34;],&#34;pageLength&#34;:5,&#34;order&#34;:[0,&#34;asc&#34;],&#34;columnDefs&#34;:[],&#34;orderClasses&#34;:false,&#34;orderCellsTop&#34;:true,&#34;lengthMenu&#34;:[5,10,25,50,100]}},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;This table allows you to see which textbooks Springer offers (together with some information) and allows you to find the ones that you are most likely to be interested in.&lt;/p&gt;
&lt;p&gt;Note that you can create a similar table for German books with the &lt;code&gt;download_springer_table(lan = &#34;ger&#34;)&lt;/code&gt; function.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;download-only-specific-books&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Download only specific books&lt;/h1&gt;
&lt;p&gt;Now that you have a better idea about the books you are interested in, you can download them by their title, author or subject.&lt;/p&gt;
&lt;div id=&#34;by-title&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;By title&lt;/h2&gt;
&lt;p&gt;Say that you are interested in downloading only one specific book and you know its title. For instance, suppose you want to download the book entitled “All of Statistics”:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;download_springer_book_files(springer_books_titles = &amp;quot;All of Statistics&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are interested to download more than one book, run the following command:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;download_springer_book_files(
  springer_books_titles = c(
    &amp;quot;All of Statistics&amp;quot;,
    &amp;quot;A Modern Introduction to Probability and Statistics&amp;quot;
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, if you do not have a specific title in mind but you are interested in downloading all books with the word “Statistics” in the title, you can run:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;springer_table &amp;lt;- download_springer_table()

library(dplyr)
specific_titles_list &amp;lt;- springer_table %&amp;gt;%
  filter(str_detect(
    book_title, # look for a pattern in the book_title column
    &amp;quot;Statistics&amp;quot; # specify the word
  )) %&amp;gt;%
  pull(book_title)

download_springer_book_files(springer_books_titles = specific_titles_list)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; If you would like to download all books with the word “Statistics” or “Data Science” in the title, replace &lt;code&gt;&#34;Statistics&#34;&lt;/code&gt; in the above code by &lt;code&gt;&#34;Statistics|Data Science&#34;&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;by-author&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;By author&lt;/h2&gt;
&lt;p&gt;If you want to download all books from a specific author, you can run:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;springer_table &amp;lt;- download_springer_table()

# library(dplyr)
specific_titles_list &amp;lt;- springer_table %&amp;gt;%
  filter(str_detect(
    author, # look for a pattern in the author column
    &amp;quot;John Hunt&amp;quot; # specify the author
  )) %&amp;gt;%
  pull(book_title)

download_springer_book_files(springer_books_titles = specific_titles_list)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;by-subject&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;By subject&lt;/h2&gt;
&lt;p&gt;You can also download all textbooks covering a specific subject (see all subjects in the &lt;code&gt;subject_classification&lt;/code&gt; column in the summary table). For instance, here is how to download all books categorized in the &lt;code&gt;Statistics&lt;/code&gt; subject:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;springer_table &amp;lt;- download_springer_table()

# library(dplyr)
specific_titles_list &amp;lt;- springer_table %&amp;gt;%
  filter(str_detect(
    subject_classification, # look for a pattern in the subject_classification column
    &amp;quot;Statistics&amp;quot; # specify the subject
  )) %&amp;gt;%
  pull(book_title)

download_springer_book_files(springer_books_titles = specific_titles_list)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;improvements&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Improvements&lt;/h1&gt;
&lt;p&gt;Below a list of features that can potentially be implemented in order to improve the package:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add the possibility to download all editions of a book. Currently, only the latest edition can be downloaded.&lt;/li&gt;
&lt;li&gt;Add the possibility to resume downloading if it stopped. Currently, if the code is executed again, the downloads start from scratch.&lt;/li&gt;
&lt;li&gt;Add the possibility of downloading books by topic. Currently, it is only possible by &lt;a href=&#34;https://statsandr.com/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/#by-title&#34;&gt;title&lt;/a&gt;, &lt;a href=&#34;https://statsandr.com/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/#by-author&#34;&gt;author&lt;/a&gt; or &lt;a href=&#34;https://statsandr.com/blog/a-package-to-download-free-springer-books-during-covid-19-quarantine/#by-subject&#34;&gt;subject&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Feel free to open a pull request on GitHub if you have another improvement in mind.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;acknowledgments&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Acknowledgments&lt;/h1&gt;
&lt;p&gt;I would like to thank:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Renan Xavier Cortes (and all contributors) for providing this package&lt;/li&gt;
&lt;li&gt;The &lt;a href=&#34;https://github.com/alexgand/springer_free_books&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;springer_free_books&lt;/code&gt;&lt;/a&gt; Python project which was used as inspiration to the &lt;code&gt;{springerQuarantineBooksR}&lt;/code&gt; package&lt;/li&gt;
&lt;li&gt;And last but not least, Springer who offers many of their excellent books for free!&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 this article will help you to download and read more high quality materials made available by Springer during this Covid-19 quarantine.&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;Note that I am not the author nor the maintainer of this shared folder. Therefore, I do not know how long the books will be available through this link, and I am not responsible if some (or all) books are removed.&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;Note that you can change the folder name by specifying the argument &lt;code&gt;destination_folder = &#34;name_of_your_choice&#34;&lt;/code&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>COVID-19 in Belgium</title>
      <link>https://statsandr.com/blog/covid-19-in-belgium/</link>
      <pubDate>Tue, 31 Mar 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/covid-19-in-belgium/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#top-r-resources-on-coronavirus&#34;&gt;Top R resources on Coronavirus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-dashboard-for-your-own-country&#34;&gt;Coronavirus dashboard for your own country&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#motivations-limitations-and-structure-of-the-article&#34;&gt;Motivations, limitations and structure of the article&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#analysis-of-coronavirus-in-belgium&#34;&gt;Analysis of Coronavirus in Belgium&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#a-classic-epidemiological-model-the-sir-model&#34;&gt;A classic epidemiological model: the &lt;em&gt;SIR&lt;/em&gt; model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#fitting-a-sir-model-to-the-belgium-data&#34;&gt;Fitting a &lt;em&gt;SIR&lt;/em&gt; model to the Belgium data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#reproduction-number-r_0&#34;&gt;Reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#using-our-model-to-analyze-the-outbreak-if-there-was-no-intervention&#34;&gt;Using our model to analyze the outbreak if there was no intervention&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#more-summary-statistics&#34;&gt;More summary statistics&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#additional-considerations&#34;&gt;Additional considerations&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#ascertainment-rates&#34;&gt;Ascertainment rates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#more-sophisticated-models&#34;&gt;More sophisticated models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#modelling-the-epidemic-trajectory-using-log-linear-models&#34;&gt;Modelling the epidemic trajectory using log-linear models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#estimating-changes-in-the-effective-reproduction-number-r_e&#34;&gt;Estimating changes in the effective reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_e\)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#more-sophisticated-projections&#34;&gt;More sophisticated projections&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-31-covid-19-in-belgium_files/Covid-19%20in%20Belgium.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;The Novel COVID-19 Coronavirus is still spreading quickly in several countries and it does not seem like it is going to stop anytime soon as the peak has not yet been reached in many countries.&lt;/p&gt;
&lt;p&gt;Since the beginning of its expansion, a large number of scientists across the world have been analyzing this Coronavirus from different perspectives and with different technologies with the hope of coming up with a cure in order to stop its expansion and limit its impact on citizens.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;top-r-resources-on-coronavirus&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Top R resources on Coronavirus&lt;/h1&gt;
&lt;p&gt;In the meantime, epidemiologists, statisticians and data scientists are working towards a better understanding of the spread of the virus in order to help governments and health agencies in taking the most optimal decisions. This led to the publication of a great deal of online resources about the virus, which I collected and organized in an article covering the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;top R resources on Coronavirus&lt;/a&gt;. This article is a collection of the best resources I’ve had the chance to discover, with a brief summary for each of them. It includes Shiny apps, dashboards, R packages, blog posts and datasets.&lt;/p&gt;
&lt;p&gt;Publishing this collection led many readers to submit their piece of work, which made the article even more complete and more insightful for anyone interested in analyzing the virus from a quantitative perspective. Thanks to everyone who contributed and who helped me in collecting and summarizing these R resources about COVID-19!&lt;/p&gt;
&lt;p&gt;Given my field of expertise, I am not able to help in this fight against the virus from a medical point of view. However, I still wanted to contribute as much as I could. From understanding better the disease to bringing scientists and doctors together to build something bigger and more impactful, I truly hope that this collection will, to a small extent, help to fight the pandemic.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus-dashboard-for-your-own-country&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Coronavirus dashboard for your own country&lt;/h1&gt;
&lt;p&gt;Besides receiving analyses, blog posts, R code and Shiny apps from people across the world, I realized that many people were trying to create a dashboard tracking the spread of the Coronavirus for their own country. So in addition to the collection of top R resources, I also published an article detailing the steps to follow to create a dashboard specific to a country. See how to create such dashboard in this &lt;a href=&#34;https://statsandr.com/blog/how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r/&#34;&gt;article&lt;/a&gt; and an &lt;a href=&#34;https://www.antoinesoetewey.com/files/coronavirus-dashboard.html&#34; target=&#34;_blank&#34;&gt;example with Belgium&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The code has been made available on GitHub and is open source so everyone can copy it and adapt it to their own country. The dashboard was intentionally kept simple so anyone with a minimum knowledge in R could easily replicate it, and advanced users could enhance it according to their needs.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;motivations-limitations-and-structure-of-the-article&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Motivations, limitations and structure of the article&lt;/h1&gt;
&lt;p&gt;By seeing and organizing many &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;R resources about COVID-19&lt;/a&gt;, I am fortunate enough to have read a lot of excellent analyses on the disease outbreak, the impact of different health measures, forecasts of the number of cases, projections about the length of the pandemic, hospitals capacity, etc.&lt;/p&gt;
&lt;p&gt;Furthermore, I must admit that some countries such as China, South Korea, Italy, Spain, UK and Germany received a lot of attention as shown by the number of analyses done on these countries. However, to my knowledge and at the date of publication of this article, I am not aware of any analysis of the spread of the Coronavirus specifically for Belgium.&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; The present article aims at filling that gap.&lt;/p&gt;
&lt;p&gt;Throughout my PhD thesis in statistics, my main research interest is about survival analysis applied to cancer patients (more information in the research section of my &lt;a href=&#34;https://www.antoinesoetewey.com/research/&#34; target=&#34;_blank&#34;&gt;personal website&lt;/a&gt;). I am not an epidemiologist and I have no extensive knowledge in modelling disease outbreaks via epidemiological models.&lt;/p&gt;
&lt;p&gt;I usually write articles only about things I consider myself familiar with, mainly &lt;a href=&#34;https://statsandr.com/tags/statistics/&#34;&gt;statistics&lt;/a&gt; and its applications in &lt;a href=&#34;https://statsandr.com/tags/r/&#34;&gt;R&lt;/a&gt;. At the time of writing this article, I was however curious where Belgium stands regarding the spread of this virus, I wanted to play with this kind of data in R (which is new to me) and see what comes out.&lt;/p&gt;
&lt;p&gt;In order to satisfy my curiosity while not being an expert, in this article I am going to replicate analyses done by more knowledgeable people and apply them to my country, that is, Belgium. From all the analyses I have read so far, I decided to replicate the analyses done by Tim Churches and Prof. Dr. Holger K. von Jouanne-Diedrich. This article is based on a mix of their articles which can be found &lt;a href=&#34;https://timchurches.github.io/blog/posts/2020-02-18-analysing-covid-19-2019-ncov-outbreak-data-with-r-part-1/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;https://blog.ephorie.de/epidemiology-how-contagious-is-novel-coronavirus-2019-ncov&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;. They both present a very informative analysis on how to model the outbreak of the Coronavirus and show how contagious it is. Their articles also allowed me to gain an understanding of the topic and in particular an understanding of the most common epidemiological model. I strongly advise interested readers to also read their &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#analyzing-covid-19-outbreak-data-with-r&#34;&gt;more recent articles&lt;/a&gt; for more advanced analyses and for an even deeper understanding of the spread of the COVID-19 pandemic.&lt;/p&gt;
&lt;p&gt;Other more &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium/#additional-considerations&#34;&gt;complex analyses&lt;/a&gt; are possible and even preferable, but I leave this to experts in this field. Note also that the following analyses take into account only the data until the date of publication of this article, so the results should not be viewed, by default, as current findings.&lt;/p&gt;
&lt;p&gt;In the remaining of the article, we first introduce the model which will be used to analyze the Coronavirus outbreak in Belgium. We also briefly discuss and show how to compute an important epidemiological measure, the reproduction number. We then use our model to analyze the outbreak of the disease in the case where there would be no public health intervention. We conclude the article by summarizing more advanced tools and techniques that could be used to further model COVID-19 in Belgium.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;analysis-of-coronavirus-in-belgium&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Analysis of Coronavirus in Belgium&lt;/h1&gt;
&lt;div id=&#34;a-classic-epidemiological-model-the-sir-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;A classic epidemiological model: the &lt;em&gt;SIR&lt;/em&gt; model&lt;/h2&gt;
&lt;p&gt;Before diving into the real-life application, we first introduce the model that will be used.&lt;/p&gt;
&lt;p&gt;There are many epidemiological models but we will use one of the most common one, the &lt;strong&gt;&lt;em&gt;SIR&lt;/em&gt; model&lt;/strong&gt;. The &lt;em&gt;SIR&lt;/em&gt; model can be complexified to incorporate more specificities of the virus outbreak, but in this article we keep its simplest version. Tim Churches’ explanation of this model and how to fit it using R is so nice, I will reproduce it here with a few minor changes.&lt;/p&gt;
&lt;p&gt;The basic idea behind the &lt;em&gt;SIR&lt;/em&gt; model (&lt;strong&gt;S&lt;/strong&gt;usceptible - &lt;strong&gt;I&lt;/strong&gt;nfectious - &lt;strong&gt;R&lt;/strong&gt;ecovered) of communicable disease outbreaks is that there are three groups (also called compartments) of individuals:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;S&lt;/em&gt;: those who are healthy but susceptible to the disease (i.e., at risk of being contaminated). At the start of the pandemic, &lt;em&gt;S&lt;/em&gt; is the entire population since no one is immune to the virus.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;I&lt;/em&gt;: the infectious (and thus, infected) people&lt;/li&gt;
&lt;li&gt;&lt;em&gt;R&lt;/em&gt;: individuals who were contaminated but who have either recovered or died. They are not infectious anymore.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These groups evolve over time as the virus progresses in the population:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;S&lt;/em&gt; decreases when individuals are contaminated and move to the infectious group &lt;em&gt;I&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;As people recover or die, they go from the infected group &lt;em&gt;I&lt;/em&gt; to the recovered group &lt;em&gt;R&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To model the dynamics of the outbreak we need three differential equations to describe the rates of change in each group, parameterised by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt;, the infection rate, which controls the transition between &lt;em&gt;S&lt;/em&gt; and &lt;em&gt;I&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt;, the removal or recovery rate, which controls the transition between &lt;em&gt;I&lt;/em&gt; and &lt;em&gt;R&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Formally, this gives:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\frac{dS}{dt} = - \frac{\beta IS}{N} \text{ (Eq. 1)}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\frac{dI}{dt} = \frac{\beta IS}{N} - \gamma I \text{ (Eq. 2)}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\frac{dR}{dt} = \gamma I \text{ (Eq. 3)}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The first equation (Eq. 1) states that the number of susceptible individuals (&lt;em&gt;S&lt;/em&gt;) decreases with the number of newly infected individuals, where new infected cases are the result of the infection rate (&lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt;) multiplied by the number of susceptible individuals (&lt;em&gt;S&lt;/em&gt;) who had a contact with infectious individuals (&lt;em&gt;I&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;The second equation (Eq. 2) states that the number of infectious individuals (&lt;em&gt;I&lt;/em&gt;) increases with the newly infected individuals (&lt;span class=&#34;math inline&#34;&gt;\(\beta I S\)&lt;/span&gt;), minus the previously infected people who recovered (i.e., &lt;span class=&#34;math inline&#34;&gt;\(\gamma I\)&lt;/span&gt; which is the removal rate &lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt; multiplied by the infectious individuals &lt;em&gt;I&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;Finally, the last equation (Eq. 3) states that the recovered group (&lt;em&gt;R&lt;/em&gt;) increases with the number of individuals who were infectious and who either recovered or died (&lt;span class=&#34;math inline&#34;&gt;\(\gamma I\)&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;An epidemic develops as follows:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Before the start of the disease outbreak, &lt;em&gt;S&lt;/em&gt; equals the entire population as no one has anti-bodies.&lt;/li&gt;
&lt;li&gt;At the beginning of the outbreak, as soon as the first individual is infected, &lt;em&gt;S&lt;/em&gt; decreases by 1 and &lt;em&gt;I&lt;/em&gt; increases by 1 as well.&lt;/li&gt;
&lt;li&gt;This first infectious individual contaminates (before recovering or dying) other individuals who were susceptible.&lt;/li&gt;
&lt;li&gt;The dynamic continues, with recently contaminated individuals who in turn infect other susceptible people before they recover.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Visually, we have:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-03-31-covid-19-in-belgium_files/SIR-model-covid-19-belgium.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;SIR model. Source: Kai Sasaki.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Before fitting the &lt;em&gt;SIR&lt;/em&gt; model to the data, the first step is to express these differential equations as an R function, with respect to time &lt;em&gt;t&lt;/em&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;SIR &amp;lt;- function(time, state, parameters) {
  par &amp;lt;- as.list(c(state, parameters))
  with(par, {
    dS &amp;lt;- -beta * I * S / N
    dI &amp;lt;- beta * I * S / N - gamma * I
    dR &amp;lt;- gamma * I
    list(c(dS, dI, dR))
  })
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;fitting-a-sir-model-to-the-belgium-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Fitting a &lt;em&gt;SIR&lt;/em&gt; model to the Belgium data&lt;/h2&gt;
&lt;p&gt;To fit the model to the data we need two things:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;a solver for these differential equations&lt;/li&gt;
&lt;li&gt;an optimiser to find the optimal values for our two unknown parameters, &lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The function &lt;code&gt;ode()&lt;/code&gt; (for ordinary differential equations) from the &lt;code&gt;{deSolve}&lt;/code&gt; R package makes solving the system of equations easy, and to find the optimal values for the parameters we wish to estimate, we can just use the &lt;code&gt;optim()&lt;/code&gt; function built into base R.&lt;/p&gt;
&lt;p&gt;Specifically, what we need to do is minimise the sum of the squared differences between &lt;span class=&#34;math inline&#34;&gt;\(I(t)\)&lt;/span&gt;, which is the number of people in the infectious compartment &lt;span class=&#34;math inline&#34;&gt;\(I\)&lt;/span&gt; at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, and the corresponding number of cases as predicted by our model &lt;span class=&#34;math inline&#34;&gt;\(\hat{I}(t)\)&lt;/span&gt;. This quantity is known as the residual sum of squares (&lt;em&gt;RSS&lt;/em&gt;):&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[RSS(\beta, \gamma) = \sum_t \big(I(t) - \hat{I}(t) \big)^2\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In order to fit a model to the incidence data for Belgium, we need a value &lt;em&gt;N&lt;/em&gt; for the initial uninfected population. The population of Belgium in November 2019 was 11,515,793 people, according to &lt;a href=&#34;https://en.wikipedia.org/wiki/Belgium&#34; target=&#34;_blank&#34;&gt;Wikipedia&lt;/a&gt;. We will thus use &lt;em&gt;N = 11515793&lt;/em&gt; as the initial uninfected population.&lt;/p&gt;
&lt;p&gt;Next, we need to create a vector with the daily cumulative incidence for Belgium, from February 4 (when our daily incidence data starts), through to March 30 (last available date at the time of publication of this article). We will then compare the predicted incidence from the &lt;em&gt;SIR&lt;/em&gt; model fitted to these data with the actual incidence since February 4. We also need to initialise the values for &lt;em&gt;N&lt;/em&gt;, &lt;em&gt;S&lt;/em&gt;, &lt;em&gt;I&lt;/em&gt; and &lt;em&gt;R&lt;/em&gt;. Note that the daily cumulative incidence for Belgium is extracted from the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#coronavirus&#34;&gt;&lt;code&gt;{coronavirus}&lt;/code&gt; R package&lt;/a&gt; developed by Rami Krispin.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# devtools::install_github(&amp;quot;RamiKrispin/coronavirus&amp;quot;)
library(coronavirus)
data(coronavirus)

`%&amp;gt;%` &amp;lt;- magrittr::`%&amp;gt;%`

# extract the cumulative incidence
df &amp;lt;- coronavirus %&amp;gt;%
  dplyr::filter(country == &amp;quot;Belgium&amp;quot;) %&amp;gt;%
  dplyr::group_by(date, type) %&amp;gt;%
  dplyr::summarise(total = sum(cases, na.rm = TRUE)) %&amp;gt;%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %&amp;gt;%
  dplyr::arrange(date) %&amp;gt;%
  dplyr::ungroup() %&amp;gt;%
  dplyr::mutate(active = confirmed - death - recovered) %&amp;gt;%
  dplyr::mutate(
    confirmed_cum = cumsum(confirmed),
    death_cum = cumsum(death),
    recovered_cum = cumsum(recovered),
    active_cum = cumsum(active)
  )

# put the daily cumulative incidence numbers for Belgium from
# Feb 4 to March 30 into a vector called Infected
library(lubridate)

sir_start_date &amp;lt;- &amp;quot;2020-02-04&amp;quot;
sir_end_date &amp;lt;- &amp;quot;2020-03-30&amp;quot;

Infected &amp;lt;- subset(df, date &amp;gt;= ymd(sir_start_date) &amp;amp; date &amp;lt;= ymd(sir_end_date))$active_cum

# Create an incrementing Day vector the same length as our
# cases vector
Day &amp;lt;- 1:(length(Infected))

# now specify initial values for N, S, I and R
N &amp;lt;- 11515793
init &amp;lt;- c(
  S = N - Infected[1],
  I = Infected[1],
  R = 0
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Note that what is needed are currently infected persons (cumulative infected minus the removed, i.e. recovered or dead). However, numbers of recovered persons are hard to obtain and probably underestimated due to underreporting bias. I thus consider the &lt;strong&gt;cumulative&lt;/strong&gt; number of infected people, which is probably not an issue here since the number of recovered cases is negligible at the time of the analysis.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Then we need to define a function to calculate the &lt;em&gt;RSS&lt;/em&gt;, given a set of values for &lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# define a function to calculate the residual sum of squares
# (RSS), passing in parameters beta and gamma that are to be
# optimised for the best fit to the incidence data
RSS &amp;lt;- function(parameters) {
  names(parameters) &amp;lt;- c(&amp;quot;beta&amp;quot;, &amp;quot;gamma&amp;quot;)
  out &amp;lt;- ode(y = init, times = Day, func = SIR, parms = parameters)
  fit &amp;lt;- out[, 3]
  sum((Infected - fit)^2)
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we can fit the &lt;em&gt;SIR&lt;/em&gt; model to our data by finding the values for &lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt; that minimise the residual sum of squares between the observed cumulative incidence (observed in Belgium) and the predicted cumulative incidence (predicted by our model). We also need to check that our model has converged, as indicated by the message shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# now find the values of beta and gamma that give the
# smallest RSS, which represents the best fit to the data.
# Start with values of 0.5 for each, and constrain them to
# the interval 0 to 1.0

# install.packages(&amp;quot;deSolve&amp;quot;)
library(deSolve)

Opt &amp;lt;- optim(c(0.5, 0.5),
  RSS,
  method = &amp;quot;L-BFGS-B&amp;quot;,
  lower = c(0, 0),
  upper = c(1, 1)
)

# check for convergence
Opt$message&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;CONVERGENCE: REL_REDUCTION_OF_F &amp;lt;= FACTR*EPSMCH&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Convergence is confirmed. Note that you may find different estimates for different choices of initial values or constraints. This proves that the fitting process is not stable. Here is a potential &lt;a href=&#34;http://blog.ephorie.de/contagiousness-of-covid-19-part-i-improvements-of-mathematical-fitting-guest-post&#34; target=&#34;_blank&#34;&gt;solution&lt;/a&gt; for a better fitting process.&lt;/p&gt;
&lt;p&gt;Now we can examine the fitted values for &lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Opt_par &amp;lt;- setNames(Opt$par, c(&amp;quot;beta&amp;quot;, &amp;quot;gamma&amp;quot;))
Opt_par&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      beta     gamma 
## 0.5841185 0.4158816&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember that &lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt; controls the transition between &lt;em&gt;S&lt;/em&gt; and &lt;em&gt;I&lt;/em&gt; (i.e., susceptible and infectious) and &lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt; controls the transition between &lt;em&gt;I&lt;/em&gt; and &lt;em&gt;R&lt;/em&gt; (i.e., infectious and recovered). However, those values do not mean a lot but we use them to get the fitted numbers of people in each compartment of our &lt;em&gt;SIR&lt;/em&gt; model for the dates up to March 30 that were used to fit the model, and compare those fitted values with the observed (real) data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# time in days for predictions
t &amp;lt;- 1:as.integer(ymd(sir_end_date) + 1 - ymd(sir_start_date))

# get the fitted values from our SIR model
fitted_cumulative_incidence &amp;lt;- data.frame(ode(
  y = init, times = t,
  func = SIR, parms = Opt_par
))

# add a Date column and the observed incidence data
library(dplyr)
fitted_cumulative_incidence &amp;lt;- fitted_cumulative_incidence %&amp;gt;%
  mutate(
    Date = ymd(sir_start_date) + days(t - 1),
    Country = &amp;quot;Belgium&amp;quot;,
    cumulative_incident_cases = Infected
  )

# plot the data
library(ggplot2)
fitted_cumulative_incidence %&amp;gt;%
  ggplot(aes(x = Date)) +
  geom_line(aes(y = I), colour = &amp;quot;red&amp;quot;) +
  geom_point(aes(y = cumulative_incident_cases), colour = &amp;quot;blue&amp;quot;) +
  labs(
    y = &amp;quot;Cumulative incidence&amp;quot;,
    title = &amp;quot;COVID-19 fitted vs observed cumulative incidence, Belgium&amp;quot;,
    subtitle = &amp;quot;(Red = fitted from SIR model, blue = observed)&amp;quot;
  ) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-31-covid-19-in-belgium_files/figure-html/unnamed-chunk-6-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the above graph we see that the number of observed confirmed cases follows (unfortunately) the number of confirmed cases expected by our model. The fact that both trends are overlapping indicates that the pandemic is clearly in an exponential phase in Belgium. More data would be needed to see whether this trend is confirmed in the long term.&lt;/p&gt;
&lt;p&gt;The following graph is similar than the previous one, except that the &lt;em&gt;y&lt;/em&gt;-axis is measured on a log scale. This kind of plot is called a semi-log plot or more precisely a log-linear plot because only the &lt;em&gt;y&lt;/em&gt;-axis is transformed with a logarithm scale. Transforming the scale in log has the advantage that it is more easily readable in terms of difference between the observed and expected number of confirmed cases and it also shows how the number of observed confirmed cases differs from an exponential trend.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fitted_cumulative_incidence %&amp;gt;%
  ggplot(aes(x = Date)) +
  geom_line(aes(y = I), colour = &amp;quot;red&amp;quot;) +
  geom_point(aes(y = cumulative_incident_cases), colour = &amp;quot;blue&amp;quot;) +
  labs(
    y = &amp;quot;Cumulative incidence&amp;quot;,
    title = &amp;quot;COVID-19 fitted vs observed cumulative incidence, Belgium&amp;quot;,
    subtitle = &amp;quot;(Red = fitted from SIR model, blue = observed)&amp;quot;
  ) +
  theme_minimal() +
  scale_y_log10(labels = scales::comma)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-31-covid-19-in-belgium_files/figure-html/unnamed-chunk-7-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The plot indicates that, at the beginning of the pandemic and until March 12, the number of confirmed cases stayed below what would be expected in an exponential phase. In particular, the number of confirmed cases stayed constant at 1 case from February 4 to February 29. From March 13 and until March 30, the number of confirmed cases kept increasing at a rate close to an exponential rate.&lt;/p&gt;
&lt;p&gt;We also notice a small jump between March 12 and March 13, which may potentially indicate an error in the data collection, or a change in the testing/screening methods.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;reproduction-number-r_0&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Our &lt;em&gt;SIR&lt;/em&gt; model looks like a good fit to the observed cumulative incidence data in Belgium, so we can now use our fitted model to calculate the basic reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt;, also referred as basic reproduction ratio, and which is closely linked to &lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt;.&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;The basic reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt; gives the average number of susceptible people who are infected by each infectious person where all individuals are susceptible to infection. In other words, the reproduction number refers to the number of healthy people that get infected per number of sick people. When &lt;span class=&#34;math inline&#34;&gt;\(R_0 &amp;gt; 1\)&lt;/span&gt; the disease starts spreading in a population, but not if &lt;span class=&#34;math inline&#34;&gt;\(R_0 &amp;lt; 1\)&lt;/span&gt;. Usually, the larger the value of &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt;, the harder it is to control the epidemic and the higher the probability of a pandemic.&lt;/p&gt;
&lt;p&gt;Formally, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[R_0 = \frac{\beta}{\gamma}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We can compute it in R:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Opt_par&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      beta     gamma 
## 0.5841185 0.4158816&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;R0 &amp;lt;- as.numeric(Opt_par[1] / Opt_par[2])
R0&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1.404531&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;An &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt; of 1.4 is below values found by others for COVID-19 and the &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt; for SARS and MERS, which are similar diseases also caused by coronavirus. Furthermore, in the literature, it has been estimated that the reproduction number for COVID-19 is approximately 2.7 (with &lt;span class=&#34;math inline&#34;&gt;\(\beta\)&lt;/span&gt; close to 0.54 and &lt;span class=&#34;math inline&#34;&gt;\(\gamma\)&lt;/span&gt; close to 0.2). Our reproduction number being lower is mainly due to the fact that the number of confirmed cases stayed constant and equal to 1 at the beginning of the pandemic.&lt;/p&gt;
&lt;p&gt;A &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt; of 1.4 means that, on average in Belgium, 1.4 persons are infected for each infected person.&lt;/p&gt;
&lt;p&gt;For simple models, the proportion of the population that needs to be effectively immunized to prevent sustained spread of the disease, known as the “herd immunity threshold”, has to be larger than &lt;span class=&#34;math inline&#34;&gt;\(1 - \frac{1}{R_0}\)&lt;/span&gt; &lt;span class=&#34;citation&#34;&gt;(Fine, Eames, and Heymann &lt;a href=&#34;#ref-fine2011herd&#34; role=&#34;doc-biblioref&#34;&gt;2011&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;!-- Under some conditions, $1 - \frac{1}{R_0}$ gives an indication about the proportion of the population likely to be infected throughout the pandemic. --&gt;
&lt;p&gt;The reproduction number of 1.4 we just calculated suggests that, given the formula 1 - (1 / 1.4), 28.8% of the population should be immunized to stop the spread of the infection. With a population in Belgium of approximately 11.5 million, this translates into roughly 3.3 million people.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;using-our-model-to-analyze-the-outbreak-if-there-was-no-intervention&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Using our model to analyze the outbreak if there was no intervention&lt;/h2&gt;
&lt;p&gt;It is instructive to use our model fitted to the first 56 days of available data on confirmed cases in Belgium, to see what would happen if the outbreak were left to run its course, without public health intervention.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# time in days for predictions
t &amp;lt;- 1:120

# get the fitted values from our SIR model
fitted_cumulative_incidence &amp;lt;- data.frame(ode(
  y = init, times = t,
  func = SIR, parms = Opt_par
))

# add a Date column and join the observed incidence data
fitted_cumulative_incidence &amp;lt;- fitted_cumulative_incidence %&amp;gt;%
  mutate(
    Date = ymd(sir_start_date) + days(t - 1),
    Country = &amp;quot;Belgium&amp;quot;,
    cumulative_incident_cases = c(Infected, rep(NA, length(t) - length(Infected)))
  )

# plot the data
fitted_cumulative_incidence %&amp;gt;%
  ggplot(aes(x = Date)) +
  geom_line(aes(y = I), colour = &amp;quot;red&amp;quot;) +
  geom_line(aes(y = S), colour = &amp;quot;black&amp;quot;) +
  geom_line(aes(y = R), colour = &amp;quot;green&amp;quot;) +
  geom_point(aes(y = cumulative_incident_cases),
    colour = &amp;quot;blue&amp;quot;
  ) +
  scale_y_continuous(labels = scales::comma) +
  labs(y = &amp;quot;Persons&amp;quot;, title = &amp;quot;COVID-19 fitted vs observed cumulative incidence, Belgium&amp;quot;) +
  scale_colour_manual(name = &amp;quot;&amp;quot;, values = c(
    red = &amp;quot;red&amp;quot;, black = &amp;quot;black&amp;quot;,
    green = &amp;quot;green&amp;quot;, blue = &amp;quot;blue&amp;quot;
  ), labels = c(
    &amp;quot;Susceptible&amp;quot;,
    &amp;quot;Recovered&amp;quot;, &amp;quot;Observed&amp;quot;, &amp;quot;Infectious&amp;quot;
  )) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-31-covid-19-in-belgium_files/figure-html/unnamed-chunk-10-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The same graph in log scale for the &lt;em&gt;y&lt;/em&gt;-axis and with a legend for better readability:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot the data
fitted_cumulative_incidence %&amp;gt;%
  ggplot(aes(x = Date)) +
  geom_line(aes(y = I, colour = &amp;quot;red&amp;quot;)) +
  geom_line(aes(y = S, colour = &amp;quot;black&amp;quot;)) +
  geom_line(aes(y = R, colour = &amp;quot;green&amp;quot;)) +
  geom_point(aes(y = cumulative_incident_cases, colour = &amp;quot;blue&amp;quot;)) +
  scale_y_log10(labels = scales::comma) +
  labs(
    y = &amp;quot;Persons&amp;quot;,
    title = &amp;quot;COVID-19 fitted vs observed cumulative incidence, Belgium&amp;quot;
  ) +
  scale_colour_manual(
    name = &amp;quot;&amp;quot;,
    values = c(red = &amp;quot;red&amp;quot;, black = &amp;quot;black&amp;quot;, green = &amp;quot;green&amp;quot;, blue = &amp;quot;blue&amp;quot;),
    labels = c(&amp;quot;Susceptible&amp;quot;, &amp;quot;Observed&amp;quot;, &amp;quot;Recovered&amp;quot;, &amp;quot;Infectious&amp;quot;)
  ) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-31-covid-19-in-belgium_files/figure-html/unnamed-chunk-11-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;more-summary-statistics&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;More summary statistics&lt;/h3&gt;
&lt;p&gt;Other interesting statistics can be computed from the fit of our model. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the peak of the pandemic&lt;/li&gt;
&lt;li&gt;the number of severe cases&lt;/li&gt;
&lt;li&gt;the number of people in need of intensive care&lt;/li&gt;
&lt;li&gt;the number of deaths&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fit &amp;lt;- fitted_cumulative_incidence

# peak of pandemic
fit[fit$I == max(fit$I), c(&amp;quot;Date&amp;quot;, &amp;quot;I&amp;quot;)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##          Date        I
## 89 2020-05-02 531000.4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# severe cases
max_infected &amp;lt;- max(fit$I)
max_infected * 0.2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 106200.1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# cases with need for intensive care
max_infected * 0.06&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 31860.03&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# deaths with supposed 4.5% fatality rate
max_infected * 0.045&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 23895.02&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Given these predictions, with the exact same settings and no intervention at all to limit the spread of the pandemic, the peak in Belgium is expected to be reached by the beginning of May. About 530,000 people would be infected by then, which translates to about 106,000 severe cases, about 32,000 persons in need of intensive care (given that there are about 2000 intensive care units in Belgium, the health sector would be completely overwhelmed) and up to 24,000 deaths (assuming a 4.5% fatality rate, as suggested by this &lt;a href=&#34;https://learning-from-the-curve.github.io/epidemic-models/2020/04/13/COVID-SIR.html&#34; target=&#34;_blank&#34;&gt;source&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;At this point, we understand why such strict containment measures and regulations are taken in Belgium!&lt;/p&gt;
&lt;p&gt;Note that those predictions should be taken with a lot of caution. On the one hand, as mentioned above, they are based on rather unrealistic assumptions (for example, no public health interventions, fixed reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt;, etc.). More advanced projections are possible with the &lt;code&gt;{projections}&lt;/code&gt; package, among others (see this &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium/#more-sophisticated-projections&#34;&gt;section&lt;/a&gt; for more information on this matter). On the other hand, we still have to be careful and strictly follow public health interventions because previous pandemics such as the Spanish and swine flu have shown that incredibly high numbers are not impossible!&lt;/p&gt;
&lt;p&gt;The purpose of this article was to give an illustration of how such analyses are done in R with a simple epidemiological model. Those are the numbers our simple model produces and we hope they are wrong because the cost in terms of lives would be enormous.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-considerations&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Additional considerations&lt;/h1&gt;
&lt;p&gt;As previously mentioned, the &lt;em&gt;SIR&lt;/em&gt; model and the analyses done above are rather simplistic and may not give a true representation of the reality. In the following sections, we highlight five improvements that could be done to enhance theses analyses and lead to a better overview of the spread of the Coronavirus in Belgium.&lt;/p&gt;
&lt;div id=&#34;ascertainment-rates&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Ascertainment rates&lt;/h2&gt;
&lt;p&gt;In the previous analyses and graphs, it is assumed that the number of confirmed cases represent all the cases that are infectious. This is far from reality as only a proportion of all cases are screened, detected and counted in the official figures. This proportion is known as the ascertainment rate.&lt;/p&gt;
&lt;p&gt;The ascertainment rate is likely to vary during the course of an outbreak, in particular if testing and screening efforts are increased, or if detections methods are changed. Such changing ascertainment rates can be easily incorporated into the model by using a weighting function for the incidence cases.&lt;/p&gt;
&lt;p&gt;In his first &lt;a href=&#34;https://timchurches.github.io/blog/posts/2020-02-18-analysing-covid-19-2019-ncov-outbreak-data-with-r-part-1/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;, Tim Churches demonstrates that a fixed ascertainment rates of 20% makes little difference to the modelled outbreak with no intervention, except that it all happens a bit more quickly.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;more-sophisticated-models&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;More sophisticated models&lt;/h2&gt;
&lt;p&gt;More sophisticated models could also be used to better reflect real-life transmission processes. For instance, another classical model in disease outbreak is the &lt;em&gt;SEIR&lt;/em&gt; model. This extended model is similar to the &lt;em&gt;SIR&lt;/em&gt; model, where &lt;strong&gt;S&lt;/strong&gt; stands for &lt;strong&gt;S&lt;/strong&gt;usceptible and &lt;strong&gt;R&lt;/strong&gt; stands for &lt;strong&gt;R&lt;/strong&gt;ecovered, but the infected people are divided into two compartments:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;strong&gt;E&lt;/strong&gt; for the &lt;strong&gt;E&lt;/strong&gt;xposed/infected but asymptomatic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;I&lt;/strong&gt; for the &lt;strong&gt;I&lt;/strong&gt;nfected and symptomatic&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These models belong to the continuous-time dynamic models that assume fixed transition rates. There are other stochastic models that allow for varying transition rates depending on attributes of individuals, social networking, etc.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;modelling-the-epidemic-trajectory-using-log-linear-models&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Modelling the epidemic trajectory using log-linear models&lt;/h2&gt;
&lt;p&gt;As noted above, the initial exponential phase of an outbreak, when shown in a log-linear plot (the &lt;em&gt;y&lt;/em&gt;-axis on a log scale and the &lt;em&gt;x&lt;/em&gt;-axis without transformation), appears (somewhat) linear. This suggests that we can model epidemic growth, and decay, using a simple log-linear model of the form:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[log(y)=rt+b\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;em&gt;y&lt;/em&gt; is the incidence, &lt;em&gt;r&lt;/em&gt; is the growth rate, &lt;em&gt;t&lt;/em&gt; is the number of days since a specific point in time (typically the start of the outbreak), and &lt;em&gt;b&lt;/em&gt; is the intercept. In this context, two log-linear models:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;one to the growth phase (before the peak), and&lt;/li&gt;
&lt;li&gt;one to the decay phase (after the peak)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;are fitted to the epidemic (incidence cases) curve.&lt;/p&gt;
&lt;p&gt;The doubling and halving time estimates which you very often hear in the news can be estimated from these log-linear models. Furthermore, these log-linear models can also be used on the epidemic trajectory to estimate the reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt; in the growth and decay phases of the epidemic.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;{incidence}&lt;/code&gt; package in R, part of the &lt;a href=&#34;https://www.repidemicsconsortium.org/&#34; target=&#34;_blank&#34;&gt;R Epidemics Consortium (RECON)&lt;/a&gt; suite of packages for epidemic modelling and control, makes the fitting of this kind of models very convenient.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;estimating-changes-in-the-effective-reproduction-number-r_e&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Estimating changes in the effective reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_e\)&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;In our model, we set a reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_0\)&lt;/span&gt; and kept it constant. It would nonetheless be useful to estimate the current effective reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R_e\)&lt;/span&gt; on a day-by-day basis so as to track the effectiveness of public health interventions, and possibly predict when an incidence curve will start to decrease.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;{EpiEstim}&lt;/code&gt; package in R can be used to estimate &lt;span class=&#34;math inline&#34;&gt;\(R_e\)&lt;/span&gt; and allow to take into consideration human travel from other geographical regions in addition to local transmission &lt;span class=&#34;citation&#34;&gt;(Cori et al. &lt;a href=&#34;#ref-cori2013new&#34; role=&#34;doc-biblioref&#34;&gt;2013&lt;/a&gt;; Thompson et al. &lt;a href=&#34;#ref-thompson2019improved&#34; role=&#34;doc-biblioref&#34;&gt;2019&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;more-sophisticated-projections&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;More sophisticated projections&lt;/h2&gt;
&lt;p&gt;In addition to naïve predictions based on a simple &lt;em&gt;SIR&lt;/em&gt; model, more advanced and complex projections are also possible, notably, with the &lt;code&gt;{projections}&lt;/code&gt; package. This packages uses data on daily incidence, the serial interval and the reproduction number to simulate plausible epidemic trajectories and project future incidence.&lt;/p&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;This article started with (i) a description of a couple of R resources on the Coronavirus pandemic (i.e., a &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;collection&lt;/a&gt; and a &lt;a href=&#34;https://statsandr.com/blog/how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r/&#34;&gt;dashboard&lt;/a&gt;) that can be used as background materials and (ii) the motivations behind this article. We then detailed the most common epidemiological model, i.e. the &lt;em&gt;SIR&lt;/em&gt; model, before actually applying it on Belgium incidence data.&lt;/p&gt;
&lt;p&gt;This resulted in a visual comparison of the fitted and observed cumulative incidence in Belgium. It showed that the COVID-19 pandemic is clearly in an exponential phase in Belgium in terms of number of confirmed cases.&lt;/p&gt;
&lt;p&gt;We then explained what is the reproduction number and how to compute it in R. Finally, our model was used to analyze the outbreak of the Coronavirus if there was no public health intervention at all.&lt;/p&gt;
&lt;p&gt;Under this (probably too) simplistic scenario, the peak of the COVID-19 in Belgium is expected to be reached by the beginning of May, 2020, with around 530,000 infected people and about 24,000 deaths. These very alarmist naïve predictions highlight the importance of restrictive public health actions taken by governments, and the urgency for citizens to follow these health actions in order to mitigate the spread of the virus in Belgium (or at least slow it enough to allow health care systems to cope with it).&lt;/p&gt;
&lt;p&gt;We concluded this article by describing five improvements that could be implemented to further analyze the disease outbreak.&lt;/p&gt;
&lt;p&gt;Note that this article has been subject to a &lt;a href=&#34;https://www.antoinesoetewey.com/files/slides-how-can-we-predict-the-evolution-of-covid-19-in-Belgium.pdf&#34; target=&#34;_blank&#34;&gt;talk&lt;/a&gt; at UCLouvain.&lt;/p&gt;
&lt;p&gt;Thanks for reading. I hope this article gave you a good understanding of the spread of the COVID-19 Coronavirus in Belgium. Feel free to use this article as a starting point for analyzing the outbreak of this disease in your own country.&lt;/p&gt;
&lt;p&gt;For the interested readers, see also:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium-is-it-over-yet/&#34;&gt;evolution of hospital admissions and number of confirmed cases in Belgium&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;a &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;collection of top R resources on Coronavirus&lt;/a&gt; to gain even further knowledge&lt;/li&gt;
&lt;/ul&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references&#34;&gt;
&lt;div id=&#34;ref-cori2013new&#34;&gt;
&lt;p&gt;Cori, Anne, Neil M Ferguson, Christophe Fraser, and Simon Cauchemez. 2013. “A New Framework and Software to Estimate Time-Varying Reproduction Numbers During Epidemics.” &lt;em&gt;American Journal of Epidemiology&lt;/em&gt; 178 (9): 1505–12.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ref-fine2011herd&#34;&gt;
&lt;p&gt;Fine, Paul, Ken Eames, and David L Heymann. 2011. “&#34;Herd Immunity&#34;: A Rough Guide.” &lt;em&gt;Clinical Infectious Diseases&lt;/em&gt; 52 (7): 911–16.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ref-thompson2019improved&#34;&gt;
&lt;p&gt;Thompson, RN, JE Stockwin, RD van Gaalen, JA Polonsky, ZN Kamvar, PA Demarsh, E Dahlqwist, et al. 2019. “Improved Inference of Time-Varying Reproduction Numbers During Infectious Disease Outbreaks.” &lt;em&gt;Epidemics&lt;/em&gt; 29: 100356.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;Feel free to let me know in the comments or by &lt;a href=&#34;https://statsandr.com/contact/&#34;&gt;contacting me&lt;/a&gt; if you performed some analyses specifically for Belgium and which I could include in my article covering the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;top R resources on the Coronavirus&lt;/a&gt;.&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;See a more detailed &lt;a href=&#34;https://web.stanford.edu/~jhj1/teachingdocs/Jones-on-R0.pdf&#34; target=&#34;_blank&#34;&gt;note&lt;/a&gt; on the reproduction number by James Holland Jones if you need a deeper understanding.&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>How to create a simple Coronavirus dashboard specific to your country in R?</title>
      <link>https://statsandr.com/blog/how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r/</link>
      <pubDate>Mon, 23 Mar 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#top-r-resources-on-coronavirus&#34; id=&#34;toc-top-r-resources-on-coronavirus&#34;&gt;Top R resources on Coronavirus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-dashboard-the-case-of-belgium&#34; id=&#34;toc-coronavirus-dashboard-the-case-of-belgium&#34;&gt;Coronavirus dashboard: the case of Belgium&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-create-your-own-coronavirus-dashboard&#34; id=&#34;toc-how-to-create-your-own-coronavirus-dashboard&#34;&gt;How to create your own Coronavirus dashboard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#additional-notes&#34; id=&#34;toc-additional-notes&#34;&gt;Additional notes&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#open-source&#34; id=&#34;toc-open-source&#34;&gt;Open source&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#accuracy&#34; id=&#34;toc-accuracy&#34;&gt;Accuracy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#publish-your-dashboard&#34; id=&#34;toc-publish-your-dashboard&#34;&gt;Publish your dashboard&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;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-03-23-how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r_files/How%20to%20create%20a%20simple%20Coronavirus%20dashboard%20specific%20to%20your%20country%20in%20R-1.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;Coronavirus dashboard: the case of Belgium&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;The Novel COVID-19 Coronavirus is the hottest topic right now. Every day, the media and newspapers share the number of new cases and deaths in several countries, try to measure the impacts of the virus on citizens and remind us to stay home in order to stay safe. The Coronavirus is on everyone’s lips.&lt;/p&gt;
&lt;p&gt;In addition to governments, media and companies discussing about it, data scientists and data professionals in general are putting their knowledge and time at the service of the virus. This leads to a proliferation of applications, dashboards, blog posts, videos, datasets and code analyzing, in one way or another, the expansion of the COVID-19 and how it spreads in the population.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;top-r-resources-on-coronavirus&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Top R resources on Coronavirus&lt;/h1&gt;
&lt;p&gt;As a data lover myself, I discovered a multitude of great resources about the Coronavirus. However, these resources were spread all over the internet and were often hidden by the mass of information of another type (e.g., alarming headlines, names of infected celebrities, companies showing off how they helped health care agencies, etc.). To tackle this issue, I collected and then shared in a previous article &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;the best R resources on the Coronavirus&lt;/a&gt; I came across.&lt;/p&gt;
&lt;p&gt;Note that only resources on R are shared in this article as R is my favorite statistical program and the one I am most familiar with. The fact that I use this program almost daily makes it easier for me to realize the complexity and time put behind a resource, and appreciate its quality and its potential.&lt;/p&gt;
&lt;p&gt;I am sure that there are other very interesting resources online (see for example the probably &lt;a href=&#34;https://coronavirus.jhu.edu/map.html&#34; target=&#34;_blank&#34;&gt;most popular dashboard&lt;/a&gt; by the Johns Hopkins Coronavirus Resource Center).&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; Nonetheless, a lot of people are in a better position than I am to judge the quality of resources made with programming languages for which I am not competent.&lt;/p&gt;
&lt;p&gt;This &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;article&lt;/a&gt; made me discover so many great resources about the Coronavirus and I keep receiving data visualizations and data analyses from scientists all over the world so that I include them in the collection. Thanks for that, it continuously improves the quality and completeness of the collection.&lt;/p&gt;
&lt;p&gt;In addition to receiving R resources, a question often asked by readers was “How can I create a dashboard myself?” or “How can I build a dashboard specific to my country?”. I therefore thought it would serve some people if I created a dashboard specific to my country (Belgium) and detailed the steps on how to build it.&lt;/p&gt;
&lt;p&gt;Questions on how to develop such dashboards came mostly from R beginners as advanced R users most probably know how to do one, or at least can easily use the resources I collected &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;here&lt;/a&gt; as sources of inspiration for their own work. Furthermore, in response to the craze about the Coronavirus, interested users were quite in a hurry and wanted to have their own dashboard running as quickly as possible.&lt;/p&gt;
&lt;p&gt;These questions led me to the idea of creating a simple (yet powerful and visually appealing) &lt;strong&gt;dashboard&lt;/strong&gt;, as opposed to a &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;Shiny app&lt;/a&gt;. Shiny apps have the advantage that they are interactive in the sense that users can edit the outputs and the visualizations by simply changing some inputs in a user-friendly way, while dashboards are static and cannot be modified by the final user. On the other hand, the advantage of a dashboard over a Shiny app is that it is much easier to code, especially if you are already proficient in &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus-dashboard-the-case-of-belgium&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Coronavirus dashboard: the case of Belgium&lt;/h1&gt;
&lt;p&gt;Amongst all the visualizations I have seen so far, one is standing out by its simplicity and at the same time, by its completeness and by the quality of its visualizations. I thus decided to create a Coronavirus dashboard based on this already existing &lt;a href=&#34;https://ramikrispin.github.io/coronavirus_dashboard/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; by Rami Krispin (which comes with a license that allows to be freely adapted and shared) and adapt it so that it is specific to Belgium. Note that I also removed some visualizations and tables from the initial dashboard to keep it really simple and straight to the point.&lt;/p&gt;
&lt;p&gt;Before reading further, here is my &lt;a href=&#34;https://www.antoinesoetewey.com/files/coronavirus-dashboard.html&#34; target=&#34;_blank&#34;&gt;Coronavirus dashboard&lt;/a&gt; adapted to Belgium and previews of the main sections below:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-23-how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r_files/How%20to%20create%20a%20simple%20Coronavirus%20dashboard%20specific%20to%20your%20country%20in%20R-1.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-23-how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r_files/How%20to%20create%20a%20simple%20Coronavirus%20dashboard%20specific%20to%20your%20country%20in%20R-2.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-23-how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r_files/How%20to%20create%20a%20simple%20Coronavirus%20dashboard%20specific%20to%20your%20country%20in%20R-3.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The dashboard is segmented into several sections that can be selected at the top:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The summary section provides key measures about the Coronavirus (total cases, active cases and deaths) and a plot displaying the cumulative number of active cases and deaths from January 22, 2020 to the latest available date.&lt;/li&gt;
&lt;li&gt;The comparison section presents a comparison of the number of daily new cases (left panel) and the distribution of cases by type (right panel) with other European countries (you can also change these countries by replacing them in the code).&lt;/li&gt;
&lt;li&gt;The map section shows a world map of the confirmed cases and deaths. You can uncheck one or several types of cases (top right corner) and zoom in or out (top left corner) to adapt the map to your needs.&lt;/li&gt;
&lt;li&gt;The about section gives more information about the data, the dashboard in general and how often it is updated.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I believe this simple dashboard is easy enough to be adapted to any country (and by anyone from beginner to expert), and still communicate key measures about the virus throughout some visualizations.&lt;/p&gt;
&lt;p&gt;A little extra which is worth mentioning is the fact that all plots are generated with the &lt;code&gt;{plotly}&lt;/code&gt; package. This package allows to enhance plots by displaying additional relevant information when hovering over them (try by yourself!).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-create-your-own-coronavirus-dashboard&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to create your own Coronavirus dashboard&lt;/h1&gt;
&lt;p&gt;If you want to build your own dashboard specific to a country, follow these steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Open the dashboard &lt;a href=&#34;https://www.antoinesoetewey.com/files/coronavirus-dashboard.html&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;See the entire code via the button “Source code” located in the top right corner of the dashboard, or see the code on &lt;a href=&#34;https://github.com/AntoineSoetewey/coronavirus_dashboard&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;. Copy that code.&lt;/li&gt;
&lt;li&gt;Open a new R Markdown file (&lt;code&gt;.Rmd&lt;/code&gt;), type any title and author (they will be replaced in the next step anyway), select HTML as the output format and click on OK:&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-23-how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r_files/Screenshot%202020-03-23%20at%2015.38.45.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;4&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Remove all the template code already present and paste the code you copied in step 1.&lt;/li&gt;
&lt;li&gt;Make sure that the required packages are installed:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;install.packages(c(&amp;quot;devtools&amp;quot;, &amp;quot;flexdashboard&amp;quot;, &amp;quot;leaflet&amp;quot;, &amp;quot;leafpop&amp;quot;))
devtools::install_github(&amp;quot;RamiKrispin/coronavirus&amp;quot;, force = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If R asks you which package you would like to update, there should be no need to update them: type 3 for “None”.&lt;/p&gt;
&lt;ol start=&#34;6&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;In the code, replace &lt;code&gt;Belgium&lt;/code&gt; with your country. Here is the list of all available countries in the dataset:&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;Canada&lt;/em&gt;, &lt;em&gt;United Kingdom&lt;/em&gt;, &lt;em&gt;China&lt;/em&gt;, &lt;em&gt;Netherlands&lt;/em&gt;, &lt;em&gt;Australia&lt;/em&gt;, &lt;em&gt;New Zealand&lt;/em&gt;, &lt;em&gt;Denmark&lt;/em&gt;, &lt;em&gt;France&lt;/em&gt;, &lt;em&gt;Afghanistan&lt;/em&gt;, &lt;em&gt;Albania&lt;/em&gt;, &lt;em&gt;Algeria&lt;/em&gt;, &lt;em&gt;Andorra&lt;/em&gt;, &lt;em&gt;Angola&lt;/em&gt;, &lt;em&gt;Antarctica&lt;/em&gt;, &lt;em&gt;Antigua and Barbuda&lt;/em&gt;, &lt;em&gt;Argentina&lt;/em&gt;, &lt;em&gt;Armenia&lt;/em&gt;, &lt;em&gt;Austria&lt;/em&gt;, &lt;em&gt;Azerbaijan&lt;/em&gt;, &lt;em&gt;Bahamas&lt;/em&gt;, &lt;em&gt;Bahrain&lt;/em&gt;, &lt;em&gt;Bangladesh&lt;/em&gt;, &lt;em&gt;Barbados&lt;/em&gt;, &lt;em&gt;Belarus&lt;/em&gt;, &lt;em&gt;Belgium&lt;/em&gt;, &lt;em&gt;Belize&lt;/em&gt;, &lt;em&gt;Benin&lt;/em&gt;, &lt;em&gt;Bhutan&lt;/em&gt;, &lt;em&gt;Bolivia&lt;/em&gt;, &lt;em&gt;Bosnia and Herzegovina&lt;/em&gt;, &lt;em&gt;Botswana&lt;/em&gt;, &lt;em&gt;Brazil&lt;/em&gt;, &lt;em&gt;Brunei&lt;/em&gt;, &lt;em&gt;Bulgaria&lt;/em&gt;, &lt;em&gt;Burkina Faso&lt;/em&gt;, &lt;em&gt;Burma&lt;/em&gt;, &lt;em&gt;Burundi&lt;/em&gt;, &lt;em&gt;Cabo Verde&lt;/em&gt;, &lt;em&gt;Cambodia&lt;/em&gt;, &lt;em&gt;Cameroon&lt;/em&gt;, &lt;em&gt;Central African Republic&lt;/em&gt;, &lt;em&gt;Chad&lt;/em&gt;, &lt;em&gt;Chile&lt;/em&gt;, &lt;em&gt;Colombia&lt;/em&gt;, &lt;em&gt;Comoros&lt;/em&gt;, &lt;em&gt;Congo (Brazzaville)&lt;/em&gt;, &lt;em&gt;Congo (Kinshasa)&lt;/em&gt;, &lt;em&gt;Costa Rica&lt;/em&gt;, &lt;em&gt;Cote d’Ivoire&lt;/em&gt;, &lt;em&gt;Croatia&lt;/em&gt;, &lt;em&gt;Cuba&lt;/em&gt;, &lt;em&gt;Cyprus&lt;/em&gt;, &lt;em&gt;Czechia&lt;/em&gt;, &lt;em&gt;Diamond Princess&lt;/em&gt;, &lt;em&gt;Djibouti&lt;/em&gt;, &lt;em&gt;Dominica&lt;/em&gt;, &lt;em&gt;Dominican Republic&lt;/em&gt;, &lt;em&gt;Ecuador&lt;/em&gt;, &lt;em&gt;Egypt&lt;/em&gt;, &lt;em&gt;El Salvador&lt;/em&gt;, &lt;em&gt;Equatorial Guinea&lt;/em&gt;, &lt;em&gt;Eritrea&lt;/em&gt;, &lt;em&gt;Estonia&lt;/em&gt;, &lt;em&gt;Eswatini&lt;/em&gt;, &lt;em&gt;Ethiopia&lt;/em&gt;, &lt;em&gt;Fiji&lt;/em&gt;, &lt;em&gt;Finland&lt;/em&gt;, &lt;em&gt;Gabon&lt;/em&gt;, &lt;em&gt;Gambia&lt;/em&gt;, &lt;em&gt;Georgia&lt;/em&gt;, &lt;em&gt;Germany&lt;/em&gt;, &lt;em&gt;Ghana&lt;/em&gt;, &lt;em&gt;Greece&lt;/em&gt;, &lt;em&gt;Grenada&lt;/em&gt;, &lt;em&gt;Guatemala&lt;/em&gt;, &lt;em&gt;Guinea&lt;/em&gt;, &lt;em&gt;Guinea-Bissau&lt;/em&gt;, &lt;em&gt;Guyana&lt;/em&gt;, &lt;em&gt;Haiti&lt;/em&gt;, &lt;em&gt;Holy See&lt;/em&gt;, &lt;em&gt;Honduras&lt;/em&gt;, &lt;em&gt;Hungary&lt;/em&gt;, &lt;em&gt;Iceland&lt;/em&gt;, &lt;em&gt;India&lt;/em&gt;, &lt;em&gt;Indonesia&lt;/em&gt;, &lt;em&gt;Iran&lt;/em&gt;, &lt;em&gt;Iraq&lt;/em&gt;, &lt;em&gt;Ireland&lt;/em&gt;, &lt;em&gt;Israel&lt;/em&gt;, &lt;em&gt;Italy&lt;/em&gt;, &lt;em&gt;Jamaica&lt;/em&gt;, &lt;em&gt;Japan&lt;/em&gt;, &lt;em&gt;Jordan&lt;/em&gt;, &lt;em&gt;Kazakhstan&lt;/em&gt;, &lt;em&gt;Kenya&lt;/em&gt;, &lt;em&gt;Kiribati&lt;/em&gt;, &lt;em&gt;Korea, North&lt;/em&gt;, &lt;em&gt;Korea, South&lt;/em&gt;, &lt;em&gt;Kosovo&lt;/em&gt;, &lt;em&gt;Kuwait&lt;/em&gt;, &lt;em&gt;Kyrgyzstan&lt;/em&gt;, &lt;em&gt;Laos&lt;/em&gt;, &lt;em&gt;Latvia&lt;/em&gt;, &lt;em&gt;Lebanon&lt;/em&gt;, &lt;em&gt;Lesotho&lt;/em&gt;, &lt;em&gt;Liberia&lt;/em&gt;, &lt;em&gt;Libya&lt;/em&gt;, &lt;em&gt;Liechtenstein&lt;/em&gt;, &lt;em&gt;Lithuania&lt;/em&gt;, &lt;em&gt;Luxembourg&lt;/em&gt;, &lt;em&gt;Madagascar&lt;/em&gt;, &lt;em&gt;Malawi&lt;/em&gt;, &lt;em&gt;Malaysia&lt;/em&gt;, &lt;em&gt;Maldives&lt;/em&gt;, &lt;em&gt;Mali&lt;/em&gt;, &lt;em&gt;Malta&lt;/em&gt;, &lt;em&gt;Marshall Islands&lt;/em&gt;, &lt;em&gt;Mauritania&lt;/em&gt;, &lt;em&gt;Mauritius&lt;/em&gt;, &lt;em&gt;Mexico&lt;/em&gt;, &lt;em&gt;Micronesia&lt;/em&gt;, &lt;em&gt;Moldova&lt;/em&gt;, &lt;em&gt;Monaco&lt;/em&gt;, &lt;em&gt;Mongolia&lt;/em&gt;, &lt;em&gt;Montenegro&lt;/em&gt;, &lt;em&gt;Morocco&lt;/em&gt;, &lt;em&gt;Mozambique&lt;/em&gt;, &lt;em&gt;MS Zaandam&lt;/em&gt;, &lt;em&gt;Namibia&lt;/em&gt;, &lt;em&gt;Nepal&lt;/em&gt;, &lt;em&gt;Nicaragua&lt;/em&gt;, &lt;em&gt;Niger&lt;/em&gt;, &lt;em&gt;Nigeria&lt;/em&gt;, &lt;em&gt;North Macedonia&lt;/em&gt;, &lt;em&gt;Norway&lt;/em&gt;, &lt;em&gt;Oman&lt;/em&gt;, &lt;em&gt;Pakistan&lt;/em&gt;, &lt;em&gt;Palau&lt;/em&gt;, &lt;em&gt;Panama&lt;/em&gt;, &lt;em&gt;Papua New Guinea&lt;/em&gt;, &lt;em&gt;Paraguay&lt;/em&gt;, &lt;em&gt;Peru&lt;/em&gt;, &lt;em&gt;Philippines&lt;/em&gt;, &lt;em&gt;Poland&lt;/em&gt;, &lt;em&gt;Portugal&lt;/em&gt;, &lt;em&gt;Qatar&lt;/em&gt;, &lt;em&gt;Romania&lt;/em&gt;, &lt;em&gt;Russia&lt;/em&gt;, &lt;em&gt;Rwanda&lt;/em&gt;, &lt;em&gt;Saint Kitts and Nevis&lt;/em&gt;, &lt;em&gt;Saint Lucia&lt;/em&gt;, &lt;em&gt;Saint Vincent and the Grenadines&lt;/em&gt;, &lt;em&gt;Samoa&lt;/em&gt;, &lt;em&gt;San Marino&lt;/em&gt;, &lt;em&gt;Sao Tome and Principe&lt;/em&gt;, &lt;em&gt;Saudi Arabia&lt;/em&gt;, &lt;em&gt;Senegal&lt;/em&gt;, &lt;em&gt;Serbia&lt;/em&gt;, &lt;em&gt;Seychelles&lt;/em&gt;, &lt;em&gt;Sierra Leone&lt;/em&gt;, &lt;em&gt;Singapore&lt;/em&gt;, &lt;em&gt;Slovakia&lt;/em&gt;, &lt;em&gt;Slovenia&lt;/em&gt;, &lt;em&gt;Solomon Islands&lt;/em&gt;, &lt;em&gt;Somalia&lt;/em&gt;, &lt;em&gt;South Africa&lt;/em&gt;, &lt;em&gt;South Sudan&lt;/em&gt;, &lt;em&gt;Spain&lt;/em&gt;, &lt;em&gt;Sri Lanka&lt;/em&gt;, &lt;em&gt;Sudan&lt;/em&gt;, &lt;em&gt;Summer Olympics 2020&lt;/em&gt;, &lt;em&gt;Suriname&lt;/em&gt;, &lt;em&gt;Sweden&lt;/em&gt;, &lt;em&gt;Switzerland&lt;/em&gt;, &lt;em&gt;Syria&lt;/em&gt;, _Taiwan*_, &lt;em&gt;Tajikistan&lt;/em&gt;, &lt;em&gt;Tanzania&lt;/em&gt;, &lt;em&gt;Thailand&lt;/em&gt;, &lt;em&gt;Timor-Leste&lt;/em&gt;, &lt;em&gt;Togo&lt;/em&gt;, &lt;em&gt;Tonga&lt;/em&gt;, &lt;em&gt;Trinidad and Tobago&lt;/em&gt;, &lt;em&gt;Tunisia&lt;/em&gt;, &lt;em&gt;Turkey&lt;/em&gt;, &lt;em&gt;Uganda&lt;/em&gt;, &lt;em&gt;Ukraine&lt;/em&gt;, &lt;em&gt;United Arab Emirates&lt;/em&gt;, &lt;em&gt;Uruguay&lt;/em&gt;, &lt;em&gt;US&lt;/em&gt;, &lt;em&gt;Uzbekistan&lt;/em&gt;, &lt;em&gt;Vanuatu&lt;/em&gt;, &lt;em&gt;Venezuela&lt;/em&gt;, &lt;em&gt;Vietnam&lt;/em&gt;, &lt;em&gt;West Bank and Gaza&lt;/em&gt;, &lt;em&gt;Winter Olympics 2022&lt;/em&gt;, &lt;em&gt;Yemen&lt;/em&gt;, &lt;em&gt;Zambia&lt;/em&gt; and &lt;em&gt;Zimbabwe&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Note that if your country is spelled in two words or more, you will need to surround it by a backtick (but only at one specific line in the code, see an example with United Kingdom):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#----------------------------------------
# Plotting the data

daily_confirmed %&amp;gt;%
  plotly::plot_ly() %&amp;gt;%
  plotly::add_trace(
    x = ~date,
    y = ~`United Kingdom`,
    type = &amp;quot;scatter&amp;quot;,
    mode = &amp;quot;lines+markers&amp;quot;,
    name = &amp;quot;United Kingdom&amp;quot;
  ) %&amp;gt;%&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Do not add backticks in the rest of the code as everywhere else the country’s name is surrounded by double quotes &lt;code&gt;&#34;&#34;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Do not forget to also change the title and the author at the top of the document, and edit the about section at the bottom of the document. Last but not least, as you can see on the plot in the summary section, the arrows point to different (sad) “milestones” in Belgium (i.e., first case, first death and new containment measures).&lt;/p&gt;
&lt;p&gt;You will need to adapt these milestones for your country (or remove them if you do not want to have any milestone displayed on the plot). Change this in the code following the &lt;code&gt;plotly::add_annotations()&lt;/code&gt; functions.&lt;/p&gt;
&lt;ol start=&#34;7&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Knit the document (see this &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;article&lt;/a&gt; if you are unfamiliar with R Markdown). Your dashboard should appear in HTML format.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Following these 7 steps, you should already have a simple dashboard specific to your country. I have intentionally kept it simple so that everyone could copy it and have their own dashboard in a limited amount of time.&lt;/p&gt;
&lt;p&gt;If you are familiar with the &lt;a href=&#34;https://rmarkdown.rstudio.com/flexdashboard/&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{flexdashboard}&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;https://plot.ly/r/&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{plotly}&lt;/code&gt;&lt;/a&gt; and &lt;a href=&#34;https://rstudio.github.io/leaflet/&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{leaflet}&lt;/code&gt;&lt;/a&gt; packages for the dashboard interface and the visualizations, and the &lt;a href=&#34;https://dplyr.tidyverse.org/&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{dplyr}&lt;/code&gt;&lt;/a&gt; and &lt;a href=&#34;https://tidyr.tidyverse.org/&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{tidyr}&lt;/code&gt;&lt;/a&gt; packages for the data manipulation, feel free to edit the code according to your needs and improve your dashboard.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-notes&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Additional notes&lt;/h1&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;The input data for this dashboard is the dataset available from the &lt;a href=&#34;https://github.com/RamiKrispin/coronavirus&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{coronavirus}&lt;/code&gt;&lt;/a&gt; R package. Make sure to download the development version of the package to have the latest data:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;RamiKrispin/coronavirus&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To update your dashboard with the latest data, you have to manually update the data by reinstalling the &lt;code&gt;{coronavirus}&lt;/code&gt; package with &lt;code&gt;devtools::install_github(&#34;RamiKrispin/coronavirus&#34;, force = TRUE)&lt;/code&gt;. Again, if R asks you whether you would like to update other packages, type 3 for “None”.&lt;/p&gt;
&lt;p&gt;This question was often raised so I repeat, your dashboard will not update by itself every day, you need to manually update it. After updating the data, you may also need to restart your R session in order to have the last available data.&lt;/p&gt;
&lt;p&gt;The raw data is pulled from the Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus &lt;a href=&#34;https://github.com/RamiKrispin/coronavirus-csv&#34; target=&#34;_blank&#34;&gt;repository&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;open-source&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Open source&lt;/h2&gt;
&lt;p&gt;This dashboard and the code available on &lt;a href=&#34;https://github.com/AntoineSoetewey/coronavirus_dashboard&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt; are open source so feel free to copy it, adapt it and share it as much as you want.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;accuracy&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Accuracy&lt;/h2&gt;
&lt;p&gt;Please note that this dashboard has been built mainly for educational purposes. I update the dashboard as often as possible to keep it accurate. However, there is some uncertainty concerning the COVID-19 case numbers and the testing methods vary between countries so the figures on this dashboard may be slightly different compared to other sources. Currently, the maintainer of the &lt;a href=&#34;https://statsandr.com/blog/how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r/#data&#34;&gt;dataset&lt;/a&gt; updates it on a daily basis, but updates may become less frequent in the future.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;publish-your-dashboard&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Publish your dashboard&lt;/h2&gt;
&lt;p&gt;If you want to share your dashboard, you can either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Upload it on your website if you have one (and I strongly suggest you to &lt;a href=&#34;https://statsandr.com/blog/7-benefits-of-sharing-your-code-in-a-data-science-blog/#how-to-start-your-own-blog&#34;&gt;create one&lt;/a&gt; if you do not already have one)&lt;/li&gt;
&lt;li&gt;Publish it through &lt;a href=&#34;https://rpubs.com/&#34; target=&#34;_blank&#34;&gt;RPubs&lt;/a&gt; (it is free and easy to publish your work directly from RStudio)&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 this article helped you to build your first Coronavirus dashboard in R. See these &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/&#34;&gt;top R resources on Coronavirus&lt;/a&gt; if you need inspiration to enhance further your dashboard.&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;I would be glad to mention a collection of Python resources if someone is willing to create a collection of resources about the Coronavirus made with this programming language. Feel free to &lt;a href=&#34;https://statsandr.com/contact/&#34;&gt;contact me&lt;/a&gt; if this is the case.&lt;a href=&#34;#fnref1&#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>How to do a t-test or ANOVA for more than one variable at once in R?</title>
      <link>https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/</link>
      <pubDate>Thu, 19 Mar 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#perform-multiple-tests-at-once&#34; id=&#34;toc-perform-multiple-tests-at-once&#34;&gt;Perform multiple tests at once&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#concise-and-easily-interpretable-results&#34; id=&#34;toc-concise-and-easily-interpretable-results&#34;&gt;Concise and easily interpretable results&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#t-test&#34; id=&#34;toc-t-test&#34;&gt;T-test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#additional-p-value-adjustment-methods&#34; id=&#34;toc-additional-p-value-adjustment-methods&#34;&gt;Additional &lt;em&gt;p&lt;/em&gt;-value adjustment methods&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#anova&#34; id=&#34;toc-anova&#34;&gt;ANOVA&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#to-go-even-further&#34; id=&#34;toc-to-go-even-further&#34;&gt;To go even further&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#update-with-the-ggstatsplot-package&#34; id=&#34;toc-update-with-the-ggstatsplot-package&#34;&gt;Update with the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/How%20to%20do%20a%20t-test%20or%20ANOVA%20for%20many%20variables%20at%20once%20in%20R%20and%20communicate%20the%20results%20in%20a%20better%20way.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;As part of my teaching assistant position in a Belgian university, students often ask me for some help in their statistical analyses for their master’s thesis.&lt;/p&gt;
&lt;p&gt;A frequent question is how to compare groups of patients in terms of several &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;quantitative continuous&lt;/a&gt; variables. Most of us know that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To compare two groups, a &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test&lt;/a&gt; should be used&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;li&gt;To compare three groups or more, an &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; should be performed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These two tests are quite basic and have been extensively documented online and in statistical textbooks so the difficulty is not in how to perform these tests.&lt;/p&gt;
&lt;p&gt;In the past, I used to do the analyses by following these 3 steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Draw boxplots illustrating the distributions by group (with the &lt;code&gt;boxplot()&lt;/code&gt; function or thanks to 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; R Studio addin&lt;/a&gt; if I wanted to use 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;/li&gt;
&lt;li&gt;Perform a t-test or an ANOVA depending on the number of groups to compare (with the &lt;code&gt;t.test()&lt;/code&gt; and &lt;code&gt;oneway.test()&lt;/code&gt; functions for t-test and ANOVA, respectively)&lt;/li&gt;
&lt;li&gt;Repeat steps 1 and 2 for each variable&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This was feasible as long as there were only a couple of variables to test. Nonetheless, most students came to me asking to perform these kind of tests not on one or two variables, but on &lt;strong&gt;multiples&lt;/strong&gt; variables. So when there were more than one variable to test, I quickly realized that I was wasting my time and that there must be a more efficient way to do the job.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt;: you must be very careful with the issue of &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#issue-of-multiple-testing&#34;&gt;multiple testing&lt;/a&gt; (also referred as multiplicity) which can arise when you perform multiple tests. In short, when a large number of statistical tests are performed, some will have &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values less than 0.05 purely by chance, even if all null hypotheses are in fact really true. This is known as multiplicity or multiple testing. You can tackle this problem by using the Bonferroni correction, among others. The Bonferroni correction is a simple method that allows many t-tests to be made while still assuring an overall confidence level is maintained. For this, instead of using the standard threshold of &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 5\)&lt;/span&gt;% for the significance level, you can use &lt;span class=&#34;math inline&#34;&gt;\(\alpha = \frac{0.05}{m}\)&lt;/span&gt; where &lt;span class=&#34;math inline&#34;&gt;\(m\)&lt;/span&gt; is the number of t-tests. For example, if you perform 20 t-tests with a desired &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;, the Bonferroni correction implies that you would reject the null hypothesis for each individual test when the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value is smaller than &lt;span class=&#34;math inline&#34;&gt;\(\alpha = \frac{0.05}{20} = 0.0025\)&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Note also that there is no universally accepted approach for dealing with the problem of multiple comparisons. Usually, you should choose a &lt;em&gt;p&lt;/em&gt;-value adjustment measure familiar to your audience or in your field of study. The Bonferroni correction is easy to implement. It is however not appropriate if you have a very large number of tests to perform (imagine you want to do 10,000 t-tests, a &lt;em&gt;p&lt;/em&gt;-value would have to be less than &lt;span class=&#34;math inline&#34;&gt;\(\frac{0.05}{10000} = 0.000005\)&lt;/span&gt; to be significant). A more powerful method is also to adjust the false discovery rate using the Benjamini-Hochberg or Holm procedure &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-mcdonald2014multiple&#34;&gt;McDonald 2014&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Another option is to use a multivariate ANOVA (MANOVA), if your independent variable has more than two levels. This is particularly useful when your dependent variables are correlated. Correlation between the dependent variables provides MANOVA the following advantages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Identify patterns between several dependent variables&lt;/strong&gt;: The independent variables can influence the relationship between dependent variables instead of influencing a single dependent variable.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Address the issue of multiple testing&lt;/strong&gt;: with MANOVA, the error rate equals the significance level (with no &lt;em&gt;p&lt;/em&gt;-value adjustment method needed).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Greater statistical power&lt;/strong&gt;: When the dependent variables are correlated, MANOVA can identify effects that are too small for the ANOVA to detect.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that MANOVA is used if your independent variable has more than two levels. If your independent variable has only two levels, the multivariate equivalent of the t-test is Hotelling’s &lt;span class=&#34;math inline&#34;&gt;\(T^2\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;This article aims at presenting a way to perform multiple t-tests and ANOVA from a &lt;strong&gt;technical point of view&lt;/strong&gt; (how to implement it in R). Discussion on which adjustment method to use or whether there is a more appropriate model to fit the data is beyond the scope of this article (so be sure to understand the implications of using the code below for your own analyses). Make sure also to test the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#underlying-assumptions-of-anova&#34;&gt;assumptions&lt;/a&gt; of the ANOVA before interpreting results.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;perform-multiple-tests-at-once&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Perform multiple tests at once&lt;/h1&gt;
&lt;p&gt;I thus wrote a piece of code that automated the process, by drawing boxplots and performing the tests on several variables at once. Below is the code I used, illustrating the process with the &lt;code&gt;iris&lt;/code&gt; dataset. The &lt;code&gt;Species&lt;/code&gt; variable has 3 levels, so let’s remove one, and then draw a boxplot and apply a t-test on all 4 continuous variables at once. Note that the continuous variables that we would like to test are variables 1 to 4 in the &lt;code&gt;iris&lt;/code&gt; dataset.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iris

# remove one level to have only two groups
dat &amp;lt;- subset(dat, Species != &amp;quot;setosa&amp;quot;)
dat$Species &amp;lt;- factor(dat$Species)

# boxplots and t-tests for the 4 variables at once
for (i in 1:4) { # variables to compare are variables 1 to 4
  boxplot(dat[, i] ~ dat$Species, # draw boxplots by group
    ylab = names(dat[i]), # rename y-axis with variable&amp;#39;s name
    xlab = &amp;quot;Species&amp;quot;
  )
  print(t.test(dat[, i] ~ dat$Species)) # print results of t-test
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-1-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Welch Two Sample t-test
## 
## data:  dat[, i] by dat$Species
## t = -5.6292, df = 94.025, p-value = 1.866e-07
## alternative hypothesis: true difference in means between group versicolor and group virginica is not equal to 0
## 95 percent confidence interval:
##  -0.8819731 -0.4220269
## sample estimates:
## mean in group versicolor  mean in group virginica 
##                    5.936                    6.588&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-1-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Welch Two Sample t-test
## 
## data:  dat[, i] by dat$Species
## t = -3.2058, df = 97.927, p-value = 0.001819
## alternative hypothesis: true difference in means between group versicolor and group virginica is not equal to 0
## 95 percent confidence interval:
##  -0.33028364 -0.07771636
## sample estimates:
## mean in group versicolor  mean in group virginica 
##                    2.770                    2.974&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-1-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Welch Two Sample t-test
## 
## data:  dat[, i] by dat$Species
## t = -12.604, df = 95.57, p-value &amp;lt; 2.2e-16
## alternative hypothesis: true difference in means between group versicolor and group virginica is not equal to 0
## 95 percent confidence interval:
##  -1.49549 -1.08851
## sample estimates:
## mean in group versicolor  mean in group virginica 
##                    4.260                    5.552&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-1-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Welch Two Sample t-test
## 
## data:  dat[, i] by dat$Species
## t = -14.625, df = 89.043, p-value &amp;lt; 2.2e-16
## alternative hypothesis: true difference in means between group versicolor and group virginica is not equal to 0
## 95 percent confidence interval:
##  -0.7951002 -0.6048998
## sample estimates:
## mean in group versicolor  mean in group virginica 
##                    1.326                    2.026&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, the above piece of code draws a boxplot and then prints results of the test for each continuous variable, all at once.&lt;/p&gt;
&lt;p&gt;At some point in the past, I even wrote code to:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;draw a boxplot&lt;/li&gt;
&lt;li&gt;test for the equality of variances (thanks to the Levene’s test)&lt;/li&gt;
&lt;li&gt;depending on whether the variances were equal or unequal, the appropriate test was applied: the Welch test if the variances were unequal and the Student’s t-test in the case the variances were equal (see more details about the different versions of the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;t-test for two samples&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;apply steps 1 to 3 for all continuous variables at once&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I had a similar code for ANOVA in case I needed to compare more than two groups.&lt;/p&gt;
&lt;p&gt;The code was doing the job relatively well. Indeed, thanks to this code I was able to test several variables in an automated way in the sense that it compared groups for all variables at once.&lt;/p&gt;
&lt;p&gt;The only thing I had to change from one project to another is that I needed to modify the name of the grouping variable and the numbering of the continuous variables to test (&lt;code&gt;Species&lt;/code&gt; and &lt;code&gt;1:4&lt;/code&gt; in the above code).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;concise-and-easily-interpretable-results&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Concise and easily interpretable results&lt;/h1&gt;
&lt;div id=&#34;t-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;T-test&lt;/h2&gt;
&lt;p&gt;Although it was working quite well and applicable to different projects with only minor changes, I was still unsatisfied with another point.&lt;/p&gt;
&lt;p&gt;Someone who is proficient in statistics and R can read and interpret the output of a t-test without any difficulty. However, as you may have noticed with your own statistical projects, most people do not know what to look for in the results and are sometimes a bit confused when they see so many graphs, code, output, results and numeric values in a document. They are quite easily overwhelmed by this mass of information and unable to extract the key message.&lt;/p&gt;
&lt;p&gt;With my old R routine, the time I was saving by automating the process of t-tests and ANOVA was (partially) lost when I had to explain R outputs to my students so that they could interpret the results correctly. Although most of the time it simply boiled down to pointing out what to look for in the outputs (i.e., &lt;em&gt;p&lt;/em&gt;-values), I was still losing quite a lot of time because these outputs were, in my opinion, too detailed for most real-life applications and for students in introductory classes. In other words, too much information seemed to be confusing for many people so I was still not convinced that it was the most optimal way to share statistical results to nonscientists.&lt;/p&gt;
&lt;p&gt;Of course, they came to me for statistical advices, so they expected to have these results and I needed to give them answers to their questions and hypotheses. Nonetheless, I wanted to find a better way to communicate these results to this type of audience, with the minimum of information required to arrive at a conclusion. No more and no less than that.&lt;/p&gt;
&lt;p&gt;After a long time spent online trying to figure out a way to present results in a more concise and readable way, I discovered the &lt;a href=&#34;https://cran.r-project.org/web/packages/ggpubr/index.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{ggpubr}&lt;/code&gt; package&lt;/a&gt;. This package allows to indicate the test used and the &lt;em&gt;p&lt;/em&gt;-value of the test directly on a ggplot2-based graph. It also facilitates the creation of publication-ready plots for non-advanced statistical audiences.&lt;/p&gt;
&lt;p&gt;After many refinements and modifications of the initial code (available in this &lt;a href=&#34;http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;), I finally came up with a rather stable and robust process to perform t-tests and ANOVA for more than one variable at once, and more importantly, make the results concise and easily readable by anyone (statisticians or not).&lt;/p&gt;
&lt;p&gt;A graph is worth a thousand words, so here are the exact same tests than in the previous section, but this time with my new R routine:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggpubr)

# Edit from here #
x &amp;lt;- which(names(dat) == &amp;quot;Species&amp;quot;) # name of grouping variable
y &amp;lt;- which(names(dat) == &amp;quot;Sepal.Length&amp;quot; # names of variables to test
| names(dat) == &amp;quot;Sepal.Width&amp;quot; |
  names(dat) == &amp;quot;Petal.Length&amp;quot; |
  names(dat) == &amp;quot;Petal.Width&amp;quot;)
method &amp;lt;- &amp;quot;t.test&amp;quot; # one of &amp;quot;wilcox.test&amp;quot; or &amp;quot;t.test&amp;quot;
paired &amp;lt;- FALSE # if paired make sure that in the dataframe you have first all individuals at T1, then all individuals again at T2
# Edit until here


# Edit at your own risk
for (i in y) {
  for (j in x) {
    if (paired == TRUE) {
      p &amp;lt;- ggpaired(dat,
        x = colnames(dat[j]), y = colnames(dat[i]),
        color = colnames(dat[j]), line.color = &amp;quot;gray&amp;quot;, line.size = 0.4,
        palette = &amp;quot;npg&amp;quot;,
        legend = &amp;quot;none&amp;quot;,
        xlab = colnames(dat[j]),
        ylab = colnames(dat[i]),
        add = &amp;quot;jitter&amp;quot;
      )
    } else {
      p &amp;lt;- ggboxplot(dat,
        x = colnames(dat[j]), y = colnames(dat[i]),
        color = colnames(dat[j]),
        palette = &amp;quot;npg&amp;quot;,
        legend = &amp;quot;none&amp;quot;,
        add = &amp;quot;jitter&amp;quot;
      )
    }
    #  Add p-value
    print(p + stat_compare_means(aes(label = paste0(after_stat(method), &amp;quot;, p-value = &amp;quot;, after_stat(p.format))),
      method = method,
      paired = paired,
      # group.by = NULL,
      ref.group = NULL
    ))
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-2-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-2-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-2-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-2-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see from the graphs above, only the most important information is presented for each variable:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a visual comparison of the groups thanks to boxplots&lt;/li&gt;
&lt;li&gt;the name of the &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;the &lt;em&gt;p&lt;/em&gt;-value of the test&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Of course, experts may be interested in more advanced results. However, this simple yet complete graph, which includes the name of the test and the &lt;em&gt;p&lt;/em&gt;-value, gives all the necessary information to answer the question: “Are the groups different?”.&lt;/p&gt;
&lt;p&gt;In my experience, I have noticed that students and professionals (especially those from a less scientific background) understand way better these results than the ones presented in the previous section.&lt;/p&gt;
&lt;p&gt;The only lines of code that need to be modified for your own project is the name of the grouping variable (&lt;code&gt;Species&lt;/code&gt; in the above code), the names of the variables you want to test (&lt;code&gt;Sepal.Length&lt;/code&gt;, &lt;code&gt;Sepal.Width&lt;/code&gt;, etc.),&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; whether you want to apply a &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;t-test&lt;/a&gt; (&lt;code&gt;t.test&lt;/code&gt;) or &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Wilcoxon test&lt;/a&gt; (&lt;code&gt;wilcox.test&lt;/code&gt;) and whether the samples are paired or not (&lt;code&gt;FALSE&lt;/code&gt; if samples are independent, &lt;code&gt;TRUE&lt;/code&gt; if they are paired).&lt;/p&gt;
&lt;p&gt;Based on these graphs, it is easy, even for non-experts, to interpret the results and conclude that the &lt;code&gt;versicolor&lt;/code&gt; and &lt;code&gt;virginica&lt;/code&gt; species are significantly different in terms of all 4 variables (since all &lt;em&gt;p&lt;/em&gt;-values &lt;span class=&#34;math inline&#34;&gt;\(&amp;lt; \frac{0.05}{4} = 0.0125\)&lt;/span&gt; (remind that the Bonferroni correction is applied to avoid the issue of multiple testing, so we divide the usual &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; level by 4 because there are 4 t-tests)).&lt;/p&gt;
&lt;div id=&#34;additional-p-value-adjustment-methods&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Additional &lt;em&gt;p&lt;/em&gt;-value adjustment methods&lt;/h3&gt;
&lt;p&gt;If you would like to use another &lt;em&gt;p&lt;/em&gt;-value adjustment method, you can use the &lt;code&gt;p.adjust()&lt;/code&gt; function. Below are the raw &lt;em&gt;p&lt;/em&gt;-values found above, together with &lt;em&gt;p&lt;/em&gt;-values derived from the main adjustment methods (presented in a dataframe):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;raw_pvalue &amp;lt;- numeric(length = length(1:4))
for (i in (1:4)) {
  raw_pvalue[i] &amp;lt;- t.test(dat[, i] ~ dat$Species,
    alternative = &amp;quot;two.sided&amp;quot;
  )$p.value
}

df &amp;lt;- data.frame(
  Variable = names(dat[, 1:4]),
  raw_pvalue = round(raw_pvalue, 3)
)

df$Bonferroni &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;bonferroni&amp;quot;
  )
df$BH &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;BH&amp;quot;
  )
df$Holm &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;holm&amp;quot;
  )
df$Hochberg &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;hochberg&amp;quot;
  )
df$Hommel &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;hommel&amp;quot;
  )
df$BY &amp;lt;-
  round(p.adjust(df$raw_pvalue,
    method = &amp;quot;BY&amp;quot;
  ), 3)
df&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Variable raw_pvalue Bonferroni    BH  Holm Hochberg Hommel    BY
## 1 Sepal.Length      0.000      0.000 0.000 0.000    0.000  0.000 0.000
## 2  Sepal.Width      0.002      0.008 0.002 0.002    0.002  0.002 0.004
## 3 Petal.Length      0.000      0.000 0.000 0.000    0.000  0.000 0.000
## 4  Petal.Width      0.000      0.000 0.000 0.000    0.000  0.000 0.000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Regardless of the &lt;em&gt;p&lt;/em&gt;-value adjustment method, the two species are different for all 4 variables. Note that the adjustment method should be chosen before looking at the results to avoid choosing the method based on the results.&lt;/p&gt;
&lt;p&gt;Below another function that allows to perform multiple Student’s t-tests or Wilcoxon tests at once and choose the &lt;em&gt;p&lt;/em&gt;-value adjustment method. The function also allows to specify whether samples are paired or unpaired and whether the variances are assumed to be equal or not. (The code has been adapted from Mark White’s &lt;a href=&#34;https://www.markhw.com/blog/t-table&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.)&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;t_table &amp;lt;- function(data, dvs, iv,
                    var_equal = TRUE,
                    p_adj = &amp;quot;none&amp;quot;,
                    alpha = 0.05,
                    paired = FALSE,
                    wilcoxon = FALSE) {
  if (!inherits(data, &amp;quot;data.frame&amp;quot;)) {
    stop(&amp;quot;data must be a data.frame&amp;quot;)
  }

  if (!all(c(dvs, iv) %in% names(data))) {
    stop(&amp;quot;at least one column given in dvs and iv are not in the data&amp;quot;)
  }

  if (!all(sapply(data[, dvs], is.numeric))) {
    stop(&amp;quot;all dvs must be numeric&amp;quot;)
  }

  if (length(unique(na.omit(data[[iv]]))) != 2) {
    stop(&amp;quot;independent variable must only have two unique values&amp;quot;)
  }

  out &amp;lt;- lapply(dvs, function(x) {
    if (paired == FALSE &amp;amp; wilcoxon == FALSE) {
      tres &amp;lt;- t.test(data[[x]] ~ data[[iv]], var.equal = var_equal)
    } else if (paired == FALSE &amp;amp; wilcoxon == TRUE) {
      tres &amp;lt;- wilcox.test(data[[x]] ~ data[[iv]])
    } else if (paired == TRUE &amp;amp; wilcoxon == FALSE) {
      tres &amp;lt;- t.test(data[[x]] ~ data[[iv]],
        var.equal = var_equal,
        paired = TRUE
      )
    } else {
      tres &amp;lt;- wilcox.test(data[[x]] ~ data[[iv]],
        paired = TRUE
      )
    }

    c(
      p_value = tres$p.value
    )
  })

  out &amp;lt;- as.data.frame(do.call(rbind, out))
  out &amp;lt;- cbind(variable = dvs, out)
  names(out) &amp;lt;- gsub(&amp;quot;[^0-9A-Za-z_]&amp;quot;, &amp;quot;&amp;quot;, names(out))

  out$p_value &amp;lt;- p.adjust(out$p_value, p_adj)
  out$conclusion &amp;lt;- ifelse(out$p_value &amp;lt; alpha,
    paste0(&amp;quot;Reject H0 at &amp;quot;, alpha * 100, &amp;quot;%&amp;quot;),
    paste0(&amp;quot;Do not reject H0 at &amp;quot;, alpha * 100, &amp;quot;%&amp;quot;)
  )
  out$p_value &amp;lt;- ifelse(out$p_value &amp;lt; 0.001,
    &amp;quot;&amp;lt;0.001&amp;quot;,
    round(out$p_value, 3)
  )

  return(out)
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Applied to our dataset, with no adjustment method for the &lt;em&gt;p&lt;/em&gt;-values:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;result &amp;lt;- t_table(
  data = dat,
  c(&amp;quot;Sepal.Length&amp;quot;, &amp;quot;Sepal.Width&amp;quot;, &amp;quot;Petal.Length&amp;quot;, &amp;quot;Petal.Width&amp;quot;),
  &amp;quot;Species&amp;quot;
)

result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       variable p_value      conclusion
## 1 Sepal.Length  &amp;lt;0.001 Reject H0 at 5%
## 2  Sepal.Width   0.002 Reject H0 at 5%
## 3 Petal.Length  &amp;lt;0.001 Reject H0 at 5%
## 4  Petal.Width  &amp;lt;0.001 Reject H0 at 5%&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And with the &lt;span class=&#34;citation&#34;&gt;Holm (&lt;a href=&#34;#ref-holm1979simple&#34;&gt;1979&lt;/a&gt;)&lt;/span&gt; adjustment method:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;result &amp;lt;- t_table(
  data = dat,
  c(&amp;quot;Sepal.Length&amp;quot;, &amp;quot;Sepal.Width&amp;quot;, &amp;quot;Petal.Length&amp;quot;, &amp;quot;Petal.Width&amp;quot;),
  &amp;quot;Species&amp;quot;,
  p_adj = &amp;quot;holm&amp;quot;
)

result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       variable p_value      conclusion
## 1 Sepal.Length  &amp;lt;0.001 Reject H0 at 5%
## 2  Sepal.Width   0.002 Reject H0 at 5%
## 3 Petal.Length  &amp;lt;0.001 Reject H0 at 5%
## 4  Petal.Width  &amp;lt;0.001 Reject H0 at 5%&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Again, with the Holm’s adjustment method, we conclude that, at the 5% significance level, the two species are significantly different from each other in terms of all 4 variables.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;anova&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;ANOVA&lt;/h2&gt;
&lt;p&gt;Below the same process with an ANOVA. Note that we reload the dataset &lt;code&gt;iris&lt;/code&gt; to include all three &lt;code&gt;Species&lt;/code&gt; this time:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iris

# Edit from here
x &amp;lt;- which(names(dat) == &amp;quot;Species&amp;quot;) # name of grouping variable
y &amp;lt;- which(names(dat) == &amp;quot;Sepal.Length&amp;quot; # names of variables to test
| names(dat) == &amp;quot;Sepal.Width&amp;quot; |
  names(dat) == &amp;quot;Petal.Length&amp;quot; |
  names(dat) == &amp;quot;Petal.Width&amp;quot;)
method1 &amp;lt;- &amp;quot;anova&amp;quot; # one of &amp;quot;anova&amp;quot; or &amp;quot;kruskal.test&amp;quot;
method2 &amp;lt;- &amp;quot;t.test&amp;quot; # one of &amp;quot;wilcox.test&amp;quot; or &amp;quot;t.test&amp;quot;
my_comparisons &amp;lt;- list(c(&amp;quot;setosa&amp;quot;, &amp;quot;versicolor&amp;quot;), c(&amp;quot;setosa&amp;quot;, &amp;quot;virginica&amp;quot;), c(&amp;quot;versicolor&amp;quot;, &amp;quot;virginica&amp;quot;)) # comparisons for post-hoc tests
# Edit until here


# Edit at your own risk
for (i in y) {
  for (j in x) {
    p &amp;lt;- ggboxplot(dat,
      x = colnames(dat[j]), y = colnames(dat[i]),
      color = colnames(dat[j]),
      legend = &amp;quot;none&amp;quot;,
      palette = &amp;quot;npg&amp;quot;,
      add = &amp;quot;jitter&amp;quot;
    )
    print(
      p + stat_compare_means(aes(label = paste0(after_stat(method), &amp;quot;, p-value = &amp;quot;, after_stat(p.format))),
        method = method1, label.y = max(dat[, i], na.rm = TRUE)
      )
      + stat_compare_means(comparisons = my_comparisons, method = method2, label = &amp;quot;p.format&amp;quot;) # remove if p-value of ANOVA or Kruskal-Wallis test &amp;gt;= alpha
    )
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-7-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-7-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-7-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-7-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Like the improved routine for the t-test, I have noticed that students and non-expert professionals understand ANOVA results presented this way much more easily compared to the default R outputs.&lt;/p&gt;
&lt;p&gt;With one graph for each variable, it is easy to see that all species are different from each other in terms of all 4 variables.&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you want to apply the same automated process to your data, you will need to modify the name of the grouping variable (&lt;code&gt;Species&lt;/code&gt;), the names of the variables you want to test (&lt;code&gt;Sepal.Length&lt;/code&gt;, etc.), whether you want to perform an &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; (&lt;code&gt;anova&lt;/code&gt;) or &lt;a href=&#34;https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/&#34;&gt;Kruskal-Wallis test&lt;/a&gt; (&lt;code&gt;kruskal.test&lt;/code&gt;) and finally specify the comparisons for the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#post-hoc-test&#34;&gt;post-hoc tests&lt;/a&gt;.&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;to-go-even-further&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;To go even further&lt;/h1&gt;
&lt;p&gt;As we have seen, these two improved R routines allow to:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Perform t-tests and ANOVA on a small or large number of variables with only minor changes to the code. I basically only have to replace the variable names and the name of the test I want to use. It takes almost the same time to test one or several variables so it is quite an improvement compared to testing one variable at a time.&lt;/li&gt;
&lt;li&gt;Share test results in a much proper and cleaner way. This is possible thanks to a graph showing the observations by group and the &lt;em&gt;p&lt;/em&gt;-value of the appropriate test included directly on the graph. This is particularly important when communicating results to a wider audience or to people from diverse backgrounds.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;However, like most of my R routines, these two pieces of code are still a work in progress. Below are some additional features I have been thinking of and which could be added in the future to make the process of comparing two or more groups even more optimal:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add the possibility to select variables by their numbering in the dataframe. For the moment it is only possible to do it via their names. This will allow to automate the process even further because instead of typing all variable names one by one, we could simply type &lt;code&gt;4:25&lt;/code&gt; (to test variables 4 to 25 for instance).&lt;/li&gt;
&lt;li&gt;Add the possibility to choose a &lt;em&gt;p&lt;/em&gt;-value adjustment method. Currently, raw &lt;em&gt;p&lt;/em&gt;-values are displayed in the graphs and I manually adjust them afterwards or adjust the &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;When comparing more than two groups, it is only possible to apply an ANOVA or Kruskal-Wallis test at the moment. A major improvement would be to add the possibility to perform a repeated measures ANOVA (i.e., an ANOVA when the samples are dependent). It is currently already possible to do a t-test with two paired samples, but it is not yet possible to do the same with more than two groups.&lt;/li&gt;
&lt;li&gt;Another less important (yet still nice) feature when comparing more than 2 groups would be to automatically apply post-hoc tests only in the case where the null hypothesis of the ANOVA or Kruskal-Wallis test is rejected (so when there is at least one group different from the others, because if the null hypothesis of equal groups is not rejected we do not apply a post-hoc test). At the present time, I manually add or remove the code that displays the &lt;em&gt;p&lt;/em&gt;-values of post-hoc tests depending on the global &lt;em&gt;p&lt;/em&gt;-value of the ANOVA or Kruskal-Wallis test.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I will try to add these features in the future, or I would be glad to help if the author of the &lt;code&gt;{ggpubr}&lt;/code&gt; package needs help in including these features (I hope he will see this article!).&lt;/p&gt;
&lt;p&gt;Last but not least, the following packages may be of interest to some readers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you want to report statistical results on a graph, I advise you to check the &lt;a href=&#34;https://indrajeetpatil.github.io/ggstatsplot/&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{ggstatsplot}&lt;/code&gt; package&lt;/a&gt; and in particular the &lt;code&gt;ggbetweenstats()&lt;/code&gt; and &lt;code&gt;ggwithinstats()&lt;/code&gt; functions. These functions allow to compare a continuous variable across multiple groups or conditions (for both independent and paired samples). Two advantages of the functions is that:
&lt;ul&gt;
&lt;li&gt;it is very easy to switch from parametric to nonparametric tests and&lt;/li&gt;
&lt;li&gt;it automatically runs an ANOVA or t-test depending on the number of groups to compare&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that many different statistical results are displayed on the graph, not only the name of the test and the &lt;em&gt;p&lt;/em&gt;-value so a bit of simplicity and clarity is lost for more precision. However, it is still very convenient to be able to include tests results on a graph in order to combine the advantages of a visualization and a sound statistical analysis. Something that I still need to figure out is how to run the code on several variables at once.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;a href=&#34;https://cloud.r-project.org/web/packages/compareGroups/index.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{compareGroups}&lt;/code&gt; package&lt;/a&gt; also provides a nice way to compare groups. It comes with a really complete Shiny app, available with:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;compareGroups&amp;quot;)
library(compareGroups)
cGroupsWUI()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;update-with-the-ggstatsplot-package&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Update with the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package&lt;/h1&gt;
&lt;p&gt;Several months after having written this article, I finally found a way to plot and run analyses on several variables at once with the package &lt;code&gt;{ggstatsplot}&lt;/code&gt; &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-patil2021ggstatsplot&#34;&gt;Patil 2021&lt;/a&gt;)&lt;/span&gt;. This was the main feature I was missing and which prevented me from using it more often.&lt;/p&gt;
&lt;p&gt;Although I still find that too much statistical details are displayed (in particular for non experts), I still believe the &lt;code&gt;ggbetweenstats()&lt;/code&gt; and &lt;code&gt;ggwithinstats()&lt;/code&gt; functions are worth mentioning in this article. I actually now use those two functions almost as often as my previous routines because:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I do not have to care about the number of groups to compare, the functions automatically choose the appropriate test according to the number of groups (ANOVA for 3 groups or more, and t-test for 2 groups)&lt;/li&gt;
&lt;li&gt;I can select variables based on their column numbering, and not based on their names anymore (which prevents me from writing those variable names manually)&lt;/li&gt;
&lt;li&gt;When comparing 3 or more groups (so for ANOVA, Kruskal-Wallis, repeated measure ANOVA or Friedman), &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values of the post-hoc tests within each dependent variable are by default the adjusted &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values (Holm is the default but many adjustment methods are available)&lt;/li&gt;
&lt;li&gt;It is possible to compare both independent and paired samples, no matter the number of groups (remember that with the &lt;code&gt;ggpubr&lt;/code&gt; package I could only do paired samples for two samples, not for 3 samples)&lt;/li&gt;
&lt;li&gt;They allow to easily switch between the parametric and nonparametric version&lt;/li&gt;
&lt;li&gt;All this in a more concise manner using the &lt;code&gt;{purrr}&lt;/code&gt; package&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For those of you who are interested, below my updated R routine which include these functions and applied this time on the &lt;code&gt;penguins&lt;/code&gt; dataset.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(palmerpenguins)

dat &amp;lt;- penguins
str(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## tibble [344 × 8] (S3: tbl_df/tbl/data.frame)
##  $ species          : Factor w/ 3 levels &amp;quot;Adelie&amp;quot;,&amp;quot;Chinstrap&amp;quot;,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ island           : Factor w/ 3 levels &amp;quot;Biscoe&amp;quot;,&amp;quot;Dream&amp;quot;,..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ bill_length_mm   : num [1:344] 39.1 39.5 40.3 NA 36.7 39.3 38.9 39.2 34.1 42 ...
##  $ bill_depth_mm    : num [1:344] 18.7 17.4 18 NA 19.3 20.6 17.8 19.6 18.1 20.2 ...
##  $ flipper_length_mm: int [1:344] 181 186 195 NA 193 190 181 195 193 190 ...
##  $ body_mass_g      : int [1:344] 3750 3800 3250 NA 3450 3650 3625 4675 3475 4250 ...
##  $ sex              : Factor w/ 2 levels &amp;quot;female&amp;quot;,&amp;quot;male&amp;quot;: 2 1 1 NA 1 2 1 2 NA NA ...
##  $ year             : int [1:344] 2007 2007 2007 2007 2007 2007 2007 2007 2007 2007 ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We illustrate the routine for two groups with the variables &lt;code&gt;sex&lt;/code&gt; (two factors) as independent variable, and the 4 quantitative continuous variables &lt;code&gt;bill_length_mm&lt;/code&gt;, &lt;code&gt;bill_depth_mm&lt;/code&gt;, &lt;code&gt;flipper_length_mm&lt;/code&gt; and &lt;code&gt;body_mass_g&lt;/code&gt; as dependent variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggstatsplot)
library(tibble)

# Comparison between sexes

# edit from here
x &amp;lt;- &amp;quot;sex&amp;quot;
cols &amp;lt;- 3:6 # the 4 continuous dependent variables
type &amp;lt;- &amp;quot;parametric&amp;quot; # given the large number of observations, we use the parametric version
paired &amp;lt;- FALSE # FALSE for independent samples, TRUE for paired samples
# edit until here

# edit at your own risk
plotlist &amp;lt;-
  purrr::pmap(
    .l = list(
      data = list(as_tibble(dat)),
      x = x,
      y = as.list(colnames(dat)[cols]),
      plot.type = &amp;quot;box&amp;quot;, # for boxplot
      type = type, # parametric or nonparametric
      pairwise.comparisons = TRUE, # to run post-hoc tests if more than 2 groups
      pairwise.display = &amp;quot;significant&amp;quot;, # show only significant differences
      bf.message = FALSE, # remove message about Bayes Factor
      centrality.plotting = FALSE # remove central measure
    ),
    .f = ifelse(paired, # automatically use ggwithinstats if paired samples, ggbetweenstats otherwise
      ggstatsplot::ggwithinstats,
      ggstatsplot::ggbetweenstats
    ),
    violin.args = list(width = 0, linewidth = 0) # remove violin plots and keep only boxplots
  )

# print all plots together with statistical results
for (i in 1:length(plotlist)) {
  print(plotlist[[i]])
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-10-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-10-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-10-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-10-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We now illustrate the routine for 3 groups or more with the variable &lt;code&gt;species&lt;/code&gt; (three factors) as independent variable, and the 4 same dependent variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Comparison between species

# edit from here
x &amp;lt;- &amp;quot;species&amp;quot;
cols &amp;lt;- 3:6 # the 4 continuous dependent variables
type &amp;lt;- &amp;quot;parametric&amp;quot; # given the large number of observations, we use the parametric version
paired &amp;lt;- FALSE # FALSE for independent samples, TRUE for paired samples
# edit until here

# edit at your own risk
plotlist &amp;lt;-
  purrr::pmap(
    .l = list(
      data = list(as_tibble(dat)),
      x = x,
      y = as.list(colnames(dat)[cols]),
      plot.type = &amp;quot;box&amp;quot;, # for boxplot
      type = type, # parametric or nonparametric
      pairwise.comparisons = TRUE, # to run post-hoc tests if more than 2 groups
      pairwise.display = &amp;quot;significant&amp;quot;, # show only significant differences
      bf.message = FALSE, # remove message about Bayes Factor
      centrality.plotting = FALSE # remove central measure
    ),
    .f = ifelse(paired, # automatically use ggwithinstats if paired samples, ggbetweenstats otherwise
      ggstatsplot::ggwithinstats,
      ggstatsplot::ggbetweenstats
    ),
    violin.args = list(width = 0, linewidth = 0) # remove violin plots and keep only boxplots
  )

# print all plots together with statistical results
for (i in 1:length(plotlist)) {
  print(plotlist[[i]])
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-11-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-11-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-11-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-11-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, I only have to specify:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the name of the grouping variable (&lt;code&gt;sex&lt;/code&gt; and &lt;code&gt;species&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the number of the dependent variables (variables 3 to 6 in the dataset),&lt;/li&gt;
&lt;li&gt;whether I want to use the parametric or nonparametric version and&lt;/li&gt;
&lt;li&gt;whether samples are independent (&lt;code&gt;paired = FALSE&lt;/code&gt;) or paired (&lt;code&gt;paired = TRUE&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Everything else is automated—the outputs show a graphical representation of what we are comparing, together with the details of the statistical analyses in the subtitle of the plot (the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value among others).&lt;/p&gt;
&lt;p&gt;Note that the code shown above is actually the same if I want to compare 2 groups or more than 2 groups. I wrote twice the same code (once for 2 groups and once again for 3 groups) for illustrative purposes only, but they are the same and should be treated as one for your projects.&lt;/p&gt;
&lt;!-- Feel free to discover the package and see how it works by yourself via this [Shiny app](https://antoinesoetewey.shinyapps.io/ggstatsplotShiny/){target=&#34;_blank&#34;}. --&gt;
&lt;p&gt;I must admit I am quite &lt;strong&gt;satisfied&lt;/strong&gt; with this routine, now that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I can automate it on many variables at once and I do not need to write the variable names manually anymore,&lt;/li&gt;
&lt;li&gt;at the same time, I can choose the appropriate test among all the available ones (depending on the number of groups, whether they are paired or not, and whether I want to use the parametric or nonparametric version).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nonetheless, I must also admit that I am still &lt;strong&gt;not satisfied&lt;/strong&gt; with the level of details of the statistical results. As already mentioned, many students get confused and get lost in front of so much information (except the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value and the number of observations, most of the details are rather obscure to them because they are not covered in introductory statistic classes).&lt;/p&gt;
&lt;p&gt;I saved time thanks to all improvements in comparison to my previous routine, but I definitely lose time when I have to point out to them what they should look for. After discussing with other professors, I noticed that they have the same problem.&lt;/p&gt;
&lt;p&gt;For the moment, you can only print all results or none. I have opened an &lt;a href=&#34;https://github.com/IndrajeetPatil/ggstatsplot/issues/669&#34; target=&#34;_blank&#34;&gt;issue&lt;/a&gt; kindly requesting to add the possibility to display only a summary (with the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value and the name of the test for instance).&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt; I will update again this article if the maintainer of the package includes this feature in the future. So stay tuned!&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 will help you to perform t-tests and ANOVA for multiple variables at once and make the results more easily readable and interpretable by non-scientists. Learn more about the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;t-test&lt;/a&gt; to compare two groups, or the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; to compare 3 groups or more.&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-holm1979simple&#34; class=&#34;csl-entry&#34;&gt;
Holm, Sture. 1979. &lt;span&gt;“A Simple Sequentially Rejective Multiple Test Procedure.”&lt;/span&gt; &lt;em&gt;Scandinavian Journal of Statistics&lt;/em&gt;, 65–70.
&lt;/div&gt;
&lt;div id=&#34;ref-mcdonald2014multiple&#34; class=&#34;csl-entry&#34;&gt;
McDonald, JH. 2014. &lt;span&gt;“Multiple Tests.”&lt;/span&gt; &lt;em&gt;Handbook of Biological Statistics. 3rd Ed Baltimore, Maryland: Sparky House Publishing&lt;/em&gt;, 233–36.
&lt;/div&gt;
&lt;div id=&#34;ref-patil2021ggstatsplot&#34; class=&#34;csl-entry&#34;&gt;
Patil, Indrajeet. 2021. &lt;span&gt;“&lt;span class=&#34;nocase&#34;&gt;Visualizations with statistical details: The &lt;span class=&#34;nocase&#34;&gt;’ggstatsplot’&lt;/span&gt; approach&lt;/span&gt;.”&lt;/span&gt; &lt;em&gt;&lt;span class=&#34;nocase&#34;&gt;Journal of Open Source Software&lt;/span&gt;&lt;/em&gt; 6 (61): 3167. &lt;a href=&#34;https://doi.org/10.21105/joss.03167&#34;&gt;https://doi.org/10.21105/joss.03167&lt;/a&gt;.
&lt;/div&gt;
&lt;/div&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;In theory, an ANOVA can also be used to compare two groups as it will give the same results compared to a Student’s t-test, but in practice we use the Student’s t-test to compare two groups and the ANOVA to compare three groups or more.&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;Do not forget to separate the variables you want to test with &lt;code&gt;|&lt;/code&gt;.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Do not forget to adjust the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values or the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;. If you use the Bonferroni correction, the adjusted &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; is simply the desired &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; level divided by the number of comparisons.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Post-hoc test is only the name used to refer to a specific type of statistical tests. Post-hoc test includes, among others, the Tukey HSD test, the Bonferroni correction, Dunnett’s test. Even if an ANOVA or a Kruskal-Wallis test can determine whether there is at least one group that is different from the others, it does not allow us to conclude &lt;strong&gt;which&lt;/strong&gt; are different from each other. For this purpose, there are post-hoc tests that compare all groups two by two to determine which ones are different, after adjusting for multiple comparisons. Concretely, post-hoc tests are performed to each possible pair of groups &lt;strong&gt;after&lt;/strong&gt; an ANOVA or a Kruskal-Wallis test has shown that there is at least one group which is different (hence “post” in the name of this type of test). The null and alternative hypotheses and the interpretations of these tests are similar to a Student’s t-test for two samples.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;I am open to contribute to the package if I can help!&lt;a href=&#34;#fnref5&#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>Top 100 R resources on COVID-19 Coronavirus</title>
      <link>https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/</link>
      <pubDate>Thu, 12 Mar 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#r-shiny-apps-and-dashboards&#34; id=&#34;toc-r-shiny-apps-and-dashboards&#34;&gt;R Shiny apps and dashboards&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-tracker&#34; id=&#34;toc-coronavirus-tracker&#34;&gt;Coronavirus tracker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-dashboard-from-the-coronavirus-package&#34; id=&#34;toc-coronavirus-dashboard-from-the-coronavirus-package&#34;&gt;Coronavirus dashboard from the &lt;code&gt;{coronavirus} package&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualization-of-covid-19-cases&#34; id=&#34;toc-visualization-of-covid-19-cases&#34;&gt;Visualization of Covid-19 Cases&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#modeling-covid-19-spread-vs-healthcare-capacity&#34; id=&#34;toc-modeling-covid-19-spread-vs-healthcare-capacity&#34;&gt;Modeling COVID-19 Spread vs Healthcare Capacity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-data-visualization-platform&#34; id=&#34;toc-covid-19-data-visualization-platform&#34;&gt;COVID-19 Data Visualization Platform&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-10-day-forecast&#34; id=&#34;toc-coronavirus-10-day-forecast&#34;&gt;Coronavirus 10-day forecast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-covid-19-across-the-world&#34; id=&#34;toc-coronavirus-covid-19-across-the-world&#34;&gt;Coronavirus (COVID-19) across the world&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-outbreak&#34; id=&#34;toc-covid-19-outbreak&#34;&gt;COVID-19 outbreak&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#flatten-the-curve&#34; id=&#34;toc-flatten-the-curve&#34;&gt;Flatten the Curve&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#explore-the-spread-of-covid-19&#34; id=&#34;toc-explore-the-spread-of-covid-19&#34;&gt;Explore the spread of Covid-19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#governments-and-covid-19&#34; id=&#34;toc-governments-and-covid-19&#34;&gt;Governments and COVID-19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#simulating-covid-19-epidemic-in-togo---west-africa&#34; id=&#34;toc-simulating-covid-19-epidemic-in-togo---west-africa&#34;&gt;Simulating COVID-19 Epidemic in Togo - West Africa&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-prediction&#34; id=&#34;toc-covid-19-prediction&#34;&gt;Covid-19 Prediction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-dashboard&#34; id=&#34;toc-covid-19-dashboard&#34;&gt;Covid-19 Dashboard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#healthcare-worker-deaths-from-novel-coronavirus-covid-19-in-the-us&#34; id=&#34;toc-healthcare-worker-deaths-from-novel-coronavirus-covid-19-in-the-us&#34;&gt;Healthcare worker deaths from novel Coronavirus (COVID-19) in the US&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-hospitalizations-in-belgium&#34; id=&#34;toc-covid-19-hospitalizations-in-belgium&#34;&gt;Covid-19 Hospitalizations in Belgium&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covidminder-where-you-live-matters&#34; id=&#34;toc-covidminder-where-you-live-matters&#34;&gt;COVIDMINDER: Where you live matters!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-canada-data-explorer-tool&#34; id=&#34;toc-covid-19-canada-data-explorer-tool&#34;&gt;COVID-19 Canada Data Explorer Tool&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#philippine-covid-19-case-forecasting&#34; id=&#34;toc-philippine-covid-19-case-forecasting&#34;&gt;Philippine COVID-19 Case Forecasting&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-case-death-report-number-corrector&#34; id=&#34;toc-covid-19-case-death-report-number-corrector&#34;&gt;COVID-19 Case &amp;amp; Death Report Number Corrector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-the-spqeir-model&#34; id=&#34;toc-covid-19-the-spqeir-model&#34;&gt;Covid-19: the SPQEIR model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#the-belgian-covid-cases-tracker&#34; id=&#34;toc-the-belgian-covid-cases-tracker&#34;&gt;The Belgian Covid Cases Tracker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-monitor&#34; id=&#34;toc-covid-19-monitor&#34;&gt;COVID-19 monitor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-bulletin-board&#34; id=&#34;toc-covid-19-bulletin-board&#34;&gt;COVID-19 Bulletin Board&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-statistics-displayer&#34; id=&#34;toc-covid-19-statistics-displayer&#34;&gt;Covid-19 Statistics Displayer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronamapper&#34; id=&#34;toc-coronamapper&#34;&gt;CoronaMapper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronadash&#34; id=&#34;toc-coronadash&#34;&gt;CoronaDash&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covidfrance&#34; id=&#34;toc-covidfrance&#34;&gt;Covidfrance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#the-impact-of-covid-19-on-mobility&#34; id=&#34;toc-the-impact-of-covid-19-on-mobility&#34;&gt;The Impact of COVID-19 on Mobility&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-analysis-platform&#34; id=&#34;toc-coronavirus-analysis-platform&#34;&gt;Coronavirus Analysis Platform&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-tracker&#34; id=&#34;toc-covid-19-tracker&#34;&gt;COVID-19 Tracker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-overview&#34; id=&#34;toc-covid-19-overview&#34;&gt;COVID-19 Overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-exit-strategies&#34; id=&#34;toc-covid-19-exit-strategies&#34;&gt;COVID-19 Exit Strategies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#corona-virus-statistics-covid19&#34; id=&#34;toc-corona-virus-statistics-covid19&#34;&gt;Corona Virus Statistics : COVID19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid19-data&#34; id=&#34;toc-covid19-data&#34;&gt;Covid19 Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#who-covid-19-explorer&#34; id=&#34;toc-who-covid-19-explorer&#34;&gt;WHO COVID-19 Explorer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-scenario-analysis-tool&#34; id=&#34;toc-covid-19-scenario-analysis-tool&#34;&gt;COVID-19 Scenario Analysis Tool&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-track&#34; id=&#34;toc-covid-19-track&#34;&gt;Covid-19 track&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#r-packages&#34; id=&#34;toc-r-packages&#34;&gt;R packages&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#ncov2019&#34; id=&#34;toc-ncov2019&#34;&gt;&lt;code&gt;{nCov2019}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus&#34; id=&#34;toc-coronavirus&#34;&gt;&lt;code&gt;{coronavirus}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#tidycovid19&#34; id=&#34;toc-tidycovid19&#34;&gt;&lt;code&gt;{tidycovid19}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#r-packages-from-r-epidemics-consortium&#34; id=&#34;toc-r-packages-from-r-epidemics-consortium&#34;&gt;R packages from R Epidemics Consortium&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covdata&#34; id=&#34;toc-covdata&#34;&gt;&lt;code&gt;{covdata}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid19italy&#34; id=&#34;toc-covid19italy&#34;&gt;&lt;code&gt;{covid19italy}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid19&#34; id=&#34;toc-covid19&#34;&gt;&lt;code&gt;{COVID19}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covoid&#34; id=&#34;toc-covoid&#34;&gt;&lt;code&gt;{COVOID}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#cdccovidview&#34; id=&#34;toc-cdccovidview&#34;&gt;&lt;code&gt;{cdccovidview}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#babsim.hospital&#34; id=&#34;toc-babsim.hospital&#34;&gt;&lt;code&gt;{babsim.hospital}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#epilps&#34; id=&#34;toc-epilps&#34;&gt;&lt;code&gt;{EpiLPS}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#r-code-and-blog-posts&#34; id=&#34;toc-r-code-and-blog-posts&#34;&gt;R code and blog posts&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#analyzing-covid-19-outbreak-data-with-r&#34; id=&#34;toc-analyzing-covid-19-outbreak-data-with-r&#34;&gt;Analyzing COVID-19 outbreak data with R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-data-analysis-with-tidyverse-and-ggplot2&#34; id=&#34;toc-covid-19-data-analysis-with-tidyverse-and-ggplot2&#34;&gt;COVID-19 Data Analysis with &lt;code&gt;{tidyverse}&lt;/code&gt; and &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-cumulative-observed-case-fatality-rate-over-time&#34; id=&#34;toc-covid-19-cumulative-observed-case-fatality-rate-over-time&#34;&gt;COVID-19 cumulative observed case fatality rate over time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-tracking&#34; id=&#34;toc-covid-19-tracking&#34;&gt;Covid 19 Tracking&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#infectious-diseases-and-nonlinear-differential-equations&#34; id=&#34;toc-infectious-diseases-and-nonlinear-differential-equations&#34;&gt;Infectious diseases and nonlinear differential equations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#epidemic-modelling-of-covid-19-in-the-uk-using-an-sir-model&#34; id=&#34;toc-epidemic-modelling-of-covid-19-in-the-uk-using-an-sir-model&#34;&gt;Epidemic modelling of COVID-19 in the UK using an SIR model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#modeling-pandemics&#34; id=&#34;toc-modeling-pandemics&#34;&gt;Modeling Pandemics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-the-case-of-germany&#34; id=&#34;toc-covid-19-the-case-of-germany&#34;&gt;COVID-19: The Case of Germany&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#flatten-the-covid-19-curve&#34; id=&#34;toc-flatten-the-covid-19-curve&#34;&gt;Flatten the COVID-19 Curve&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#flattening-vs-shrinking-the-math-of-flattenthecurve&#34; id=&#34;toc-flattening-vs-shrinking-the-math-of-flattenthecurve&#34;&gt;Flattening vs shrinking: the math of #FlattenTheCurve&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#explaincovid19-challenge&#34; id=&#34;toc-explaincovid19-challenge&#34;&gt;explainCovid19 challenge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#an-r-package-to-explore-the-novel-coronavirus&#34; id=&#34;toc-an-r-package-to-explore-the-novel-coronavirus&#34;&gt;An R Package to explore the Novel Coronavirus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-model-using-r-colombia&#34; id=&#34;toc-coronavirus-model-using-r-colombia&#34;&gt;Coronavirus model using R – Colombia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-the-case-of-spain&#34; id=&#34;toc-covid-19-the-case-of-spain&#34;&gt;COVID-19: The Case of Spain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#tidying-the-new-johns-hopkins-covid-19-time-series-datasets&#34; id=&#34;toc-tidying-the-new-johns-hopkins-covid-19-time-series-datasets&#34;&gt;Tidying the new Johns Hopkins Covid-19 time-series datasets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-in-belgium&#34; id=&#34;toc-covid-19-in-belgium&#34;&gt;COVID-19 in Belgium&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#facts-about-coronavirus-disease-2019-covid-19-in-5-charts-created-with-r-and-ggplot2&#34; id=&#34;toc-facts-about-coronavirus-disease-2019-covid-19-in-5-charts-created-with-r-and-ggplot2&#34;&gt;Facts About Coronavirus Disease 2019 (COVID-19) in 5 Charts created with R and ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#contagiousness-of-covid-19-part-i-improvements-of-mathematical-fitting&#34; id=&#34;toc-contagiousness-of-covid-19-part-i-improvements-of-mathematical-fitting&#34;&gt;Contagiousness of COVID-19 Part I: Improvements of Mathematical Fitting&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coronavirus-spatially-smoothed-decease-in-france-and-decease-animation-map&#34; id=&#34;toc-coronavirus-spatially-smoothed-decease-in-france-and-decease-animation-map&#34;&gt;Coronavirus : spatially smoothed decease in France and decease animation map&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#another-flatten-the-covid-19-curve-simulation-in-r&#34; id=&#34;toc-another-flatten-the-covid-19-curve-simulation-in-r&#34;&gt;Another “flatten the COVID-19 curve” simulation… in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#tracking-covid19-cases-throughout-nj-with-r&#34; id=&#34;toc-tracking-covid19-cases-throughout-nj-with-r&#34;&gt;Tracking Covid19 Cases Throughout NJ with R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#its-fun-to-look-at-the-yacm-yet-another-covid-model&#34; id=&#34;toc-its-fun-to-look-at-the-yacm-yet-another-covid-model&#34;&gt;It’s fun to look at the YACM (Yet Another COVID Model)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#is-covid-19-as-bad-as-all-that-yes-it-probably-is&#34; id=&#34;toc-is-covid-19-as-bad-as-all-that-yes-it-probably-is&#34;&gt;Is COVID-19 as bad as all that? Yes it probably is&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#potential-long-term-intervention-strategies-for-covid-19&#34; id=&#34;toc-potential-long-term-intervention-strategies-for-covid-19&#34;&gt;Potential Long-Term Intervention Strategies for COVID-19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#animations-in-the-time-of-coronavirus&#34; id=&#34;toc-animations-in-the-time-of-coronavirus&#34;&gt;Animations in the time of Coronavirus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-data-and-prediction-for-michigan&#34; id=&#34;toc-covid-19-data-and-prediction-for-michigan&#34;&gt;COVID-19 Data and Prediction for Michigan&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data-visualization-of-covid-19-in-the-us&#34; id=&#34;toc-data-visualization-of-covid-19-in-the-us&#34;&gt;Data Visualization of COVID-19 in the US&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#the-spread-of-covid-19-across-countries-visualization-with-r&#34; id=&#34;toc-the-spread-of-covid-19-across-countries-visualization-with-r&#34;&gt;The spread of COVID-19 across countries visualization with R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-and-rural-areas-in-the-u.s&#34; id=&#34;toc-covid-19-and-rural-areas-in-the-u.s&#34;&gt;Covid-19 and Rural Areas in the U.S&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-death-rates-is-the-data-correct&#34; id=&#34;toc-covid-death-rates-is-the-data-correct&#34;&gt;Covid Death Rates: Is the data correct?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-risk-heat-maps-with-location-data-apache-arrow-markov-chain-modeling-and-r-shiny&#34; id=&#34;toc-covid-19-risk-heat-maps-with-location-data-apache-arrow-markov-chain-modeling-and-r-shiny&#34;&gt;COVID-19 Risk Heat Maps with Location Data, Apache Arrow, Markov Chain Modeling, and R Shiny&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-tracker-indonesia&#34; id=&#34;toc-covid-19-tracker-indonesia&#34;&gt;COVID-19 Tracker Indonesia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-projections-using-machine-learning&#34; id=&#34;toc-covid-19-projections-using-machine-learning&#34;&gt;COVID-19 Projections Using Machine Learning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-in-belgium-is-it-over-yet&#34; id=&#34;toc-covid-19-in-belgium-is-it-over-yet&#34;&gt;COVID-19 in Belgium: is it over yet?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-cases-by-ethnicity&#34; id=&#34;toc-covid-19-cases-by-ethnicity&#34;&gt;COVID-19 Cases by Ethnicity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#tennessee-covid-19-update&#34; id=&#34;toc-tennessee-covid-19-update&#34;&gt;Tennessee COVID-19 Update&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#simulating-coronavirus-outbreak-in-cities-with-origin-destination-matrix-and-seir-model&#34; id=&#34;toc-simulating-coronavirus-outbreak-in-cities-with-origin-destination-matrix-and-seir-model&#34;&gt;Simulating Coronavirus Outbreak in Cities with Origin-Destination Matrix and SEIR Model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-population-mobility---how-has-human-mobility-changed-under-the-covid-19-pandemic&#34; id=&#34;toc-covid-19-population-mobility---how-has-human-mobility-changed-under-the-covid-19-pandemic&#34;&gt;COVID-19 Population Mobility - How has human mobility changed under the COVID-19 Pandemic?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-build-covid-19-data-driven-shiny-apps-in-5-minutes&#34; id=&#34;toc-how-to-build-covid-19-data-driven-shiny-apps-in-5-minutes&#34;&gt;How to Build COVID-19 Data-Driven Shiny Apps in 5 minutes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#analyzing-data-from-covid19-r-package&#34; id=&#34;toc-analyzing-data-from-covid19-r-package&#34;&gt;Analyzing data from COVID19 R package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#body-mass-and-risk-from-covid-19-and-influenza&#34; id=&#34;toc-body-mass-and-risk-from-covid-19-and-influenza&#34;&gt;Body Mass and Risk from COVID-19 and Influenza&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hmd-weekly-data&#34; id=&#34;toc-hmd-weekly-data&#34;&gt;HMD – Weekly Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#guest-posts-on-chris-muirs-blog&#34; id=&#34;toc-guest-posts-on-chris-muirs-blog&#34;&gt;Guest posts on Chris Muir’s blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#an-r-view-into-epidemiology&#34; id=&#34;toc-an-r-view-into-epidemiology&#34;&gt;An R View into Epidemiology&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#articles-by-rob-j-hyndman&#34; id=&#34;toc-articles-by-rob-j-hyndman&#34;&gt;Articles by Rob J Hyndman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#turkey-vs.-germany-covid-19&#34; id=&#34;toc-turkey-vs.-germany-covid-19&#34;&gt;Turkey vs. Germany: COVID-19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hands-on-how-to-build-an-interactive-map-in-r-shiny-an-example-for-the-covid-19-dashboard&#34; id=&#34;toc-hands-on-how-to-build-an-interactive-map-in-r-shiny-an-example-for-the-covid-19-dashboard&#34;&gt;Hands-on: How to build an interactive map in R-Shiny: An example for the COVID-19 Dashboard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#modelling-covid-19-in-morocco&#34; id=&#34;toc-modelling-covid-19-in-morocco&#34;&gt;Modelling COVID-19 in Morocco&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sir-models-with-kermack-and-mckendrick&#34; id=&#34;toc-sir-models-with-kermack-and-mckendrick&#34;&gt;SIR models with Kermack and McKendrick&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#johns-hopkins-covid-19-data-and-r&#34; id=&#34;toc-johns-hopkins-covid-19-data-and-r&#34;&gt;Johns Hopkins Covid-19 Data and R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#estimating-covid-19s-r_t-in-real-time&#34; id=&#34;toc-estimating-covid-19s-r_t-in-real-time&#34;&gt;Estimating COVID-19’s &lt;span class=&#34;math inline&#34;&gt;\(R_t\)&lt;/span&gt; in Real-Time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#from-static-to-animated-time-series-the-tidyverse-way&#34; id=&#34;toc-from-static-to-animated-time-series-the-tidyverse-way&#34;&gt;From static to animated time series: the tidyverse way&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sneak-peek-new-summit-data-tool-helps-clients-visualize-us-areas-that-are-most-heavily-impacted-by-the-covid-19-virus&#34; id=&#34;toc-sneak-peek-new-summit-data-tool-helps-clients-visualize-us-areas-that-are-most-heavily-impacted-by-the-covid-19-virus&#34;&gt;Sneak peek: new Summit data tool helps clients visualize US areas that are most heavily impacted by the COVID-19 virus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-reproduce-financial-times-style-covid19-daily-reporting&#34; id=&#34;toc-how-to-reproduce-financial-times-style-covid19-daily-reporting&#34;&gt;How to Reproduce Financial Times Style COVID19 Daily Reporting?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#what-can-tweets-about-contact-tracing-apps-tell-us-about-attitudes-towards-data-sharing-for-public-health&#34; id=&#34;toc-what-can-tweets-about-contact-tracing-apps-tell-us-about-attitudes-towards-data-sharing-for-public-health&#34;&gt;What can tweets about contact tracing apps tell us about attitudes towards data sharing for public health?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualizing-covid-cases-in-belgium&#34; id=&#34;toc-visualizing-covid-cases-in-belgium&#34;&gt;Visualizing COVID cases in Belgium&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#a-spatio-temporal-analysis-of-the-environmental-correlates-of-covid-19-incidence-in-spain&#34; id=&#34;toc-a-spatio-temporal-analysis-of-the-environmental-correlates-of-covid-19-incidence-in-spain&#34;&gt;A spatio-temporal analysis of the environmental correlates of COVID-19 incidence in Spain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#covid-19-analysis&#34; id=&#34;toc-covid-19-analysis&#34;&gt;Covid-19 Analysis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#a-simple-way-to-gather-all-coronavirus-related-data-with-r&#34; id=&#34;toc-a-simple-way-to-gather-all-coronavirus-related-data-with-r&#34;&gt;A Simple Way to Gather all Coronavirus Related Data with R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#australian-governments-can-choose-to-slow-the-spread-of-coronavirus-but-they-would-need-to-act-immediately&#34; id=&#34;toc-australian-governments-can-choose-to-slow-the-spread-of-coronavirus-but-they-would-need-to-act-immediately&#34;&gt;Australian governments can choose to slow the spread of coronavirus, but they would need to act immediately&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#does-covid-raise-everyones-relative-risk-of-dying-by-a-similar-amount-more-evidence&#34; id=&#34;toc-does-covid-raise-everyones-relative-risk-of-dying-by-a-similar-amount-more-evidence&#34;&gt;Does Covid raise everyone’s relative risk of dying by a similar amount? More evidence&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#tracking-coronavirus-building-parameterized-reports-to-analyze-changing-data-sources&#34; id=&#34;toc-tracking-coronavirus-building-parameterized-reports-to-analyze-changing-data-sources&#34;&gt;Tracking Coronavirus: Building Parameterized Reports to Analyze Changing Data Sources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#mapping-nz-cases-of-covid-19&#34; id=&#34;toc-mapping-nz-cases-of-covid-19&#34;&gt;Mapping NZ cases of COVID-19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualize-the-pandemic-with-r-covid-19&#34; id=&#34;toc-visualize-the-pandemic-with-r-covid-19&#34;&gt;Visualize the Pandemic with R #COVID-19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#exploring-the-temporal-evolution-of-covid-19-cases-in-the-united-states&#34; id=&#34;toc-exploring-the-temporal-evolution-of-covid-19-cases-in-the-united-states&#34;&gt;Exploring the Temporal Evolution of COVID-19 Cases in the United States&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#r-data-analysis-covid-19&#34; id=&#34;toc-r-data-analysis-covid-19&#34;&gt;R Data Analysis: COVID-19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ga-covid-19-reports&#34; id=&#34;toc-ga-covid-19-reports&#34;&gt;GA COVID-19 Reports&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#corona-in-belgium&#34; id=&#34;toc-corona-in-belgium&#34;&gt;Corona in Belgium&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#the-coronavirus-in-italy-from-the-twitters-point-of-view&#34; id=&#34;toc-the-coronavirus-in-italy-from-the-twitters-point-of-view&#34;&gt;The Coronavirus in Italy from the Twitter’s Point of View&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#use-r-and-tidycensus-to-look-at-covid-19-risk-factors&#34; id=&#34;toc-use-r-and-tidycensus-to-look-at-covid-19-risk-factors&#34;&gt;Use R and Tidycensus to Look at COVID-19 Risk Factors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#animating-u.s.-covid-19-hotspots-over-time&#34; id=&#34;toc-animating-u.s.-covid-19-hotspots-over-time&#34;&gt;Animating U.S. COVID-19 hotspots over time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#understanding-covid19-in-connecticut.-it-takes-a-town&#34; id=&#34;toc-understanding-covid19-in-connecticut.-it-takes-a-town&#34;&gt;Understanding COVID19 in Connecticut. It takes a town&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#other-lists-or-collections-of-resources&#34; id=&#34;toc-other-lists-or-collections-of-resources&#34;&gt;Other lists or collections of resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#non-english-resources&#34; id=&#34;toc-non-english-resources&#34;&gt;Non-english 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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/top-r-resources-on-coronavirus-covid-19.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Warning: Some links or resources may have been moved or deleted, and are thus not accessible anymore. If you are the author and would like to update the URL, feel free to contact me so I can update the link.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The Coronavirus is a serious concern around the globe. With its expansion, there are also more and more online resources about it. This article presents a selection of the best R resources on the COVID-19 virus.&lt;/p&gt;
&lt;p&gt;This list is by no means exhaustive. I am not aware of all R resources available online about the Coronavirus, so please feel free to let me know in the comments or by &lt;a href=&#34;https://statsandr.com/contact/&#34;&gt;contacting me&lt;/a&gt; if you believe that another resource (R package, Shiny app, R code, blog posts, datasets, etc.) deserves to be on this list.&lt;/p&gt;
&lt;div id=&#34;r-shiny-apps-and-dashboards&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;R Shiny apps and dashboards&lt;/h1&gt;
&lt;div id=&#34;coronavirus-tracker&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coronavirus tracker&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/r-shiny-app-coronavirus-john-coene.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by John Coene, this &lt;a href=&#34;https://shiny.john-coene.com/coronavirus/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; tracks the spread of the Coronavirus, based on three data sources (John Hopkins, Weixin and DXY Data). The Shiny app, built with shinyMobile (which makes it responsive on different screen sizes), presents in a really nice way the number of deaths, confirmed, suspected and recovered cases by time and region.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/JohnCoene/coronavirus&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus-dashboard-from-the-coronavirus-package&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coronavirus dashboard from the &lt;code&gt;{coronavirus} package&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Coronavirus%20dashboard%20from%20the%20coronavirus%20R%20package.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by the author of the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#coronavirus&#34;&gt;&lt;code&gt;{coronavirus} package&lt;/code&gt;&lt;/a&gt;, this &lt;a href=&#34;https://ramikrispin.github.io/coronavirus_dashboard/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic. The data and dashboard are refreshed on a daily basis.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/RamiKrispin/coronavirus_dashboard&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;From this dashboard, I created another &lt;a href=&#34;https://www.antoinesoetewey.com/files/coronavirus-dashboard.html&#34; target=&#34;_blank&#34;&gt;dashboard specific to Belgium&lt;/a&gt;. Feel free to use the code available on &lt;a href=&#34;https://github.com/AntoineSoetewey/coronavirus_dashboard&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt; to build one specific to your country. See more details in this &lt;a href=&#34;https://statsandr.com/blog/how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r/&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization-of-covid-19-cases&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualization of Covid-19 Cases&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Visualization-of-Covid-19-Cases-R-shiny-app.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Nico Hahn, this &lt;a href=&#34;https://nicohahn.shinyapps.io/covid19/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; uses leaflet, plotly and the data from Johns Hopkins University to visualize the outbreak of the novel Coronavirus and shows data for the entire world or singular countries.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/nicoFhahn/covid_shiny&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;modeling-covid-19-spread-vs-healthcare-capacity&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Modeling COVID-19 Spread vs Healthcare Capacity&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Modeling%20COVID-19%20Spread%20vs%20Healthcare%20Capacity%20R%20shiny%20app.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Dr. Alison Hill, this &lt;a href=&#34;https://alhill.shinyapps.io/COVID19seir/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; uses an epidemiological model based on the classic SEIR model to describe the spread and clinical progression of COVID-19. It includes different clinical trajectories of infection, interventions to reduce transmission, and comparisons to healthcare capacity.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/alsnhll/SEIR_COVID19&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-data-visualization-platform&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Data Visualization Platform&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Data%20Visualization%20Platform%20R%20Shiny%20app.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Shubhram Pandey, this &lt;a href=&#34;https://shubhrampandey.shinyapps.io/coronaVirusViz/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; provides a clear visualization of Covid19 impact all over the world and it also provides a sentiment analysis using natural language processing from Twitter.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/shubhrampandey/coronaVirus-dataViz&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus-10-day-forecast&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coronavirus 10-day forecast&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Coronavirus-10-day-forecast-R-shiny-app.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by the Spatial Ecology and Evolution Lab, this &lt;a href=&#34;http://covid19forecast.science.unimelb.edu.au/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; gives a ten-day forecast, by country, on likely numbers of Coronavirus cases and gives citizens a sense of how fast this epidemic is progressing.&lt;/p&gt;
&lt;p&gt;See a detailed explanation of the app and how to read it in this &lt;a href=&#34;https://blphillipsresearch.wordpress.com/2020/03/12/coronavirus-forecast/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt;. The code is available on &lt;a href=&#34;https://github.com/benflips/nCovForecast&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus-covid-19-across-the-world&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coronavirus (COVID-19) across the world&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/shiny%20app%20Coronavirus%20(COVID-19)%20Across%20The%20World.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Anisa Dhana in collaboration with datascience+, this &lt;a href=&#34;https://dash.datascienceplus.com/covid19/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; monitors the spread of COVID-19 across the world via a map visualization of the confirmed cases and some graphs on the growth of the virus.&lt;/p&gt;
&lt;p&gt;The dataset used is from &lt;a href=&#34;https://github.com/CSSEGISandData/COVID-19&#34; target=&#34;_blank&#34;&gt;Johns Hopkins CSSE&lt;/a&gt; and part of the code is available in this &lt;a href=&#34;https://datascienceplus.com/map-visualization-of-covid19-across-world&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-outbreak&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 outbreak&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Covid-19-outbreak-interactive-shiny-app.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Dr. Thibaut Fabacher in collaboration with the department of Public Health of the Strasbourg University Hospital and the Laboratory of Biostatistics and Medical Informatics of the Strasbourg Medicine Faculty, this &lt;a href=&#34;https://thibautfabacher.shinyapps.io/covid-19/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; shows an interactive map for global monitoring of the infection. It focuses on the evolution of the number of cases per country and for a given period in terms of incidence and prevalence.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/DrFabach/Corona&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt; and this &lt;a href=&#34;https://r-posts.com/covid-19-interactive-map-using-r-with-shiny-leaflet-and-dplyr/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; discusses it in more detail.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;flatten-the-curve&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Flatten the Curve&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Flatten%20the%20Curve.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Tinu Schneider, this &lt;a href=&#34;https://tinu.shinyapps.io/Flatten_the_Curve/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; illustrates, in an interactive way, the different scenarios behind the #FlattenTheCurve message.&lt;/p&gt;
&lt;p&gt;The app has been built upon Michael Höhle’s &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#flatten-the-covid-19-curve&#34;&gt;article&lt;/a&gt; and the code is available on &lt;a href=&#34;https://github.com/tinu-schneider/Flatten_the_Curve&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;explore-the-spread-of-covid-19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Explore the spread of Covid-19&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/explore%20the%20spread%20of%20covid-19%20R%20shiny%20app.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Joachim Gassen, this &lt;a href=&#34;https://jgassen.shinyapps.io/tidycovid19/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; allows you to visualize confirmed, recovered cases and reported deaths for several countries via one summary graph.&lt;/p&gt;
&lt;p&gt;The Shiny app is based on data from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/CSSEGISandData/COVID-19&#34; target=&#34;_blank&#34;&gt;Johns Hopkins University CSSE team&lt;/a&gt; on the spread of the SARS-CoV-2 virus&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.acaps.org/covid19-government-measures-dataset&#34; target=&#34;_blank&#34;&gt;ACAPS governmental measures database&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://data.worldbank.org/&#34; target=&#34;_blank&#34;&gt;World Bank&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This &lt;a href=&#34;https://joachim-gassen.github.io/2020/03/meet-tidycovid19-yet-another-covid-19-related-r-package/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; explains the Shiny app in further details and in particular the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#tidycovid19&#34;&gt;&lt;code&gt;{tidycovid19}&lt;/code&gt; R package&lt;/a&gt; behind it.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;governments-and-covid-19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Governments and COVID-19&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Governments%20and%20COVID-19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Sebastian Engel-Wolf, this &lt;a href=&#34;https://sebastianwolf.shinyapps.io/Corona-Shiny/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; presents in a elegant way the following measurements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Maximum time of exponential growth in a row&lt;/li&gt;
&lt;li&gt;Days to double infections&lt;/li&gt;
&lt;li&gt;Exponential growth today&lt;/li&gt;
&lt;li&gt;Confirmed cases&lt;/li&gt;
&lt;li&gt;Deaths&lt;/li&gt;
&lt;li&gt;Population&lt;/li&gt;
&lt;li&gt;Confirmed cases on 100,000 inhabitants&lt;/li&gt;
&lt;li&gt;Mortality rate&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/zappingseb/coronashiny&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt; and this &lt;a href=&#34;https://mail-wolf.de/?p=4632&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; explains it in further details.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;simulating-covid-19-epidemic-in-togo---west-africa&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Simulating COVID-19 Epidemic in Togo - West Africa&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Simulating%20COVID-19%20Epidemic%20in%20Togo%20-%20West%20Africa%20R%20shiny%20app.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Dr. Kankoé Sallah, this &lt;a href=&#34;https://c2m-africa.shinyapps.io/togo-covid-shiny/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; uses SEIR metapopulation model with mobility between catchment areas to describe country level spread of COVID-19 and the impact of interventions in Togo, West Africa.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-prediction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid-19 Prediction&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Covid-19%20Prediction.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Manuel Oviedo and Manuel Febrero (Modestya research group of the University of Santiago de Compostela), this &lt;a href=&#34;http://modestya.securized.net/covid19prediction/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; predicts the growth rate at 5-day horizon using the evolution during the last 15 days of growth rate. Three functional regression models are fitted and re-estimated when new data is available. The app also shows an interactive plot and table for the expected number of accumulated cases and new daily cases to each horizon (for confirmed and deaths responses) by country (from &lt;a href=&#34;https://github.com/CSSEGISandData/COVID-19&#34; target=&#34;_blank&#34;&gt;Johns Hopkins CSSE&lt;/a&gt;) and Spanish region (from &lt;a href=&#34;https://covid19.isciii.es/&#34; target=&#34;_blank&#34;&gt;ISCII&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;See an explanation of the methodology in the About tab.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-dashboard&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid-19 Dashboard&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/CoVid-19%20Dahsboard.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Philippe De Brouwer, this &lt;a href=&#34;http://www.de-brouwer.com/about/covid.html#covid&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; displays several key measures regarding the outbreak of the virus (by country or for all countries combined), together with some forecasts, a world map and other interactive plots.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;healthcare-worker-deaths-from-novel-coronavirus-covid-19-in-the-us&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Healthcare worker deaths from novel Coronavirus (COVID-19) in the US&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Healthcare%20worker%20deaths%20from%20novel%20Coronavirus%20(COVID-19)%20in%20the%20US.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Jonathan Gross, this &lt;a href=&#34;https://jontheepi.shinyapps.io/hcwcoronavirus/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; visualizes healthcare worker deaths from Coronavirus (COVID-19) in the US reported in the news. It is updated daily and the code is available on &lt;a href=&#34;https://github.com/jontheepi/hcwcoronavirus&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-hospitalizations-in-belgium&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid-19 Hospitalizations in Belgium&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Covid-19%20Hospitalizations%20in%20Belgium.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Jean-Michel Bodart, this &lt;a href=&#34;https://rpubs.com/JMBodart/Covid19-hosp-be&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; provides an overview of the evolution of Covid-19-related hospitalizations in Belgium, by region and province.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/jmbo1190/Covid19&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covidminder-where-you-live-matters&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVIDMINDER: Where you live matters!&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVIDMINDER-%20Where%20you%20live%20matters!.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by The Rensselaer Institute for Data Exploration and Applications, this &lt;a href=&#34;https://covidminder.idea.rpi.edu/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; reveals the regional disparities in outcomes, determinants and medications (e.g., mortality rates, test cases, diabetes, and hospital beds) across United States, with a special focus on New York.&lt;/p&gt;
&lt;p&gt;This &lt;a href=&#34;https://towardsdatascience.com/covidminder-where-you-live-matters-rshiny-and-leaflet-based-visualization-tool-168e3857dbf2&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; explains the Shiny app in more detail and the code is available on &lt;a href=&#34;https://github.com/TheRensselaerIDEA/COVIDMINDER&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-canada-data-explorer-tool&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Canada Data Explorer Tool&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Canada%20Data%20Explorer%20Tool.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Petr Baranovskiy from Data Enthusiast’s Blog, this &lt;a href=&#34;https://dataenthusiast.ca/apps/covid_ca/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; processes the official dataset available from the Government of Canada and shows several indicators related to the SARS-CoV-2 epidemic in Canada.&lt;/p&gt;
&lt;p&gt;This &lt;a href=&#34;https://dataenthusiast.ca/2020/covid-19-canada-data-explorer/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; details the application in further detail.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;philippine-covid-19-case-forecasting&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Philippine COVID-19 Case Forecasting&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Philippine%20COVID-19%20Case%20Forecasting.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Jamal Kay Rogers and Yvonne Grace Arandela, this &lt;a href=&#34;https://jamalrogersapp.shinyapps.io/tsforecast/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; provides a 5-day forecast of confirmed positive, deaths, and recoveries of COVID-19 cases in The Philippines.&lt;/p&gt;
&lt;p&gt;The app also delivers graphical plots of a 10-day forecast and the daily and cumulated cases of COVID-19 in The Philippines. The data source is Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-case-death-report-number-corrector&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Case &amp;amp; Death Report Number Corrector&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Case%20&amp;amp;%20Death%20Report%20Number%20Corrector.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Matt Maciejewski, this &lt;a href=&#34;https://pharmhax.shinyapps.io/covid-corrector-shiny/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; focuses on the correction of underreported Covid-19 case and death counts using a reference country based on &lt;a href=&#34;https://www.medrxiv.org/content/10.1101/2020.03.14.20036178v2&#34; target=&#34;_blank&#34;&gt;Lachmann et al. (2020)&lt;/a&gt;, and via a multiplicative estimator for total deaths and cases. The estimator will be turned into a posterior prediction once data becomes available.&lt;/p&gt;
&lt;p&gt;The app is explained in more detail in this &lt;a href=&#34;https://www.neurosynergy.io/articles/fixingcovid-19underreporting&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; and the code of the Shiny app can be found on &lt;a href=&#34;https://github.com/pharmhax/covid19-corrector&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-the-spqeir-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid-19: the SPQEIR model&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Covid-19%20the%20SPQEIR%20model.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by several researchers from the Luxembourg Centre for Systems Biomedicine (LCSB) of the University of Luxembourg, the KU Leuven and the UGent, this &lt;a href=&#34;https://jose-ameijeiras.shinyapps.io/SPQEIR_model/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; uses the new &lt;a href=&#34;https://www.medrxiv.org/content/10.1101/2020.04.22.20075804v1&#34; target=&#34;_blank&#34;&gt;SPQEIR model&lt;/a&gt; to simulate the impact of various suppression strategies (social distancing, lockdown, protection, etc.) on the development of COVID-19.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-belgian-covid-cases-tracker&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The Belgian Covid Cases Tracker&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/The%20Belgian%20Covid%20Cases%20Tracker%20shiny%20app.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Patrick Sciortino, this &lt;a href=&#34;https://psciortino.shinyapps.io/BelgianCovidCasesTracker/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; aims at estimating the curve of true Covid-19 cases based on the idea that a hospitalized case in time &lt;em&gt;t&lt;/em&gt; informs us about an infection that took place a few days earlier.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-monitor&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 monitor&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20monitor.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Trafford Data Lab, this &lt;a href=&#34;https://trafforddatalab.shinyapps.io/covid-19/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; visualizes daily confirmed Coronavirus cases and deaths in the UK.&lt;/p&gt;
&lt;p&gt;It uses the following data sources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.ecdc.europa.eu/en/publications-data/download-todays-data-geographic-distribution-covid-19-cases-worldwide&#34; target=&#34;_blank&#34;&gt;European Centre for Disease Prevention and Control&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.gov.uk/government/publications/covid-19-track-coronavirus-cases&#34; target=&#34;_blank&#34;&gt;Public Health England&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.bsg.ox.ac.uk/research/research-projects/coronavirus-government-response-tracker&#34; target=&#34;_blank&#34;&gt;Blavatnik School of Government, Oxford University&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The code can be found on &lt;a href=&#34;https://github.com/traffordDataLab/covid-19&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-bulletin-board&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Bulletin Board&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Bulletin%20Board.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Wei Su, this &lt;a href=&#34;https://covid-2019.live/en/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; shows real-time visualization of the COVID-19 epidemic in Japan. It mainly shows various indicators including, but not limited to, PCR test, positive confirmed, hospital discharge and death, as well as trends in each prefecture in Japan. There are also a variety of charts such as cluster network, new confirmed cases in log scale for users’ reference.&lt;/p&gt;
&lt;p&gt;The dashboard is based on this &lt;a href=&#34;https://covid-2019.live/&#34; target=&#34;_blank&#34;&gt;Japanese version&lt;/a&gt; (developed by the same author). The code can be found on &lt;a href=&#34;https://github.com/swsoyee/2019-ncov-japan&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-statistics-displayer&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid-19 Statistics Displayer&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Covid-19%20Statistics%20Displayer.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Created by Carl Sansfaçon, this &lt;a href=&#34;http://moduloinfo.ca/wordpress/&#34; target=&#34;_blank&#34;&gt;Wordpress plugin&lt;/a&gt; associates R &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; graphics&lt;/a&gt; with ARIMA forecast and PHP coding to show evolution of the confirmed, death and recovered cases in different countries, states/provinces and US cities.&lt;/p&gt;
&lt;p&gt;It uses &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#data&#34;&gt;data&lt;/a&gt; from the COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University. The plugin can be installed as a &lt;a href=&#34;https://wordpress.org/plugins/covid-19-statistics-displayer/&#34; target=&#34;_blank&#34;&gt;Wordpress plugin&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronamapper&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;CoronaMapper&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/coronascreen.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Supported by OxyLabs, created by Paolo Montemurro and Peter, this &lt;a href=&#34;http://coronamapper.com/&#34; target=&#34;_blank&#34;&gt;visualization&lt;/a&gt; displays the four days average growth indicator, which clearly shows how a certain statistic of the virus is evolving over time, filtering out the noise.&lt;/p&gt;
&lt;p&gt;The website receives data each hour from several official data-sources, and visualizes the historical evolution of COVID19 in an intuitive &amp;amp; interactive way.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronadash&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;CoronaDash&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/CoronaDash.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Peter Laurinec, this &lt;a href=&#34;https://petolau.shinyapps.io/coronadash/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; provides various data mining and visualization techniques for comparing countries’ COVID-19 data statistics as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extrapolating total confirmed cases by exponential smoothing model,&lt;/li&gt;
&lt;li&gt;trajectories of cases/deaths spread,&lt;/li&gt;
&lt;li&gt;multidimensional clustering of countries’ data/ statistics - with dendrogram and table of clusters averages,&lt;/li&gt;
&lt;li&gt;aggregated views for the whole world,&lt;/li&gt;
&lt;li&gt;hierarchical clustering of countries’ trajectories based on DTW distance and preprocessing by SMA (+ normalization), for fast comparison of a large number of countries’ COVID-19 magnitudes and trends.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This &lt;a href=&#34;https://petolau.github.io/CoronaDash-hierarchical-clustering-countries-trajectories/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; explained in further detail the last point of the above list. The code of the app is available on &lt;a href=&#34;https://github.com/PetoLau/CoronaDash&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covidfrance&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covidfrance&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Pressiat.JPG&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Guillaume Pressiat, this &lt;a href=&#34;https://guillaumepressiat.shinyapps.io/covidfrance/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; illustrates the evolution of number of hospitalizations, intensive care units, recoveries and deaths in France (by department).&lt;/p&gt;
&lt;p&gt;This &lt;a href=&#34;https://guillaumepressiat.github.io//blog/2020/05/covidview&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; presents the application and the code of the app is available on &lt;a href=&#34;https://gist.github.com/GuillaumePressiat/0e3658624e42f763e3e6a67df92bc6c5&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-impact-of-covid-19-on-mobility&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The Impact of COVID-19 on Mobility&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/google_mobility_plot-COVID19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Dimiter Toshkov, this &lt;a href=&#34;https://dimiter.shinyapps.io/covid-19_mobility/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; shows relative changes in mobility (visits and length of stay) for a specific category of places within a country compared to a baseline. The baseline is computed as the median for the day of the week during the 5-week period between January 3 and February 6, 2020. Hence, the plot shows how mobility has changed relative to the situation in the same country in the beginning of the year.&lt;/p&gt;
&lt;p&gt;The author also developed a version for the &lt;a href=&#34;https://dimiter.shinyapps.io/COVID-19-US-Mobility/&#34; target=&#34;_blank&#34;&gt;US states&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Data is from &lt;a href=&#34;https://www.google.com/covid19/mobility/&#34; target=&#34;_blank&#34;&gt;Google Community Mobility Reports&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus-analysis-platform&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coronavirus Analysis Platform&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Corona%20Virus%20Analysis%20Platform.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Khaled M Alqahtani, this &lt;a href=&#34;https://drkhalid.shinyapps.io/covid19/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; offers a powerful analysis tools, including:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Descriptive analysis&lt;/li&gt;
&lt;li&gt;Growth rate and curve flatting&lt;/li&gt;
&lt;li&gt;Cumulative forecast&lt;/li&gt;
&lt;li&gt;Daily cases forecasting containing 16 different models&lt;/li&gt;
&lt;li&gt;Newspaper analysis&lt;/li&gt;
&lt;li&gt;TV analysis&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Data is from &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#data&#34;&gt;Johns Hopkins CSSE&lt;/a&gt; and some GDELT APIs.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-tracker&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Tracker&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Tracker.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Dr. Magda Bucholc from Ulster University, this &lt;a href=&#34;https://nicovidtracker.org/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; reports cases at the local government district in Northern Ireland and county level across the island of Ireland, providing gender and age breakdowns of reported cases, growth rates, and statistics per 100,000 of the population; it also has daily mobility data from Google and Apple.&lt;/p&gt;
&lt;p&gt;More information about this dashboard can be found &lt;a href=&#34;https://www.ulster.ac.uk/news/2020/june/ulster-university-covid-19-tracker-compares-ni-and-roi-data-on-coronavirus-testing,-positive-cases-and-deaths&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-overview&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Overview&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Overview.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Fabian Dablander, Alexandra Rusu, Marcel Schreiner, and Aleksandar Tomasevic as part of the Science versus Corona project, this &lt;a href=&#34;https://scienceversuscorona.shinyapps.io/covid-overview/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; provides an overview of confirmed cases, deaths, and measures that countries have taken to curb the spread of the virus.&lt;/p&gt;
&lt;p&gt;For a more information about this dashboard, see this &lt;a href=&#34;https://scienceversuscorona.com/visualising-the-covid-19-pandemic/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-exit-strategies&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Exit Strategies&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Interactive%20exploration%20of%20COVID-19%20exit%20strategies.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed as part of the Science versus Corona project, this &lt;a href=&#34;https://scienceversuscorona.shinyapps.io/covid-exit/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; compares several alternative exit strategies that either aim to keep the number of infections as low as possible (e.g., contact tracing), or that aim to develop herd immunity without exceeding health care capacity.&lt;/p&gt;
&lt;p&gt;The Shiny app is based on the stochastic individual-based SEIR model developed by &lt;span class=&#34;citation&#34;&gt;de Vlas and Coffeng (&lt;a href=&#34;#ref-de2020phased&#34; role=&#34;doc-biblioref&#34;&gt;2020&lt;/a&gt;)&lt;/span&gt;. This &lt;a href=&#34;https://fabiandablander.com/r/Covid-Exit.html&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; explains the Shiny app in more detail.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;corona-virus-statistics-covid19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Corona Virus Statistics : COVID19&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/alenazi-covid19-dashboard.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Dr. Mohammed N. Alenezi, this &lt;a href=&#34;https://m-alenezi.shinyapps.io/CoronaKW3/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; displays the latest information about Coronavirus for Kuwait, GCC, and the world. The dashboard contains a collection of different plots and models presented under 8 tabs.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid19-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid19 Data&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Covid19%20Data.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Dhafer Malouche, this &lt;a href=&#34;https://malouche.github.io/covid19data/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; presents statistics for more than 200 countries and regions, with the estimation of the reproduction number &lt;span class=&#34;math inline&#34;&gt;\(R(t)\)&lt;/span&gt; in the previous 60 days and a Covid19 country classification.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;who-covid-19-explorer&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;WHO COVID-19 Explorer&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/WHO%20COVID-19%20Explorer.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by the World Health Organization (WHO), this &lt;a href=&#34;https://worldhealthorg.shinyapps.io/covid/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; aims to provide frequently updated data visualizations about confirmed cases and deaths at the global, regional and country level.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-scenario-analysis-tool&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Scenario Analysis Tool&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Scenario%20Analysis%20Tool.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by the MRC Centre for Global Infectious Disease Analysis (Imperial College London), this &lt;a href=&#34;https://www.covidsim.org/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; illustrates the epidemic trajectory, the healthcare demand and the &lt;span class=&#34;math inline&#34;&gt;\(R_t\)&lt;/span&gt; &amp;amp; &lt;span class=&#34;math inline&#34;&gt;\(R_{eff}\)&lt;/span&gt; measures for many countries over time in interactive plots.&lt;/p&gt;
&lt;p&gt;The dashboard uses the &lt;a href=&#34;https://github.com/mrc-ide/squire&#34; target=&#34;_blank&#34;&gt;squire&lt;/a&gt; R package, among others.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-track&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid-19 track&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/covid19-track-redzuan.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Redzuan, this Shiny &lt;a href=&#34;https://redzuana.shinyapps.io/covid_track/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt; analyses, combines and harmonizes the latest Covid-19 data into progress timeline, comparative analysis on various areas, mapping, latest news, forecasting using various models, prediction on Herd Immunity target, summary table, downloadable fact sheet and other features.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;r-packages&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;R packages&lt;/h1&gt;
&lt;div id=&#34;ncov2019&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{nCov2019}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/nCov2019%20R%20package%20for%20studying%20COVID-19%20coronavirus%20outbreak.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/GuangchuangYu/nCov2019&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{nCov2019}&lt;/code&gt; package&lt;/a&gt; gives you access to epidemiological data on the Coronavirus outbreak.&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; The package gives real-time statistics, includes historical data and a Shiny app. The &lt;a href=&#34;https://guangchuangyu.github.io/nCov2019/&#34; target=&#34;_blank&#34;&gt;vignette&lt;/a&gt; explains the main functions and possibilities of the package.&lt;/p&gt;
&lt;p&gt;Furthermore, the authors of the package also developed a &lt;a href=&#34;http://www.bcloud.org/e/&#34; target=&#34;_blank&#34;&gt;website&lt;/a&gt; with interactive plots and time-series forecasts, which could be useful in informing the public and studying how the virus spread in populous countries.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{coronavirus}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/coronavirus%20R%20package.png&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Rami Krispin, the &lt;a href=&#34;https://github.com/RamiKrispin/coronavirus&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{coronavirus} package&lt;/code&gt;&lt;/a&gt; provides a tidy format dataset of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic. Pulled from the dataset of &lt;a href=&#34;https://github.com/CSSEGISandData/COVID-19&#34; target=&#34;_blank&#34;&gt;John Hopkins&lt;/a&gt;, the R package gives a daily summary of the Coronavirus cases by state/province. The data set contains various variables such as confirmed cases, death, and recovered across different countries and states.&lt;/p&gt;
&lt;p&gt;More details are available &lt;a href=&#34;https://ramikrispin.github.io/coronavirus/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;, a &lt;code&gt;csv&lt;/code&gt; format of the package dataset is available &lt;a href=&#34;https://github.com/RamiKrispin/coronavirus-csv&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; and a summary dashboard is available &lt;a href=&#34;https://ramikrispin.github.io/coronavirus_dashboard/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tidycovid19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{tidycovid19}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/%7Btidycovid19%7D%20Yet%20another%20Covid-19%20related%20R%20Package.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Joachim Gassen, the &lt;a href=&#34;https://github.com/joachim-gassen/tidycovid19&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{tidycovid19}&lt;/code&gt; package&lt;/a&gt; allows you to download, tidy and visualize Covid-19 related data (including data on governmental measures) directly from authoritative sources. It also provides a flexible function and an accompanying &lt;a href=&#34;https://jgassen.shinyapps.io/tidycovid19/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; to visualize the spreading of the virus.&lt;/p&gt;
&lt;p&gt;The package is available on &lt;a href=&#34;https://github.com/joachim-gassen/tidycovid19&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt; and these blog posts &lt;a href=&#34;https://joachim-gassen.github.io/2020/03/meet-tidycovid19-yet-another-covid-19-related-r-package/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;https://joachim-gassen.github.io/2020/04/tidycovid19-new-viz-and-npi_lifting/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; explain it in more detail.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;r-packages-from-r-epidemics-consortium&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;R packages from R Epidemics Consortium&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/R%20packages%20from%20R%20Epidemics%20Consortium%20to%20analyze%20COVID-19%20outbreak.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;These &lt;a href=&#34;https://www.repidemicsconsortium.org/projects/&#34; target=&#34;_blank&#34;&gt;R packages&lt;/a&gt; from R Epidemics Consortium allows you to find the most advanced tools used by professional epidemiologists and experts in the domain of analyzing disease outbreaks.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covdata&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{covdata}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/covdata%20R%20package%20COVID-19%20datasets.png&#34; style=&#34;width:50.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Prof. Kieran Healy, the &lt;a href=&#34;https://kjhealy.github.io/covdata/&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{covdata}&lt;/code&gt; package&lt;/a&gt; is a R package providing COVID-19 case data from multiple sources:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;National level data from the &lt;a href=&#34;https://www.ecdc.europa.eu/en&#34; target=&#34;_blank&#34;&gt;European Centers for Disease Control&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;State-level data for the United States from the &lt;a href=&#34;https://covidtracking.com/&#34; target=&#34;_blank&#34;&gt;COVID Tracking Project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;State-level and county-level data for the United States from the &lt;a href=&#34;https://github.com/nytimes/covid-19-data&#34; target=&#34;_blank&#34;&gt;New York Times&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Data from the US Centers for Disease Control’s &lt;a href=&#34;https://www.cdc.gov/coronavirus/2019-ncov/covid-data/covidview/index.html&#34; target=&#34;_blank&#34;&gt;Coronavirus Disease 2019 (COVID-19)-Associated Hospitalization Surveillance Network&lt;/a&gt; (COVID-NET)&lt;/li&gt;
&lt;li&gt;Data from &lt;a href=&#34;https://www.apple.com/covid19/mobility&#34; target=&#34;_blank&#34;&gt;Apple&lt;/a&gt; on relative trends in mobility in cities and countries since mid-January of 2020, based on usage of their Maps application&lt;/li&gt;
&lt;li&gt;Data from &lt;a href=&#34;https://www.google.com/covid19/mobility/index.html?hl=en&#34; target=&#34;_blank&#34;&gt;Google&lt;/a&gt; on relative trends in mobility in regions and countries since mid-January of 2020, based on location and activity information&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/kjhealy/covdata/&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid19italy&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{covid19italy}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/covid19italy%20r%20package.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/Covid19R/covid19italy&#34; target=&#34;_blank&#34;&gt;covid19italy R package&lt;/a&gt; provides a tidy format dataset of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) pandemic outbreak in Italy. The package includes the following three datasets:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;italy_total&lt;/code&gt;: daily summary of the outbreak on the national level&lt;/li&gt;
&lt;li&gt;&lt;code&gt;italy_region&lt;/code&gt;: daily summary of the outbreak on the region level&lt;/li&gt;
&lt;li&gt;&lt;code&gt;italy_province&lt;/code&gt;: daily summary of the outbreak on the province level&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;More information about the package datasets available in this &lt;a href=&#34;https://covid19r.github.io/covid19italy/articles/intro.html&#34; target=&#34;_blank&#34;&gt;vignette&lt;/a&gt;, this &lt;a href=&#34;https://ramikrispin.github.io/2020/05/covid19italy-v0-2-0-is-now-on-cran/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt;, and this supporting &lt;a href=&#34;https://ramikrispin.github.io/italy_dash/&#34; target=&#34;_blank&#34;&gt;dashboard&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Data source: &lt;a href=&#34;http://www.protezionecivile.it/&#34; target=&#34;_blank&#34;&gt;Italy Department of Civil Protection&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{COVID19}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID19%20R%20package.png&#34; style=&#34;width:50.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The goal of &lt;a href=&#34;https://covid19datahub.io/&#34; target=&#34;_blank&#34;&gt;COVID-19 Data Hub&lt;/a&gt; is to provide the research community with a unified data hub by collecting worldwide fine-grained case data, merged with exogenous variables helpful for a better understanding of COVID-19. Featured by the University of Milano and funded by the &lt;a href=&#34;https://ivado.ca/en/covid-19/#phares&#34; target=&#34;_blank&#34;&gt;Institute for Data Valorization IVADO&lt;/a&gt;, Canada.&lt;/p&gt;
&lt;p&gt;The package collects COVID-19 data across governmental sources, includes policy measures from &lt;a href=&#34;https://www.bsg.ox.ac.uk/research/research-projects/coronavirus-government-response-tracker&#34; target=&#34;_blank&#34;&gt;Oxford COVID-19 Government Response Tracker&lt;/a&gt;, and extends the dataset via an interface to &lt;a href=&#34;https://data.worldbank.org/&#34; target=&#34;_blank&#34;&gt;World Bank Open Data&lt;/a&gt;, &lt;a href=&#34;https://www.google.com/covid19/mobility/&#34; target=&#34;_blank&#34;&gt;Google Mobility Reports&lt;/a&gt; and &lt;a href=&#34;https://www.apple.com/covid19/mobility&#34; target=&#34;_blank&#34;&gt;Apple Mobility Reports&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The package is available on &lt;a href=&#34;https://cloud.r-project.org/package=COVID19&#34; target=&#34;_blank&#34;&gt;CRAN&lt;/a&gt;, it is 100% &lt;a href=&#34;https://github.com/covid19datahub/COVID19/&#34; target=&#34;_blank&#34;&gt;open source&lt;/a&gt; and external contributors are welcomed to join.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covoid&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{COVOID}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVOID%20R%20package.png&#34; style=&#34;width:50.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://cbdrh.github.io/covoidance/&#34; target=&#34;_blank&#34;&gt;COVOID&lt;/a&gt; (for &lt;strong&gt;COV&lt;/strong&gt;ID-19 &lt;strong&gt;O&lt;/strong&gt;pen-source &lt;strong&gt;I&lt;/strong&gt;nfection &lt;strong&gt;D&lt;/strong&gt;ynamics project) is a R package for modelling COVID-19 and other infectious diseases using deterministic compartmental models (DCMs).&lt;/p&gt;
&lt;p&gt;It contains a built-in &lt;a href=&#34;https://cbdrh.shinyapps.io/covoidance/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; enabling easy use and demonstration of key concepts to those without R programming backgrounds, along with an expanding API for simulating and estimating homogeneous and age-structured SIR, SEIR and extended models. In particular COVOID allows the simultaneous simulation of age specific (e.g. school closures) and general interventions over varying time intervals.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/CBDRH/covoid&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;cdccovidview&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{cdccovidview}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/%7Bcdccovidview%7D%20—%20To%20Work%20with%20the%20U.S.%20CDC’s%20New%20COVID-19%20Trackers-%20COVIDView%20and%20COVID-NET.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Bob Rudis, the &lt;a href=&#34;https://cinc.rud.is/web/packages/cdccovidview/index.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{cdccovidview}&lt;/code&gt; package&lt;/a&gt; can be used to work with the U.S. CDC’s New COVID-19 Trackers: &lt;a href=&#34;https://www.cdc.gov/coronavirus/2019-ncov/covid-data/covidview/index.html&#34; target=&#34;_blank&#34;&gt;COVIDView&lt;/a&gt; and &lt;a href=&#34;https://gis.cdc.gov/grasp/COVIDNet/COVID19_3.html&#34; target=&#34;_blank&#34;&gt;COVID-NET&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;babsim.hospital&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{babsim.hospital}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/BaBSim.Hospital%20R%20package.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by several researchers from TH Köln, the &lt;a href=&#34;https://CRAN.R-project.org/package=babsim.hospital&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{babsim.hospital}&lt;/code&gt; package&lt;/a&gt; implements a discrete-event simulation model for a hospital resource planning problem. It can be used by health departments to forecast demand for intensive care beds, ventilators, and staff resources.&lt;/p&gt;
&lt;p&gt;The team also developed a &lt;a href=&#34;https://covid-resource-sim.th-koeln.de/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; which predicts COVID-19 ICU bed resources in hospitals. The app is available in English and German.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;epilps&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{EpiLPS}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/EpiLPS.PNG&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by several researchers working in the field of epidemiology, the package shows how to smooth epidemic curves and estimate the time-varying reproduction number in a flexible way.&lt;/p&gt;
&lt;p&gt;More information can be found in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the &lt;a href=&#34;https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1010618&#34;&gt;research paper&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;the accompanying &lt;a href=&#34;https://epilps.com/&#34;&gt;website&lt;/a&gt;, and&lt;/li&gt;
&lt;li&gt;this &lt;a href=&#34;https://statsandr.com/blog/paper-epilps-a-fast-and-flexible-bayesian-tool-for-estimation-of-the-time-varying-reproduction-number/&#34;&gt;summary&lt;/a&gt; written by one of the authors.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;r-code-and-blog-posts&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;R code and blog posts&lt;/h1&gt;
&lt;div id=&#34;analyzing-covid-19-outbreak-data-with-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Analyzing COVID-19 outbreak data with R&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Analyzing%20COVID-19%20outbreak%20data%20with%20R.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Tim Churches, these two articles (&lt;a href=&#34;https://timchurches.github.io/blog/posts/2020-02-18-analysing-covid-19-2019-ncov-outbreak-data-with-r-part-1/&#34; target=&#34;_blank&#34;&gt;part 1&lt;/a&gt; and &lt;a href=&#34;https://timchurches.github.io/blog/posts/2020-03-01-analysing-covid-19-2019-ncov-outbreak-data-with-r-part-2/&#34; target=&#34;_blank&#34;&gt;part 2&lt;/a&gt;) explore the R tools and packages that might be used to analyze the COVID-19 data. In particular, the author considers when the pandemic will subside in China, and then turns the analysis on Japan, South Korea, Italy and Iran. He also shows improvements on the cumulative incidence plots that are so common. Moreover, he presents R code to analyze how contagious is the Coronavirus thanks to the classic SIR (Susceptible-Infectious-Recovered) compartmental model of communicable disease outbreaks.&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;The code is available on GitHub (&lt;a href=&#34;https://github.com/timchurches/blog/tree/master/_posts/2020-02-18-analysing-covid-19-2019-ncov-outbreak-data-with-r-part-1&#34; target=&#34;_blank&#34;&gt;part 1&lt;/a&gt; and &lt;a href=&#34;https://github.com/timchurches/blog/tree/master/_posts/2020-03-01-analysing-covid-19-2019-ncov-outbreak-data-with-r-part-2&#34; target=&#34;_blank&#34;&gt;part 2&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Part 1 is actually based on another shorter blog post by Prof. Dr. Holger K. von Jouanne-Diedrich from &lt;a href=&#34;https://blog.ephorie.de/&#34; target=&#34;_blank&#34;&gt;Learning Machines&lt;/a&gt;. Read his &lt;a href=&#34;https://blog.ephorie.de/epidemiology-how-contagious-is-novel-coronavirus-2019-ncov&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; for a more concise analysis on how to model the outbreak of the Coronavirus and discover how contagious it is. Note that I have personally written an article analyzing &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium/&#34;&gt;COVID-19 in Belgium&lt;/a&gt; based on articles from these two authors.&lt;/p&gt;
&lt;p&gt;More recently, Tim Churches published a series of other interesting articles:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Modelling the effect of various public health interventions on the local epidemic spread of COVID-19 infection using stochastic individual compartmental models (ICMs) implemented by the &lt;code&gt;{EpiModel}&lt;/code&gt; package for R:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://timchurches.github.io/blog/posts/2020-03-10-modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-1/&#34; target=&#34;_blank&#34;&gt;Part 1&lt;/a&gt; (code &lt;a href=&#34;https://github.com/timchurches/blog/tree/master/_posts/2020-03-10-modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-1&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://timchurches.github.io/blog/posts/2020-03-18-modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-2/&#34; target=&#34;_blank&#34;&gt;Part 2&lt;/a&gt; (code &lt;a href=&#34;https://github.com/timchurches/blog/tree/master/_posts/2020-03-18-modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-2&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rviews.rstudio.com/2020/03/19/simulating-covid-19-interventions-with-r/&#34; target=&#34;_blank&#34;&gt;The use of simulations to explore the effects of various interventions on COVID-19 spread&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rviews.rstudio.com/2020/03/05/covid-19-epidemiology-with-r/&#34; target=&#34;_blank&#34;&gt;COVID-19 epidemiology with R&lt;/a&gt;: in this blog post, the author, using relatively early and partial US data, separates out inbound from community cases, and predicts the next few weeks of incident numbers. He also highlights several R functions to analyze a disease outbreak.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://newsroom.unsw.edu.au/news/health/we-can-shrink-covid-19-curve-rather-just-flatten-it&#34; target=&#34;_blank&#34;&gt;We can “shrink” the COVID-19 curve, rather than just flatten it&lt;/a&gt; (in collaboration with Louisa Jorm)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-data-analysis-with-tidyverse-and-ggplot2&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Data Analysis with &lt;code&gt;{tidyverse}&lt;/code&gt; and &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Coronavirus%20-%20cases%20by%20country%20in%20R.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Dr. Yanchang Zhao from RDataMining published a data analysis around the Coronavirus with the &lt;code&gt;{tidyverse}&lt;/code&gt; and &lt;code&gt;{ggplot2}&lt;/code&gt; packages, for &lt;a href=&#34;http://www.rdatamining.com/docs/Coronavirus-data-analysis-china.pdf&#34; target=&#34;_blank&#34;&gt;China&lt;/a&gt; and &lt;a href=&#34;http://www.rdatamining.com/docs/Coronavirus-data-analysis-world.pdf&#34; target=&#34;_blank&#34;&gt;world wide&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Both documents are a mix of data cleaning, data processing and visualizations of the confirmed/cured cases and death rates across countries or regions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-cumulative-observed-case-fatality-rate-over-time&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 cumulative observed case fatality rate over time&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20cumulative%20observed%20case%20fatality%20rate%20over%20time.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Peter Ellis, this &lt;a href=&#34;http://freerangestats.info/blog/2020/03/17/covid19-cfr&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; focuses on how the observed case fatality rate of COVID-19 has evolved over time across 7 countries and comments on why the rates vary (low testing rates, age of the population, overwhelmed hospitals, etc.).&lt;/p&gt;
&lt;p&gt;The code is available at the end of the article. The data is from John Hopkins and it uses the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#coronavirus&#34;&gt;&lt;code&gt;{coronavirus} package&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;More recently, the author published a series of other articles:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;http://freerangestats.info/blog/2020/03/21/covid19-cfr-demographics&#34; target=&#34;_blank&#34;&gt;Impact of a country’s age breakdown on COVID-19 case fatality rate&lt;/a&gt;: it looks at estimated fatalities in different countries according to the age distributions in those countries (based on Italy’s data). The data is from The Istituto Superiore di Sanità (Roma) and all the code is shown in the post.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://freerangestats.info/blog/2020/04/06/crazy-fox-y-axis&#34; target=&#34;_blank&#34;&gt;How to make that crazy Fox News y axis chart with ggplot2 and scales&lt;/a&gt;: less about COVID19 than about how a bizarre Fox News graph can be re-created with the correct transformations needed to make its scale appropriate.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://freerangestats.info/blog/2020/05/09/covid-population-incidence&#34; target=&#34;_blank&#34;&gt;Test positivity rates and actual incidence and growth of diseases&lt;/a&gt;: this blog post looks at several different ways of accounting for the information given to us by high positive testing rates for COVID-19 and looks at the impact on estimates of effective reproduction number at a point in time.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://freerangestats.info/blog/2020/05/17/covid-texas-incidence&#34; target=&#34;_blank&#34;&gt;Incidence of COVID-19 in Texas after adjusting for test positivity&lt;/a&gt;: the author examines the trends in COVID-19 cases in Texas, with and without being adjusted by a multiplier of the square root of the test positivity rate.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-tracking&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid 19 Tracking&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Coronavirus%20Covid%2019%20Tracking.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Prof. Kieran Healy, this &lt;a href=&#34;https://kieranhealy.org/blog/archives/2020/03/21/covid-19-tracking/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; discusses how to get an overview of best-available counts of deaths, using the &lt;a href=&#34;https://www.ecdc.europa.eu/en/publications-data/download-todays-data-geographic-distribution-covid-19-cases-worldwide&#34; target=&#34;_blank&#34;&gt;COVID-19 Data from the European Centers for Disease Control&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Code can be found in the article and on &lt;a href=&#34;https://github.com/kjhealy/covid&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;More recently, the author published three other articles:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://kieranhealy.org/blog/archives/2020/03/27/a-covid-small-multiple/&#34; target=&#34;_blank&#34;&gt;A COVID Small Multiple&lt;/a&gt;: this article discusses how to create a small-multiple plot of cases by country, showing the trajectory of the outbreak for a large number of countries, with the background of each small-multiple panel also showing (in grey) the trajectory of every other country for comparison.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/A%20COVID%20Small%20Multiple.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://kieranhealy.org/blog/archives/2020/04/23/apples-covid-mobility-data/&#34; target=&#34;_blank&#34;&gt;Apple’s COVID Mobility Data&lt;/a&gt;: this article uses Apple’s time series mobility data for several cities and countries (via the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#covdata&#34;&gt;&lt;code&gt;{covdata}&lt;/code&gt; package&lt;/a&gt;) to plot three modes of getting around: driving, public transit, and walking. The series begins on January 13th indexed to 100 at the beginning of the series, so trends are relative to that baseline.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Apple&amp;#39;s%20COVID%20Mobility%20Data.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://kieranhealy.org/blog/archives/2020/04/28/new-orleans-and-normalization/&#34; target=&#34;_blank&#34;&gt;New Orleans and Normalization&lt;/a&gt;: this article responds to a thoughtful &lt;a href=&#34;https://leancrew.com/all-this/2020/04/small-multiples-and-normalization/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; by Dr. Drang regarding an improvement in normalization of the data.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/New%20Orleans%20and%20Normalization-Healy.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;infectious-diseases-and-nonlinear-differential-equations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Infectious diseases and nonlinear differential equations&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Infectious%20diseases%20and%20nonlinear%20differential%20equations.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Fabian Dablander, this math intensive &lt;a href=&#34;https://fabiandablander.com/r/Nonlinear-Infection.html&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; explains what SIR and SIRS models take into account and how they calculate their results.&lt;/p&gt;
&lt;p&gt;From a pandemic perspective, the author writes “The SIRS model extends the SIR model, allowing the recovered population to become susceptible again (hence the extra ‘S’). It assumes that the susceptible population increases proportional to the recovered population”.&lt;/p&gt;
&lt;p&gt;More recently, the author, in collaboration with other researchers, published another &lt;a href=&#34;https://scienceversuscorona.com/visualising-the-covid-19-pandemic/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; outlining a number of excellent visualizations of the COVID19 pandemic, as well as presenting their own &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#covid-19-overview&#34;&gt;dashboard&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;epidemic-modelling-of-covid-19-in-the-uk-using-an-sir-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Epidemic modelling of COVID-19 in the UK using an SIR model&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Epidemic%20modelling%20of%20COVID-19%20in%20the%20UK%20using%20an%20SIR%20model.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Thomas Wilding, this &lt;a href=&#34;https://tjwilding.wordpress.com/2020/03/20/epidemic-modelling-of-covid-19-in-the-uk-using-an-sir-model/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; applies the SIR model to UK data.&lt;/p&gt;
&lt;p&gt;As further extensions to the model, the author suggests:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using an SEIR model (adding an Exposed compartment for people who are infected but not yet infectious)&lt;/li&gt;
&lt;li&gt;Adding a “Q” layer since a lot of people are being Quarantined or isolated&lt;/li&gt;
&lt;li&gt;Considering the “hidden”” population that is infected but is denied being tested due to shortage of tests&lt;/li&gt;
&lt;li&gt;Feasibility of a second wave / outbreak of the epidemic later in the year (as seen in previous outbreaks, such as Swine Flu)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Data sources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/2020_coronavirus_pandemic_in_the_United_Kingdom&#34; target=&#34;_blank&#34;&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.worldometers.info/coronavirus/country/uk/&#34; target=&#34;_blank&#34;&gt;Worldometers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.theguardian.com/world/2020/mar/23/coronavirus-uk-how-many-confirmed-cases-are-in-your-area&#34; target=&#34;_blank&#34;&gt;The Guardian&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;modeling-pandemics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Modeling Pandemics&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/MODELING%20PANDEMICS.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Arthur Charpentier, this series of 3 blog post (&lt;a href=&#34;https://freakonometrics.hypotheses.org/60482&#34; target=&#34;_blank&#34;&gt;part 1&lt;/a&gt;, &lt;a href=&#34;https://freakonometrics.hypotheses.org/60543&#34; target=&#34;_blank&#34;&gt;part 2&lt;/a&gt;, &lt;a href=&#34;https://freakonometrics.hypotheses.org/60514&#34; target=&#34;_blank&#34;&gt;part 3&lt;/a&gt;) walks through the SIR model and its parameters, how ODEquations solves it, and generating the reproductive rate. It also gives a mathematical explanation of a model for how quickly a pandemic will return, albeit with diminishing intensity. Last, it explains a model that is more sophisticated than SIR, the SEIR model, and illustrates it with Ebola data.&lt;/p&gt;
&lt;p&gt;More recently, the author published another &lt;a href=&#34;https://freakonometrics.hypotheses.org/60900&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; which examines what proportion of the population in various U.S. states have been tested for the novel Coronavirus and tries to answer the following two questions:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;How many people are tested on a daily basis?&lt;/li&gt;
&lt;li&gt;What are we actually testing for?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Last but not least, this &lt;a href=&#34;https://freakonometrics.hypotheses.org/60931&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; reproduces one of his scientific paper entitled “&lt;a href=&#34;https://hal.archives-ouvertes.fr/hal-02572966&#34; target=&#34;_blank&#34;&gt;COVID-19 pandemic control: balancing detection policy and lockdown intervention under ICU sustainability&lt;/a&gt;”.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-the-case-of-germany&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19: The Case of Germany&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20The%20Case%20of%20Germany.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Prof. Dr. Holger K. von Jouanne-Diedrich from Learning Machines, this &lt;a href=&#34;https://blog.ephorie.de/covid-19-the-case-of-germany&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; uses the SIR model and German data to estimate the duration and severity of the pandemic.&lt;/p&gt;
&lt;p&gt;Download the data from &lt;a href=&#34;https://interaktiv.morgenpost.de/corona-virus-karte-infektionen-deutschland-weltweit/data/Coronavirus.history.v2.csv&#34; target=&#34;_blank&#34;&gt;Morgenpost&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;More recently, the author published other articles:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.ephorie.de/covid-19-in-the-us-back-of-the-envelope-calculation-of-actual-infections-and-future-deaths&#34; target=&#34;_blank&#34;&gt;COVID-19 in the US: Back-of-the-Envelope Calculation of Actual Infections and Future Deaths&lt;/a&gt;: Working back from reported deaths from Covid19, the post shows how to estimate infections at a prior date, based on several assumptions about fatality rates and infected periods (and acknowledging many unknowns and data problems).&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.ephorie.de/covid-19-analyze-mobility-trends-with-r&#34; target=&#34;_blank&#34;&gt;How to analyze mobility trends with R&lt;/a&gt; using anonymized and aggregated &lt;a href=&#34;https://www.apple.com/covid19/mobility&#34; target=&#34;_blank&#34;&gt;Apple’s mobility data&lt;/a&gt; available to the public. The article presents a R function to return the data in a well-structured format for countries and major cities, and to visualize the drop in vehicular and pedestrian movement caused by the pandemic.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Analyze%20Mobility%20Trends%20with%20R%20using%20apple%20mobility%20data.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.ephorie.de/covid-19-false-positive-alarm&#34; target=&#34;_blank&#34;&gt;COVID-19: False Positive Alarm&lt;/a&gt;, demonstrating the importance of infection rates on the likelihood that someone testing positive for the Coronavirus is actually positive.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;flatten-the-covid-19-curve&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Flatten the COVID-19 Curve&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Flatten%20the%20COVID-19%20curve.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Michael Höhle from Theory meets practice, this &lt;a href=&#34;https://staff.math.su.se/hoehle/blog/2020/03/16/flatteningthecurve.html&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; discusses why the message of flattening the COVID-19 curve is right, but why some of the visualizations used to show the effect are wrong: Reducing the basic reproduction number does not just stretch the outbreak, it also reduces the final size of the outbreak.&lt;/p&gt;
&lt;p&gt;From a pandemic point of view, the author writes “Because of limited health capacities, stretching out the outbreak over a longer time period will ensure, that a larger proportion of those in need of hospital treatment will actually get it. Other advantages of this approach are to win time in order to find better treatment forms and, possibly, to eventually develop a vaccine”.&lt;/p&gt;
&lt;p&gt;A &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#flatten-the-curve&#34;&gt;Shiny app&lt;/a&gt; has also been built upon this article to investigate different scenarios.&lt;/p&gt;
&lt;p&gt;In a second article entitled “&lt;a href=&#34;https://staff.math.su.se/hoehle/blog/2020/04/15/effectiveR0.html&#34; target=&#34;_blank&#34;&gt;Effective reproduction number estimation&lt;/a&gt;”, Michael Höhle estimates with the &lt;code&gt;{R0}&lt;/code&gt; package the time-varying effective reproduction number during an infectious disease outbreak such as COVID-19. Using a single simulated outbreak he compares the performance of three different estimation methods.&lt;/p&gt;
&lt;p&gt;More recently, in this &lt;a href=&#34;https://staff.math.su.se/hoehle/blog/2020/05/31/superspreader.html&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; the author looks at “superspreading” in infectious disease transmission from a statistical point of view. He characterises heterogeneity in the offspring distribution [who becomes infected by the superspreader person] by the Gini coefficient instead of the usual dispersion parameter of the negative binomial distribution. This allows us to consider more flexible offspring distributions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;flattening-vs-shrinking-the-math-of-flattenthecurve&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Flattening vs shrinking: the math of #FlattenTheCurve&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Flattening%20vs%20shrinking%20the%20math%20of%20FlattenTheCurve.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Ben Bolker and Jonathan Dushoff, this &lt;a href=&#34;http://ms.mcmaster.ca/~bolker/misc/peak_I_simple.html&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; gives a clear explanation of physical distancing and explains how physical distancing makes several beneficial outcomes possible.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/bbolker/bbmisc/blob/master/peak_I_simple.rmd&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;explaincovid19-challenge&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;explainCovid19 challenge&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/explainCovid19%20challenge.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Przemyslaw Biecek, this &lt;a href=&#34;https://medium.com/@ModelOriented/explaincovid19-challenge-2453b255a908&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; gives an overview of a model that uses gradient boosting to predict survival based on age, country, and gender. It also shows how older people are more at risk and it lets you play with the model yourself with a &lt;a href=&#34;https://pbiecek.github.io/explainCOVID19/&#34; target=&#34;_blank&#34;&gt;modelStudio interactive dashboard&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Data sources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.google.com/spreadsheets/u/2/d/e/2PACX-1vQU0SIALScXx8VXDX7yKNKWWPKE1YjFlWc6VTEVSN45CklWWf-uWmprQIyLtoPDA18tX9cFDr-aQ9S6/pubhtml&#34; target=&#34;_blank&#34;&gt;Google sheet&lt;/a&gt; (with most recent data at the end of February)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.kaggle.com/sudalairajkumar/novel-corona-virus-2019-dataset&#34; target=&#34;_blank&#34;&gt;Kaggle dataset&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;an-r-package-to-explore-the-novel-coronavirus&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;An R Package to explore the Novel Coronavirus&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/An%20R%20Package%20to%20Explore%20the%20Novel%20Coronavirus.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Patrick Tung via Towards Data Science, this &lt;a href=&#34;https://towardsdatascience.com/an-r-package-to-explore-the-novel-coronavirus-590055738ad6&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; translates into English an R package originally written in Chinese.&lt;/p&gt;
&lt;p&gt;Data is collected from Tencent, at &lt;a href=&#34;https://news.qq.com/zt2020/page/feiyan.htm&#34; target=&#34;_blank&#34;&gt;https://news.qq.com/zt2020/page/feiyan.htm&lt;/a&gt;, which contains one of the most up-to-date public information of the Coronavirus.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus-model-using-r-colombia&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coronavirus model using R – Colombia&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Coronavirus%20model%20using%20R%20—%20Colombia.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Daniel Pena Chavez, this &lt;a href=&#34;https://medium.com/@daniel.pena.chaves/simple-coronavirus-model-using-r-cf6b1bc93949&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; uses the code from Prof. Dr. Holger K. von Jouanne-Diedrich to model height of pandemic in Colombia and projected deaths. The author also points out that a huge number of other variables need to be considered, such as density, climate and government response.&lt;/p&gt;
&lt;p&gt;Data is from &lt;a href=&#34;https://github.com/RamiKrispin&#34; target=&#34;_blank&#34;&gt;Rami Krispin’s GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;More recently, the author published another &lt;a href=&#34;https://medium.com/analytics-vidhya/can-the-worse-be-over-covid-19-data-analysis-4e9dd042dd26&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; comparing China and Italy’s rates on log scales.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-the-case-of-spain&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19: The Case of Spain&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/polynomial%20regression%20model%20COVID-19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Jose from Diarium - Statistics and R software, this &lt;a href=&#34;https://diarium.usal.es/jose/2020/03/20/covid-19-the-case-of-spain/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt;, using data for Spain, applies the SIR model, and then a cubic polynomial regression model to predict infections, hospitalizations, deaths and peak date.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tidying-the-new-johns-hopkins-covid-19-time-series-datasets&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tidying the new Johns Hopkins Covid-19 time-series datasets&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Tidying%20the%20new%20Johns%20Hopkins%20Covid-19%20time-series%20datasets.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Joachim Gassen, this &lt;a href=&#34;https://joachim-gassen.github.io/2020/03/tidying-the-new-johns-hopkins-covid-19-datasests/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; provides functions and code to deal with different country names and changes on the Johns Hopkins site.&lt;/p&gt;
&lt;p&gt;More recently, the author published a series of other interesting articles:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://joachim-gassen.github.io/2020/03/merge-covid-19-data-with-governmental-interventions-data/&#34; target=&#34;_blank&#34;&gt;Merge Covid-19 Data with Governmental Interventions Data&lt;/a&gt;: this article analyzes five kinds of intervention on the spread of COVID-19.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Merge%20Covid-19%20Data%20with%20Governmental%20Interventions%20Data.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://joachim-gassen.github.io/2020/04/scrape-google-covid19-cmr-data/&#34; target=&#34;_blank&#34;&gt;Scraping Google Covid-19 community movement data from PDF figures&lt;/a&gt;: this article explains how to scrape data from a Google site that tracks movements of people. The author uses the &lt;code&gt;{tidycovid19}&lt;/code&gt; R package and prepares an analysis of Germany and then across countries.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Scraping%20Google%20Covid-19%20community%20movement%20data%20from%20PDF%20figures.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://joachim-gassen.github.io/2020/04/covid19-explore-your-visualier-dof/&#34; target=&#34;_blank&#34;&gt;Covid-19: Explore Your Visualizer Degrees of Freedom&lt;/a&gt;: in this article, the author uses COVID-19 data to demonstrate how graphs can communicate very differently, and be manipulated. He shows that getting a ‘neutral’ message to the reader is far from trivial and that visualizations without guidance can be particularly misleading.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://joachim-gassen.github.io/2020/05/tidycovid19-new-data-and-doc/&#34; target=&#34;_blank&#34;&gt;{tidycovid19} New data and documentation&lt;/a&gt;: A recent update to the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#tidycovid19&#34;&gt;{tidycovid19}&lt;/a&gt; package brings data on testing, alternative case data, some regional data and proper data documentation. Using all this, you can use the package to explore the associations of (the lifting of) governmental measures, citizen behavior and the Covid-19 spread.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://joachim-gassen.github.io/2020/04/exploring-and-benchmarking-oxford-government-response-data/&#34; target=&#34;_blank&#34;&gt;Exploring and Benchmarking Oxford Government Response Data&lt;/a&gt;: A post assessing the impact of non-pharmaceutical interventions on the spread of Covid-19 based on the &lt;a href=&#34;https://www.acaps.org/covid19-government-measures-dataset&#34; target=&#34;_blank&#34;&gt;Assessment Capacities Project (ACAPS)&lt;/a&gt; and the &lt;a href=&#34;https://www.bsg.ox.ac.uk/research/research-projects/coronavirus-government-response-tracker&#34; target=&#34;_blank&#34;&gt;Oxford Covid-19 Government Response Tracker&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-in-belgium&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 in Belgium&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Coronavirus%20in%20Belgium.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Based on Tim Churches’ &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#analyzing-covid-19-outbreak-data-with-r&#34;&gt;article&lt;/a&gt;, I published an &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium/&#34;&gt;analysis of the COVID-19 specifically for Belgium&lt;/a&gt;. In this article, I also use the most common epidemiological model, the SIR model (to its simplest form), to analyze the outbreak of the disease in the case where there would be no public health intervention. I also show how to compute the reproduction number and I present some additional improvements that can be made to further analyze the epidemic.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/AntoineSoetewey/statsandr/blob/master/content/blog/2020-03-31-covid-19-in-belgium.Rmd&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;, so feel free to use it as starting point for an analysis of the virus outbreak in your own country.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;facts-about-coronavirus-disease-2019-covid-19-in-5-charts-created-with-r-and-ggplot2&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Facts About Coronavirus Disease 2019 (COVID-19) in 5 Charts created with R and ggplot2&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19-Period-of-Infectivity.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Gregory Kanevsky, this &lt;a href=&#34;https://novyden.blogspot.com/2020/03/facts-about-coronavirus-disease-2019.html&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; compiles some useful facts about COVID-19 into 5 charts, including gauge charts, and discusses R and &lt;code&gt;{ggplot2}&lt;/code&gt; techniques used to create them.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;contagiousness-of-covid-19-part-i-improvements-of-mathematical-fitting&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Contagiousness of COVID-19 Part I: Improvements of Mathematical Fitting&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Contagiousness%20of%20COVID-19%20Part%20I-%20Improvements%20of%20Mathematical%20Fitting.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Martijn Weterings on Learning Machines, this &lt;a href=&#34;https://blog.ephorie.de/contagiousness-of-covid-19-part-i-improvements-of-mathematical-fitting-guest-post&#34; target=&#34;_blank&#34;&gt;guest post&lt;/a&gt; describes the fitting of Covid-19 data with the SIR model and explains tricky parts of the fitting methodology and how we can mitigate some of the problems (e.g., early stopping of the algorithm or an ill-conditioned problem). It provides a very clear explanation of some tweaks to the standard model.&lt;/p&gt;
&lt;p&gt;The code is available &lt;a href=&#34;https://blog.ephorie.de/wp-content/uploads/2020/03/covid.r&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coronavirus-spatially-smoothed-decease-in-france-and-decease-animation-map&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coronavirus : spatially smoothed decease in France and decease animation map&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Coronavirus%20spatially%20smoothed%20decease%20in%20France.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by Michael Ires, this &lt;a href=&#34;http://r.iresmi.net/2020/03/30/coronavirus-spatially-smoothed-decease-in-france/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; shows R code on how to use kernel weighted smoothing with arbitrary bounding areas to display a map of deaths from Covid-19 in France.&lt;/p&gt;
&lt;p&gt;The author also published two other articles on how to build an animated map of deaths from Covid-19 in &lt;a href=&#34;http://r.iresmi.net/2020/04/01/covid-19-decease-animation-map/&#34; target=&#34;_blank&#34;&gt;France&lt;/a&gt; and in &lt;a href=&#34;http://r.iresmi.net/2020/05/02/europe-covid-19-death-map/&#34; target=&#34;_blank&#34;&gt;Europe&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;More recently, the author published an &lt;a href=&#34;http://r.iresmi.net/2020/05/26/polygons-to-hexagons/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; where he uses the &lt;code&gt;{geogrid}&lt;/code&gt; package to show the incidence of Covid19 by French departments as well as spread.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;another-flatten-the-covid-19-curve-simulation-in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Another “flatten the COVID-19 curve” simulation… in R&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Another%20flatten%20the%20COVID-19%20curve%20simulation%20in%20R.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Javier Fernandez-Lopez, this &lt;a href=&#34;http://allthiswasfield.blogspot.com/2020/04/another-flatten-covid-19-curve.html&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; shows R code to create static plots and then simulations to demonstrate how social distancing could help to “flat the curve” of COVID-19 infections.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tracking-covid19-cases-throughout-nj-with-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tracking Covid19 Cases Throughout NJ with R&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/ZoleaNJ04102020.gif&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Kevin Zolea, this &lt;a href=&#34;https://www.kevinzolea.com/posts/covid19_nj/tracking-covid19-cases-throughout-nj-with-r/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; shows how to use the &lt;code&gt;{gganimate}&lt;/code&gt; package to create an animated time series map showing how Covid19 spread throughout the U.S. state of New Jersey’s counties.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;its-fun-to-look-at-the-yacm-yet-another-covid-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;It’s fun to look at the YACM (Yet Another COVID Model)&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Barnettmicrosim04102020.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Adrian Barnett from Median Watch, all the models in this &lt;a href=&#34;https://medianwatch.netlify.com/post/covid-uncertainty/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; are based on the excellent ordinary differential equation models by Alison Hill. They are microsimulations of those models that make heavy use of the &lt;code&gt;{MicSim}&lt;/code&gt; package for running microsimulations in R.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;is-covid-19-as-bad-as-all-that-yes-it-probably-is&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Is COVID-19 as bad as all that? Yes it probably is&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/SmartSimulation-covid19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Dr. Francis Smart from Econometrics By Simulation, this &lt;a href=&#34;http://www.econometricsbysimulation.com/2020/04/is-covid-19-as-bad-as-all-that-yes-it.html&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; explains clearly some of the factors that determine the infections and deaths from COVID19, with different scenarios of seriousness.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;potential-long-term-intervention-strategies-for-covid-19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Potential Long-Term Intervention Strategies for COVID-19&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Potential%20Long-Term%20Intervention%20Strategies%20for%20COVID-19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;On this &lt;a href=&#34;https://covid-measures.github.io/&#34; target=&#34;_blank&#34;&gt;website&lt;/a&gt;, several professors and members of Stanford University (Marissa Childs, Morgan Kain, Devin Kirk, Mallory Harris, Jacob Ritchie, Lisa Couper, Isabel Delwel, Nicole Nova, Erin Mordecai) developed a compartmental model of COVID-19 to evaluate possible outcomes of non-pharmaceutical interventions such as social distancing.&lt;/p&gt;
&lt;p&gt;The website presents an introduction to the problem, the possibility to play around with the model to predict the effects of COVID intervention strategies (thanks to a Shiny app), the model details, and predictions for Santa Clara County, California.&lt;/p&gt;
&lt;p&gt;The code is available on &lt;a href=&#34;https://github.com/morgankain/COVID_interventions&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;animations-in-the-time-of-coronavirus&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Animations in the time of Coronavirus&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Animations%20in%20the%20time%20of%20Coronavirus.png&#34; style=&#34;width:50.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Martin Henze from the Heads or Tails blog, this &lt;a href=&#34;https://heads0rtai1s.github.io/2020/04/30/animate-map-covid/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; describes how to extract and prepare the necessary data to animate the spread of the virus over time in Germany, using &lt;code&gt;{gganimate}&lt;/code&gt; and &lt;code&gt;{sf}&lt;/code&gt; R packages to create animated map visuals.&lt;/p&gt;
&lt;p&gt;The author posted the dataset associated with the Germany maps to &lt;a href=&#34;https://www.kaggle.com/headsortails/covid19-tracking-germany&#34; target=&#34;_blank&#34;&gt;Kaggle&lt;/a&gt;, where he is maintaining it on a daily basis. In addition, he posted a version of the &lt;a href=&#34;https://www.kaggle.com/headsortails/covid19-us-county-jhu-data-demographics&#34; target=&#34;_blank&#34;&gt;JHU US county level dataset&lt;/a&gt; where he added some key demographic info from the US census. This dataset is also updated daily.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-data-and-prediction-for-michigan&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Data and Prediction for Michigan&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Data%20and%20Prediction%20for%20Michigan.png&#34; style=&#34;width:75.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Nagdev Amruthnath, this &lt;a href=&#34;https://iamnagdev.com/?p=646&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; builds and tests an exponential regression model based on (not much) State of Michigan data.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-visualization-of-covid-19-in-the-us&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Visualization of COVID-19 in the US&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Data%20Visualization%20of%20COVID-19%20in%20the%20US.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Daniel Reiff, this &lt;a href=&#34;https://towardsdatascience.com/data-visualization-of-covid-19-in-the-us-1881938aaf17&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; examines COVID-19 growth dynamics using exponential and logistic curves.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-spread-of-covid-19-across-countries-visualization-with-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The spread of COVID-19 across countries visualization with R&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/The%20spread%20of%20COVID-19%20across%20countries%20visualization%20with%20R.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Sergey Bryl, this &lt;a href=&#34;https://analyzecore.com/2020/05/04/the-spread-of-covid-19-across-countries-visualization-with-r/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; examines the speed and spreading of the virus across countries. One animated visualization and two stationary charts show:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how long and intensive were previous phases and&lt;/li&gt;
&lt;li&gt;compare the effectiveness against COVID-19 for different countries&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The code can be found at the end of the article.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-and-rural-areas-in-the-u.s&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid-19 and Rural Areas in the U.S&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Covid-19%20and%20Rural%20Areas%20in%20the%20U.S.png&#34; style=&#34;width:80.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Elliot Meador from Deltanomics, this &lt;a href=&#34;https://www.thedeltanomics.com/post/covid-19-rural-deltanomics/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; focuses on cases of Covid-19 in rural areas of the U.S, including whether in the South any particular state appears to be an outlier.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-death-rates-is-the-data-correct&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid Death Rates: Is the data correct?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Covid%20Death%20Rates%20Is%20the%20data%20correct.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Sam Weiss, this &lt;a href=&#34;http://scweiss.blogspot.com/2020/05/covid-death-rates-is-data-correct.html&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; raises questions about the accuracy of reports of case numbers, in that they may fail to backfill for corrected data.&lt;/p&gt;
&lt;p&gt;More recently, the author published two articles (&lt;a href=&#34;https://scweiss.blogspot.com/2020/03/can-trade-explain-covid-19-cases.html&#34; target=&#34;_blank&#34;&gt;part 1&lt;/a&gt; and &lt;a href=&#34;https://scweiss.blogspot.com/2020/03/can-trade-with-china-predict-covid-19.html&#34; target=&#34;_blank&#34;&gt;part 2&lt;/a&gt;) in which he finds and visualizes an association between number of people that tested positive for COVID-19 in a country and imports from China. In addition he finds that there are particular industries that are particularly correlated with COVID-19 rates.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-risk-heat-maps-with-location-data-apache-arrow-markov-chain-modeling-and-r-shiny&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Risk Heat Maps with Location Data, Apache Arrow, Markov Chain Modeling, and R Shiny&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Risk%20Heat%20Maps%20with%20Location%20Data,%20Apache%20Arrow,%20Markov%20Chain%20Modeling,%20and%20R%20Shiny.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Filip Stachura, this &lt;a href=&#34;https://appsilon.com/covid-19-risk-heat-maps-with-location-data-apache-arrow-markov-chain-modeling-and-r-shiny/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; describes Appsilon’s solution (CoronaRank) submitted to the recent Pandemic Response Hackathon. Inspired by Google’s PageRank, it uses geolocation data in the Apache Parquet format from Veraset for effective exposure risk assessment using Markov Chain modeling.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-tracker-indonesia&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Tracker Indonesia&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Tracker%20Indonesia.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Dio Ariadi from DataWizArt, this &lt;a href=&#34;https://www.datawizart.com/covid-19-tracker-indonesia.html&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; shows some very nice plots on regional variation in COVID-19 cases and deaths in Indonesia, with very neatly integrated R code for each plot.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-projections-using-machine-learning&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Projections Using Machine Learning&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Projections%20Using%20Machine%20Learning%20by%20Youyang%20Gu.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Developed by Youyang Gu, this &lt;a href=&#34;https://covid19-projections.com/&#34; target=&#34;_blank&#34;&gt;website&lt;/a&gt; presents an intuitive model that builds machine learning techniques on top of a classic infectious disease model to make COVID-19 infections and deaths projections for the US, all 50 US states, and more than 60 countries.&lt;/p&gt;
&lt;p&gt;The code can be found on &lt;a href=&#34;https://github.com/youyanggu/covid19_projections&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-in-belgium-is-it-over-yet&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 in Belgium: is it over yet?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-05-22-covid-19-in-belgium-is-it-over-yet_files/Belgian_Hospitalisations_COVID-19_1.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by myself in collaboration with Prof. Niko Speybroeck and Angel Rosas-Aguirre, this &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium-is-it-over-yet/&#34;&gt;article&lt;/a&gt; shows the evolution of the number of hospital admissions and the number of confirmed cases in Belgium (by province and at the national level).&lt;/p&gt;
&lt;p&gt;Code of the plots is available in the article.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-cases-by-ethnicity&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Cases by Ethnicity&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/05202020Tommi.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Tommi Suvitaival, this &lt;a href=&#34;https://tommi-s.com/COVID-19/US_Cases_by_Ethnicity/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; investigates Covid19 deaths as a function of the percentage of a county’s population that comes from various ethnic backgrounds.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tennessee-covid-19-update&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tennessee COVID-19 Update&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/05202020Tennessee.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Prof. James M. Luther, this &lt;a href=&#34;https://rpubs.com/JMLuther/614989&#34; target=&#34;_blank&#34;&gt;document&lt;/a&gt; presents a summary of the daily data for the state of Tennessee. The author uses an interactive map, a seven-day rolling average of various metrics, and facet charts.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;simulating-coronavirus-outbreak-in-cities-with-origin-destination-matrix-and-seir-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Simulating Coronavirus Outbreak in Cities with Origin-Destination Matrix and SEIR Model&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/05202020Tokyo.JPG&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Yihui Fan, this &lt;a href=&#34;https://www.databentobox.com/2020/03/28/covid19_city_sim_seir/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; lays out a step-by-step guide on simulating and visualising the spread of Coronavirus in the Greater Tokyo Area based on Origin-Destination Matrix and SEIR Model.&lt;/p&gt;
&lt;p&gt;Another &lt;a href=&#34;https://www.databentobox.com/2020/03/08/covid19_sim_tokyo/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; from the same author focuses on the effectiveness of reducing population movement in managing Coronavirus outbreak.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-population-mobility---how-has-human-mobility-changed-under-the-covid-19-pandemic&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;COVID-19 Population Mobility - How has human mobility changed under the COVID-19 Pandemic?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID-19%20Population%20Mobility.gif&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Kelsey E. Gonzalez, this &lt;a href=&#34;https://arizona.figshare.com/articles/How_has_human_mobility_changed_under_the_COVID-19_Pandemic_/12374810/1?file=22805480&#34; target=&#34;_blank&#34;&gt;visualization&lt;/a&gt; aims to understand population behavior during the COVID-19 pandemic.&lt;/p&gt;
&lt;p&gt;Data is from &lt;a href=&#34;https://www.cuebiq.com/visitation-insights-covid19/&#34; target=&#34;_blank&#34;&gt;Cuebiq&lt;/a&gt; and the code is available on &lt;a href=&#34;https://github.com/kelseygonzalez/covid_mobility&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-build-covid-19-data-driven-shiny-apps-in-5-minutes&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;How to Build COVID-19 Data-Driven Shiny Apps in 5 minutes&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/How%20to%20Build%20COVID-19%20Data-Driven%20Shiny%20Apps%20in%205mins.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Emanuele Guidotti, this &lt;a href=&#34;https://tutorial.guidotti.dev/h83h5/&#34; target=&#34;_blank&#34;&gt;tutorial&lt;/a&gt; shows how to build a simple yet complete Shiny application using the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#covid19&#34;&gt;R Package COVID19&lt;/a&gt;: R Interface to COVID-19 Data Hub.&lt;/p&gt;
&lt;p&gt;In another &lt;a href=&#34;https://tutorial.guidotti.dev/jv7v8/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt;, the author explores the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#covid19&#34;&gt;R package &lt;code&gt;{COVID19}&lt;/code&gt;&lt;/a&gt; in further detail.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;analyzing-data-from-covid19-r-package&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Analyzing data from COVID19 R package&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/CanovasExcessDeaths.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Pablo Cánovas, this &lt;a href=&#34;https://typethepipe.com/post/analyzing-data-covid19-r-package/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; explores whether deaths from COVID19 are being reported accurately.&lt;/p&gt;
&lt;p&gt;It uses data from &lt;a href=&#34;https://www.mortality.org/&#34; target=&#34;_blank&#34;&gt;The Human Mortality Database&lt;/a&gt; and the &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#covid19&#34;&gt;COVID-19 Data Hub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;body-mass-and-risk-from-covid-19-and-influenza&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Body Mass and Risk from COVID-19 and Influenza&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/bmi-mortality-by-sex-covid19.png&#34; style=&#34;width:50.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Prof. Radford Neal, this &lt;a href=&#34;https://radfordneal.wordpress.com/2020/04/06/body-mass-and-risk-from-covid-19-and-influenza/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; looks at data from flu-like illnesses and some preliminary Covid19 data. The author concludes that being underweight and being seriously obese are both risk factors for serious respiratory illness.&lt;/p&gt;
&lt;p&gt;More recently, the author published a series of other articles:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://radfordneal.wordpress.com/2020/04/23/the-puzzling-linearity-of-covid-19/&#34; target=&#34;_blank&#34;&gt;The Puzzling Linearity of COVID-19&lt;/a&gt; discussing the fact that for many countries, the linear plots of total cases or total deaths go up exponentially at first, and then approach a straight line that is not horizontal&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://radfordneal.wordpress.com/2020/04/30/seasonality-of-covid-19-other-coronaviruses-and-influenza/&#34; target=&#34;_blank&#34;&gt;Seasonality of COVID-19, Other Coronaviruses, and Influenza&lt;/a&gt;: this post looks at the evidence for seasonality in influenza and the common cold Coronaviruses, and to what extent one might expect COVID-19 to also be seasonal&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://radfordneal.wordpress.com/2020/05/27/critique-of-projecting-the-transmission-dynamics-of-sars-cov-2-through-the-postpandemic-period-part-1-reproducing-the-results/&#34; target=&#34;_blank&#34;&gt;Critique of “Projecting the transmission dynamics of SARS-CoV-2 through the postpandemic period”&lt;/a&gt;: this post analyzes and criticizes an earlier paper by &lt;span class=&#34;citation&#34;&gt;Kissler et al. (&lt;a href=&#34;#ref-kissler2020projecting&#34; role=&#34;doc-biblioref&#34;&gt;2020&lt;/a&gt;)&lt;/span&gt;. See also &lt;a href=&#34;https://radfordneal.wordpress.com/2020/06/17/critique-of-projecting-the-transmission-dynamics-of-sars-cov-2-through-the-postpandemic-period-part-2-proxies-for-incidence-of-coronaviruses/&#34; target=&#34;_blank&#34;&gt;part 2&lt;/a&gt; and &lt;a href=&#34;https://radfordneal.wordpress.com/2020/06/24/critique-of-projecting-the-transmission-dynamics-of-sars-cov-2-through-the-postpandemic-period-part-3-estimating-reproduction-numbers/&#34; target=&#34;_blank&#34;&gt;part 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;hmd-weekly-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;HMD – Weekly Data&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Richman.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Ronald Richman, this &lt;a href=&#34;http://ronaldrichman.co.za/2020/05/21/hmd-weekly-data/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; explores the highly improbable level of deaths currently being reported using the Human Mortality Database and its recently begun special time series of weekly death data across 13 countries.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;guest-posts-on-chris-muirs-blog&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Guest posts on Chris Muir’s blog&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Skylar.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Skylar Hara, this &lt;a href=&#34;https://cdmuir.netlify.app/post/2020-05-20-biol297-skylar-covid19/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; examines whether the incidence of Covid19 changed after the Governor of Hawaii issued a stay-at-home order.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Steinbach.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Ronja Steinbach, this &lt;a href=&#34;https://cdmuir.netlify.app/post/2020-05-19-biol297-ronja-covid19/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; gathers data on Trump or Clinton states, percentages of minorities, and median household income to answer the following questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Does party affiliation of a state in the 2016 election have a significant impact on the incidence rate of the virus in that state?&lt;/li&gt;
&lt;li&gt;Does the proportion of the population that is minority and median household income affect the incident rate of the virus across states?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Akemi%20Santiago%20on%20COVID-19.png&#34; style=&#34;width:50.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Akemi Santiago, this &lt;a href=&#34;https://cdmuir.netlify.app/post/2020-05-21-biol297-akemi-covid19/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; shows a statistically different mortality rate between African-Americans in the United States and white Americans.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/correlation%20between%20population%20size%20and%20covid-19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Masha Rutenberg, this &lt;a href=&#34;https://cdmuir.netlify.app/post/2020-05-27-biol297-masha-covid19/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; focuses on the correlation between the population of a country and the number of confirmed infections in the country.&lt;/p&gt;
&lt;p&gt;All authors are students of Prof. Chris Muir.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;an-r-view-into-epidemiology&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;An R View into Epidemiology&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Rickert.JPG&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Joseph Rickert in R Views, this &lt;a href=&#34;https://rviews.rstudio.com/2020/05/20/some-r-resources-for-epidemiology/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; tracks down R packages that help epidemiology research and shows the number of downloads in recent months for the five most popular packages.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;articles-by-rob-j-hyndman&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Articles by Rob J Hyndman&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Hyndman-Excess-death-covid19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Rob J. Hyndman, Professor of Statistics and Head of the Department of Econometrics and Business Statistics at Monash University (Australia), published a series of Covid19 related articles:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://robjhyndman.com/hyndsight/forecasting-covid19/&#34; target=&#34;_blank&#34;&gt;Forecasting COVID-19&lt;/a&gt;: this blog post does not use R, although Prof. Hyndman is an expert with it, but it does explain some of the problems with time series forecasting or other methods of forecasting&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://robjhyndman.com/hyndsight/logratios-covid19/&#34; target=&#34;_blank&#34;&gt;Why log ratios are useful for tracking COVID-19&lt;/a&gt;: this post presents the benefits of reporting log-scale graphics&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://robjhyndman.com/hyndsight/excess-deaths/&#34; target=&#34;_blank&#34;&gt;Excess deaths for 2020&lt;/a&gt;: the reported COVID19 deaths in each country are often underestimated. One way to explore the true mortality effect of the pandemic is to look at “excess deaths” — the difference between death rates this year and the same time in previous years&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://robjhyndman.com/hyndsight/seasonal-mortality-rates/&#34; target=&#34;_blank&#34;&gt;Seasonal mortality rates&lt;/a&gt;: this post shows how the weekly mortality data published by the Human Mortality Database can be used to explore seasonality in mortality rates. Mortality rates are known to be seasonal due to temperatures and other weather-related effects&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;turkey-vs.-germany-covid-19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Turkey vs. Germany: COVID-19&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Turkey%20vs.%20Germany-%20COVID-19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Selcuk Disci from DataGeeek, this &lt;a href=&#34;https://datageeek.wordpress.com/2020/05/31/turkey-vs-germany-covid-19/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; compares efforts by Turkey and Germany to control the pandemic, and tests several regression models.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;hands-on-how-to-build-an-interactive-map-in-r-shiny-an-example-for-the-covid-19-dashboard&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Hands-on: How to build an interactive map in R-Shiny: An example for the COVID-19 Dashboard&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID19%20Analytics.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Sangmeng, this &lt;a href=&#34;https://r-posts.com/hands-on-how-to-build-an-interactive-map-in-r-shiny-an-example-for-the-covid-19-dashboard/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; explains how to build an interactive dashboard with Shiny with an example for the &lt;a href=&#34;https://sangmeng.shinyapps.io/COVID19/&#34; target=&#34;_blank&#34;&gt;COVID-19 Dashboard&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;modelling-covid-19-in-morocco&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Modelling COVID-19 in Morocco&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/SIR-Model-2019-nCoV-Morocco.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Zakariah Gassasse, this &lt;a href=&#34;https://www.internationalmorocco.com/modelling-covid-19-in-morocco/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; presents data on cases of Covid19 in Morocco and applies the &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium/&#34;&gt;SIR model&lt;/a&gt; to the data.&lt;/p&gt;
&lt;p&gt;More recently, the author published two other articles. The first &lt;a href=&#34;https://www.linkedin.com/pulse/100-days-covid-19-arima-zakariah-gassasse/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; provides a short-term forecast of COVID-19 cases and deaths in Morocco by using simple but effective time-series analyses. The second &lt;a href=&#34;https://www.linkedin.com/pulse/part-3-mapping-outbreak-zakariah-gassasse/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt; maps the outbreak to see which regions are suffering the most.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sir-models-with-kermack-and-mckendrick&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;SIR models with Kermack and McKendrick&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/SIR%20models%20with%20Kermack%20and%20McKendrick.gif&#34; style=&#34;width:80.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Pierre Jacob, this &lt;a href=&#34;https://statisfaction.wordpress.com/2020/04/09/sir-models-with-kermack-and-mckendrick/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; is mostly a retrospective look at the origins of the much-used SIR model.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;johns-hopkins-covid-19-data-and-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Johns Hopkins Covid-19 Data and R&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Johns%20Hopkins%20Covid-19%20Data%20and%20R,%20Part%20II,%20data.table%20functions%20and%20graphics,%20plus%20R-Naught.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Steve Miller, these blog posts (&lt;a href=&#34;https://st5.ning.com/topology/rest/1.0/file/get/4791290285?profile=original&#34; target=&#34;_blank&#34;&gt;part 1&lt;/a&gt; &amp;amp; &lt;a href=&#34;https://st1.ning.com/topology/rest/1.0/file/get/5518972265?profile=original&#34; target=&#34;_blank&#34;&gt;part 2&lt;/a&gt;) showcase the handling of daily data of cases/deaths from Covid-19 in the U.S. published by Johns Hopkins University, and visualize moving averages of cases and deaths.&lt;/p&gt;
&lt;p&gt;The author also published a &lt;a href=&#34;http://svmiller.com/blog/2020/03/the-covid19-initial-claims-spike-in-context-r/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; putting unemployment claims in the U.S. in perspective.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;estimating-covid-19s-r_t-in-real-time&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Estimating COVID-19’s &lt;span class=&#34;math inline&#34;&gt;\(R_t\)&lt;/span&gt; in Real-Time&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Estimating%20COVID-19&amp;#39;s%20R_t%20in%20Real-Time.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Ramnath Vaidyanathan, this &lt;a href=&#34;https://www.datacamp.com/community/tutorials/replicating-in-r-covid19&#34; target=&#34;_blank&#34;&gt;tutorial&lt;/a&gt; shows how to estimate &lt;span class=&#34;math inline&#34;&gt;\(R_t\)&lt;/span&gt;, the measure known as effective reproduction number, which is the number of people who become infected per infectious person at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;from-static-to-animated-time-series-the-tidyverse-way&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;From static to animated time series: the tidyverse way&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/From%20static%20to%20animated%20time%20series-%20the%20tidyverse%20way.gif&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Giulia Ruggeri, this &lt;a href=&#34;https://medium.com/epfl-extension-school/from-static-to-animated-time-series-the-tidyverse-way-d696eb75f2fa&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; goes through the steps necessary to create an animated COVID-19 time series plot.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sneak-peek-new-summit-data-tool-helps-clients-visualize-us-areas-that-are-most-heavily-impacted-by-the-covid-19-virus&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sneak peek: new Summit data tool helps clients visualize US areas that are most heavily impacted by the COVID-19 virus&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Sneak%20peek-%20new%20Summit%20data%20tool%20helps%20clients%20visualize%20US%20areas%20that%20are%20most%20heavily%20impacted%20by%20the%20COVID-19%20virus.jpg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Colby Ziegler, this &lt;a href=&#34;https://www.summitllc.us/blog/sneak-peek-new-summit-data-tool-helps-clients-visualize-us-areas-that-are-most-heavily-impacted-by-the-covid-19-virus&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; describes a tool (built primarily in R using the &lt;code&gt;{leaflet}&lt;/code&gt;, &lt;code&gt;{tidyverse}&lt;/code&gt;, and &lt;code&gt;{tigris}&lt;/code&gt; packages) tracking and displaying the total number of confirmed COVID-19 cases and deaths by U.S. county, overlaid with the locations of Certified Community Development Financial Institutions (CDFIs).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-reproduce-financial-times-style-covid19-daily-reporting&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;How to Reproduce Financial Times Style COVID19 Daily Reporting?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/How%20to%20Reproduce%20Financial%20Times%20Style%20COVID19%20Daily%20Reporting.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Peyman Kor, this &lt;a href=&#34;https://peymankor.netlify.app/post/ft/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; shows how to reproduce in R the Financial Times facet plot by country.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-can-tweets-about-contact-tracing-apps-tell-us-about-attitudes-towards-data-sharing-for-public-health&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What can tweets about contact tracing apps tell us about attitudes towards data sharing for public health?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/What%20can%20tweets%20about%20contact%20tracing%20apps%20tell%20us%20about%20attitudes%20towards%20data%20sharing%20for%20public%20health.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Holly Clarke, these 2 blog posts (&lt;a href=&#34;https://www.cdrc.ac.uk/what-can-tweets-about-contact-tracing-apps-tell-us-about-attitudes-towards-data-sharing-for-public-health/&#34; target=&#34;_blank&#34;&gt;part 1&lt;/a&gt; &amp;amp; &lt;a href=&#34;https://www.cdrc.ac.uk/what-can-tweets-about-contact-tracing-apps-tell-us-about-attitudes-towards-data-sharing-for-public-health-part-2/&#34; target=&#34;_blank&#34;&gt;part 2&lt;/a&gt;) discuss about attitudes towards contact tracing apps to manage the spread of Covid-19 and data-sharing for public health, using tweets, text analysis and natural language processing.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;visualizing-covid-cases-in-belgium&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualizing COVID cases in Belgium&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/belgium_covid.gif&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this &lt;a href=&#34;https://bluegreen.ai/post/covid-cases-belgium/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt;, Koen Hufkens plots cases in Belgium and addresses a challenge in geo-spatial plotting.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;a-spatio-temporal-analysis-of-the-environmental-correlates-of-covid-19-incidence-in-spain&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;A spatio-temporal analysis of the environmental correlates of COVID-19 incidence in Spain&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/SUR%20models%20covid19%20antonio%20paez.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Antonio Paez and several co-authors, this &lt;a href=&#34;https://github.com/paezha/covid19-environmental-correlates#a-spatio-temporal-analysis-of-the-environmental-correlates-of-covid-19-incidence-in-spain&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; looks at weather, humidity and other factors in Spain to create a SUR model.&lt;/p&gt;
&lt;p&gt;Another &lt;a href=&#34;https://findingspress.org/article/12976&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; by Antonio Paez investigates the incidence of COVID-19 in the United States using Google Community Mobility Reports.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;covid-19-analysis&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Covid-19 Analysis&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/covid19%20analysis%20Rizami%20Annuar.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Rizami Annuar, this &lt;a href=&#34;https://rizami.com/covid-19/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; compares data on cases and deaths in Malaysia to other countries, including correlations.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;a-simple-way-to-gather-all-coronavirus-related-data-with-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;A Simple Way to Gather all Coronavirus Related Data with R&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/A%20Simple%20Way%20to%20Gather%20all%20Coronavirus%20Related%20Data%20with%20R.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Federico Riveroll, this &lt;a href=&#34;https://medium.com/swlh/a-simple-way-to-gather-all-coronavirus-related-data-with-r-b1e7ecb74346&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; shows how to combine data on Covid19 cases, news references (such as to China) and economic indicators in R. (For Python users, see this &lt;a href=&#34;https://towardsdatascience.com/gather-all-the-coronavirus-data-with-python-19aa22167dea&#34; target=&#34;_blank&#34;&gt;version&lt;/a&gt;.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;australian-governments-can-choose-to-slow-the-spread-of-coronavirus-but-they-would-need-to-act-immediately&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Australian governments can choose to slow the spread of coronavirus, but they would need to act immediately&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Australian%20governments%20can%20choose%20to%20slow%20the%20spread%20of%20coronavirus,%20but%20they%20would%20need%20to%20act%20immediately.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Matt Cowgill, this &lt;a href=&#34;https://grattan.edu.au/news/australian-governments-can-choose-to-slow-the-spread-of-coronavirus-but-they-must-act-immediately/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; shows that Australia early on had relatively few cases, but the post argues that the country needed to act urgently. Data is from the &lt;code&gt;{gtrendsR}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;In a more recent &lt;a href=&#34;https://grattan.edu.au/news/why-we-wont-know-the-full-effect-of-covid-19-on-jobs-in-australia-for-at-least-another-month/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt;, using Google trends data for key words associated with unemployment, the authors trace the effects of COVID19 in Australia in the early months.&lt;/p&gt;
&lt;p&gt;In addition to these posts, a series of other posts have been published by Stephen Duckett and Brendan Coates:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://grattan.edu.au/news/australia-should-join-new-zealand-and-shoot-for-eliminating-coronavirus/&#34; target=&#34;_blank&#34;&gt;Australia should join New Zealand and shoot for eliminating coronavirus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://grattan.edu.au/news/is-the-covid-19-glass-half-full-or-half-empty/&#34; target=&#34;_blank&#34;&gt;Is the COVID-19 glass half full or half empty?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://grattan.edu.au/news/australias-covid-19-are-still-growing-rapidly-our-hospitals-may-soon-hit-capacity/&#34; target=&#34;_blank&#34;&gt;Australia’s COVID-19 cases are still growing rapidly. Our hospitals may soon hit capacity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://grattan.edu.au/news/as-more-australians-get-covid-19-will-we-have-enough-hospital-beds/&#34; target=&#34;_blank&#34;&gt;As more Australians get COVID-19, will we have enough hospital beds?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://grattan.edu.au/news/covid-19-our-most-vulnerable-workers-need-more-help/&#34;&gt;COVID-19: Our most vulnerable workers need more help&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://grattan.edu.au/news/as-the-covid-19-crisis-deepens-few-australians-have-much-cash-in-the-bank/&#34;&gt;As the COVID-19 crisis deepens, few Australians have much cash in the bank&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;does-covid-raise-everyones-relative-risk-of-dying-by-a-similar-amount-more-evidence&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Does Covid raise everyone’s relative risk of dying by a similar amount? More evidence&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Does%20Covid%20raise%20everyone’s%20relative%20risk%20of%20dying%20by%20a%20similar%20amount.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Prof. David Spiegelhalter (author of the great book “&lt;a href=&#34;https://dspiegel29.github.io/ArtofStatistics/&#34; target=&#34;_blank&#34;&gt;The Art of Statistics&lt;/a&gt;”), this &lt;a href=&#34;https://medium.com/wintoncentre/does-covid-raise-everyones-relative-risk-of-dying-by-a-similar-amount-more-evidence-e7d30abf6821&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; looks at relative mortality rates by age and gender, using data from the U.K.’s Office for National Statistics.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tracking-coronavirus-building-parameterized-reports-to-analyze-changing-data-sources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tracking Coronavirus: Building Parameterized Reports to Analyze Changing Data Sources&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Tracking%20Coronavirus-%20Building%20Parameterized%20Reports%20to%20Analyze%20Changing%20Data%20Sources.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this &lt;a href=&#34;https://redoakstrategic.com/tracking-coronavirus-building-parameterized-reports-to-analyze-changing-data-sources/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt;, using Johns Hopkins data, Tyler Sanders builds a virus dashboard that can be updated each day with just the click of a button as an example of how to build parameterized reports with &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;mapping-nz-cases-of-covid-19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Mapping NZ cases of COVID-19&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Mapping%20NZ%20cases%20of%20COVID-19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this &lt;a href=&#34;https://notstatschat.rbind.io/2020/03/26/mapping-nz-cases-of-covid-19/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt;, using his own choropleth package (&lt;code&gt;{DHBins}&lt;/code&gt;) and its hexagonal bins, Thomas Lumley maps cases of COVID19 by Health Boards in New Zealand.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;visualize-the-pandemic-with-r-covid-19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualize the Pandemic with R #COVID-19&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Visualize%20the%20Pandemic%20with%20R%20-%20COVID-19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this &lt;a href=&#34;https://towardsdatascience.com/visualize-the-pandemic-with-r-covid-19-c3443de3b4e4&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt;, Xinhan Qian carries out a variety of explorations with Covid19 data, including the precipitous declines in U.S. movie box office revenue and restaurant reservations.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;exploring-the-temporal-evolution-of-covid-19-cases-in-the-united-states&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Exploring the Temporal Evolution of COVID-19 Cases in the United States&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Exploring%20the%20Temporal%20Evolution%20of%20COVID-19%20Cases%20in%20the%20United%20States.gif&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Robert Winkelman and Colin Waltz, this &lt;a href=&#34;https://rpubs.com/rdwinkelman/covid19_us_spread_gif&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; shows clearly how to create animated plots of the spread of COVID19 infections in the United States.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;r-data-analysis-covid-19&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;R Data Analysis: COVID-19&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/covid19_new-cases_success-failure_small-multiple_v2.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published on the blog of Sharp Sight, this series of blog posts (part &lt;a href=&#34;https://www.sharpsightlabs.com/blog/r-data-analysis-covid-19-part1-data-wrangling/&#34; target=&#34;_blank&#34;&gt;1&lt;/a&gt;, &lt;a href=&#34;https://www.sharpsightlabs.com/blog/r-data-analysis-covid-19-part-2-merge-datasets/&#34; target=&#34;_blank&#34;&gt;2&lt;/a&gt;, &lt;a href=&#34;https://www.sharpsightlabs.com/blog/r-data-exploration-covid19-part3/&#34; target=&#34;_blank&#34;&gt;3&lt;/a&gt;, &lt;a href=&#34;https://www.sharpsightlabs.com/blog/r-data-visualization-covid19-part4/&#34; target=&#34;_blank&#34;&gt;4&lt;/a&gt;, &lt;a href=&#34;https://www.sharpsightlabs.com/blog/r-covid19-analysis-part5-data-issues/&#34; target=&#34;_blank&#34;&gt;5&lt;/a&gt; and &lt;a href=&#34;https://www.sharpsightlabs.com/blog/r-data-analysis-covid19-part6-successful-countries/&#34; target=&#34;_blank&#34;&gt;6&lt;/a&gt;) explain how to rename and reorder columns, standardize dates (with the &lt;code&gt;{lubridate}&lt;/code&gt; package), merge datasets, take other preparatory steps, plot with the &lt;code&gt;{ggplot2}&lt;/code&gt; package and finally, reproduce in R a plot that shows the relative progress of 16 countries in coping with the pandemic.&lt;/p&gt;
&lt;p&gt;All posts use the Johns Hopkins data and data from the company’s own collection.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ga-covid-19-reports&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;GA COVID-19 Reports&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/GA%20COVID-19%20Report.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Based on data from the GA Department of Public Health’s report, Andrew Benesh posts a daily analysis of the U.S. state Georgia’s cases, deaths, ICU usage etc.&lt;/p&gt;
&lt;p&gt;All his reports are posted on &lt;a href=&#34;https://medium.com/@andrewbenesh&#34; target=&#34;_blank&#34;&gt;Medium&lt;/a&gt; and the code is available &lt;a href=&#34;https://bitbucket.org/asb12f/covid19-ga/src/master/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;corona-in-belgium&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Corona in Belgium&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Corona%20in%20Belgium.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Published by bnosac, this &lt;a href=&#34;http://www.bnosac.be/index.php/blog/97-corona-in-belgium&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; covers the early exploration of the exponential spread of Covid19, with a focus on Belgium and the Netherlands.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-coronavirus-in-italy-from-the-twitters-point-of-view&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The Coronavirus in Italy from the Twitter’s Point of View&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/The%20Coronavirus%20in%20Italy%20from%20the%20Twitter&amp;#39;s%20Point%20of%20View.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by the Kode team, these two posts (&lt;a href=&#34;http://tech.kode-datacenter.net:11000/covid19/articles/twitter-analysis-overview/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;http://tech.kode-datacenter.net:11000/covid19/articles/twitter-analysis-sentiment/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;) use text-mining techniques to analyze tweets in Italy early in the pandemic and on speeches by the Prime Minister of Italy regarding Covid19.&lt;/p&gt;
&lt;p&gt;They also published an &lt;a href=&#34;http://tech.kode-datacenter.net:10200/covid-dashboard/&#34; target=&#34;_blank&#34;&gt;interactive dashboard&lt;/a&gt; (in Italian) allowing to explore the data released daily by the &lt;a href=&#34;http://www.protezionecivile.gov.it/&#34; target=&#34;_blank&#34;&gt;Civil Protection&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;use-r-and-tidycensus-to-look-at-covid-19-risk-factors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Use R and Tidycensus to Look at COVID-19 Risk Factors&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/Use%20R%20and%20Tidycensus%20to%20Look%20at%20COVID-19%20Risk%20Factors.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by René F. Najera, this &lt;a href=&#34;https://medium.com/rebel-public-health/use-r-and-tidycensus-to-look-at-covid-19-risk-factors-88485aa31ddd&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; uses US census data to identify “overcrowded” areas and considers them in terms of Covid19 risk.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;animating-u.s.-covid-19-hotspots-over-time&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Animating U.S. COVID-19 hotspots over time&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/us_covid19_rolling_cases.jpg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Written by Nathan Chaney, this &lt;a href=&#34;https://www.nathanchaney.com/2020/10/09/animating-u-s-covid-19-hotspots-over-time/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; presents an animated map of the 7-day rolling average of new COVID-19 cases in US. Code for the animated map is available directly at the end of the post.&lt;/p&gt;
&lt;p&gt;This post is an extension of his previous post on &lt;a href=&#34;http://www.nathanchaney.com/2020/09/29/visualization-of-covid-19-cases-in-arkansas/&#34; target=&#34;_blank&#34;&gt;visualizing COVID-19 in Arkansas&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;understanding-covid19-in-connecticut.-it-takes-a-town&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Understanding COVID19 in Connecticut. It takes a town&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-r-resources-on-coronavirus_files/COVID19-in-Connecticut.gif&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Based on these two &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#animating-u.s.-covid-19-hotspots-over-time&#34;&gt;posts&lt;/a&gt; by Nathan Chaney, Chuck Powell shows in his &lt;a href=&#34;https://ibecav.netlify.app/post/understanding-covid19-in-connecticut-it-takes-a-town/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; how to create an animated map of 7-day rolling average of new COVID19 cases per 100,000 in Connecticut (by town).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/CSSEGISandData/COVID-19&#34; target=&#34;_blank&#34;&gt;2019 Novel Coronavirus COVID-19 (2019-nCoV) Data Repository by Johns Hopkins CSSE&lt;/a&gt;: this dataset is used by many resources mentioned in this article and has become the gold standard for COVID-19 modeling&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://covid19.who.int/&#34; target=&#34;_blank&#34;&gt;World Health Organization (WHO)&lt;/a&gt;. See also their accompanying &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#who-covid-19-explorer&#34;&gt;Shiny app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.kaggle.com/allen-institute-for-ai/CORD-19-research-challenge&#34; target=&#34;_blank&#34;&gt;COVID-19 Open Research Dataset Challenge (CORD-19)&lt;/a&gt; (via Kaggle)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.kaggle.com/sudalairajkumar/novel-corona-virus-2019-dataset&#34; target=&#34;_blank&#34;&gt;Novel Corona Virus 2019 Dataset: Day level information on Covid-19 affected cases&lt;/a&gt; (via Kaggle)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.ecdc.europa.eu/en/publications-data/download-todays-data-geographic-distribution-covid-19-cases-worldwide&#34; target=&#34;_blank&#34;&gt;COVID-19 Data from the European Centers for Disease Control&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://covidtracking.com/&#34; target=&#34;_blank&#34;&gt;The COVID Tracking Project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://joachim-gassen.github.io/2020/03/tidying-the-new-johns-hopkins-covid-19-datasests/&#34; target=&#34;_blank&#34;&gt;Tidying the John Hopkins Covid-19 data to long format and merging some World Bank data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://towardsdatascience.com/a-short-review-of-covid-19-data-sources-ba7f7aa1c342&#34; target=&#34;_blank&#34;&gt;A Short Review of COVID-19 Data Sources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;COVID-19 datasets by &lt;a href=&#34;https://coronavirus-disasterresponse.hub.arcgis.com/datasets/51b7109ab2cc49e29783babad27d64a2&#34; target=&#34;_blank&#34;&gt;esri&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/beoutbreakprepared/nCoV2019/tree/master/latest_data&#34; target=&#34;_blank&#34;&gt;beoutbreakprepared/nCoV2019&lt;/a&gt;: one of the very few non-aggregated dataset available online. Such a dataset of individual-level information on patients with confirmed COVID-19, (including their travel history, location, symptoms, reported onset and confirmation dates and basic demographics) is important to understand, among others, transmissibility, risk of geographic spread, routes of transmission and risk factors for infection&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://towardsdatascience.com/fighting-the-covid-19-all-the-datasets-and-data-efforts-in-one-place-4d6aeb0157ab&#34; target=&#34;_blank&#34;&gt;Fighting the Covid-19: All the datasets and data efforts in one place&lt;/a&gt;: this post gathers many relevant datasets and data efforts&lt;/li&gt;
&lt;li&gt;A &lt;a href=&#34;https://sourceful.co.uk/doc/533/public-covid-19-data-table-lower-tier-regional-bre&#34; target=&#34;_blank&#34;&gt;Google Sheet&lt;/a&gt; which helps with tracking of the local lockdowns in the UK&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;other-lists-or-collections-of-resources&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Other lists or collections of resources&lt;/h1&gt;
&lt;p&gt;With so many great resources about the Coronavirus, other people also collected and organized similar lists.&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt; Below some collections I have been fortunate enough to discover:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://connorrothschild.shinyapps.io/covid-posts/&#34; target=&#34;_blank&#34;&gt;COVID-19 Blog Post Directory&lt;/a&gt;: developed by Connor Rothschild and Rees Morrison, this Shiny app lets users interactively search a collection of over 400 posts by primary topic, post title, date, and whether the post uses a particular mathematical technique or data source. See also the accompanying &lt;a href=&#34;https://www.connorrothschild.com/post/covid-posts/&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://idea.rpi.edu/covid-19-resources&#34; target=&#34;_blank&#34;&gt;COVID-19 Modelling Resources, Data and Challenges&lt;/a&gt; by IDEA (not only R)&lt;/li&gt;
&lt;li&gt;GitHub repo &lt;a href=&#34;https://github.com/mine-cetinkaya-rundel/covid19-r&#34; target=&#34;_blank&#34;&gt;covid19-r&lt;/a&gt; by Mine Cetinkaya-Rundel (only R)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://simplystatistics.org/posts/2020-04-29-amplifying-people-i-trust-on-covid-19/&#34; target=&#34;_blank&#34;&gt;Amplifying people I trust on COVID-19&lt;/a&gt;: written by Jeff Leek from Simply Statistics, this article is a collection of trustworthy people and experts who share good information about the COVID-19 pandemic&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rviews.rstudio.com/2020/04/07/some-select-covid-19-modeling-resources/&#34; target=&#34;_blank&#34;&gt;Some Select COVID-19 Modeling Resources&lt;/a&gt; and &lt;a href=&#34;https://rviews.rstudio.com/2020/06/03/more-select-covid-19-resources/&#34; target=&#34;_blank&#34;&gt;More Select COVID-19 Resources&lt;/a&gt; by Joseph Rickert, assembling dashboards, Shiny apps, blog posts, packages, datasets, videos and conference proceedings that pertain to the Covid19 pandemic&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://milano-r.github.io/erum2020-covidr-contest/index.html&#34; target=&#34;_blank&#34;&gt;CovidR Contest&lt;/a&gt;: launched by the European R users meeting (eRum), this contest is an open-source contest and pre-conference event, featuring any work done with R around the topic of the COVID-19 pandemic&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ocean.sagepub.com/blog/tools-and-tech/turning-covid-19-into-a-data-visualization-exercise-for-your-students&#34; target=&#34;_blank&#34;&gt;Turning COVID-19 into a data visualization exercise for your students&lt;/a&gt;: written by Daniela Duca, this blog post presents a variety of methods to visualize data, drawing on several blog posts, Shiny apps and dashboards&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://outbreak.info/&#34; target=&#34;_blank&#34;&gt;Outbreak.info&lt;/a&gt; is an open source tool built by Scripps Research that standardizes and aggregates COVID-19 data. The interface aggregates journal articles, preprints, datasets, clinical trials, protocols, and other resources in one place, standardizing metadata and applying NLP to make these sources searchable and more accessible. The interactive data dashboards allow for quick comparison of countries, states, counties, and metro areas, and includes an API and R Package for researchers who want to access all of the raw data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope that, in addition to my collection, these rich lists done by others will give you enough background materials to analyze the outbreak of COVID-19 on your own (or at least some ideas)!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;non-english-resources&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Non-english resources&lt;/h1&gt;
&lt;p&gt;This section may be of interested to only a limited number or people, but still, there are great resources in languages other than English. See a collection of them below listed by language:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Japanese:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://covid-2019.live/&#34; target=&#34;_blank&#34;&gt;Coronavirus infection bulletin&lt;/a&gt;: original version of this &lt;a href=&#34;https://statsandr.com/blog/top-r-resources-on-covid-19-coronavirus/#covid-19-bulletin-board&#34;&gt;dashboard&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;German:
&lt;ul&gt;
&lt;li&gt;Developed by Prof. Dr. Helmut Küchenhoff, this &lt;a href=&#34;https://corona.stat.uni-muenchen.de/&#34; target=&#34;_blank&#34;&gt;CoronaMaps&lt;/a&gt; presents the situation of the Coronavirus in the world, in Europe and in Germany via a map and a table&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Spanish:
&lt;ul&gt;
&lt;li&gt;GitHub repository with official government data and R code used to extract it, see &lt;a href=&#34;https://github.com/rubenfcasal/COVID-19&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;https://github.com/datadista/datasets/tree/master/COVID%2019&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://commonsense.shinyapps.io/CovidChile/&#34; target=&#34;_blank&#34;&gt;COVID-19 en Chile&lt;/a&gt;: this Shiny app shows the accumulated confirmed contagion cases and provides an estimate of the growth rate for each municipality&lt;/li&gt;
&lt;li&gt;Developed by Que Oferton, this &lt;a href=&#34;https://queoferton.shinyapps.io/covid19/_w_b59da639/&#34; target=&#34;_blank&#34;&gt;Shiny app&lt;/a&gt; provides an overview of the 2019 Novel Coronavirus COVID-19 epidemic in Central America, including statistics, forecast, SIR and SEIR models. The data and dashboard are refreshed on a daily basis&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;French:
&lt;ul&gt;
&lt;li&gt;Written by Arthur Charpentier, this &lt;a href=&#34;https://freakonometrics.hypotheses.org/60845&#34; target=&#34;_blank&#34;&gt;blog post&lt;/a&gt; shows how to quantify excess mortality using french mortality data&lt;/li&gt;
&lt;/ul&gt;&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 will find these R resources on the COVID-19 Coronavirus useful. Feel free to let me know in the comments if I missed one.&lt;/p&gt;
&lt;p&gt;A special thanks to Rees Morrison for his tremendous work on collecting and organizing several articles, which greatly helped in improving the section about blog posts. Read his articles (&lt;a href=&#34;https://medium.com/@rees_32356/blog-posts-about-covid19-that-use-r-c10e4a96fdf9&#34; target=&#34;_blank&#34;&gt;part 1&lt;/a&gt; and &lt;a href=&#34;https://medium.com/@rees_32356/covid19-related-blog-posts-and-the-r-packages-they-use-f0b82a4d07eb&#34; target=&#34;_blank&#34;&gt;2&lt;/a&gt;) presenting a descriptive analysis of all the posts collected.&lt;/p&gt;
&lt;p&gt;Although I have carefully read all resources, inclusion on the list does not mean that I endorse the findings. Moreover, some of the analyses, code, dashboards, packages or datasets might be out of date, so these should not be viewed, by default, as current findings. If you are the author of one of these resources, do not hesitate to &lt;a href=&#34;https://statsandr.com/contact/&#34;&gt;contact me&lt;/a&gt; if you see any inconsistency or if you would like to remove it from this article.&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-de2020phased&#34; class=&#34;csl-entry&#34;&gt;
de Vlas, Sake J, and Luc E Coffeng. 2020. &lt;span&gt;“A Phased Lift of Control: A Practical Strategy to Achieve Herd Immunity Against Covid-19 at the Country Level.”&lt;/span&gt; &lt;em&gt;medRxiv&lt;/em&gt;.
&lt;/div&gt;
&lt;div id=&#34;ref-kissler2020projecting&#34; class=&#34;csl-entry&#34;&gt;
Kissler, Stephen M, Christine Tedijanto, Edward Goldstein, Yonatan H Grad, and Marc Lipsitch. 2020. &lt;span&gt;“Projecting the Transmission Dynamics of SARS-CoV-2 Through the Postpandemic Period.”&lt;/span&gt; &lt;em&gt;Science&lt;/em&gt; 368 (6493): 860–68.
&lt;/div&gt;
&lt;/div&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;The package has also been the subject of a &lt;a href=&#34;https://doi.org/10.1101/2020.02.25.20027433&#34; target=&#34;_blank&#34;&gt;preprint&lt;/a&gt;.&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;See more information about this epidemiological model in this &lt;a href=&#34;https://rpubs.com/choisy/sir&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt; by Marc Choisy.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Note that unlike my list, collections by others may include resources on COVID-19 using other tools than R.&lt;a href=&#34;#fnref3&#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>How to perform a one-sample t-test by hand and in R: test on one mean</title>
      <link>https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/</link>
      <pubDate>Mon, 09 Mar 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#null-and-alternative-hypothesis&#34; id=&#34;toc-null-and-alternative-hypothesis&#34;&gt;Null and alternative hypothesis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hypothesis-testing&#34; id=&#34;toc-hypothesis-testing&#34;&gt;Hypothesis testing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#two-versions-of-the-one-sample-t-test&#34; id=&#34;toc-two-versions-of-the-one-sample-t-test&#34;&gt;Two versions of the one-sample t-test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-compute-the-one-sample-t-test-by-hand&#34; id=&#34;toc-how-to-compute-the-one-sample-t-test-by-hand&#34;&gt;How to compute the one-sample t-test by hand?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-1-variance-of-the-population-is-known&#34; id=&#34;toc-scenario-1-variance-of-the-population-is-known&#34;&gt;Scenario 1: variance of the population is known&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-2-variance-of-the-population-is-unknown&#34; id=&#34;toc-scenario-2-variance-of-the-population-is-unknown&#34;&gt;Scenario 2: variance of the population is unknown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#different-underlying-distributions-for-the-critical-value&#34; id=&#34;toc-different-underlying-distributions-for-the-critical-value&#34;&gt;Different underlying distributions for the critical value&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-compute-the-one-sample-t-test-in-r&#34; id=&#34;toc-how-to-compute-the-one-sample-t-test-in-r&#34;&gt;How to compute the one-sample t-test in R?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-1-variance-of-the-population-is-known-1&#34; id=&#34;toc-scenario-1-variance-of-the-population-is-known-1&#34;&gt;Scenario 1: variance of the population is known&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-2-variance-of-the-population-is-unknown-1&#34; id=&#34;toc-scenario-2-variance-of-the-population-is-unknown-1&#34;&gt;Scenario 2: variance of the population is unknown&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#confidence-interval&#34; id=&#34;toc-confidence-interval&#34;&gt;Confidence interval&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-plot-and-statistical-test&#34; id=&#34;toc-combination-of-plot-and-statistical-test&#34;&gt;Combination of plot and statistical test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-2-variance-of-the-population-is-unknown-2&#34; id=&#34;toc-scenario-2-variance-of-the-population-is-unknown-2&#34;&gt;Scenario 2: variance of the population is unknown&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#assumptions&#34; id=&#34;toc-assumptions&#34;&gt;Assumptions&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r_files/how-to-perform-a-one-sample-t-test-by-hand-and-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;After having written an article on the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test for two samples&lt;/a&gt; (independent and paired samples), I believe it is time to explain in details how to perform one-sample t-tests by hand and in R.&lt;/p&gt;
&lt;p&gt;One-sample t-test is an important part of inferential statistics (probably one of the first &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt; that students learn). Remind that, unlike &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;descriptive statistics&lt;/a&gt;, inferential statistics is a branch of statistics aiming at drawing conclusions about one or two &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;populations&lt;/a&gt;, based on a subset (or two) of that population (called samples). In other words, we first collect a random set of observations from a population, and then some measurements are calculated in order to generalize to the population the information found through the sample.&lt;/p&gt;
&lt;p&gt;In this context, the &lt;strong&gt;one-sample t-test is used to determine whether the mean of a measurement variable is different from a specified value&lt;/strong&gt; (a belief or a theoretical expectation for example). It works as follows: if the mean of the sample is too distant from the specified value (the value under the null hypothesis), it is considered that the mean of the population is different from what is expected. On the contrary, if the mean of the sample is close to the specified value, we cannot reject the hypothesis that the population mean is equal to what is expected.&lt;/p&gt;
&lt;p&gt;Like the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test for two samples&lt;/a&gt; and the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; (for 3 or more samples), there are also different versions of the one-sample t-test. Luckily, there are only two different versions for this test (the Student’s t-test for two samples has 5 versions!). The difference between the two versions of the one-sample t-test lies in the fact that one version is used when the variance of the &lt;em&gt;population&lt;/em&gt; (not the variance of the sample!) is known, the other version being used when the variance of the population is unknown.&lt;/p&gt;
&lt;p&gt;In this article, I will first detail step by step how to perform both versions of the one-sample t-test by hand. The analyses will be done on a small set of observations for the sake of illustration and easiness. I will then show how to perform this test in R with the exact same data in order to verify the results found by hand. Reminders about the reasoning behind &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt;, interpretations of the &lt;em&gt;p&lt;/em&gt;-value and the results, and assumptions of this test will also be presented.&lt;/p&gt;
&lt;p&gt;Note that the aim of this article is to show how to compute the one-sample t-test by hand and in R, so we refrain from testing the assumptions and we assume all assumptions are met for this exercise. For completeness, we still mention the assumptions and how to test them. Interested readers are invited to have a look at the &lt;a href=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/#assumptions&#34;&gt;end of the article&lt;/a&gt; for more information about these assumptions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;null-and-alternative-hypothesis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Null and alternative hypothesis&lt;/h1&gt;
&lt;p&gt;Before diving into the computations of the one-sample t-test by hand, let’s recap the null and alternative hypotheses of this test:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu = \mu_0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu \ne \mu_0\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; is the population mean and &lt;span class=&#34;math inline&#34;&gt;\(\mu_0\)&lt;/span&gt; is the known or &lt;strong&gt;hypothesized&lt;/strong&gt; value of the mean in the population.&lt;/p&gt;
&lt;p&gt;This is in the general case where we simply want to determine whether the population mean is &lt;strong&gt;different&lt;/strong&gt; (in terms of the dependent variable) compared to the hypothesized value. In this sense, we have no prior belief about the population mean being larger or smaller than the hypothesized value. This type of test is referred as a &lt;strong&gt;two-sided&lt;/strong&gt; or bilateral test.&lt;/p&gt;
&lt;p&gt;If we have some prior beliefs about the population mean being larger or smaller than the hypothesized value, the one-sample t-test also allows to test the following hypotheses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu = \mu_0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu &amp;gt; \mu_0\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu = \mu_0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu &amp;lt; \mu_0\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the first case, we want to test if the population mean is significantly larger than the hypothesized value, while in the latter case, we want to test if the population mean is significantly smaller than the hypothesized value. This type of test is referred as a &lt;strong&gt;one-sided&lt;/strong&gt; or unilateral test.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;hypothesis-testing&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Hypothesis testing&lt;/h1&gt;
&lt;p&gt;In statistics, many statistical tests is in the form of &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt;. Hypothesis tests are used to determine whether a certain belief can be deemed as true (plausible) or not, based on the data at hand (i.e., the sample(s)). Most hypothesis tests boil down to the following 4 steps:&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;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;State the null and alternative hypothesis.&lt;/li&gt;
&lt;li&gt;Compute the test statistic, denoted t-stat. Formulas to compute the test statistic differ among the different versions of the one-sample t-test but they have the same structure. See scenarios 1 and 2 below to see the different formulas.&lt;/li&gt;
&lt;li&gt;Find the critical value given the theoretical statistical distribution of the test, the parameters of the distribution and the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;. For the two versions of the one-sample t-test, it is either the normal or the Student’s t distribution (&lt;em&gt;t&lt;/em&gt; denoting the Student distribution and &lt;em&gt;z&lt;/em&gt; denoting the normal distribution).&lt;/li&gt;
&lt;li&gt;Conclude by comparing the t-stat (found in step 2.) with the critical value (found in step. 3). If the t-stat lies in the rejection region (determined thanks to the critical value and the direction of the test), we reject the null hypothesis, otherwise we do not reject the null hypothesis. These two alternatives (reject or do not reject the null hypothesis) are the only two possible solutions, we never “accept” an hypothesis. It is also a good practice to always interpret the decision in the terms of the initial question.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For the interested reader, see these 4 steps of hypothesis testing in more details in this &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;two-versions-of-the-one-sample-t-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Two versions of the one-sample t-test&lt;/h1&gt;
&lt;p&gt;There are two versions of the one-sample t-test, depending on whether the variance of the population (not the variance of the sample!) is known or unknown. This criteria is rather straightforward, we either know the variance of the population or we do not. The variance of the population cannot be computed because if you can compute the variance of a population, it means you have the data for the whole population, then there is no need to do a hypothesis test anymore…&lt;/p&gt;
&lt;p&gt;So the variance of the population is either given in the statement (use them in that case), or there is no information about the variance and in that case, it is assumed that the variance is unknown. In practice, the variance of the population is most of the time unknown. However, we still illustrate how to do both versions of this test by hand and in R in the next sections following the 4 steps of a hypothesis test.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-compute-the-one-sample-t-test-by-hand&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to compute the one-sample t-test by hand?&lt;/h1&gt;
&lt;p&gt;Note that the data are artificial and do not represent any real variable. Furthermore, remind that the assumptions may or may not be met. The point of the article is to detail how to compute the different versions of the test by hand and in R, so all assumptions are assumed to be met. Moreover, we assume that for all tests the significance level, that is, the type I error is &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 5\)&lt;/span&gt;%.&lt;/p&gt;
&lt;p&gt;If you are interested in applying these tests by hand without having to do the computations yourself, here is a &lt;a href=&#34;https://statsandr.com/blog/a-shiny-app-for-inferential-statistics-by-hand/&#34;&gt;Shiny app&lt;/a&gt; which does it for you. You just need to enter the data and choose the appropriate version of the test thanks to the sidebar menu. There is also a graphical representation that helps you to visualize the test statistic and the rejection region. I hope you will find it useful!&lt;/p&gt;
&lt;div id=&#34;scenario-1-variance-of-the-population-is-known&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 1: variance of the population is known&lt;/h2&gt;
&lt;p&gt;For the first scenario, suppose the data below. Moreover, suppose that the population variance &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2 = 1\)&lt;/span&gt; and that we would like to test whether the population mean is different from 0.&lt;/p&gt;
&lt;table style=&#34;width:11%;&#34;&gt;
&lt;colgroup&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;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;0.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1.7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;5 observations: &lt;span class=&#34;math inline&#34;&gt;\(n = 5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of the sample: &lt;span class=&#34;math inline&#34;&gt;\(\bar{x} = 0.56\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;variance of the population: &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2 = 1\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\mu_0 = 0\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Following the 4 steps of hypothesis testing we have:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu = 0\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu \ne 0\)&lt;/span&gt;. (&lt;span class=&#34;math inline&#34;&gt;\(\ne\)&lt;/span&gt; because we want to test whether the population mean is different from 0, we do not impose a direction in the test.)&lt;/li&gt;
&lt;li&gt;Test statistic: &lt;span class=&#34;math display&#34;&gt;\[z_{obs} = \frac{\bar{x} - \mu_0}{\frac{\sigma}{\sqrt{n}}} = \frac{0.56-0}{0.447} = 1.252\]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Critical value: &lt;span class=&#34;math inline&#34;&gt;\(\pm z_{\alpha / 2} = \pm z_{0.025} = \pm 1.96\)&lt;/span&gt; (see a guide on &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;how to read statistical tables&lt;/a&gt; if you struggle to find the critical value)&lt;/li&gt;
&lt;li&gt;Conclusion: The rejection regions are thus from &lt;span class=&#34;math inline&#34;&gt;\(-\infty\)&lt;/span&gt; to -1.96 and from 1.96 to &lt;span class=&#34;math inline&#34;&gt;\(+\infty\)&lt;/span&gt;. The test statistic is outside the rejection regions so we do not reject the null hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. In terms of the initial question: At the 5% significance level, we do not reject the hypothesis that the population mean is equal to 0, or there is no sufficient evidence in the data to conclude that the population mean is different from 0.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-2-variance-of-the-population-is-unknown&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 2: variance of the population is unknown&lt;/h2&gt;
&lt;p&gt;For the second scenario, suppose the data below. Moreover, suppose that the variance in the population is unknown and that we would like to test whether the population mean is larger than 5.&lt;/p&gt;
&lt;table style=&#34;width:11%;&#34;&gt;
&lt;colgroup&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;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;7.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;5.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;6.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;7.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;6.7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;5 observations: &lt;span class=&#34;math inline&#34;&gt;\(n = 5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of the sample: &lt;span class=&#34;math inline&#34;&gt;\(\bar{x} = 6.8\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;standard deviation of the sample: &lt;span class=&#34;math inline&#34;&gt;\(s = 0.825\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\mu_0 = 5\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Following the 4 steps of hypothesis testing we have:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu = 5\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu &amp;gt; 5\)&lt;/span&gt;. (&amp;gt; because we want to test whether the population mean is larger than 5.)&lt;/li&gt;
&lt;li&gt;Test statistic: &lt;span class=&#34;math display&#34;&gt;\[t_{obs} = \frac{\bar{x} - \mu_0}{\frac{s}{\sqrt{n}}} = \frac{6.8-5}{0.369} = 4.881\]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Critical value: &lt;span class=&#34;math inline&#34;&gt;\(t_{\alpha, n - 1} = t_{0.05, 4} = 2.132\)&lt;/span&gt; (see a guide on &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;how to read statistical tables&lt;/a&gt; if you struggle to find the critical value)&lt;/li&gt;
&lt;li&gt;Conclusion: The rejection region is thus from 2.132 to &lt;span class=&#34;math inline&#34;&gt;\(+\infty\)&lt;/span&gt;. The test statistic lies within the rejection region so we reject the null hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. In terms of the initial question: At the 5% significance level, we conclude that the population mean is larger than 5.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This concludes how to perform the two versions of the one-sample t-test by hand. In the next sections, we detail how to perform the exact same tests in R.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;different-underlying-distributions-for-the-critical-value&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Different underlying distributions for the critical value&lt;/h2&gt;
&lt;p&gt;As you may have noticed, the underlying probability distributions used to find the critical value are different depending on whether the variance of the population is known or unknown.&lt;/p&gt;
&lt;p&gt;The underlying probability distribution when the variance is known (scenario 1) is the normal distribution, while the probability distribution in the case where the variance is unknown (scenario 2) is the Student’s t distribution. This difference is partially explained by the fact that when the variance of the population is unknown, there is more “uncertainty” in the data, so we need to use the Student’s t distribution instead of the normal distribution.&lt;/p&gt;
&lt;p&gt;Note that when the sample size is large (usually when &lt;em&gt;n &amp;gt; 30&lt;/em&gt;), the Student’s t distribution tends to a normal distribution. Using a normal distribution when the variance is known and a Student’s t distribution when the variance is unknown also applies to a &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;t-test for two samples&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-compute-the-one-sample-t-test-in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to compute the one-sample t-test in R?&lt;/h1&gt;
&lt;p&gt;A good practice before doing t-tests in R is to visualize the data thanks to a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; (or eventually a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; or a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#density-plot&#34;&gt;density plot&lt;/a&gt;). A boxplot gives a first indication on the location of the sample, and thus, a first indication on whether the null hypothesis is likely to be rejected or not. However, even if a boxplot or a density plot is great in showing the distribution of a sample, only a sound statistical test will confirm our first impression.&lt;/p&gt;
&lt;p&gt;After a visualization of the data, we replicate in R the results found by hand. Note that we use the same data, the same assumptions and the same question for both scenarios to facilitate the comparison between the tests performed by hand and in R.&lt;/p&gt;
&lt;div id=&#34;scenario-1-variance-of-the-population-is-known-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 1: variance of the population is known&lt;/h2&gt;
&lt;p&gt;For the first scenario, suppose the data below. Moreover, suppose that the population variance &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2 = 1\)&lt;/span&gt; and that we would like to test whether the population mean is different from 0.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat1 &amp;lt;- data.frame(
  value = c(0.9, -0.8, 1.3, -0.3, 1.7)
)

dat1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   value
## 1   0.9
## 2  -0.8
## 3   1.3
## 4  -0.3
## 5   1.7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)

ggplot(dat1) +
  aes(y = value) +
  geom_boxplot() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that you can use 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; RStudio addin&lt;/a&gt; if you want to draw a boxplot with the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;package &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt; without writing the code yourself. If you prefer the default graphics, use the &lt;code&gt;boxplot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(dat1$value)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The boxplot shows that the distribution of the sample is not distant from 0 (the hypothesized value), so we tend to believe that we will not be able to reject the null hypothesis that the population mean is equal to 0. However, only a formal statistical test will confirm this belief.&lt;/p&gt;
&lt;p&gt;Below a function to perform a t-test with a known population variance, with arguments accepting the sample (&lt;code&gt;x&lt;/code&gt;), the variance of the population (&lt;code&gt;V&lt;/code&gt;), the mean under the null hypothesis (&lt;code&gt;m0&lt;/code&gt;, default is &lt;code&gt;0&lt;/code&gt;), the significance level (&lt;code&gt;alpha&lt;/code&gt;, default is &lt;code&gt;0.05&lt;/code&gt;) and the alternative (&lt;code&gt;alternative&lt;/code&gt;, one of &lt;code&gt;&#34;two.sided&#34;&lt;/code&gt; (default), &lt;code&gt;&#34;less&#34;&lt;/code&gt; or &lt;code&gt;&#34;greater&#34;&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;t.test2 &amp;lt;- function(x, V, m0 = 0, alpha = 0.05, alternative = &amp;quot;two.sided&amp;quot;) {
  M &amp;lt;- mean(x)
  n &amp;lt;- length(x)
  sigma &amp;lt;- sqrt(V)
  S &amp;lt;- sqrt(V / n)
  statistic &amp;lt;- (M - m0) / S
  p &amp;lt;- if (alternative == &amp;quot;two.sided&amp;quot;) {
    2 * pnorm(abs(statistic), lower.tail = FALSE)
  } else if (alternative == &amp;quot;less&amp;quot;) {
    pnorm(statistic, lower.tail = TRUE)
  } else {
    pnorm(statistic, lower.tail = FALSE)
  }
  LCL &amp;lt;- (M - S * qnorm(1 - alpha / 2))
  UCL &amp;lt;- (M + S * qnorm(1 - alpha / 2))
  value &amp;lt;- list(mean = M, m0 = m0, sigma = sigma, statistic = statistic, p.value = p, LCL = LCL, UCL = UCL, alternative = alternative)
  # print(sprintf(&amp;quot;P-value = %g&amp;quot;,p))
  # print(sprintf(&amp;quot;Lower %.2f%% Confidence Limit = %g&amp;quot;,
  #               alpha, LCL))
  # print(sprintf(&amp;quot;Upper %.2f%% Confidence Limit = %g&amp;quot;,
  #               alpha, UCL))
  return(value)
}

test &amp;lt;- t.test2(dat1$value,
  V = 1
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $mean
## [1] 0.56
## 
## $m0
## [1] 0
## 
## $sigma
## [1] 1
## 
## $statistic
## [1] 1.252198
## 
## $p.value
## [1] 0.2104977
## 
## $LCL
## [1] -0.3165225
## 
## $UCL
## [1] 1.436523
## 
## $alternative
## [1] &amp;quot;two.sided&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output above recaps all the information needed to perform the test: the test statistic, the &lt;em&gt;p&lt;/em&gt;-value, the alternative used, the sample mean, the hypothesized value and the population variance (compare these results found in R with the results found by hand).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value can be extracted as usual:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.2104977&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.21 so at the 5% significance level we do not reject the null hypothesis. There is no sufficient evidence in the data to reject the hypothesis that the population mean is equal to 0. This result confirms what we found by hand.&lt;/p&gt;
&lt;p&gt;Note that a similar function exists in the &lt;code&gt;{BSDA}&lt;/code&gt; package:&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;pre class=&#34;r&#34;&gt;&lt;code&gt;library(BSDA)

z.test(dat1$value,
  alternative = &amp;quot;two.sided&amp;quot;,
  mu = 0,
  sigma.x = 1,
  conf.level = 0.95
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	One-sample z-Test
## 
## data:  dat1$value
## z = 1.2522, p-value = 0.2105
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  -0.3165225  1.4365225
## sample estimates:
## mean of x 
##      0.56&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are unfamiliar with the concept of &lt;em&gt;p&lt;/em&gt;-value, I invite you to read my &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;note on &lt;em&gt;p&lt;/em&gt;-value and significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To sum up&lt;/strong&gt; what have been said in that article about &lt;em&gt;p&lt;/em&gt;-value and significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the &lt;em&gt;p&lt;/em&gt;-value is smaller than the predetermined significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (usually 5%) so if &lt;em&gt;p&lt;/em&gt;-value &amp;lt; 0.05, we reject the null hypothesis&lt;/li&gt;
&lt;li&gt;If the &lt;em&gt;p&lt;/em&gt;-value is greater than or equal to the predetermined significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (usually 5%) so if &lt;em&gt;p&lt;/em&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(\ge\)&lt;/span&gt; 0.05, we do &lt;strong&gt;not reject&lt;/strong&gt; the null hypothesis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This applies to all statistical tests without exception. Of course, the null and alternative hypotheses change depending on the test.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-2-variance-of-the-population-is-unknown-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 2: variance of the population is unknown&lt;/h2&gt;
&lt;p&gt;For the second scenario, suppose the data below. Moreover, suppose that the variance in the population is unknown and that we would like to test whether the population mean is larger than 5.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat2 &amp;lt;- data.frame(
  value = c(7.9, 5.8, 6.3, 7.3, 6.7)
)

dat2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   value
## 1   7.9
## 2   5.8
## 3   6.3
## 4   7.3
## 5   6.7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat2) +
  aes(y = value) +
  geom_boxplot() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r_files/figure-html/unnamed-chunk-8-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Unlike the previous scenario, the box is quite distant from the hypothesized value of 5. From this boxplot, we can expect the test to reject the null hypothesis of the population mean being equal to 5. Nonetheless, only a formal statistical test will confirm this expectation.&lt;/p&gt;
&lt;p&gt;There is a function in R, and it is simply the &lt;code&gt;t.test()&lt;/code&gt; function. This version of the test is actually the “standard” t-test for one-sample. Note that in our case the alternative hypothesis is &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu &amp;gt; 5\)&lt;/span&gt; so we need to add the arguments &lt;code&gt;mu = 5&lt;/code&gt; and &lt;code&gt;alternative = &#34;greater&#34;&lt;/code&gt; to the function because the default arguments are &lt;code&gt;mu = 0&lt;/code&gt; and the two-sided test:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- t.test(dat2$value,
  mu = 5,
  alternative = &amp;quot;greater&amp;quot;
)

test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	One Sample t-test
## 
## data:  dat2$value
## t = 4.8809, df = 4, p-value = 0.004078
## alternative hypothesis: true mean is greater than 5
## 95 percent confidence interval:
##  6.013814      Inf
## sample estimates:
## mean of x 
##       6.8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output above recaps all the information needed to perform the test: the name of the test, the test statistic, the degrees of freedom, the &lt;em&gt;p&lt;/em&gt;-value, the alternative used, the hypothesized value and the sample mean (compare these results found in R with the results found by hand).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value can be extracted as usual:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.004077555&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.004 so at the 5% significance level we reject the null hypothesis.&lt;/p&gt;
&lt;p&gt;Unlike the first scenario, the &lt;em&gt;p&lt;/em&gt;-value in this scenario is below 5% so we reject the null hypothesis. At the 5% significance level, we can conclude that the population mean is significantly larger than 5. This result confirms what we found by hand.&lt;/p&gt;
&lt;div id=&#34;confidence-interval&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Confidence interval&lt;/h3&gt;
&lt;p&gt;Note that the confidence interval can be extracted with &lt;code&gt;$conf.int&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$conf.int&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 6.013814      Inf
## attr(,&amp;quot;conf.level&amp;quot;)
## [1] 0.95&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see that the 95% confidence interval for the population mean is &lt;span class=&#34;math inline&#34;&gt;\([6.01; \infty]\)&lt;/span&gt;, meaning that, at the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 5\)&lt;/span&gt;%, we reject the null hypothesis as long as the hypothesized value &lt;span class=&#34;math inline&#34;&gt;\(\mu_0\)&lt;/span&gt; is below 6.01, otherwise the null hypothesis cannot be rejected.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-plot-and-statistical-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Combination of plot and statistical test&lt;/h2&gt;
&lt;p&gt;After having written this article, I discovered the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package which I believe is worth mentioning here, in particular the &lt;code&gt;gghistostats()&lt;/code&gt; function for one-sample Student’s t-test.&lt;/p&gt;
&lt;p&gt;This function combines a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt;—representing the distribution—and the results of the statistical test displayed in the subtitle of the plot.&lt;/p&gt;
&lt;p&gt;See examples below for scenario 2. Unfortunately, the package does not allow to run the test for scenario 1.&lt;/p&gt;
&lt;div id=&#34;scenario-2-variance-of-the-population-is-unknown-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scenario 2: variance of the population is unknown&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load packages
library(ggstatsplot)
library(ggplot2)

# plot with stat test
gghistostats(
  data = dat2, # dataframe from which variable is to be taken
  x = value, # numeric variable whose distribution is of interest
  type = &amp;quot;parametric&amp;quot;, # for student&amp;#39;s t-test
  test.value = 5 # default value is 0
) +
  labs(caption = NULL) # remove caption&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r_files/figure-html/unnamed-chunk-12-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is displayed after &lt;code&gt;p =&lt;/code&gt; in the subtitle of the plot. Based on this plot and the &lt;em&gt;p&lt;/em&gt;-value being lower than 5% (&lt;em&gt;p&lt;/em&gt;-value = 0.008), we reject the null hypothesis that the population mean is equal to 5.&lt;/p&gt;
&lt;p&gt;Note that, the &lt;em&gt;p&lt;/em&gt;-value is two times as large as the one obtained with the &lt;code&gt;t.test()&lt;/code&gt; function because when we ran &lt;code&gt;t.test()&lt;/code&gt; we specified &lt;code&gt;alternative = &#34;greater&#34;&lt;/code&gt; (i.e., a one-sided test). In our plot with the &lt;code&gt;gghistostats()&lt;/code&gt; function, it is a two-sided test that is performed by default, that is, &lt;code&gt;alternative = &#34;two.sided&#34;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The point of this section was to illustrate how to easily draw plots together with statistical results, which is exactly the aim of the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package. See more details and examples in this &lt;a href=&#34;https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;assumptions&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Assumptions&lt;/h1&gt;
&lt;p&gt;As for many &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt;, there are some assumptions that need to be met in order to be able to interpret the results. When one or several assumptions are not met, although it is technically possible to perform these tests, it would be incorrect to interpret the results. Below are the assumptions of the one-sample t-test and how to test them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Variable type&lt;/strong&gt;: The dependent variable (i.e., the measured variable) must be measured on a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;continuous&lt;/a&gt; or &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#ordinal&#34;&gt;ordinal scale&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Independence&lt;/strong&gt;: The data, collected from a representative and randomly selected portion of the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt;, should be independent of one another. The assumption of independence is most often verified based on the design of the experiment and on the good control of experimental conditions rather than via a formal test. If you are still unsure about independence based on the experiment design, ask yourself if one observation is related to another (if one observation has an impact on another). If not, it is most likely that you have independent &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;samples&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normality&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;With a small sample size (usually &lt;span class=&#34;math inline&#34;&gt;\(n &amp;lt; 30\)&lt;/span&gt;), observations should follow a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;&lt;strong&gt;normal distribution&lt;/strong&gt;&lt;/a&gt;. The normality assumption can be tested visually thanks to a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; and a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#qq-plot&#34;&gt;QQ-plot&lt;/a&gt;, and/or formally via a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;normality test&lt;/a&gt; such as the Shapiro-Wilk or Kolmogorov-Smirnov test. Some transformations, such as among others, the logarithm, the square root or the Box-Cox transformation can be applied on the observations to transform you data to better fit the normal distribution. If, even after a transformation, your data still do not follow a normal distribution, the &lt;a href=&#34;https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/&#34;&gt;one-sample Wilcoxon test&lt;/a&gt; (&lt;code&gt;wilcox.test(variable_name, data = dat&lt;/code&gt; in R) can be applied. This non-parametric test is robust to non normal distributions so it does not require normality of the data.&lt;/li&gt;
&lt;li&gt;With a large sample size (&lt;span class=&#34;math inline&#34;&gt;\(n \ge 30\)&lt;/span&gt;), &lt;strong&gt;normality of the data is not required&lt;/strong&gt; (this is a common misconception!). By the &lt;a href=&#34;https://en.wikipedia.org/wiki/Central_limit_theorem&#34; target=&#34;_blank&#34;&gt;central limit theorem&lt;/a&gt;, sample means of large samples are often well-approximated by a normal distribution even if the data are not normally distributed &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-stevens2013intermediate&#34;&gt;Stevens 2013&lt;/a&gt;)&lt;/span&gt;. It is therefore not required to test the normality assumption when the number of observations is large.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Outliers&lt;/strong&gt;: There should be no &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt; in your data. An observation slightly different from the others does not pose a problem, but it starts to be an issue when you have at least one &lt;em&gt;extreme&lt;/em&gt; outlier. In presence of at least one extreme outlier, it is best to transform your data (with the logarithm transformation for instance, as you would do with a non normal distribution) or use the non-parametric &lt;a href=&#34;https://statsandr.com/blog/one-sample-wilcoxon-test-in-r/&#34;&gt;one-sample Wilcoxon test&lt;/a&gt;.&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 this article helped you to understand how the different versions of the one-sample t-test work and how to perform them by hand and in R.&lt;/p&gt;
&lt;p&gt;If you are interested, here is a &lt;a href=&#34;https://statsandr.com/blog/a-shiny-app-for-inferential-statistics-by-hand/&#34;&gt;Shiny app&lt;/a&gt; to perform these tests by hand easily (you just need to enter your data and select the appropriate version of the test thanks to the sidebar menu). Moreover, read &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;this article&lt;/a&gt; if you would like to know how to compute the Student’s t-test but this time, for two samples—in order to compare two dependent or independent groups—or this &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;article&lt;/a&gt; if you want to use an ANOVA to compare 3 or more groups.&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-stevens2013intermediate&#34; class=&#34;csl-entry&#34;&gt;
Stevens, James P. 2013. &lt;em&gt;Intermediate Statistics: A Modern Approach&lt;/em&gt;. Routledge.
&lt;/div&gt;
&lt;/div&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;It is a least the case regarding parametric hypothesis tests. A parametric test means that it is based on a theoretical statistical distribution, which depends on some defined parameters. In the case of the one-sample t-test, it is based on the Student’s t distribution with a single parameter, the degrees of freedom (&lt;span class=&#34;math inline&#34;&gt;\(df = n - 1\)&lt;/span&gt; where &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; is the sample size), or the normal distribution.&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 gmacar for pointing it out to me.&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>The 9 concepts and formulas in probability that every data scientist should know</title>
      <link>https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/</link>
      <pubDate>Tue, 03 Mar 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-is-probability&#34; id=&#34;toc-what-is-probability&#34;&gt;What is probability?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#a-probability-is-always-between-0-and-1&#34; id=&#34;toc-a-probability-is-always-between-0-and-1&#34;&gt;1. A probability is always between 0 and 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#compute-a-probability&#34; id=&#34;toc-compute-a-probability&#34;&gt;2. Compute a probability&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#complement-of-an-event&#34; id=&#34;toc-complement-of-an-event&#34;&gt;3. Complement of an event&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#union-of-two-events&#34; id=&#34;toc-union-of-two-events&#34;&gt;4. Union of two events&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#intersection-of-two-events&#34; id=&#34;toc-intersection-of-two-events&#34;&gt;5. Intersection of two events&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#independence-of-two-events&#34; id=&#34;toc-independence-of-two-events&#34;&gt;6. Independence of two events&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conditional-probability&#34; id=&#34;toc-conditional-probability&#34;&gt;7. Conditional probability&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#bayes-theorem&#34; id=&#34;toc-bayes-theorem&#34;&gt;Bayes’ theorem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#example&#34; id=&#34;toc-example&#34;&gt;Example&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#accuracy-measures&#34; id=&#34;toc-accuracy-measures&#34;&gt;8. Accuracy measures&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#false-negatives&#34; id=&#34;toc-false-negatives&#34;&gt;False negatives&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#false-positives&#34; id=&#34;toc-false-positives&#34;&gt;False positives&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sensitivity&#34; id=&#34;toc-sensitivity&#34;&gt;Sensitivity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#specificity&#34; id=&#34;toc-specificity&#34;&gt;Specificity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#positive-predictive-value&#34; id=&#34;toc-positive-predictive-value&#34;&gt;Positive predictive value&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#negative-predictive-value&#34; id=&#34;toc-negative-predictive-value&#34;&gt;Negative predictive value&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#counting-techniques&#34; id=&#34;toc-counting-techniques&#34;&gt;9. Counting techniques&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#multiplication&#34; id=&#34;toc-multiplication&#34;&gt;Multiplication&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#example-1&#34; id=&#34;toc-example-1&#34;&gt;Example&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#permutation&#34; id=&#34;toc-permutation&#34;&gt;Permutation&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#example-2&#34; id=&#34;toc-example-2&#34;&gt;Example&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand&#34; id=&#34;toc-by-hand&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-r&#34; id=&#34;toc-in-r&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination&#34; id=&#34;toc-combination&#34;&gt;Combination&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#example-3&#34; id=&#34;toc-example-3&#34;&gt;Example&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand-1&#34; id=&#34;toc-by-hand-1&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-r-1&#34; id=&#34;toc-in-r-1&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&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/the-7-formulas-in-probability-that-every-data-scientist-should-know_files/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;what-is-probability&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What is probability?&lt;/h1&gt;
&lt;p&gt;A probability is a number that reflects the &lt;strong&gt;chance that a particular event will occur&lt;/strong&gt;. In other words, it quantifies (on a scale from 0 to 1, or from 0% to 100%) &lt;strong&gt;how likely an event is to occur&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Probability is a branch of mathematics that provides models to describe random processes. These mathematical tools allow to establish theoretical models for random phenomena and to use them to make predictions. Like every model, the probabilistic model is a simplification of the world. However, the model is useful as soon as it captures the essential features.&lt;/p&gt;
&lt;p&gt;In this article, we present 9 fundamental formulas and concepts in probability that every data scientist should understand and master in order to appropriately handle any project involving probabilities.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;a-probability-is-always-between-0-and-1&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;1. A probability is always between 0 and 1&lt;/h1&gt;
&lt;p&gt;The probability of an event is always between 0 and 1 (or 0% and 100%). If we denote the probability that an event A (which could be any event) occurs by &lt;span class=&#34;math inline&#34;&gt;\(P(A)\)&lt;/span&gt;, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[0 \le P(A) \le 1\]&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If an event is impossible: &lt;span class=&#34;math inline&#34;&gt;\(P(A) = 0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;If an event is certain: &lt;span class=&#34;math inline&#34;&gt;\(P(A) = 1\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, throwing a 7 with a standard six-sided dice (with faces ranging from 1 to 6) is impossible so its probability is equal to 0. Throwing head &lt;em&gt;or&lt;/em&gt; tail with a coin is certain, so its probability is equal to 1.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;compute-a-probability&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;2. Compute a probability&lt;/h1&gt;
&lt;p&gt;If the elements of a sample space (the set of all possible results of a randomized experiment) are equiprobable (= all elements have the same probability), then the probability of an event occurring is equal to the number of favourable cases (number of ways it can happen) divided by the number of possible cases (total number of outcomes):&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A) = \frac{\text{number of favourable cases}}{\text{number of possible cases}}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For example, all numbers of a six-sided dice are equiprobable since they all have the same probability of occurring. The probability of rolling a 3 with a dice is thus&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(3) = \frac{\text{number of favourable cases}}{\text{number of possible cases}} = \frac{1}{6}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;because there is only one favourable case (there is only one face with a 3 on it), and there are 6 possible cases (because there are 6 faces altogether).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;complement-of-an-event&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;3. Complement of an event&lt;/h1&gt;
&lt;p&gt;The probability of the complement (or opposite) of an event is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(\text{not A}) = P(\bar{A}) = 1 - P(A)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For instance, the probability of &lt;em&gt;not&lt;/em&gt; throwing a 3 with a dice is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(\bar{A}) = 1 - P(A) = 1 - \frac{1}{6} = \frac{5}{6}\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;union-of-two-events&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;4. Union of two events&lt;/h1&gt;
&lt;p&gt;The probability of the union of two events is the probability of either occurring:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
P(\text{A or B)} &amp;amp;= P(A \cup B) \\
&amp;amp;= P(A) + P(B) - P(A \cap B)
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Suppose that the probability of a fire breaking out in two houses in a given year is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;in house A: 60%, so &lt;span class=&#34;math inline&#34;&gt;\(P(A) = 0.6\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;in house B: 45%, so &lt;span class=&#34;math inline&#34;&gt;\(P(B) = 0.45\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;in at least one of the two houses: 80%, so &lt;span class=&#34;math inline&#34;&gt;\(P(A \cup B) = 0.8\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Graphically we have&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/the-7-formulas-in-probability-that-every-data-scientist-should-know_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The probability of a fire breaking out in house A &lt;strong&gt;or&lt;/strong&gt; house B is&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A \cup B) = P(A) + P(B) - P(A \cap B)\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[= 0.6 + 0.45 - 0.25 = 0.8\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;By summing &lt;span class=&#34;math inline&#34;&gt;\(P(A)\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(P(B)\)&lt;/span&gt;, the intersection of A and B, i.e. &lt;span class=&#34;math inline&#34;&gt;\(P(A \cap B)\)&lt;/span&gt;, is counted twice. This is the reason we subtract it to count it only once.&lt;/p&gt;
&lt;p&gt;If two events are mutually exclusive (i.e., two events that cannot occur simultaneously), the probability of both events occurring &lt;span class=&#34;math inline&#34;&gt;\(P(A \cap B)\)&lt;/span&gt; is equal to 0, so the above formula becomes&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A \cup B) = P(A) + P(B)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For example, the event “rolling a 3” and the event “rolling a 6” on a six-sided dice are two mutually exclusive events since they cannot both occur at the same time. Since their joint probability is equal to 0, the probability of rolling a 3 or 6 on a six-sided dice is&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(3 \cup 6) = P(3) + P(6) = \frac{1}{6} + \frac{1}{6} = \frac{1}{3}\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intersection-of-two-events&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;5. Intersection of two events&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;If two events are independent&lt;/strong&gt;, the probability of the intersection of the two events (i.e., the joint probability) is the probability of the two events occurring:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(\text{A and B)} = P(A \cap B) = P(A) \cdot P(B)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For instance, if two coins are flipped, the probability of both coins being tails is&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(T_1 \cap T_2) = P(T_1) \cdot P(T_2) = \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{4}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(T_1\)&lt;/span&gt; (&lt;span class=&#34;math inline&#34;&gt;\(T_2\)&lt;/span&gt;) denotes the event that the first (second) coin is tail.&lt;/p&gt;
&lt;p&gt;Note that &lt;span class=&#34;math inline&#34;&gt;\(P(A \cap B) = P(B \cap A)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;If two events are mutually exclusive, their joint probability is equal to 0:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A \cap B) = 0\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;independence-of-two-events&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;6. Independence of two events&lt;/h1&gt;
&lt;p&gt;Another important concept in probability is the independence of two events. Formally, the events A and B are independent if and only if&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A \cap B) = P(A) \cdot P(B)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If the equality holds, the two events are said to be independent, otherwise the two events are said to be dependent.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the example of the two coins:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(T_1 \cap T_2) = \frac{1}{4}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(T_1) \cdot P(T_2) = \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{4}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;so the following equality holds&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(T_1 \cap T_2) = P(T_1) \cdot P(T_2) = \frac{1}{4}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The two events are thus independent, denoted &lt;span class=&#34;math inline&#34;&gt;\(T_1{\perp\!\!\!\perp}T_2\)&lt;/span&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the example of the fire breaking out in two houses (see &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/#union-of-two-events&#34;&gt;section 4&lt;/a&gt;):&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A \cap B) = 0.25\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A) \cdot P(B) = 0.6 \cdot 0.45 = 0.27\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;so the following equality does not hold&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A \cap B) \ne P(A) \cdot P(B)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The two events are thus dependent (or not independent), denoted &lt;span class=&#34;math inline&#34;&gt;\(A \not\!\perp\!\!\!\perp B\)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;conditional-probability&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;7. Conditional probability&lt;/h1&gt;
&lt;p&gt;Suppose two events A and B and &lt;span class=&#34;math inline&#34;&gt;\(P(B) &amp;gt; 0\)&lt;/span&gt;. The conditional probability of A given (knowing) B is the likelihood of event A occurring given that event B has occurred:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A | B) = \frac{P(A \cap B)}{P(B)}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[= \frac{P(B \cap A)}{P(B)} \text{ (since } P(A \cap B) = P(B \cap A))\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note that, in general, the probability of A given B is not equal to the probability of B given A, that is, &lt;span class=&#34;math inline&#34;&gt;\(P(A | B) \ne P(B | A)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;From the formula of the conditional probability, we can derive the multiplicative law:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A | B) = \frac{P(A \cap B)}{P(B)} \text{ (Eq. 1)}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[P(A | B) \cdot P(B) = \frac{P(A \cap B)}{P(B)} \cdot P(B)\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[P(A | B) \cdot P(B) = P(A \cap B) \text{ (multiplicative law)}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If two events are independent, &lt;span class=&#34;math inline&#34;&gt;\(P(A \cap B) = P(A) \cdot P(B)\)&lt;/span&gt;, and:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(P(B) &amp;gt; 0\)&lt;/span&gt;, the conditional probability becomes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A | B) = \frac{P(A \cap B)}{P(B)}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[P(A | B) = \frac{P(A) \cdot P(B)}{P(B)}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[P(A | B) = P(A) \text{ (Eq. 2)}\]&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(P(A) &amp;gt; 0\)&lt;/span&gt;, the conditional probability becomes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(B | A) = \frac{P(B \cap A)}{P(A)}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[P(B | A) = \frac{P(B) \cdot P(A)}{P(A)}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[P(B | A) = P(B) \text{ (Eq. 3)}\]&lt;/span&gt;
Equations 2 and 3 mean that knowing that one event occurred does not influence the probability of the outcome of the other event. This is in fact the definition of the independence: if knowing that one event occurred does not help to predict (does not influence) the outcome of the other event, the two events are by essence independent.&lt;/p&gt;
&lt;div id=&#34;bayes-theorem&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Bayes’ theorem&lt;/h2&gt;
&lt;p&gt;From the formulas of the conditional probability and the multiplicative law, we can derive the Bayes’ theorem:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
P(B | A) &amp;amp;= \frac{P(B \cap A)}{P(A)} \\
&amp;amp; \text{(from conditional probability)} \\
&amp;amp;= \frac{P(A \cap B)}{P(A)} \\
&amp;amp; \text{(since } P(A \cap B) = P(B \cap A)) \\
&amp;amp;= \frac{P(A | B) \cdot P(B)}{P(A)} \\
&amp;amp; \text{ (from multiplicative law)}
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;which is equivalent to&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
P(B | A) &amp;amp;= \frac{P(B | A) \cdot P(A)}{P(B)} \\
&amp;amp; \text{(Bayes&amp;#39; theorem)}
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;example&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Example&lt;/h2&gt;
&lt;p&gt;In order to illustrate the conditional probability and the Bayes’ theorem, suppose the following problem:&lt;/p&gt;
&lt;p&gt;In order to determine the presence of a disease in a person, a blood test is performed. When a person has the disease, the test can reveal the disease in 80% of cases. When the disease is not present, the test is negative in 90% of cases. Experience has shown that the probability of the disease being present is 10%. A researcher would like to know the probability that an individual has the disease &lt;em&gt;given that the result of the test is positive&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;To answer this question, the following events are defined:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;P: the test result is positive&lt;/li&gt;
&lt;li&gt;D: the person has the disease&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Moreover, we use a tree diagram to illustrate the statement:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/the-7-formulas-in-probability-that-every-data-scientist-should-know_files/Screenshot%202020-03-03%20at%2013.54.24.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;(The sum of all 4 scenarios must be equal to 1 since these 4 scenarios cover all possible cases.)&lt;/p&gt;
&lt;p&gt;We are looking for the probability that an individual has the disease given that the result of the test is positive, &lt;span class=&#34;math inline&#34;&gt;\(P(D | P)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Following the formula of the conditional probability (Eq. 1) we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(A | B) = \frac{P(A \cap B)}{P(B)}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In terms of our problem:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(D | P) = \frac{P(D \cap P)}{P(P)}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[P(D | P) = \frac{0.08}{P(P)} \text{ (Eq. 4)}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;From the tree diagram, we can see that a positive test result is possible under two scenarios:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;when a person has the disease, or&lt;/li&gt;
&lt;li&gt;when the person does not actually have the disease (because the test is not always correct).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In order to find the probability of a positive test result, &lt;span class=&#34;math inline&#34;&gt;\(P(P)\)&lt;/span&gt;, we need to sum up those two scenarios:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
P(P) &amp;amp;= P(D \cap P) + P(\bar{D} \cap P) \\
&amp;amp;= 0.08 + 0.09 \\
&amp;amp;= 0.17
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Eq. 4 then becomes&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(D | P) = \frac{0.08}{0.17} = 0.4706\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The probability of having the disease given that the result of the test is positive is only 47.06%. This means that in this specific case (with the same percentages), an individual with a positive test has less than 1 chance out of 2 of having the disease!&lt;/p&gt;
&lt;p&gt;This relatively small percentage is due to the facts that the disease is quite rare (only 10% of the population is affected) and that the test is not always correct (sometimes it detects the disease although it is not present, and sometimes it does not detect it although it is present).&lt;/p&gt;
&lt;p&gt;As a consequence, a higher percentage of healthy people have a positive result (9%) compared to the percentage of people who have a positive result and who actually have the disease (8%). This explains why several diagnostic tests are often performed before announcing the diagnosis, especially for rare diseases.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;accuracy-measures&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;8. Accuracy measures&lt;/h1&gt;
&lt;p&gt;Based on the example of the disease and the diagnostic test presented above, we explain the most common accuracy measures:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;False negative (number and rate)&lt;/li&gt;
&lt;li&gt;False positive (number and rate)&lt;/li&gt;
&lt;li&gt;Sensitivity&lt;/li&gt;
&lt;li&gt;Specificity&lt;/li&gt;
&lt;li&gt;Positive predictive value&lt;/li&gt;
&lt;li&gt;Negative predictive value&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before diving into the details of these accuracy measures, here is an overview of the measures and the tree diagram with the labels added for each of the 4 scenarios:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/the-7-formulas-in-probability-that-every-data-scientist-should-know_files/the-7-concepts-and-formulas-in-probability-that-every-data-scientist-should-know.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;Adapted from Wikipedia&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/the-7-formulas-in-probability-that-every-data-scientist-should-know_files/Screenshot%202020-03-03%20at%2015.53.19.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;false-negatives&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;False negatives&lt;/h2&gt;
&lt;p&gt;The false negatives (FN) are the number of people incorrectly labeled as &lt;strong&gt;not&lt;/strong&gt; having the disease or the condition, when in reality it is present. It is like telling a women who is 7 months pregnant that she is not pregnant.&lt;/p&gt;
&lt;p&gt;From the tree diagram, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[FN = P(D \cap \bar{P}) = 0.02\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Moreover, the false negative &lt;strong&gt;rate&lt;/strong&gt; (&lt;em&gt;FNR&lt;/em&gt;) is defined as&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
FNR &amp;amp;= \frac{FN}{FN + TP} \\
&amp;amp;= P(\bar{P} | D) \\
&amp;amp;= \frac{P(\bar{P} \cap D)}{P(D)} \\
&amp;amp;= \frac{0.02}{0.08 + 0.02} \\
&amp;amp;= 0.2
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;false-positives&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;False positives&lt;/h2&gt;
&lt;p&gt;The false positives (FP) are the number of people incorrectly labeled as having the disease or the condition, when in reality it is &lt;strong&gt;not&lt;/strong&gt; present. It is like telling a man he is pregnant.&lt;/p&gt;
&lt;p&gt;From the tree diagram, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[FP = P(\bar{D} \cap P) = 0.09\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Moreover, the false positive &lt;strong&gt;rate&lt;/strong&gt; (&lt;em&gt;FPR&lt;/em&gt;) is defined as&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
FPR &amp;amp;= \frac{FP}{FP + TN} \\
&amp;amp;= P(P | \bar{D}) \\
&amp;amp;= \frac{P(P \cap \bar{D})}{P(\bar{D})} \\
&amp;amp;= \frac{0.09}{0.09 + 0.81} \\
&amp;amp;= 0.1
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sensitivity&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sensitivity&lt;/h2&gt;
&lt;p&gt;The sensitivity of a test, also referred as the recall, measures the ability of a test to detect the condition when the condition is present (the percentage of sick people who are correctly identified as having the disease):&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[ Sensitivity = \frac{TP}{TP + FN}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;em&gt;TP&lt;/em&gt; is the true positives.&lt;/p&gt;
&lt;p&gt;From the tree diagram, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
Sensitivity &amp;amp;= \frac{TP}{TP + FN} \\
&amp;amp;= P(P|D) \\
&amp;amp;= 0.8
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note also that &lt;span class=&#34;math inline&#34;&gt;\(1 - sensitivity = FNR\)&lt;/span&gt; (false negative rate).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;specificity&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Specificity&lt;/h2&gt;
&lt;p&gt;The specificity of a test measures the ability of a test to correctly exclude the condition when the condition is absent (the percentage of healthy people who are correctly identified as not having the disease):&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[Specificity = \frac{TN}{TN + FP}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;em&gt;TN&lt;/em&gt; is the true negatives.&lt;/p&gt;
&lt;p&gt;From the tree diagram, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
Specificity &amp;amp;= \frac{TN}{TN + FP} \\
&amp;amp;= P(\bar{P} | \bar{D}) \\
&amp;amp;= 0.9
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note also that &lt;span class=&#34;math inline&#34;&gt;\(1 - specificity = FPR\)&lt;/span&gt; (false positive rate).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;positive-predictive-value&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Positive predictive value&lt;/h2&gt;
&lt;p&gt;The positive predictive value, also referred as the precision, is the proportion of positives that correspond to the presence of the condition, so the proportions of positive results that are true positive results:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[PPV = \frac{TP}{TP+FP}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;From the tree diagram, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
PPV &amp;amp;= \frac{TP}{TP+FP} \\
&amp;amp;= P(D | P) \\
&amp;amp;= \frac{P(D \cap P)}{P(P)} \\
&amp;amp;= \frac{0.08}{0.08+0.09} \\
&amp;amp;= 0.4706
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;negative-predictive-value&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Negative predictive value&lt;/h2&gt;
&lt;p&gt;The negative predictive value is the proportion of negatives that correspond to the absence of the condition, so the proportions of negative results that are true negative results:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[NPV = \frac{TN}{TN + FN}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;From the tree diagram, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
NPV &amp;amp;= \frac{TN}{TN + FN} \\
&amp;amp;= P(\bar{D} | \bar{P}) \\
&amp;amp;= \frac{P(\bar{D} \cap \bar{P})}{P(\bar{P})} \\
&amp;amp;= \frac{0.81}{0.81+0.02} \\
&amp;amp;= 0.9759
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;counting-techniques&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;9. Counting techniques&lt;/h1&gt;
&lt;p&gt;In order to use the formula in &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/#compute-a-probability&#34;&gt;section 2&lt;/a&gt;, one must know how to count the number of possible elements (both for favorable and possible cases).&lt;/p&gt;
&lt;p&gt;There are 3 main counting techniques in probability:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Multiplication&lt;/li&gt;
&lt;li&gt;Permutation&lt;/li&gt;
&lt;li&gt;Combination&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;See below how to count the number of possible elements in case of equiprobable results.&lt;/p&gt;
&lt;div id=&#34;multiplication&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Multiplication&lt;/h2&gt;
&lt;p&gt;The multiplication rule is as follows:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\#(A \times B) = (\#A) \times (\#B)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(\#\)&lt;/span&gt; is the number of elements.&lt;/p&gt;
&lt;div id=&#34;example-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Example&lt;/h3&gt;
&lt;p&gt;In a restaurant, a customer has to choose a starter, a main course and a dessert. The restaurant offers 2 starters, 3 main courses and 2 desserts. How many different choices are possible?&lt;/p&gt;
&lt;p&gt;There are &lt;span class=&#34;math inline&#34;&gt;\(2 \cdot 3 \cdot 2 = 12\)&lt;/span&gt; different possible choices.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;permutation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Permutation&lt;/h2&gt;
&lt;p&gt;The number of permutations is as follows:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
P^r_n &amp;amp;= n \times (n - 1) \times \cdots \times (n - r + 1) \\
&amp;amp;= \frac{n !}{(n - r)!}
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;with &lt;span class=&#34;math inline&#34;&gt;\(r\)&lt;/span&gt; the length, &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; the number of elements and &lt;span class=&#34;math inline&#34;&gt;\(r \le n\)&lt;/span&gt;. Note that &lt;span class=&#34;math inline&#34;&gt;\(0! = 1\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(k! = k \times (k - 1) \times (k - 2) \times \cdots \times 2 \times 1\)&lt;/span&gt; if &lt;span class=&#34;math inline&#34;&gt;\(k = 1, 2, \dots\)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The order is important in permutations!&lt;/p&gt;
&lt;div id=&#34;example-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Example&lt;/h3&gt;
&lt;p&gt;Count the permutations of length 2 of the set &lt;span class=&#34;math inline&#34;&gt;\(A = \{a, b, c, d\}\)&lt;/span&gt;, without a letter being repeated. How many permutations do you find?&lt;/p&gt;
&lt;div id=&#34;by-hand&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;By hand&lt;/h4&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P^4_2 = \frac{4!}{(4-2)!} = \frac{4\cdot3\cdot2\cdot1}{2\cdot1} = 12\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;In R&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(gtools)

x &amp;lt;- c(&amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot;, &amp;quot;d&amp;quot;)

# See all different permutations
perms &amp;lt;- permutations(
  n = 4, r = 2, v = x,
  repeats.allowed = FALSE
)
perms&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       [,1] [,2]
##  [1,] &amp;quot;a&amp;quot;  &amp;quot;b&amp;quot; 
##  [2,] &amp;quot;a&amp;quot;  &amp;quot;c&amp;quot; 
##  [3,] &amp;quot;a&amp;quot;  &amp;quot;d&amp;quot; 
##  [4,] &amp;quot;b&amp;quot;  &amp;quot;a&amp;quot; 
##  [5,] &amp;quot;b&amp;quot;  &amp;quot;c&amp;quot; 
##  [6,] &amp;quot;b&amp;quot;  &amp;quot;d&amp;quot; 
##  [7,] &amp;quot;c&amp;quot;  &amp;quot;a&amp;quot; 
##  [8,] &amp;quot;c&amp;quot;  &amp;quot;b&amp;quot; 
##  [9,] &amp;quot;c&amp;quot;  &amp;quot;d&amp;quot; 
## [10,] &amp;quot;d&amp;quot;  &amp;quot;a&amp;quot; 
## [11,] &amp;quot;d&amp;quot;  &amp;quot;b&amp;quot; 
## [12,] &amp;quot;d&amp;quot;  &amp;quot;c&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Count the number of permutations
nrow(perms)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;combination&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Combination&lt;/h2&gt;
&lt;p&gt;The number of combinations is as follows:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
C^r_n &amp;amp;= \frac{P^r_n}{r!} \\
&amp;amp;= \frac{n !}{r!(n - r)!} \\
&amp;amp;= {n \choose r} \\
&amp;amp;= \frac{n}{r} \times \frac{n - 1}{r - 1} \times \dots \times \frac{n - r + 1}{1}
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;with &lt;span class=&#34;math inline&#34;&gt;\(r\)&lt;/span&gt; the length, &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; the number of elements and &lt;span class=&#34;math inline&#34;&gt;\(r \le n\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The order is &lt;strong&gt;not&lt;/strong&gt; important in combinations!&lt;/p&gt;
&lt;div id=&#34;example-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Example&lt;/h3&gt;
&lt;p&gt;In a family of 5 children, what is the probability that there are 3 girls and 2 boys? Assume that the probabilities of giving birth to a girl and a boy are equal.&lt;/p&gt;
&lt;div id=&#34;by-hand-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;By hand&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Count of 3 girls and 2 boys (favourable cases): &lt;span class=&#34;math inline&#34;&gt;\(C^3_5 = {5 \choose 3} = \frac{5!}{3!(5-3)!} = 10\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Count of possible cases: &lt;span class=&#34;math inline&#34;&gt;\(2^5 = 32\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(\Rightarrow P(3 \text{ girls and 2 boys}) = \frac{\text{# of favourable cases}}{\text{# of possible cases}}\)&lt;/span&gt; &lt;span class=&#34;math display&#34;&gt;\[= \frac{10}{32} = 0.3125\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;In R&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Count of 3 girls and 2 boys:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;choose(n = 5, k = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 10&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Count of possible cases:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;2^5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 32&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Probability of 3 girls and 2 boys:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;choose(n = 5, k = 3) / 2^5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.3125&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&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 this article helped you to understand the most important formulas and concepts from probability theory.&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>Student&#39;s t-test in R and by hand: how to compare two groups under different scenarios?</title>
      <link>https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/</link>
      <pubDate>Fri, 28 Feb 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/</guid>
      <description>
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/viz/viz.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/DiagrammeR-styles/styles.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/grViz-binding/grViz.js&#34;&gt;&lt;/script&gt;

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#null-and-alternative-hypothesis&#34; id=&#34;toc-null-and-alternative-hypothesis&#34;&gt;Null and alternative hypothesis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hypothesis-testing&#34; id=&#34;toc-hypothesis-testing&#34;&gt;Hypothesis testing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#different-versions-of-the-students-t-test&#34; id=&#34;toc-different-versions-of-the-students-t-test&#34;&gt;Different versions of the Student’s t-test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-compute-students-t-test-by-hand&#34; id=&#34;toc-how-to-compute-students-t-test-by-hand&#34;&gt;How to compute Student’s t-test by hand?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-1-independent-samples-with-2-known-variances&#34; id=&#34;toc-scenario-1-independent-samples-with-2-known-variances&#34;&gt;Scenario 1: Independent samples with 2 known variances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-2-independent-samples-with-2-equal-but-unknown-variances&#34; id=&#34;toc-scenario-2-independent-samples-with-2-equal-but-unknown-variances&#34;&gt;Scenario 2: Independent samples with 2 equal but unknown variances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-3-independent-samples-with-2-unequal-and-unknown-variances&#34; id=&#34;toc-scenario-3-independent-samples-with-2-unequal-and-unknown-variances&#34;&gt;Scenario 3: Independent samples with 2 unequal and unknown variances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-4-paired-samples-where-the-variance-of-the-differences-is-known&#34; id=&#34;toc-scenario-4-paired-samples-where-the-variance-of-the-differences-is-known&#34;&gt;Scenario 4: Paired samples where the variance of the differences is known&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown&#34; id=&#34;toc-scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown&#34;&gt;Scenario 5: Paired samples where the variance of the differences is unknown&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-compute-students-t-test-in-r&#34; id=&#34;toc-how-to-compute-students-t-test-in-r&#34;&gt;How to compute Student’s t-test in R?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-1-independent-samples-with-2-known-variances-1&#34; id=&#34;toc-scenario-1-independent-samples-with-2-known-variances-1&#34;&gt;Scenario 1: Independent samples with 2 known variances&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#a-note-on-p-value-and-significance-level-alpha&#34; id=&#34;toc-a-note-on-p-value-and-significance-level-alpha&#34;&gt;A note on &lt;em&gt;p&lt;/em&gt;-value and significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-2-independent-samples-with-2-equal-but-unknown-variances-1&#34; id=&#34;toc-scenario-2-independent-samples-with-2-equal-but-unknown-variances-1&#34;&gt;Scenario 2: Independent samples with 2 equal but unknown variances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-3-independent-samples-with-2-unequal-and-unknown-variances-1&#34; id=&#34;toc-scenario-3-independent-samples-with-2-unequal-and-unknown-variances-1&#34;&gt;Scenario 3: Independent samples with 2 unequal and unknown variances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-4-paired-samples-where-the-variance-of-the-differences-is-known-1&#34; id=&#34;toc-scenario-4-paired-samples-where-the-variance-of-the-differences-is-known-1&#34;&gt;Scenario 4: Paired samples where the variance of the differences is known&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown-1&#34; id=&#34;toc-scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown-1&#34;&gt;Scenario 5: Paired samples where the variance of the differences is unknown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-plot-and-statistical-test&#34; id=&#34;toc-combination-of-plot-and-statistical-test&#34;&gt;Combination of plot and statistical test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-2-independent-samples-with-2-equal-but-unknown-variances-2&#34; id=&#34;toc-scenario-2-independent-samples-with-2-equal-but-unknown-variances-2&#34;&gt;Scenario 2: Independent samples with 2 equal but unknown variances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-3-independent-samples-with-2-unequal-and-unknown-variances-2&#34; id=&#34;toc-scenario-3-independent-samples-with-2-unequal-and-unknown-variances-2&#34;&gt;Scenario 3: Independent samples with 2 unequal and unknown variances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown-2&#34; id=&#34;toc-scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown-2&#34;&gt;Scenario 5: Paired samples where the variance of the differences is unknown&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#assumptions&#34; id=&#34;toc-assumptions&#34;&gt;Assumptions&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/Student-t-test-in-R-and-by-hand-how-to-compare-two-groups-under-different-scenarios.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;One of the most important test within the branch of inferential statistics is the &lt;strong&gt;Student’s t-test&lt;/strong&gt;.&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; The Student’s t-test for two samples is used to &lt;strong&gt;test whether two groups (two populations) are different&lt;/strong&gt; in terms of a quantitative variable, &lt;strong&gt;based on the comparison of two samples&lt;/strong&gt; drawn from these two groups. In other words, a Student’s t-test for two samples allows to determine whether the two populations from which your two samples are drawn are different (with the two samples being measured on a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;quantitative continuous&lt;/a&gt; variable).&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;The reasoning behind this &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt; is that if your two samples are markedly different from each other, it can be assumed that the two populations from which the samples are drawn are different. On the contrary, if the two samples are rather similar, we cannot reject the hypothesis that the two populations are similar, so there is no sufficient evidence in the data at hand to conclude that the two populations from which the samples are drawn are different. Note that this statistical tool belongs to the branch of inferential statistics because conclusions drawn from the study of the samples are generalized to the population, even though we do not have the data on the entire population.&lt;/p&gt;
&lt;p&gt;To compare two samples, it is usual to compare a measure of central tendency computed for each sample. In the case of the Student’s t-test, the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#mean&#34;&gt;mean&lt;/a&gt; is used to compare the two samples. However, in some cases, the mean is not appropriate to compare two samples so the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#median&#34;&gt;median&lt;/a&gt; is used to compare them via the &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Wilcoxon test&lt;/a&gt;. This article being already quite long and complete, the Wilcoxon test is covered in a separate &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;article&lt;/a&gt;, together with some illustrations on when to use one test or the other.&lt;/p&gt;
&lt;p&gt;These two tests (Student’s t-test and Wilcoxon test) have the same final goal, that is, compare two samples in order to determine whether the two populations from which they were drawn are different or not. Note that the Student’s t-test is more powerful than the Wilcoxon test (i.e., it more often detects a significant difference if there is a true difference, so a smaller difference can be detected with the Student’s t-test) but the Student’s t-test is sensitive to &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt; and data asymmetry. Furthermore, within each of these two tests, several versions exist, with each version using different formulas to arrive at the final result. It is thus necessary to understand the difference between the two tests and which version to use in order to carry out the appropriate analyses depending on the question and the data at hand.&lt;/p&gt;
&lt;p&gt;In this article, I will first detail step by step how to perform all versions of the Student’s t-test for independent and paired samples by hand. The analyses will be done on a small set of observations for the sake of illustration and easiness. I will then show how to perform this test in R with the exact same data in order to verify the results found by hand. Reminders about the reasoning behind &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis testing&lt;/a&gt;, interpretations of the &lt;em&gt;p&lt;/em&gt;-value and the results, and assumptions of this test will also be presented.&lt;/p&gt;
&lt;p&gt;Note that the aim of this article is to show how to compute the Student’s t-test by hand and in R, so we refrain from testing the assumptions and we assume all of them are met for this exercise. For completeness, we still mention the assumptions, how to test them and what other tests exist if one is not met. Interested readers are invited to have a look at the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#assumptions&#34;&gt;end of the article&lt;/a&gt; for more information about these assumptions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;null-and-alternative-hypothesis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Null and alternative hypothesis&lt;/h1&gt;
&lt;p&gt;Before diving into the computations of the Student’s t-test by hand, let’s recap the null and alternative hypotheses of this test:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu_1 = \mu_2\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu_1 \ne \mu_2\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(\mu_1\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\mu_2\)&lt;/span&gt; are the means of the two populations from which the samples were drawn.&lt;/p&gt;
&lt;p&gt;As mentioned in the introduction, although technically the Student’s t-test is based on the comparison of the means of the two samples, the final goal of this test is actually to test the following hypotheses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: the two populations are similar&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: the two populations are different&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is in the general case where we simply want to determine whether the two populations are &lt;strong&gt;different&lt;/strong&gt; or not (in terms of the dependent variable). In this sense, we have no prior belief about a particular population mean being larger or smaller than the other. This type of test is referred as a &lt;strong&gt;two-sided&lt;/strong&gt; or bilateral test.&lt;/p&gt;
&lt;p&gt;If we have some prior beliefs about one population mean being larger or smaller than the other, the Student’s t-test also allows to test the following hypotheses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu_1 = \mu_2\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu_1 &amp;gt; \mu_2\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu_1 = \mu_2\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\mu_1 &amp;lt; \mu_2\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the first case, we want to test if the mean of the first population is significantly larger than the mean of the second, while in the latter case, we want to test if the mean of the first population is significantly smaller than the mean of the second. This type of test is referred as a &lt;strong&gt;one-sided&lt;/strong&gt; or unilateral test.&lt;/p&gt;
&lt;p&gt;Some authors argue that one-sided tests should not be used in practice for the simple reason that, if a researcher is so sure that the mean of one population is larger (smaller) than the mean of the other and would never be smaller (larger) than the other, why would she needs to test for significance at all? This a rather philosophical question and it is beyond the scope of this article. Interested readers are invited to see part of the discussion in &lt;span class=&#34;citation&#34;&gt;Rowntree (&lt;a href=&#34;#ref-rowntree2000statistics&#34; role=&#34;doc-biblioref&#34;&gt;2000&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;hypothesis-testing&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Hypothesis testing&lt;/h1&gt;
&lt;p&gt;In statistics, many statistical tests is in the form of &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt;. Hypothesis tests are used to determine whether a certain belief can be deemed as true (plausible) or not, based on the data at hand (i.e., the sample(s)). Most hypothesis tests boil down to the following 4 steps:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;State the null and alternative hypothesis.&lt;/li&gt;
&lt;li&gt;Compute the test statistic, denoted t-stat. Formulas to compute the test statistic differ among the different versions of the Student’s t-test but they have the same structure. See scenarios 1 to 5 below to see the different formulas.&lt;/li&gt;
&lt;li&gt;Find the critical value given the theoretical statistical distribution of the test, the parameters of the distribution and the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;. For a Student’s t-test and its extended version, it is either the normal or the Student’s t distribution (&lt;em&gt;t&lt;/em&gt; denoting the Student distribution and &lt;em&gt;z&lt;/em&gt; denoting the normal distribution).&lt;/li&gt;
&lt;li&gt;Conclude by comparing the t-stat (found in step 2.) with the critical value (found in step. 3). If the t-stat lies in the rejection region (determined thanks to the critical value and the direction of the test), we reject the null hypothesis, otherwise we do not reject the null hypothesis. These two alternatives (reject or do not reject the null hypothesis) are the only two possible solutions, we never “accept” an hypothesis. It is also a good practice to always interpret the decision in the terms of the initial question.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For the interested reader, see these 4 steps of hypothesis testing in more details in this &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;different-versions-of-the-students-t-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Different versions of the Student’s t-test&lt;/h1&gt;
&lt;p&gt;There are several versions of the Student’s t-test for two samples, depending on whether the samples are independent or paired and depending on whether the variances of the populations are (un)equal and/or (un)known:&lt;/p&gt;
&lt;div id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:480px;&#34; class=&#34;grViz html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;diagram&#34;:&#34;digraph {\n\ngraph [rankdir = \&#34;LR\&#34;]\n\n\n\n  \&#34;1\&#34; [label = \&#34;Test on 2 means\&#34;, style = \&#34;filled,rounded\&#34;, shape = \&#34;box\&#34;, fontname = \&#34;helvetica\&#34;, tooltip = \&#34;- name: Test on 2 means\&#34;, fillcolor = \&#34;LightGray\&#34;, fontcolor = \&#34;#000000\&#34;] \n  \&#34;2\&#34; [label = \&#34;2 independepent samples\&#34;, style = \&#34;filled,rounded\&#34;, shape = \&#34;box\&#34;, fontname = \&#34;helvetica\&#34;, tooltip = \&#34;- name: 2 independepent samples\&#34;, fillcolor = \&#34;LightGray\&#34;, fontcolor = \&#34;#000000\&#34;] \n  \&#34;3\&#34; [label = \&#34;2 variances are known (scenario 1)\&#34;, style = \&#34;filled,rounded\&#34;, shape = \&#34;box\&#34;, fontname = \&#34;helvetica\&#34;, tooltip = \&#34;- name: 2 variances are known (scenario 1)\&#34;, fillcolor = \&#34;LightGray\&#34;, fontcolor = \&#34;#000000\&#34;] \n  \&#34;4\&#34; [label = \&#34;2 variances are equal but unknown (scenario 2)\&#34;, style = \&#34;filled,rounded\&#34;, shape = \&#34;box\&#34;, fontname = \&#34;helvetica\&#34;, tooltip = \&#34;- name: 2 variances are equal but unknown (scenario 2)\&#34;, fillcolor = \&#34;LightGray\&#34;, fontcolor = \&#34;#000000\&#34;] \n  \&#34;5\&#34; [label = \&#34;2 variances are unequal and unknown (scenario 3)\&#34;, style = \&#34;filled,rounded\&#34;, shape = \&#34;box\&#34;, fontname = \&#34;helvetica\&#34;, tooltip = \&#34;- name: 2 variances are unequal and unknown (scenario 3)\&#34;, fillcolor = \&#34;LightGray\&#34;, fontcolor = \&#34;#000000\&#34;] \n  \&#34;6\&#34; [label = \&#34;2 paired samples\&#34;, style = \&#34;filled,rounded\&#34;, shape = \&#34;box\&#34;, fontname = \&#34;helvetica\&#34;, tooltip = \&#34;- name: 2 paired samples\&#34;, fillcolor = \&#34;LightGray\&#34;, fontcolor = \&#34;#000000\&#34;] \n  \&#34;7\&#34; [label = \&#34;Variance of the differences is known (scenario 4)\&#34;, style = \&#34;filled,rounded\&#34;, shape = \&#34;box\&#34;, fontname = \&#34;helvetica\&#34;, tooltip = \&#34;- name: Variance of the differences is known (scenario 4)\&#34;, fillcolor = \&#34;LightGray\&#34;, fontcolor = \&#34;#000000\&#34;] \n  \&#34;8\&#34; [label = \&#34;Variance of the differences is unknown (scenario 5)\&#34;, style = \&#34;filled,rounded\&#34;, shape = \&#34;box\&#34;, fontname = \&#34;helvetica\&#34;, tooltip = \&#34;- name: Variance of the differences is unknown (scenario 5)\&#34;, fillcolor = \&#34;LightGray\&#34;, fontcolor = \&#34;#000000\&#34;] \n  \&#34;1\&#34;-&gt;\&#34;2\&#34; \n  \&#34;1\&#34;-&gt;\&#34;6\&#34; \n  \&#34;2\&#34;-&gt;\&#34;3\&#34; \n  \&#34;2\&#34;-&gt;\&#34;4\&#34; \n  \&#34;2\&#34;-&gt;\&#34;5\&#34; \n  \&#34;6\&#34;-&gt;\&#34;7\&#34; \n  \&#34;6\&#34;-&gt;\&#34;8\&#34; \n}&#34;,&#34;config&#34;:{&#34;engine&#34;:&#34;dot&#34;,&#34;options&#34;:null}},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;On the one hand, &lt;strong&gt;independent&lt;/strong&gt; samples means that the two samples are collected on &lt;strong&gt;different&lt;/strong&gt; experimental units or different individuals, for instance when we are working on women and men separately, or working on patients who have been randomly assigned to a control and a treatment group (and a patient belongs to only one group). On the other hand, we face &lt;strong&gt;paired&lt;/strong&gt; samples when measurements are collected on the &lt;strong&gt;same&lt;/strong&gt; experimental units, same individuals. This is often the case, for example in medical studies, when testing the efficiency of a treatment at two different times. The same patients are measured twice, before and after the treatment, and the dependency between the two samples must be taken into account in the computation of the test statistic by working on the &lt;strong&gt;differences&lt;/strong&gt; of measurements for each subject. Paired samples are usually the result of measurements at two different times, but not exclusively. Suppose we want to test the difference in vision between the left and right eyes of 50 athletes. Although the measurements are not made at two different time (before-after), it is clear that both eyes are dependent within each subject. Therefore, the Student’s t-test for paired samples should be used to account for the dependency between the two samples instead of the standard Student’s t-test for independent samples.&lt;/p&gt;
&lt;p&gt;Another criteria for choosing the appropriate version of the Student’s t-test is whether the variances of the populations (not the variances of the samples!) are known or unknown and equal or unequal. This criteria is rather straightforward, we either know the variances of the populations or we do not. The variances of the populations cannot be computed because if you can compute the variance of a population, it means you have the data for the whole population, then there is no need to do a hypothesis test anymore… So the variances of the populations are either given in the statement (use them in that case), or there is no information about these variances and in this case, it is assumed that the variances are unknown. In practice, the variances of the populations are most of the time unknown and the only thing to do in order to choose the appropriate version of the test is to check whether the variances are equal or not. However, we still illustrate how to do all versions of this test by hand and in R in the next sections following the 4 steps of hypothesis testing.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-compute-students-t-test-by-hand&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to compute Student’s t-test by hand?&lt;/h1&gt;
&lt;p&gt;Note that the data are artificial and do not represent any real variable. Furthermore, remind that the assumptions may or may not be met. The point of the article is to detail how to compute the different versions of the test by hand and in R, so all assumptions are assumed to be met. Moreover, assume that the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 5\)&lt;/span&gt;% for all tests.&lt;/p&gt;
&lt;p&gt;If you are interested in applying these tests by hand without having to do the computations yourself, here is a &lt;a href=&#34;https://statsandr.com/blog/a-shiny-app-for-inferential-statistics-by-hand/&#34;&gt;Shiny app&lt;/a&gt; which does it for you. You just need to enter the data and choose the appropriate version of the test thanks to the sidebar menu. There is also a graphical representation that helps you to visualize the test statistic and the rejection region. I hope you will find it useful!&lt;/p&gt;
&lt;div id=&#34;scenario-1-independent-samples-with-2-known-variances&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 1: Independent samples with 2 known variances&lt;/h2&gt;
&lt;p&gt;For the first scenario, suppose the data below. Moreover, suppose that the two samples are independent, that the variances &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2 = 1\)&lt;/span&gt; in both populations and that we would like to test whether the two population means are different.&lt;/p&gt;
&lt;table style=&#34;width:24%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;value&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;sample&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.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;5 observations in each sample: &lt;span class=&#34;math inline&#34;&gt;\(n_1 = n_2 = 5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of sample 1: &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}_1 = 0.02\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of sample 2: &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}_2 = 0.06\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;variances of both populations: &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_1 = \sigma^2_2 = 1\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Following the 4 steps of hypothesis testing we have:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_1 = \mu_2\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_1 - \mu_2 \ne 0\)&lt;/span&gt;. (&lt;span class=&#34;math inline&#34;&gt;\(\ne\)&lt;/span&gt; because we want to test whether the two means are different, we do not impose a direction in the test.)&lt;/li&gt;
&lt;li&gt;Test statistic: &lt;span class=&#34;math display&#34;&gt;\[z_{obs} = \frac{(\bar{x}_1 - \bar{x}_2) - (\mu_1 - \mu_2)}{\sqrt{\frac{\sigma^2_1}{n_1} + \frac{\sigma^2_2}{n_2}}}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[= \frac{0.02-0.06-0}{0.632} = -0.063\]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Critical value: &lt;span class=&#34;math inline&#34;&gt;\(\pm z_{\alpha / 2} = \pm z_{0.025} = \pm 1.96\)&lt;/span&gt; (see a guide on &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/&#34;&gt;how to read statistical tables&lt;/a&gt; if you struggle to find the critical value)&lt;/li&gt;
&lt;li&gt;Conclusion: The rejection regions are thus from &lt;span class=&#34;math inline&#34;&gt;\(-\infty\)&lt;/span&gt; to -1.96 and from 1.96 to &lt;span class=&#34;math inline&#34;&gt;\(+\infty\)&lt;/span&gt;. The test statistic is outside the rejection regions so we do not reject the null hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. In terms of the initial question: At the 5% significance level, we do not reject the hypothesis that the two population means are the same, or there is no sufficient evidence in the data to conclude that the two populations considered are different.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-2-independent-samples-with-2-equal-but-unknown-variances&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 2: Independent samples with 2 equal but unknown variances&lt;/h2&gt;
&lt;p&gt;For the second scenario, suppose the data below. Moreover, suppose that the two samples are independent, that the variances in both populations are unknown but equal (&lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_1 = \sigma^2_1\)&lt;/span&gt;) and that we would like to test whether the mean of population 1 is larger than the mean of population 2.&lt;/p&gt;
&lt;table style=&#34;width:24%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;value&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;sample&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;1.78&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1.5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;6 observations in sample 1: &lt;span class=&#34;math inline&#34;&gt;\(n_1 = 6\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;5 observations in sample 2: &lt;span class=&#34;math inline&#34;&gt;\(n_2 = 5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of sample 1: &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}_1 = 1.247\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of sample 2: &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}_2 = 0.1\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;variance of sample 1: &lt;span class=&#34;math inline&#34;&gt;\(s^2_1 = 0.303\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;variance of sample 2: &lt;span class=&#34;math inline&#34;&gt;\(s^2_1 = 0.315\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Following the 4 steps of hypothesis testing we have:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_1 = \mu_2\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_1 - \mu_2 &amp;gt; 0\)&lt;/span&gt;. (&amp;gt; because we want to test if the mean of the first population is larger than the mean of the second population.)&lt;/li&gt;
&lt;li&gt;Test statistic: &lt;span class=&#34;math display&#34;&gt;\[t_{obs} = \frac{(\bar{x}_1 - \bar{x}_2) - (\mu_1 - \mu_2)}{s_p\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}\]&lt;/span&gt; where &lt;span class=&#34;math display&#34;&gt;\[s_p = \sqrt{\frac{(n_1-1)s^2_1+ (n_2 - 1)s^2_2}{n_1 + n_2 - 2}} = 0.555\]&lt;/span&gt; so &lt;span class=&#34;math display&#34;&gt;\[t_{obs} = \frac{1.247-0.1-0}{0.555 * 0.606} = 3.411\]&lt;/span&gt;
(Note that as it is assumed the variances of the two populations are equal, a pooled (common) variance, denoted &lt;span class=&#34;math inline&#34;&gt;\(s_p\)&lt;/span&gt;, is computed.)&lt;/li&gt;
&lt;li&gt;Critical value: &lt;span class=&#34;math inline&#34;&gt;\(t_{\alpha, n_1 + n_2 - 2} = t_{0.05, 9} = 1.833\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Conclusion: The rejection region is thus from 1.833 to &lt;span class=&#34;math inline&#34;&gt;\(+\infty\)&lt;/span&gt; (there is only one rejection region because it is a one-sided test). The test statistic lies within the rejection region so we reject the null hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. In terms of the initial question: At the 5% significance level, we conclude that the mean of population 1 is larger than the mean of population 2.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-3-independent-samples-with-2-unequal-and-unknown-variances&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 3: Independent samples with 2 unequal and unknown variances&lt;/h2&gt;
&lt;p&gt;For the third scenario, suppose the data below. Moreover, suppose that the two samples are independent, that the variances in both populations are unknown and unequal (&lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_1 \ne \sigma^2_1\)&lt;/span&gt;) and that we would like to test whether the mean of population 1 is smaller than the mean of population 2.&lt;/p&gt;
&lt;table style=&#34;width:24%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;value&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;sample&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.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1.78&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1.5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;5 observations in sample 1: &lt;span class=&#34;math inline&#34;&gt;\(n_1 = 5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;6 observations in sample 2: &lt;span class=&#34;math inline&#34;&gt;\(n_2 = 6\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of sample 1: &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}_1 = 0.42\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of sample 2: &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}_2 = 1.247\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;variance of sample 1: &lt;span class=&#34;math inline&#34;&gt;\(s^2_1 = 0.107\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;variance of sample 2: &lt;span class=&#34;math inline&#34;&gt;\(s^2_1 = 0.303\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Following the 4 steps of hypothesis testing we have:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_1 = \mu_2\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_1 - \mu_2 &amp;lt; 0\)&lt;/span&gt;. (&amp;lt; because we want to test if the mean of the first population is smaller than the mean of the second population.)&lt;/li&gt;
&lt;li&gt;Test statistic: &lt;span class=&#34;math display&#34;&gt;\[t_{obs} = \frac{(\bar{x}_1 - \bar{x}_2) - (\mu_1 - \mu_2)}{\sqrt{\frac{s^2_1}{n_1} + \frac{s^2_2}{n_2}}}\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[= \frac{0.42-1.247-0}{0.268} = -3.084\]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Critical value: &lt;span class=&#34;math inline&#34;&gt;\(-t_{\alpha, \upsilon}\)&lt;/span&gt; where &lt;span class=&#34;math display&#34;&gt;\[\upsilon = \frac{\bigg(\frac{s^2_1}{n_1} + \frac{s^2_2}{n_2} \bigg)^2}{\frac{\bigg(\frac{s^2_1}{n_1}\bigg)^2}{n_1 - 1} + \frac{\bigg(\frac{s^2_2}{n_2}\bigg)^2}{n_2 - 1}} = 8.28\]&lt;/span&gt; so &lt;span class=&#34;math display&#34;&gt;\[-t_{0.05, 8.28} = -1.851\]&lt;/span&gt;
&lt;em&gt;Note:&lt;/em&gt; The degrees of freedom 8.28 does not exist in the standard Student distribution table, so simply take 8, or compute it in R with &lt;code&gt;qt(p = 0.05, df = 8.28)&lt;/code&gt;. For simplicity, this number of degrees of freedom is sometimes approximated as &lt;span class=&#34;math inline&#34;&gt;\(df = min(n_1 - 1, n_2 - 1)\)&lt;/span&gt;, so in this case it would be &lt;span class=&#34;math inline&#34;&gt;\(df = 4\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;Conclusion: The rejection region is thus from &lt;span class=&#34;math inline&#34;&gt;\(-\infty\)&lt;/span&gt; to -1.851. The test statistic lies within the rejection region so we reject the null hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. In terms of the initial question: At the 5% significance level, we conclude that the mean of population 1 is smaller than the mean of population 2.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-4-paired-samples-where-the-variance-of-the-differences-is-known&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 4: Paired samples where the variance of the differences is known&lt;/h2&gt;
&lt;p&gt;Student’s t-test with paired samples are a bit different than with independent samples, they are actually more similar to &lt;a href=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/&#34;&gt;one sample Student’s t-test&lt;/a&gt;. Here is how it works. We actually compute the difference between the two samples for each pair of observations, and then we work on these differences as if we were doing a one sample Student’s t-test by computing the test statistic on these differences.&lt;/p&gt;
&lt;p&gt;In case it is not clear, here is the fourth scenario as an illustration. Suppose the data below. Moreover, suppose that the two samples are dependent (matched), that the variance of the differences in the population is known and equal to 1 (&lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_D = 1\)&lt;/span&gt;) and that we would like to test whether the mean difference between the two populations is different than 0.&lt;/p&gt;
&lt;table style=&#34;width:25%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;before&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;after&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.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The first thing to do is to compute the differences for all pairs of observations:&lt;/p&gt;
&lt;table style=&#34;width:42%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;col width=&#34;11%&#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;before&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;after&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;difference&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.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;-0.3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;number of pairs: &lt;span class=&#34;math inline&#34;&gt;\(n = 5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of the difference: &lt;span class=&#34;math inline&#34;&gt;\(\bar{D} = 0.04\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;variance of the difference in the population: &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_D = 1\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;standard deviation of the difference in the population: &lt;span class=&#34;math inline&#34;&gt;\(\sigma_D = 1\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Following the 4 steps of hypothesis testing we have:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_D = 0\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_D \ne 0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Test statistic: &lt;span class=&#34;math display&#34;&gt;\[z_{obs} = \frac{\bar{D} - \mu_0}{\frac{\sigma_D}{\sqrt{n}}} = \frac{0.04-0}{0.447} = 0.089\]&lt;/span&gt;
(This formula is exactly the same than for one sample Student’s t-test with a known variance, except that we work on the mean of the differences.)&lt;/li&gt;
&lt;li&gt;Critical value: &lt;span class=&#34;math inline&#34;&gt;\(\pm z_{\alpha/2} = \pm z_{0.025} = \pm 1.96\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Conclusion: The rejection regions are thus from &lt;span class=&#34;math inline&#34;&gt;\(-\infty\)&lt;/span&gt; to -1.96 and from 1.96 to &lt;span class=&#34;math inline&#34;&gt;\(+\infty\)&lt;/span&gt;. The test statistic is outside the rejection regions so we do not reject the null hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. In terms of the initial question: At the 5% significance level, we do not reject the hypothesis that the mean difference between the two populations is equal to 0.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 5: Paired samples where the variance of the differences is unknown&lt;/h2&gt;
&lt;p&gt;For the fifth and final scenario, suppose the data below. Moreover, suppose that the two samples are dependent (matched), that the variance of the differences in the population is unknown and that we would like to test whether a treatment is effective in increasing running capabilities (the higher the value, the better in terms of running capabilities).&lt;/p&gt;
&lt;table style=&#34;width:25%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;before&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;after&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;9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The first thing to do is to compute the differences for all pairs of observations:&lt;/p&gt;
&lt;table style=&#34;width:42%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;col width=&#34;11%&#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;before&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;after&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;difference&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;9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;16&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;11&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;15&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;12&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;number of pairs: &lt;span class=&#34;math inline&#34;&gt;\(n = 5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;mean of the difference: &lt;span class=&#34;math inline&#34;&gt;\(\bar{D} = 8\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;variance of the difference in the sample: &lt;span class=&#34;math inline&#34;&gt;\(s^2_D = 16\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;standard deviation of the difference in the sample: &lt;span class=&#34;math inline&#34;&gt;\(s_D = 4\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Following the 4 steps of hypothesis testing we have:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0: \mu_D = 0\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_D &amp;gt; 0\)&lt;/span&gt; (&amp;gt; because we would like to test whether the treatment is effective, so whether the treatment has a positive impact on the running capabilities.)&lt;/li&gt;
&lt;li&gt;Test statistic: &lt;span class=&#34;math display&#34;&gt;\[t_{obs} = \frac{\bar{D} - \mu_0}{\frac{s_D}{\sqrt{n}}} = \frac{8-0}{1.789} = 4.472\]&lt;/span&gt;
(This formula is exactly the same than for one sample Student’s t-test with an unknown variance, except that we work on the mean of the differences.)&lt;/li&gt;
&lt;li&gt;Critical value: &lt;span class=&#34;math inline&#34;&gt;\(t_{\alpha, n-1} = t_{0.05, 4} = 2.132\)&lt;/span&gt; (&lt;em&gt;n&lt;/em&gt; is the number of pairs, not the number of observations!)&lt;/li&gt;
&lt;li&gt;Conclusion: The rejection regions are thus from 2.132 to &lt;span class=&#34;math inline&#34;&gt;\(+\infty\)&lt;/span&gt;. The test statistic lies within the rejection region so we reject the null hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. In terms of the initial question: At the 5% significance level, we conclude that the treatment has a positive impact on the running capabilities (because the mean of the differences is greater than 0)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This concludes how to perform the different versions of the Student’s t-test for two samples by hand. In the next sections, we detail how to perform the exact same tests in R.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-compute-students-t-test-in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to compute Student’s t-test in R?&lt;/h1&gt;
&lt;p&gt;A good practice before doing t-tests in R is to visualize the data by group thanks to a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; (or a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#density-plot&#34;&gt;density plot&lt;/a&gt;, or eventually both). A boxplot with the two boxes overlapping each other gives a first indication that the two samples are similar, and thus, that the null hypothesis of equal means may not be rejected. On the contrary, if the two boxes are not overlapping, it indicates that the two samples are not similar, and thus, that the populations may be different in terms of the considered variable. However, even if boxplots or density plots are great in showing a comparison between the two groups, only a sound statistical test will confirm our first impression.&lt;/p&gt;
&lt;p&gt;After a visualization of the data by group, we replicate in R the results found by hand. We will see that for some versions of the t-test, there is no default function built in R (at least to my knowledge, do not hesitate to let me know in the comments if I’m mistaken). In these cases, a function is written to replicate the results by hand.&lt;/p&gt;
&lt;p&gt;Note that we use the same data, the same assumptions and the same question for all 5 scenarios to facilitate the comparison between the tests performed by hand and in R.&lt;/p&gt;
&lt;div id=&#34;scenario-1-independent-samples-with-2-known-variances-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 1: Independent samples with 2 known variances&lt;/h2&gt;
&lt;p&gt;For the first scenario, suppose the data below. Moreover, suppose that the two samples are independent, that the variances &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2 = 1\)&lt;/span&gt; in both populations and that we would like to test whether the two population means are different.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat1 &amp;lt;- data.frame(
  sample1 = c(0.9, -0.8, 0.1, -0.3, 0.2),
  sample2 = c(0.8, -0.9, -0.1, 0.4, 0.1)
)
dat1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   sample1 sample2
## 1     0.9     0.8
## 2    -0.8    -0.9
## 3     0.1    -0.1
## 4    -0.3     0.4
## 5     0.2     0.1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat_ggplot &amp;lt;- data.frame(
  value = c(0.9, -0.8, 0.1, -0.3, 0.2, 0.8, -0.9, -0.1, 0.4, 0.1),
  sample = c(rep(&amp;quot;1&amp;quot;, 5), rep(&amp;quot;2&amp;quot;, 5))
)

library(ggplot2)

ggplot(dat_ggplot) +
  aes(x = sample, y = value) +
  geom_boxplot() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-10-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that you can use 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; RStudio addin&lt;/a&gt; if you want to draw a boxplot with the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;package &lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt; without writing the code yourself. If you prefer the default graphics, use the &lt;code&gt;boxplot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(value ~ sample,
  data = dat_ggplot
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-11-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The two boxes seem to overlap which illustrate that the two samples are quite similar, so we tend to believe that we will not be able to reject the null hypothesis that the two population means are similar. However, only a formal statistical test will confirm this belief.&lt;/p&gt;
&lt;p&gt;Below a function to perform a t-test with known variances, with arguments accepting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the two samples (&lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the two variances of the populations (&lt;code&gt;V1&lt;/code&gt; and &lt;code&gt;V2&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the difference in means under the null hypothesis (&lt;code&gt;m0&lt;/code&gt;, default is &lt;code&gt;0&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the significance level (&lt;code&gt;alpha&lt;/code&gt;, default is &lt;code&gt;0.05&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;and the alternative (&lt;code&gt;alternative&lt;/code&gt;, one of &lt;code&gt;&#34;two.sided&#34;&lt;/code&gt; (default), &lt;code&gt;&#34;less&#34;&lt;/code&gt; or &lt;code&gt;&#34;greater&#34;&lt;/code&gt;):&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;t.test_knownvar &amp;lt;- function(x, y, V1, V2, m0 = 0, alpha = 0.05, alternative = &amp;quot;two.sided&amp;quot;) {
  M1 &amp;lt;- mean(x)
  M2 &amp;lt;- mean(y)
  n1 &amp;lt;- length(x)
  n2 &amp;lt;- length(y)
  sigma1 &amp;lt;- sqrt(V1)
  sigma2 &amp;lt;- sqrt(V2)
  S &amp;lt;- sqrt((V1 / n1) + (V2 / n2))
  statistic &amp;lt;- (M1 - M2 - m0) / S
  p &amp;lt;- if (alternative == &amp;quot;two.sided&amp;quot;) {
    2 * pnorm(abs(statistic), lower.tail = FALSE)
  } else if (alternative == &amp;quot;less&amp;quot;) {
    pnorm(statistic, lower.tail = TRUE)
  } else {
    pnorm(statistic, lower.tail = FALSE)
  }
  LCL &amp;lt;- (M1 - M2 - S * qnorm(1 - alpha / 2))
  UCL &amp;lt;- (M1 - M2 + S * qnorm(1 - alpha / 2))
  value &amp;lt;- list(mean1 = M1, mean2 = M2, m0 = m0, sigma1 = sigma1, sigma2 = sigma2, S = S, statistic = statistic, p.value = p, LCL = LCL, UCL = UCL, alternative = alternative)
  # print(sprintf(&amp;quot;P-value = %g&amp;quot;,p))
  # print(sprintf(&amp;quot;Lower %.2f%% Confidence Limit = %g&amp;quot;,
  #               alpha, LCL))
  # print(sprintf(&amp;quot;Upper %.2f%% Confidence Limit = %g&amp;quot;,
  #               alpha, UCL))
  return(value)
}

test &amp;lt;- t.test_knownvar(dat1$sample1, dat1$sample2,
  V1 = 1, V2 = 1
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $mean1
## [1] 0.02
## 
## $mean2
## [1] 0.06
## 
## $m0
## [1] 0
## 
## $sigma1
## [1] 1
## 
## $sigma2
## [1] 1
## 
## $S
## [1] 0.6324555
## 
## $statistic
## [1] -0.06324555
## 
## $p.value
## [1] 0.949571
## 
## $LCL
## [1] -1.27959
## 
## $UCL
## [1] 1.19959
## 
## $alternative
## [1] &amp;quot;two.sided&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output above recaps all the information needed to perform the test: the test statistic, the &lt;em&gt;p&lt;/em&gt;-value, the alternative used, the two sample means and the two variances of the populations (compare these results found in R with the results found by hand).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value can be extracted as usual:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.949571&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.95 so at the 5% significance level we do not reject the null hypothesis of equal means. There is no sufficient evidence in the data to reject the hypothesis that the two means in the populations are similar. This result confirms what we found by hand.&lt;/p&gt;
&lt;p&gt;Note that a similar function exists in the &lt;code&gt;{BSDA}&lt;/code&gt; package:&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(BSDA)

z.test(dat1$sample1,
  dat1$sample2,
  alternative = &amp;quot;two.sided&amp;quot;,
  mu = 0,
  sigma.x = 1,
  sigma.y = 1,
  conf.level = 0.95
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Two-sample z-Test
## 
## data:  dat1$sample1 and dat1$sample2
## z = -0.063246, p-value = 0.9496
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.27959  1.19959
## sample estimates:
## mean of x mean of y 
##      0.02      0.06&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;a-note-on-p-value-and-significance-level-alpha&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;A note on &lt;em&gt;p&lt;/em&gt;-value and significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;For those unfamiliar with the concept of &lt;em&gt;p&lt;/em&gt;-value, the &lt;em&gt;p&lt;/em&gt;-value is a &lt;a href=&#34;https://statsandr.com/blog/the-9-concepts-and-formulas-in-probability-that-every-data-scientist-should-know/&#34;&gt;probability&lt;/a&gt; and as any probability it goes from 0 to 1. The &lt;strong&gt;&lt;em&gt;p&lt;/em&gt;-value is the probability of having observations at least as extreme as the one we measured (via the samples) if the null hypothesis were true&lt;/strong&gt;. In other words, it is the probability of having a test statistic at least as extreme as the one we computed, given that the null hypothesis is true. In some sense, it gives you an indication on &lt;strong&gt;how likely your null hypothesis is&lt;/strong&gt;. It is also defined as the smallest level of significance for which the data indicate rejection of the null hypothesis.&lt;/p&gt;
&lt;p&gt;If the observations are not so extreme—not unlikely to occur if the null hypothesis were true—we do not reject this null hypothesis because it is deemed plausible to be true. And if the observations are considered too extreme—too unlikely to happen under the null hypothesis—we reject the null hypothesis because it is deemed too implausible to be true. Note that it does not mean that we are 100% sure that it is too unlikely, it happens sometimes that the null hypothesis is rejected although it is true (see the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; later on).&lt;/p&gt;
&lt;p&gt;In our example above, the observations are not really extreme and the difference between the two means is not extreme, so the test statistic is not extreme (since the test statistic is partially based on the difference of the means of the two samples). Having a test statistic which is not extreme is not unlikely and that is the reason why the &lt;em&gt;p&lt;/em&gt;-value is quite high. The &lt;em&gt;p&lt;/em&gt;-value of 0.95 actually tells us that the probability of having two samples with a difference in means of -0.04 (= 0.02 - 0.06), given that the difference in means in the populations is 0 (the null hypothesis), equals 95%. A probability of 95% is definitely considered as plausible, so we do not reject the null hypothesis of equal means in the populations.&lt;/p&gt;
&lt;p&gt;One may then wonder, “What is too extreme for a test statistic?” Most of the time, we consider that a test statistic is too extreme to happen just by chance when the probability of having such an extreme test statistic given that the null hypothesis is true is below 5%. The threshold of 5% (&lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;) that you very often see in statistic courses or textbooks is the threshold used in many fields. With a &lt;em&gt;p&lt;/em&gt;-value under that threshold of 5%, we consider that the observations (and thus the test statistic) is &lt;strong&gt;too unlikely&lt;/strong&gt; to happen just by chance if the null hypothesis were true, so the null hypothesis is rejected. With a &lt;em&gt;p&lt;/em&gt;-value above that threshold of 5%, we consider that it is not really implausible to face the observations we have if the null hypothesis were true, and we therefore do not reject the null hypothesis.&lt;/p&gt;
&lt;p&gt;Note that I wrote “we do not reject the null hypothesis”, and not “we accept the null hypothesis”. This is because it may be the case that the null hypothesis is in fact false, but we failed to prove it with the samples. Suppose the analogy of a suspect accused of murder and we do not know the truth. On the one hand, if we have collected enough evidence that the suspect committed the murder, he is considered guilty: we reject the null hypothesis that he is innocent. On the other hand, if we have &lt;em&gt;not&lt;/em&gt; collected enough evidence against the suspect, he is presumed to be innocent although he may in fact have committed the crime: we failed to reject the null hypothesis of him being innocent. We are never sure that he did not commit the crime even if he is released, we just did not find sufficient evidence against the null hypothesis of the suspect being innocent. This is the reason why we do not reject the null hypothesis instead of accepting it, and why you will often read things like “there is no sufficient evidence in the data to reject the null hypothesis” or “based on the samples we fail to reject the null hypothesis”.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;&lt;/strong&gt;, derived from the threshold of 5% mentioned earlier, &lt;strong&gt;is the probability of rejecting the null hypothesis when it is in fact true&lt;/strong&gt;. In this sense, it is an error (of 5%) that we accept to deal with, in order to be able to draw conclusions. If we would accept no error (an error of 0%), we would not be able to draw any conclusion about the population(s) since we only have access to a limited portion of the population(s) via the sample(s). As a consequence, we will never be 100% sure when interpreting the result of a hypothesis test unless we have access to the data for the entire population, but then there is no reason to do a hypothesis test anymore since we can simply compare the two populations. We usually allow this error (called Type I error) to be 5%, but in order to be a bit more certain when concluding that we reject the null hypothesis, the alpha level can also be set to 1% (or even to 0.1% in some rare cases).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To sum up&lt;/strong&gt; what you need to remember about &lt;em&gt;p&lt;/em&gt;-value and significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the &lt;em&gt;p&lt;/em&gt;-value is smaller than the predetermined significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (usually 5%) so if &lt;em&gt;p&lt;/em&gt;-value &amp;lt; 0.05 &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow H_0\)&lt;/span&gt; is unlikely &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; we reject the null hypothesis&lt;/li&gt;
&lt;li&gt;If the &lt;em&gt;p&lt;/em&gt;-value is greater than or equal to the predetermined significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (usually 5%) so if &lt;em&gt;p&lt;/em&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(\ge\)&lt;/span&gt; 0.05 &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow H_0\)&lt;/span&gt; is likely &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; we do &lt;strong&gt;not reject&lt;/strong&gt; the null hypothesis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This applies to all statistical tests without exception. Of course, the null and alternative hypotheses change depending on the test.&lt;/p&gt;
&lt;p&gt;A rule of thumb is that, for most hypothesis tests, the alternative hypothesis is what you want to test and the null hypothesis is the status quo. Take this with extreme caution (!) because, even if it works for all versions of the Student’s t-test it does not apply to ALL statistical tests. For example, when testing for normality, you usually want to test whether your distribution follows a normal distribution. Following this piece of advice, you would write the alternative hypothesis &lt;span class=&#34;math inline&#34;&gt;\(H_1:\)&lt;/span&gt; the distribution follows a normal distribution. Nonetheless, for &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;normality tests&lt;/a&gt; such as the Shapiro-Wilk or Kolmogorov-Smirnov test, it is the opposite; the alternative hypothesis is &lt;span class=&#34;math inline&#34;&gt;\(H_1:\)&lt;/span&gt; the distribution does not follow a normal distribution. So for every test, make sure to use the correct hypotheses, otherwise the conclusion and interpretation of your test will be wrong.&lt;/p&gt;
&lt;p&gt;Last but not least, note that statistical significance is &lt;strong&gt;not&lt;/strong&gt; equal to scientific significance. To this end, a result may be &lt;em&gt;statistically&lt;/em&gt; significant (a &lt;em&gt;p&lt;/em&gt;-value &amp;lt; &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;), but of little or no interest from a &lt;em&gt;scientific&lt;/em&gt; point of view (because the effect is so small that it is negligible and/or useless for instance).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-2-independent-samples-with-2-equal-but-unknown-variances-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 2: Independent samples with 2 equal but unknown variances&lt;/h2&gt;
&lt;p&gt;For the second scenario, suppose the data below. Moreover, suppose that the two samples are independent, that the variances in both populations are unknown but equal (&lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_1 = \sigma^2_1\)&lt;/span&gt;) and that we would like to test whether the mean of population 1 is larger than the mean of population 2.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat2 &amp;lt;- data.frame(
  sample1 = c(1.78, 1.5, 0.9, 0.6, 0.8, 1.9),
  sample2 = c(0.8, -0.7, -0.1, 0.4, 0.1, NA)
)
dat2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   sample1 sample2
## 1    1.78     0.8
## 2    1.50    -0.7
## 3    0.90    -0.1
## 4    0.60     0.4
## 5    0.80     0.1
## 6    1.90      NA&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat_ggplot &amp;lt;- data.frame(
  value = c(1.78, 1.5, 0.9, 0.6, 0.8, 1.9, 0.8, -0.7, -0.1, 0.4, 0.1),
  sample = c(rep(&amp;quot;1&amp;quot;, 6), rep(&amp;quot;2&amp;quot;, 5))
)

ggplot(dat_ggplot) +
  aes(x = sample, y = value) +
  geom_boxplot() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-16-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Unlike the previous scenario, the two boxes do not overlap which illustrates that the two samples are different from each other. From this boxplot, we can expect the test to reject the null hypothesis of equal means in the populations. Nonetheless, only a formal statistical test will confirm this expectation.&lt;/p&gt;
&lt;p&gt;There is a function in R, and it is simply the &lt;code&gt;t.test()&lt;/code&gt; function. This version of the test is actually the “standard” Student’s t-test for two samples. Note that it is assumed that the variances of the two populations are equal so we need to specify it in the function with the argument &lt;code&gt;var.equal = TRUE&lt;/code&gt; (the default is &lt;code&gt;FALSE&lt;/code&gt;) and the alternative hypothesis is &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_1 - \mu_2 &amp;gt; 0\)&lt;/span&gt; so we need to add the argument &lt;code&gt;alternative = &#34;greater&#34;&lt;/code&gt; as well:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- t.test(dat2$sample1, dat2$sample2,
  var.equal = TRUE, alternative = &amp;quot;greater&amp;quot;
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Two Sample t-test
## 
## data:  dat2$sample1 and dat2$sample2
## t = 3.4113, df = 9, p-value = 0.003867
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  0.5304908       Inf
## sample estimates:
## mean of x mean of y 
##  1.246667  0.100000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output above recaps all the information needed to perform the test: the name of the test, the test statistic, the degrees of freedom, the &lt;em&gt;p&lt;/em&gt;-value, the alternative used and the two sample means (compare these results found in R with the results found by hand).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value can be extracted as usual:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.003866756&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.004 so at the 5% significance level we reject the null hypothesis of equal means. This result confirms what we found by hand.&lt;/p&gt;
&lt;p&gt;Unlike the first scenario, the &lt;em&gt;p&lt;/em&gt;-value in this scenario is below 5% so we reject the null hypothesis. At the 5% significance level, we can conclude that the mean of population 1 is larger than the mean of population 2.&lt;/p&gt;
&lt;p&gt;A nice and easy way to report results of a Student’s t-test in R is with the &lt;code&gt;report()&lt;/code&gt; function from the &lt;code&gt;{report}&lt;/code&gt; package:&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(test)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Effect sizes were labelled following Cohen&amp;#39;s (1988) recommendations.
## 
## The Two Sample t-test testing the difference between dat2$sample1 and
## dat2$sample2 (mean of x = 1.25, mean of y = 0.10) suggests that the effect is
## positive, statistically significant, and large (difference = 1.15, 95% CI
## [0.53, Inf], t(9) = 3.41, p = 0.004; Cohen&amp;#39;s d = 2.07, 95% CI [0.75, Inf])&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, the function interprets the test (together with the &lt;em&gt;p&lt;/em&gt;-value) 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 &lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/&#34;&gt;tips and tricks in R&lt;/a&gt; if you find this one useful.&lt;/p&gt;
&lt;p&gt;If your data is formatted in the long format (which is even better), simply use the tilde (&lt;code&gt;~&lt;/code&gt;). For instance, imagine the exact same data presented like this:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat2bis &amp;lt;- data.frame(
  value = c(1.78, 1.5, 0.9, 0.6, 0.8, 1.9, 0.8, -0.7, -0.1, 0.4, 0.1),
  sample = c(rep(&amp;quot;1&amp;quot;, 6), rep(&amp;quot;2&amp;quot;, 5))
)
dat2bis&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    value sample
## 1   1.78      1
## 2   1.50      1
## 3   0.90      1
## 4   0.60      1
## 5   0.80      1
## 6   1.90      1
## 7   0.80      2
## 8  -0.70      2
## 9  -0.10      2
## 10  0.40      2
## 11  0.10      2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is how to perform the Student’s t-test in R with data in the long format:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- t.test(value ~ sample,
  data = dat2bis,
  var.equal = TRUE,
  alternative = &amp;quot;greater&amp;quot;
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Two Sample t-test
## 
## data:  value by sample
## t = 3.4113, df = 9, p-value = 0.003867
## alternative hypothesis: true difference in means between group 1 and group 2 is greater than 0
## 95 percent confidence interval:
##  0.5304908       Inf
## sample estimates:
## mean in group 1 mean in group 2 
##        1.246667        0.100000&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.003866756&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The results are exactly the same.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-3-independent-samples-with-2-unequal-and-unknown-variances-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 3: Independent samples with 2 unequal and unknown variances&lt;/h2&gt;
&lt;p&gt;For the third scenario, suppose the data below. Moreover, suppose that the two samples are independent, that the variances in both populations are unknown and unequal (&lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_1 \ne \sigma^2_1\)&lt;/span&gt;) and that we would like to test whether the mean of population 1 is smaller than the mean of population 2.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat3 &amp;lt;- data.frame(
  value = c(0.8, 0.7, 0.1, 0.4, 0.1, 1.78, 1.5, 0.9, 0.6, 0.8, 1.9),
  sample = c(rep(&amp;quot;1&amp;quot;, 5), rep(&amp;quot;2&amp;quot;, 6))
)
dat3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    value sample
## 1   0.80      1
## 2   0.70      1
## 3   0.10      1
## 4   0.40      1
## 5   0.10      1
## 6   1.78      2
## 7   1.50      2
## 8   0.90      2
## 9   0.60      2
## 10  0.80      2
## 11  1.90      2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat3) +
  aes(x = sample, y = value) +
  geom_boxplot() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-23-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;There is a function in R for this version of the test as well, and it is simply the &lt;code&gt;t.test()&lt;/code&gt; function with the &lt;code&gt;var.equal = FALSE&lt;/code&gt; argument. &lt;code&gt;FALSE&lt;/code&gt; is the default option for the &lt;code&gt;var.equal&lt;/code&gt; argument so you actually do not need to specify it. This version of the test is actually the Welch Student’s test, used when the variances of the populations are unknown and unequal. To test if two population variances are equal, you can use the Levene’s test (&lt;code&gt;leveneTest(dat3$value, dat3$sample)&lt;/code&gt; from the &lt;code&gt;{car}&lt;/code&gt; package, or simply by comparing the dispersion of the two samples via a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#dotplot&#34;&gt;dotplot&lt;/a&gt; or a boxplot). Note that the alternative hypothesis is &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_1 - \mu_2 &amp;lt; 0\)&lt;/span&gt; so we need to add the argument &lt;code&gt;alternative = &#34;less&#34;&lt;/code&gt; as well:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- t.test(value ~ sample,
  data = dat3,
  var.equal = FALSE,
  alternative = &amp;quot;less&amp;quot;
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Welch Two Sample t-test
## 
## data:  value by sample
## t = -3.0841, df = 8.2796, p-value = 0.007206
## alternative hypothesis: true difference in means between group 1 and group 2 is less than 0
## 95 percent confidence interval:
##        -Inf -0.3304098
## sample estimates:
## mean in group 1 mean in group 2 
##        0.420000        1.246667&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output above recaps all the information needed to perform the test (compare these results found in R with the results found by hand).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value can be extracted as usual:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.00720603&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.007 so at the 5% significance level we reject the null hypothesis of equal means, meaning that we can conclude that the mean of population 1 is smaller than the mean of population 2. This result confirms what we found by hand.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-4-paired-samples-where-the-variance-of-the-differences-is-known-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 4: Paired samples where the variance of the differences is known&lt;/h2&gt;
&lt;p&gt;For the fourth scenario, suppose the data below. Moreover, suppose that the two samples are dependent (matched), that the variance of the differences in the population is known and equal to 1 (&lt;span class=&#34;math inline&#34;&gt;\(\sigma^2_D = 1\)&lt;/span&gt;) and that we would like to test whether the mean difference between the two populations is different than 0.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat4 &amp;lt;- data.frame(
  before = c(0.9, -0.8, 0.1, -0.3, 0.2),
  after = c(0.8, -0.9, -0.1, 0.4, 0.1)
)
dat4&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   before after
## 1    0.9   0.8
## 2   -0.8  -0.9
## 3    0.1  -0.1
## 4   -0.3   0.4
## 5    0.2   0.1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat4$difference &amp;lt;- dat4$after - dat4$before

ggplot(dat4) +
  aes(y = difference) +
  geom_boxplot() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-27-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Since there is no function in R to perform a t-test with paired samples where the variance of the differences is known, here is one with arguments accepting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the differences between the two samples (&lt;code&gt;x&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the variance of the differences in the population (&lt;code&gt;V&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the mean of the differences under the null hypothesis (&lt;code&gt;m0&lt;/code&gt;, default is &lt;code&gt;0&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the significance level (&lt;code&gt;alpha&lt;/code&gt;, default is &lt;code&gt;0.05&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;and the alternative (&lt;code&gt;alternative&lt;/code&gt;, one of &lt;code&gt;&#34;two.sided&#34;&lt;/code&gt; (default), &lt;code&gt;&#34;less&#34;&lt;/code&gt; or &lt;code&gt;&#34;greater&#34;&lt;/code&gt;):&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;t.test_pairedknownvar &amp;lt;- function(x, V, m0 = 0, alpha = 0.05, alternative = &amp;quot;two.sided&amp;quot;) {
  M &amp;lt;- mean(x)
  n &amp;lt;- length(x)
  sigma &amp;lt;- sqrt(V)
  S &amp;lt;- sqrt(V / n)
  statistic &amp;lt;- (M - m0) / S
  p &amp;lt;- if (alternative == &amp;quot;two.sided&amp;quot;) {
    2 * pnorm(abs(statistic), lower.tail = FALSE)
  } else if (alternative == &amp;quot;less&amp;quot;) {
    pnorm(statistic, lower.tail = TRUE)
  } else {
    pnorm(statistic, lower.tail = FALSE)
  }
  LCL &amp;lt;- (M - S * qnorm(1 - alpha / 2))
  UCL &amp;lt;- (M + S * qnorm(1 - alpha / 2))
  value &amp;lt;- list(mean = M, m0 = m0, sigma = sigma, statistic = statistic, p.value = p, LCL = LCL, UCL = UCL, alternative = alternative)
  # print(sprintf(&amp;quot;P-value = %g&amp;quot;,p))
  # print(sprintf(&amp;quot;Lower %.2f%% Confidence Limit = %g&amp;quot;,
  #               alpha, LCL))
  # print(sprintf(&amp;quot;Upper %.2f%% Confidence Limit = %g&amp;quot;,
  #               alpha, UCL))
  return(value)
}

test &amp;lt;- t.test_pairedknownvar(dat4$after - dat4$before,
  V = 1
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $mean
## [1] 0.04
## 
## $m0
## [1] 0
## 
## $sigma
## [1] 1
## 
## $statistic
## [1] 0.08944272
## 
## $p.value
## [1] 0.9287301
## 
## $LCL
## [1] -0.8365225
## 
## $UCL
## [1] 0.9165225
## 
## $alternative
## [1] &amp;quot;two.sided&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output above recaps all the information needed to perform the test (compare these results found in R with the results found by hand).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value can be extracted as usual:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.9287301&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.929 so at the 5% significance level we do not reject the null hypothesis of the mean of the differences being equal to 0. There is no sufficient evidence in the data to reject the hypothesis that the mean difference between the two populations is equal to 0. This result confirms what we found by hand.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scenario 5: Paired samples where the variance of the differences is unknown&lt;/h2&gt;
&lt;p&gt;For the fifth and final scenario, suppose the data below. Moreover, suppose that the two samples are dependent (matched), that the variance of the differences in the population is unknown and that we would like to test whether a treatment is effective in increasing running capabilities (the higher the value, the better in terms of running capabilities).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat5 &amp;lt;- data.frame(
  before = c(9, 8, 1, 3, 2),
  after = c(16, 11, 15, 12, 9)
)
dat5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   before after
## 1      9    16
## 2      8    11
## 3      1    15
## 4      3    12
## 5      2     9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat5$difference &amp;lt;- dat5$after - dat5$before

ggplot(dat5) +
  aes(y = difference) +
  geom_boxplot() +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-31-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;There is a function in R for this version of the test, and it is simply the &lt;code&gt;t.test()&lt;/code&gt; function with the &lt;code&gt;paired = TRUE&lt;/code&gt; argument. This version of the test is actually the standard version of the Student’s t-test with paired samples. Note that the alternative hypothesis is &lt;span class=&#34;math inline&#34;&gt;\(H_1: \mu_D &amp;gt; 0\)&lt;/span&gt; so we need to add the argument &lt;code&gt;alternative = &#34;greater&#34;&lt;/code&gt; as well:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- t.test(dat5$after, dat5$before,
  alternative = &amp;quot;greater&amp;quot;,
  paired = TRUE
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Paired t-test
## 
## data:  dat5$after and dat5$before
## t = 4.4721, df = 4, p-value = 0.005528
## alternative hypothesis: true mean difference is greater than 0
## 95 percent confidence interval:
##  4.186437      Inf
## sample estimates:
## mean difference 
##               8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that we wrote &lt;code&gt;after&lt;/code&gt; and then &lt;code&gt;before&lt;/code&gt; in this order. If you write &lt;code&gt;before&lt;/code&gt; and then &lt;code&gt;after&lt;/code&gt;, make sure to change the alternative to &lt;code&gt;alternative = &#34;less&#34;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If your data is in the long format, use the tilde &lt;code&gt;~&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat5 &amp;lt;- data.frame(
  value = c(9, 8, 1, 3, 2, 16, 11, 15, 12, 9),
  time = c(rep(&amp;quot;before&amp;quot;, 5), rep(&amp;quot;after&amp;quot;, 5))
)
dat5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    value   time
## 1      9 before
## 2      8 before
## 3      1 before
## 4      3 before
## 5      2 before
## 6     16  after
## 7     11  after
## 8     15  after
## 9     12  after
## 10     9  after&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- t.test(value ~ time,
  data = dat5,
  alternative = &amp;quot;greater&amp;quot;,
  paired = TRUE
)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Paired t-test
## 
## data:  value by time
## t = 4.4721, df = 4, p-value = 0.005528
## alternative hypothesis: true mean difference is greater than 0
## 95 percent confidence interval:
##  4.186437      Inf
## sample estimates:
## mean difference 
##               8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output above recaps all the information needed to perform the test (compare these results found in R with the results found by hand).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value can be extracted as usual:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.005528247&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is 0.006 so at the 5% significance level we reject the null hypothesis of the mean of the differences being equal to 0, meaning that we can conclude that the treatment is effective in increasing the running capabilities (because the mean of the differences is greater than 0). This result confirms what we found by hand.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-plot-and-statistical-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Combination of plot and statistical test&lt;/h2&gt;
&lt;p&gt;After having written this article, I discovered the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package which I believe is worth mentioning here, in particular the &lt;code&gt;ggbetweenstats()&lt;/code&gt; and &lt;code&gt;ggwithinstats()&lt;/code&gt; functions for independent and paired samples, respectively.&lt;/p&gt;
&lt;p&gt;These two functions combine a boxplot—representing the distribution for each group—and the results of the statistical test displayed in the subtitle of the plot.&lt;/p&gt;
&lt;p&gt;See examples below for scenarios 2, 3 and 5. Unfortunately, the package does not allow to run tests for scenarios 1 and 4.&lt;/p&gt;
&lt;div id=&#34;scenario-2-independent-samples-with-2-equal-but-unknown-variances-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scenario 2: Independent samples with 2 equal but unknown variances&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ggbetweenstats()&lt;/code&gt; function is used for independent samples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(ggstatsplot)
library(ggplot2)

# plot with statistical results
ggbetweenstats(
  data = dat2bis,
  x = sample,
  y = value,
  plot.type = &amp;quot;box&amp;quot;, # for boxplot
  type = &amp;quot;parametric&amp;quot;, # for student&amp;#39;s t-test
  var.equal = TRUE, # equal variances
  centrality.plotting = FALSE # remove mean
) +
  labs(caption = NULL) # remove caption&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-35-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is displayed after &lt;code&gt;p =&lt;/code&gt; in the subtitle of the plot. Based on this plot and the &lt;em&gt;p&lt;/em&gt;-value being lower than 5% (&lt;em&gt;p&lt;/em&gt;-value = 0.008), we reject the null hypothesis that the two population means are equal.&lt;/p&gt;
&lt;p&gt;Note that, the &lt;em&gt;p&lt;/em&gt;-value is two times as large as the one obtained with the &lt;code&gt;t.test()&lt;/code&gt; function because when we ran &lt;code&gt;t.test()&lt;/code&gt; we specified &lt;code&gt;alternative = &#34;greater&#34;&lt;/code&gt; (i.e., a one-sided test). In our plot with the &lt;code&gt;ggbetweenstats()&lt;/code&gt; function, it is a two-sided test that is performed by default, that is, &lt;code&gt;alternative = &#34;two.sided&#34;&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-3-independent-samples-with-2-unequal-and-unknown-variances-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scenario 3: Independent samples with 2 unequal and unknown variances&lt;/h3&gt;
&lt;p&gt;We also have independent samples so we use the &lt;code&gt;ggbetweenstats()&lt;/code&gt; function again, but this time the two populations variances are not assumed to be equal so we specify the argument &lt;code&gt;var.equal = FALSE&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot with statistical results
ggbetweenstats(
  data = dat3,
  x = sample,
  y = value,
  plot.type = &amp;quot;box&amp;quot;, # for boxplot
  type = &amp;quot;parametric&amp;quot;, # for student&amp;#39;s t-test
  var.equal = FALSE, # unequal variances
  centrality.plotting = FALSE # remove mean
) +
  labs(caption = NULL) # remove caption&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-36-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Based on the output, we reject the null hypothesis that the two population means are equal (&lt;em&gt;p&lt;/em&gt;-value = 0.01).&lt;/p&gt;
&lt;p&gt;Note that the &lt;em&gt;p&lt;/em&gt;-value displayed in the subtitle of the plot is also two times larger than with the &lt;code&gt;t.test()&lt;/code&gt; function for the same reason than above.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scenario-5-paired-samples-where-the-variance-of-the-differences-is-unknown-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scenario 5: Paired samples where the variance of the differences is unknown&lt;/h3&gt;
&lt;p&gt;In this case, the samples are paired so we use the &lt;code&gt;ggwithinstats()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggwithinstats(
  data = dat5,
  x = time,
  y = value,
  type = &amp;quot;parametric&amp;quot;, # for student&amp;#39;s t-test
  centrality.plotting = FALSE # remove mean
) +
  labs(caption = NULL) # remove caption&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios_files/figure-html/unnamed-chunk-38-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Based on the output, we reject the null hypothesis that mean of the differences between the two populations is equal to 0 (&lt;em&gt;p&lt;/em&gt;-value = 0.01).&lt;/p&gt;
&lt;p&gt;Again the &lt;em&gt;p&lt;/em&gt;-value in the subtitle of the plot is twice the one obtained with the &lt;code&gt;t.test()&lt;/code&gt; function for the same reason than above.&lt;/p&gt;
&lt;p&gt;The point of this section was to illustrate how to easily draw plots together with statistical results, which is exactly the aim of the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package. See more details and examples in this &lt;a href=&#34;https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;assumptions&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Assumptions&lt;/h1&gt;
&lt;p&gt;As for many &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt;, there are some assumptions that need to be met in order to be able to interpret the results. When one or several of them are not met, although it is technically possible to perform these tests, it would be incorrect to interpret the results or trust the conclusions.&lt;/p&gt;
&lt;p&gt;Below are the assumptions of the Student’s t-test for two samples, how to test them and which other tests exist if an assumption is not met:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Variable type&lt;/strong&gt;: A Student’s t-test requires a mix of one &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative&lt;/a&gt; dependent variable (which corresponds to the measurements to which the question relates) and one &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative&lt;/a&gt; independent variable (with exactly 2 levels which will determine the groups to compare).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Independence&lt;/strong&gt;: The data, collected from a representative and randomly selected portion of the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt;, should be independent between groups and within each group. The assumption of independence is most often verified based on the design of the experiment and on the good control of experimental conditions rather than via a formal test. If you are still unsure about independence based on the experiment design, ask yourself if one observation is related to another (if one observation has an impact on another) within each group or between the groups themselves. If not, it is most likely that you have independent &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;samples&lt;/a&gt;. If observations between samples (forming the different groups to be compared) are dependent (for example, if two measurements have been collected on the &lt;strong&gt;same individuals&lt;/strong&gt; as it is often the case in medical studies when measuring a metric (i) before and (ii) after a treatment), the paired version of the Student’s t-test, called the Student’s t-test for paired samples, should be preferred in order to take into account the dependency between the two groups to be compared.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normality&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;With small samples (usually &lt;span class=&#34;math inline&#34;&gt;\(n &amp;lt; 30\)&lt;/span&gt;), when the two samples are independent, observations in &lt;strong&gt;both samples&lt;/strong&gt; should follow a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;&lt;strong&gt;normal distribution&lt;/strong&gt;&lt;/a&gt;. When using the Student’s t-test for paired samples, it is the difference between the observations of the two samples that should follow a normal distribution. The normality assumption can be tested visually thanks to a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; and a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#qq-plot&#34;&gt;QQ-plot&lt;/a&gt;, and/or formally via a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#normality-test&#34;&gt;normality test&lt;/a&gt; such as the Shapiro-Wilk or Kolmogorov-Smirnov test. If, even after a transformation (e.g., logarithmic transformation, square root, etc.), your data still do not follow a normal distribution, the &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Wilcoxon test&lt;/a&gt; (&lt;code&gt;wilcox.test(variable1 ~ variable2, data = dat&lt;/code&gt; in R) can be applied. This non-parametric test, robust to non normal distributions, compares the medians instead of the means in order to compare the two populations.&lt;/li&gt;
&lt;li&gt;With large samples (usually &lt;span class=&#34;math inline&#34;&gt;\(n \ge 30\)&lt;/span&gt;), &lt;strong&gt;normality of the data is not required&lt;/strong&gt; (this is a common misconception!). By the &lt;a href=&#34;https://en.wikipedia.org/wiki/Central_limit_theorem&#34; target=&#34;_blank&#34;&gt;central limit theorem&lt;/a&gt;, sample means of large samples are often well-approximated by a normal distribution even if the data are not normally distributed &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-stevens2013intermediate&#34; role=&#34;doc-biblioref&#34;&gt;Stevens 2013&lt;/a&gt;)&lt;/span&gt;. It is therefore not required to test the normality assumption when the number of observations in each group/sample is large.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Equality of variances&lt;/strong&gt;: When the two samples are independent, the variances of the two groups should be equal in the populations (an assumption called &lt;strong&gt;homogeneity of the variances&lt;/strong&gt;, or even sometimes referred as homoscedasticity, as opposed to heteroscedasticity if variances are different across groups). This assumption can be tested graphically (by comparing the dispersion in a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplot&lt;/a&gt; or &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#dotplot&#34;&gt;dotplot&lt;/a&gt; for instance), or more formally via the Levene’s test (&lt;code&gt;leveneTest(variable ~ group)&lt;/code&gt; from the &lt;code&gt;{car}&lt;/code&gt; package) or via a F test (&lt;code&gt;var.test(variable ~ group)&lt;/code&gt;). If the hypothesis of equal variances is rejected, another version of the Student’s t-test can be used: the Welch test (&lt;code&gt;t.test(variable ~ group, var.equal = FALSE)&lt;/code&gt;). Note that the Welch test does not require homogeneity of the variances, but the distributions should still follow a normal distribution in case of small sample sizes. If your distributions are not normally distributed or the variances are unequal, the &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Wilcoxon test&lt;/a&gt; should be used. This test does not require the assumptions of normality nor homoscedasticity of the variances.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Outliers&lt;/strong&gt;: An &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outlier&lt;/a&gt; is a value or an observation that is distant from the other observations. There should be &lt;strong&gt;no significant outliers in the two groups&lt;/strong&gt;, or the conclusions of your t-test may be flawed. There are several methods to &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;detect outliers&lt;/a&gt; in your data but in order to deal with them, it is your choice to either:
&lt;ul&gt;
&lt;li&gt;use the non-parametric version (i.e., the &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Wilcoxon test&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;transform your data (logarithmic or Box-Cox transformation, among others)&lt;/li&gt;
&lt;li&gt;or remove them (be careful)&lt;/li&gt;
&lt;/ul&gt;&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;This concludes a relatively long article. Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article helped you to understand how the different versions of the Student’s t-test for two samples work and how to perform them by hand and in R. If you are interested, here is a &lt;a href=&#34;https://statsandr.com/blog/a-shiny-app-for-inferential-statistics-by-hand/&#34;&gt;Shiny app&lt;/a&gt; to perform these tests by hand easily (you just need to enter your data and select the appropriate version of the test thanks to the sidebar menu).&lt;/p&gt;
&lt;p&gt;Moreover, I invite you to read:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;this &lt;a href=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/&#34;&gt;article&lt;/a&gt; if you would like to know how to compute the Student’s t-test but this time, for one sample,&lt;/li&gt;
&lt;li&gt;this &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;article&lt;/a&gt; if you would like to compare 2 groups under the non-normality assumption, or&lt;/li&gt;
&lt;li&gt;this &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;article&lt;/a&gt; if you would like to use an ANOVA to compare 3 or more groups.&lt;/li&gt;
&lt;/ul&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-rowntree2000statistics&#34; class=&#34;csl-entry&#34;&gt;
Rowntree, Derek. 2000. &lt;em&gt;Statistics Without Tears&lt;/em&gt;.
&lt;/div&gt;
&lt;div id=&#34;ref-stevens2013intermediate&#34; class=&#34;csl-entry&#34;&gt;
Stevens, James P. 2013. &lt;em&gt;Intermediate Statistics: A Modern Approach&lt;/em&gt;. Routledge.
&lt;/div&gt;
&lt;/div&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;Remind that inferential statistics, as opposed to &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;descriptive statistics&lt;/a&gt;, is a branch of statistics defined as the science of drawing conclusions about a population from observations made on a representative sample of that population. See the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;difference between population and sample&lt;/a&gt;.&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;For the rest of the present article, when we write Student’s t-test, we refer to the case of 2 samples. See &lt;a href=&#34;https://statsandr.com/blog/how-to-perform-a-one-sample-t-test-by-hand-and-in-r-test-on-one-mean/&#34;&gt;one sample t-test&lt;/a&gt; if you want to compare only one sample.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;It is a least the case for parametric hypothesis tests. A parametric test means that it is based on a theoretical statistical distribution, which depends on some defined parameters. In the case of the Student’s t-test for two samples, it is based on the Student’s t distribution with a single parameter, the degrees of freedom (&lt;span class=&#34;math inline&#34;&gt;\(df = n_1 + n_2 - 2\)&lt;/span&gt; where &lt;span class=&#34;math inline&#34;&gt;\(n_1\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(n_2\)&lt;/span&gt; are the two sample sizes), or the normal distribution.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Thanks gmacar for pointing it out to me.&lt;a href=&#34;#fnref4&#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>Correlogram in R: how to highlight the most correlated variables in a dataset</title>
      <link>https://statsandr.com/blog/correlogram-in-r-how-to-highlight-the-most-correlated-variables-in-a-dataset/</link>
      <pubDate>Sat, 22 Feb 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/correlogram-in-r-how-to-highlight-the-most-correlated-variables-in-a-dataset/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-matrix&#34; id=&#34;toc-correlation-matrix&#34;&gt;Correlation matrix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlogram&#34; id=&#34;toc-correlogram&#34;&gt;Correlogram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-test&#34; id=&#34;toc-correlation-test&#34;&gt;Correlation test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#code&#34; id=&#34;toc-code&#34;&gt;Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ggstatsplot-package&#34; id=&#34;toc-ggstatsplot-package&#34;&gt;&lt;code&gt;{ggstatsplot}&lt;/code&gt; package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#lares-package&#34; id=&#34;toc-lares-package&#34;&gt;&lt;code&gt;{lares}&lt;/code&gt; package&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#all-possible-correlations&#34; id=&#34;toc-all-possible-correlations&#34;&gt;All possible correlations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-of-one-variable-against-all-others&#34; id=&#34;toc-correlation-of-one-variable-against-all-others&#34;&gt;Correlation of one variable against all others&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/correlogram-in-r-how-to-highlight-correlations-between-variables_files/correlogram-in-r-how-to-highlight-correlations-between-variables.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;Correlation&lt;/a&gt;, often computed as part of &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt;, is a statistical tool used to study the relationship between two variables, that is, whether and how strongly couples of variables are associated.&lt;/p&gt;
&lt;p&gt;Correlations are measured between 2 variables at a time. Therefore, for datasets with many variables, computing correlations can become quite cumbersome and time consuming.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation-matrix&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Correlation matrix&lt;/h1&gt;
&lt;p&gt;A solution to this problem is to compute correlations and display them in a correlation matrix, which shows correlation coefficients for all possible combinations of two variables in the dataset.&lt;/p&gt;
&lt;p&gt;For example, below is the correlation matrix for the dataset &lt;code&gt;mtcars&lt;/code&gt; (which, as described by the help documentation of R, comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles).&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; For this article, we include only the &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;continuous&lt;/a&gt; variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- mtcars[, c(1, 3:7)]
round(cor(dat), 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        mpg  disp    hp  drat    wt  qsec
## mpg   1.00 -0.85 -0.78  0.68 -0.87  0.42
## disp -0.85  1.00  0.79 -0.71  0.89 -0.43
## hp   -0.78  0.79  1.00 -0.45  0.66 -0.71
## drat  0.68 -0.71 -0.45  1.00 -0.71  0.09
## wt   -0.87  0.89  0.66 -0.71  1.00 -0.17
## qsec  0.42 -0.43 -0.71  0.09 -0.17  1.00&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Even after rounding the correlation coefficients to 2 digits, you will conceive that this correlation matrix is not easily and quickly interpretable.&lt;/p&gt;
&lt;p&gt;If you are using &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt;, you can use the &lt;code&gt;pander()&lt;/code&gt; function from the &lt;code&gt;{pander}&lt;/code&gt; package to make it slightly more readable, but still, we must admit that this table is not optimal when it comes to visualizing correlations between several variables of a dataset, especially for large datasets.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;correlogram&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Correlogram&lt;/h1&gt;
&lt;p&gt;To tackle this issue and make it much more insightful, let’s transform the correlation matrix into a correlation plot. A correlation plot (also referred as a correlogram or corrgram in &lt;span class=&#34;citation&#34;&gt;Friendly (&lt;a href=&#34;#ref-friendly2002corrgrams&#34;&gt;2002&lt;/a&gt;)&lt;/span&gt;) allows to highlight the variables that are most (positively and negatively) correlated. Below an example with the same dataset presented above:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/correlogram-in-r-how-to-highlight-correlations-between-variables_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The correlogram represents the correlations for all pairs of variables. Positive correlations are displayed in blue and negative correlations in red. The intensity of the color is proportional to the correlation coefficient so the stronger the correlation (i.e., the closer to -1 or 1), the darker the boxes. The color legend on the right hand side of the correlogram shows the correlation coefficients and the corresponding colors.&lt;/p&gt;
&lt;p&gt;As a reminder, a negative correlation implies that the two variables under consideration vary in opposite directions, that is, if one variable increases the other decreases and vice versa. A positive correlation implies that the two variables under consideration vary in the same direction, that is, if one variable increases the other increases and if one variable decreases the other decreases as well. Furthermore, the stronger the correlation, the stronger the association between the two variables.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Correlation test&lt;/h1&gt;
&lt;p&gt;Finally, a white box in the correlogram indicates that the correlation is not significantly different from 0 at the specified significance level (in this example, at &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 5\)&lt;/span&gt;%) for the couple of variables. A correlation not significantly different from 0 means that there is &lt;strong&gt;no linear&lt;/strong&gt; relationship between the two variables considered in the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt; (there could be another kind of association, but not linear).&lt;/p&gt;
&lt;p&gt;To determine whether a specific correlation coefficient is significantly different from 0, a &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation test&lt;/a&gt; has been performed. Remind that the null and alternative hypotheses of this test are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\rho = 0\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: &lt;span class=&#34;math inline&#34;&gt;\(\rho \ne 0\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(\rho\)&lt;/span&gt; is denotes the correlation. The correlation test is based on two factors: the number of observations and the correlation coefficient. The more observations and the stronger the correlation between 2 variables, the more likely it is to reject the null hypothesis of no correlation between these 2 variables.&lt;/p&gt;
&lt;p&gt;In the context of our example, the correlogram above shows that the variables &lt;code&gt;wt&lt;/code&gt; (weight) and &lt;code&gt;hp&lt;/code&gt; (horsepower) are positively correlated, while the variables &lt;code&gt;mpg&lt;/code&gt; (miles per gallon) and &lt;code&gt;wt&lt;/code&gt; (weight) are negatively correlated (both correlations make sense if we think about it). Furthermore, the variables &lt;code&gt;wt&lt;/code&gt; and &lt;code&gt;qsec&lt;/code&gt; are not correlated (indicated by a white box). Even if the correlation coefficient is -0.17 between the 2 variables, the correlation test has shown that we cannot reject the hypothesis of no correlation in the population. This is the reason the box for these two variable is white.&lt;/p&gt;
&lt;p&gt;Although this correlogram presents exactly the same information than the correlation matrix, the correlogram presents a visual representation of the correlation matrix, allowing to quickly scan through it to see which variables are correlated and which are not.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;code&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Code&lt;/h1&gt;
&lt;p&gt;For those interested to draw this correlogram with their own data, here is the code of the function I adapted based on the &lt;code&gt;corrplot()&lt;/code&gt; function from the &lt;code&gt;{corrplot}&lt;/code&gt; package (thanks again to all contributors of this package):&lt;/p&gt;
&lt;script src=&#34;https://gist.github.com/AntoineSoetewey/1fc0fe939336a8b8085e1872e045b48f.js&#34;&gt;&lt;/script&gt;
&lt;p&gt;The main arguments in the &lt;code&gt;corrplot2()&lt;/code&gt; function are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;data&lt;/code&gt;: name of your dataset&lt;/li&gt;
&lt;li&gt;&lt;code&gt;method&lt;/code&gt;: the correlation method to be computed, one of “pearson” (default), “kendall”, or “spearman”. As a rule of thumb, if your dataset contains &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;quantitative continuous&lt;/a&gt; variables that have a linear relationship, you can keep the Pearson method. If you have &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#ordinal&#34;&gt;qualitative ordinal&lt;/a&gt; variables or quantitative variables with a partially linear link, the Spearman method is more appropriate&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sig.level&lt;/code&gt;: the significance level for the correlation test, default is 0.05&lt;/li&gt;
&lt;li&gt;&lt;code&gt;order&lt;/code&gt;: order of the variables, one of “original” (default), “AOE” (angular order of the eigenvectors), “FPC” (first principal component order), “hclust” (hierarchical clustering order), “alphabet” (alphabetical order)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;diag&lt;/code&gt;: display the correlation coefficients on the diagonal? The default is &lt;code&gt;FALSE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;type&lt;/code&gt;: display the entire correlation matrix or simply the upper/lower part, one of “upper” (default), “lower”, “full”&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tl.srt&lt;/code&gt;: rotation of the variable labels&lt;/li&gt;
&lt;li&gt;(note that missing values in the dataset are automatically removed)&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- You can also play with the arguments of the `corrplot2` function and see the results thanks to this [R Shiny app](https://antoinesoetewey.shinyapps.io/correlogram/){target=&#34;_blank&#34;}. --&gt;
&lt;/div&gt;
&lt;div id=&#34;ggstatsplot-package&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;&lt;code&gt;{ggstatsplot}&lt;/code&gt; package&lt;/h1&gt;
&lt;p&gt;An alternative to the correlogram presented above is possible with the &lt;code&gt;ggcorrmat()&lt;/code&gt; function from the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load package
library(ggstatsplot)

# correlogram
ggstatsplot::ggcorrmat(
  data = dat,
  type = &amp;quot;parametric&amp;quot;, # parametric for Pearson, nonparametric for Spearman&amp;#39;s correlation
  colors = c(&amp;quot;darkred&amp;quot;, &amp;quot;white&amp;quot;, &amp;quot;steelblue&amp;quot;) # change default colors
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/correlogram-in-r-how-to-highlight-correlations-between-variables_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this correlogram, the non-significant correlations (by default at the 5% significance level with the Holm adjustment method) are shown by a cross on the correlation coefficients.&lt;/p&gt;
&lt;p&gt;The advantage of this alternative compared to the previous one is that it is directly available within a package, so you do not need to run the code of the function first in order to draw the correlogram.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;lares-package&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;&lt;code&gt;{lares}&lt;/code&gt; package&lt;/h1&gt;
&lt;p&gt;Thanks to this article, I discovered the &lt;code&gt;{lares}&lt;/code&gt; package which has really nice features regarding plotting correlations. Another advantage of this package is that it can be used to compute correlations with numerical, logical, categorical and date variables.&lt;/p&gt;
&lt;p&gt;See more information about the package in this &lt;a href=&#34;https://datascienceplus.com/find-insights-with-ranked-cross-correlations/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;all-possible-correlations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;All possible correlations&lt;/h2&gt;
&lt;p&gt;Use the &lt;code&gt;corr_cross()&lt;/code&gt; function if you want to compute all correlations and return the highest and significant ones in a plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# devtools::install_github(&amp;quot;laresbernardo/lares&amp;quot;)
library(lares)

corr_cross(dat, # name of dataset
  max_pvalue = 0.05, # display only significant correlations (at 5% level)
  top = 10 # display top 10 couples of variables (by correlation coefficient)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/correlogram-in-r-how-to-highlight-correlations-between-variables_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Negative correlations are represented in red and positive correlations in blue.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation-of-one-variable-against-all-others&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Correlation of one variable against all others&lt;/h2&gt;
&lt;p&gt;Use the &lt;code&gt;corr_var()&lt;/code&gt; function if you want to focus on the correlation of one variable against all others, and return the highest ones in a plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;corr_var(dat, # name of dataset
  mpg, # name of variable to focus on
  top = 5 # display top 5 correlations
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/correlogram-in-r-how-to-highlight-correlations-between-variables_files/figure-html/unnamed-chunk-5-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&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 this article will help you to visualize correlations between variables in a dataset and to make correlation matrices more insightful and more appealing.&lt;/p&gt;
&lt;p&gt;If you want to learn more about this topic, see:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how to &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;compute correlation coefficients and perform correlation tests in R&lt;/a&gt;, or&lt;/li&gt;
&lt;li&gt;how to &lt;a href=&#34;https://statsandr.com/blog/pearson-spearman-kendall-correlation-by-hand/&#34;&gt;compute correlation coefficients by hand&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-friendly2002corrgrams&#34; class=&#34;csl-entry&#34;&gt;
Friendly, Michael. 2002. &lt;span&gt;“Corrgrams: Exploratory Displays for Correlation Matrices.”&lt;/span&gt; &lt;em&gt;The American Statistician&lt;/em&gt; 56 (4): 316–24.
&lt;/div&gt;
&lt;/div&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;The dataset &lt;code&gt;mtcars&lt;/code&gt; is preloaded in R by default, so there is no need to import it into R. Check the article “&lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;How to import an Excel file in R&lt;/a&gt;” if you need help in importing your own dataset.&lt;a href=&#34;#fnref1&#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>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>The complete guide to clustering analysis: k-means and hierarchical clustering by hand and in R</title>
      <link>https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/</link>
      <pubDate>Thu, 13 Feb 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-is-clustering-analysis&#34; id=&#34;toc-what-is-clustering-analysis&#34;&gt;What is clustering analysis?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#application-1-computing-distances&#34; id=&#34;toc-application-1-computing-distances&#34;&gt;Application 1: Computing distances&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#solution&#34; id=&#34;toc-solution&#34;&gt;Solution&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#k-means-clustering&#34; id=&#34;toc-k-means-clustering&#34;&gt;&lt;em&gt;k&lt;/em&gt;-means clustering&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#application-2-k-means-clustering&#34; id=&#34;toc-application-2-k-means-clustering&#34;&gt;Application 2: &lt;em&gt;k&lt;/em&gt;-means clustering&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#kmeans-with-2-groups&#34; id=&#34;toc-kmeans-with-2-groups&#34;&gt;&lt;code&gt;kmeans()&lt;/code&gt; with 2 groups&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#quality-of-a-k-means-partition&#34; id=&#34;toc-quality-of-a-k-means-partition&#34;&gt;Quality of a &lt;em&gt;k&lt;/em&gt;-means partition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#nstart-for-several-initial-centers-and-better-stability&#34; id=&#34;toc-nstart-for-several-initial-centers-and-better-stability&#34;&gt;&lt;code&gt;nstart&lt;/code&gt; for several initial centers and better stability&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#kmeans-with-3-groups&#34; id=&#34;toc-kmeans-with-3-groups&#34;&gt;&lt;code&gt;kmeans()&lt;/code&gt; with 3 groups&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#optimal-number-of-clusters&#34; id=&#34;toc-optimal-number-of-clusters&#34;&gt;Optimal number of clusters&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#elbow-method&#34; id=&#34;toc-elbow-method&#34;&gt;Elbow method&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#silhouette-method&#34; id=&#34;toc-silhouette-method&#34;&gt;Silhouette method&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#gap-statistic-method&#34; id=&#34;toc-gap-statistic-method&#34;&gt;Gap statistic method&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#consensus-based-algorithm&#34; id=&#34;toc-consensus-based-algorithm&#34;&gt;Consensus-based algorithm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualizations&#34; id=&#34;toc-visualizations&#34;&gt;Visualizations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#manual-application-and-verification-in-r&#34; id=&#34;toc-manual-application-and-verification-in-r&#34;&gt;Manual application and verification in R&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#solution-by-hand&#34; id=&#34;toc-solution-by-hand&#34;&gt;Solution by hand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#solution-in-r&#34; id=&#34;toc-solution-in-r&#34;&gt;Solution in R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hierarchical-clustering&#34; id=&#34;toc-hierarchical-clustering&#34;&gt;Hierarchical clustering&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#application-3-hierarchical-clustering&#34; id=&#34;toc-application-3-hierarchical-clustering&#34;&gt;Application 3: hierarchical clustering&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#data-1&#34; id=&#34;toc-data-1&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#solution-by-hand-1&#34; id=&#34;toc-solution-by-hand-1&#34;&gt;Solution by hand&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#single-linkage&#34; id=&#34;toc-single-linkage&#34;&gt;Single linkage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#complete-linkage&#34; id=&#34;toc-complete-linkage&#34;&gt;Complete linkage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#average-linkage&#34; id=&#34;toc-average-linkage&#34;&gt;Average linkage&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#solution-in-r-1&#34; id=&#34;toc-solution-in-r-1&#34;&gt;Solution in R&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#single-linkage-1&#34; id=&#34;toc-single-linkage-1&#34;&gt;Single linkage&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#optimal-number-of-clusters-1&#34; id=&#34;toc-optimal-number-of-clusters-1&#34;&gt;Optimal number of clusters&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#complete-linkage-1&#34; id=&#34;toc-complete-linkage-1&#34;&gt;Complete linkage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#average-linkage-1&#34; id=&#34;toc-average-linkage-1&#34;&gt;Average linkage&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#k-means-versus-hierarchical-clustering&#34; id=&#34;toc-k-means-versus-hierarchical-clustering&#34;&gt;&lt;em&gt;k&lt;/em&gt;-means versus hierarchical clustering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#whats-next&#34; id=&#34;toc-whats-next&#34;&gt;What’s next?&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r-statsandr.com.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that this article is inspired from the lecture notes of Prof. Johan Segers and my personal notes as teaching assistant for his course entitled “Multivariate statistical analysis” given at UCLouvain.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;what-is-clustering-analysis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What is clustering analysis?&lt;/h1&gt;
&lt;p&gt;Clustering analysis is a form of exploratory data analysis in which observations are divided into different groups that share common characteristics.&lt;/p&gt;
&lt;p&gt;The purpose of cluster analysis (also known as classification) is to construct groups (or classes or &lt;em&gt;clusters&lt;/em&gt;) while ensuring the following property: &lt;strong&gt;within a group&lt;/strong&gt; the observations must be as &lt;strong&gt;similar&lt;/strong&gt; as possible (intracluster similarity), while observations belonging to &lt;strong&gt;different groups&lt;/strong&gt; must be as &lt;strong&gt;different&lt;/strong&gt; as possible (intercluster similarity).&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/intercluster-intracluster-distance.png&#34; style=&#34;width:100.0%&#34; alt=&#34;An illustration of intercluster and intracluster distance. Source: dinhanhthi.com&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;An illustration of intercluster and intracluster distance. Source: dinhanhthi.com&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The two most common types of classification are:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;em&gt;k&lt;/em&gt;-means clustering&lt;/li&gt;
&lt;li&gt;Hierarchical clustering&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first is generally used when the &lt;strong&gt;number of classes is fixed&lt;/strong&gt; in advance, while the second is generally used for an &lt;strong&gt;unknown number of classes&lt;/strong&gt; and helps to determine this optimal number. For this reason, &lt;em&gt;k&lt;/em&gt;-means is considered as a supervised technique, while hierarchical clustering is considered as an unsupervised technique because the estimation of the number of clusters is part of the algorithm. See more clustering methods in this &lt;a href=&#34;https://easystats.github.io/parameters/articles/clustering.html&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Both methods are illustrated below through applications by hand and in R. Note that for hierarchical clustering, only the &lt;em&gt;ascending&lt;/em&gt; classification is presented in this article.&lt;/p&gt;
&lt;p&gt;Clustering algorithms use the &lt;strong&gt;distance&lt;/strong&gt; in order to separate observations into different groups. Therefore, before diving into the presentation of the two classification methods, a reminder exercise on how to compute distances between points is presented.&lt;/p&gt;
&lt;div id=&#34;application-1-computing-distances&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Application 1: Computing distances&lt;/h2&gt;
&lt;p&gt;Let a data set containing the points &lt;span class=&#34;math inline&#34;&gt;\(\boldsymbol{a} = (0, 0)&amp;#39;\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\boldsymbol{b} = (1, 0)&amp;#39;\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\boldsymbol{c} = (5, 5)&amp;#39;\)&lt;/span&gt;. Compute the matrix of Euclidean distances between the points by hand and in R.&lt;/p&gt;
&lt;div id=&#34;solution&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;The points are as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# We create the points in R
a &amp;lt;- c(0, 0)
b &amp;lt;- c(1, 0)
c &amp;lt;- c(5, 5)

X &amp;lt;- rbind(a, b, c) # a, b and c are combined per row
colnames(X) &amp;lt;- c(&amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;) # rename columns

X # display the points&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   x y
## a 0 0
## b 1 0
## c 5 5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By the Pythagorean theorem, we will remember that the distance between 2 points &lt;span class=&#34;math inline&#34;&gt;\((x_a, y_a)\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\((x_b, y_b)\)&lt;/span&gt; in &lt;span class=&#34;math inline&#34;&gt;\(\mathbb{R}^2\)&lt;/span&gt; is given by &lt;span class=&#34;math inline&#34;&gt;\(\sqrt{(x_a - x_b)^2 + (y_a - y_b)^2}\)&lt;/span&gt;. So for instance, for the distance between the points &lt;span class=&#34;math inline&#34;&gt;\(\boldsymbol{b} = (1, 0)&amp;#39;\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\boldsymbol{c} = (5, 5)&amp;#39;\)&lt;/span&gt; presented in the statement above, we have:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{equation}
  \begin{split}
        d(b, c) &amp;amp;= \sqrt{(x_b - x_c)^2 + (y_b - y_c)^2} \\
        &amp;amp;= \sqrt{(1-5)^2 + (0-5)^2}\\
        &amp;amp;= 6.403124
  \end{split}
\end{equation}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We can proceed similarly for all pairs of points to find the distance matrix by hand. In R, the &lt;code&gt;dist()&lt;/code&gt; function allows you to find the distance of points in a matrix or dataframe in a very simple way:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# The distance is found using the dist() function:
distance &amp;lt;- dist(X, method = &amp;quot;euclidean&amp;quot;)
distance # display the distance matrix&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##          a        b
## b 1.000000         
## c 7.071068 6.403124&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the argument &lt;code&gt;method = &#34;euclidean&#34;&lt;/code&gt; is not mandatory because the Euclidean method is the default one.&lt;/p&gt;
&lt;p&gt;The distance matrix resulting from the &lt;code&gt;dist()&lt;/code&gt; function gives the distance between the different points. The Euclidean distance between the points &lt;span class=&#34;math inline&#34;&gt;\(\boldsymbol{b}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\boldsymbol{c}\)&lt;/span&gt; is 6.403124, which corresponds to what we found above via the Pythagorean formula.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If two variables do not have the same units, one may have more weight in the calculation of the Euclidean distance than the other. In that case, it is preferable to scale the data. Scaling data allows to obtain variables independent of their unit, and this can be done with the &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/#scale&#34;&gt;&lt;code&gt;scale()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;
&lt;p&gt;Now that the distance has been presented, let’s see how to perform clustering analysis with the k-means algorithm.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;k-means-clustering&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;&lt;em&gt;k&lt;/em&gt;-means clustering&lt;/h1&gt;
&lt;p&gt;The first form of classification is the method called &lt;em&gt;&lt;em&gt;k&lt;/em&gt;-means clustering&lt;/em&gt; or the mobile center algorithm. As a reminder, this method aims at partitioning &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; observations into &lt;span class=&#34;math inline&#34;&gt;\(k\)&lt;/span&gt; clusters in which each observation belongs to the cluster with the closest average, serving as a prototype of the cluster.&lt;/p&gt;
&lt;p&gt;We do not go too much into details about the mathematics. Instead, we focus on how to apply it in R and by hand.&lt;/p&gt;
&lt;div id=&#34;application-2-k-means-clustering&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Application 2: &lt;em&gt;k&lt;/em&gt;-means clustering&lt;/h2&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;p&gt;For this exercise, the &lt;code&gt;Eurojobs.csv&lt;/code&gt; database available &lt;a href=&#34;https://statsandr.com/blog/data/Eurojobs.csv&#34;&gt;here&lt;/a&gt; is used.&lt;/p&gt;
&lt;p&gt;This database contains the percentage of the population employed in different industries in 26 European countries in 1979. It contains 10 variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Country&lt;/code&gt; - the name of the country (identifier)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Agr&lt;/code&gt; - % of workforce employed in agriculture&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Min&lt;/code&gt; - % in mining&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Man&lt;/code&gt; - % in manufacturing&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PS&lt;/code&gt; - % in power supplies industries&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Con&lt;/code&gt; - % in construction&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SI&lt;/code&gt; - % in service industries&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Fin&lt;/code&gt; - % in finance&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SPS&lt;/code&gt; - % in social and personal services&lt;/li&gt;
&lt;li&gt;&lt;code&gt;TC&lt;/code&gt; - % in transportation and communications&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We first import the dataset. See &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;how to import data into R&lt;/a&gt; if you need a reminder.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Import data
Eurojobs &amp;lt;- read.csv(
  file = &amp;quot;https://statsandr.com/blog/data/Eurojobs.csv&amp;quot;,
  sep = &amp;quot;,&amp;quot;,
  dec = &amp;quot;.&amp;quot;,
  header = TRUE
)

head(Eurojobs) # head() is used to display only the first 6 observations&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      Country  Agr Min  Man  PS  Con   SI Fin  SPS  TC
## 1    Belgium  3.3 0.9 27.6 0.9  8.2 19.1 6.2 26.6 7.2
## 2    Denmark  9.2 0.1 21.8 0.6  8.3 14.6 6.5 32.2 7.1
## 3     France 10.8 0.8 27.5 0.9  8.9 16.8 6.0 22.6 5.7
## 4 W. Germany  6.7 1.3 35.8 0.9  7.3 14.4 5.0 22.3 6.1
## 5    Ireland 23.2 1.0 20.7 1.3  7.5 16.8 2.8 20.8 6.1
## 6      Italy 15.9 0.6 27.6 0.5 10.0 18.1 1.6 20.1 5.7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that there is a numbering before the first variable &lt;code&gt;Country&lt;/code&gt;. For more clarity, we will replace this numbering by the country. To do this, we add the argument &lt;code&gt;row.names = 1&lt;/code&gt; in the import function &lt;code&gt;read.csv()&lt;/code&gt; to specify that the first column corresponds to the row names:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Eurojobs &amp;lt;- read.csv(
  file = &amp;quot;https://statsandr.com/blog/data/Eurojobs.csv&amp;quot;,
  sep = &amp;quot;,&amp;quot;,
  dec = &amp;quot;.&amp;quot;,
  header = TRUE,
  row.names = 1
)

Eurojobs # displays dataset&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                 Agr Min  Man  PS  Con   SI  Fin  SPS  TC
## Belgium         3.3 0.9 27.6 0.9  8.2 19.1  6.2 26.6 7.2
## Denmark         9.2 0.1 21.8 0.6  8.3 14.6  6.5 32.2 7.1
## France         10.8 0.8 27.5 0.9  8.9 16.8  6.0 22.6 5.7
## W. Germany      6.7 1.3 35.8 0.9  7.3 14.4  5.0 22.3 6.1
## Ireland        23.2 1.0 20.7 1.3  7.5 16.8  2.8 20.8 6.1
## Italy          15.9 0.6 27.6 0.5 10.0 18.1  1.6 20.1 5.7
## Luxembourg      7.7 3.1 30.8 0.8  9.2 18.5  4.6 19.2 6.2
## Netherlands     6.3 0.1 22.5 1.0  9.9 18.0  6.8 28.5 6.8
## United Kingdom  2.7 1.4 30.2 1.4  6.9 16.9  5.7 28.3 6.4
## Austria        12.7 1.1 30.2 1.4  9.0 16.8  4.9 16.8 7.0
## Finland        13.0 0.4 25.9 1.3  7.4 14.7  5.5 24.3 7.6
## Greece         41.4 0.6 17.6 0.6  8.1 11.5  2.4 11.0 6.7
## Norway          9.0 0.5 22.4 0.8  8.6 16.9  4.7 27.6 9.4
## Portugal       27.8 0.3 24.5 0.6  8.4 13.3  2.7 16.7 5.7
## Spain          22.9 0.8 28.5 0.7 11.5  9.7  8.5 11.8 5.5
## Sweden          6.1 0.4 25.9 0.8  7.2 14.4  6.0 32.4 6.8
## Switzerland     7.7 0.2 37.8 0.8  9.5 17.5  5.3 15.4 5.7
## Turkey         66.8 0.7  7.9 0.1  2.8  5.2  1.1 11.9 3.2
## Bulgaria       23.6 1.9 32.3 0.6  7.9  8.0  0.7 18.2 6.7
## Czechoslovakia 16.5 2.9 35.5 1.2  8.7  9.2  0.9 17.9 7.0
## E. Germany      4.2 2.9 41.2 1.3  7.6 11.2  1.2 22.1 8.4
## Hungary        21.7 3.1 29.6 1.9  8.2  9.4  0.9 17.2 8.0
## Poland         31.1 2.5 25.7 0.9  8.4  7.5  0.9 16.1 6.9
## Rumania        34.7 2.1 30.1 0.6  8.7  5.9  1.3 11.7 5.0
## USSR           23.7 1.4 25.8 0.6  9.2  6.1  0.5 23.6 9.3
## Yugoslavia     48.7 1.5 16.8 1.1  4.9  6.4 11.3  5.3 4.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dim(Eurojobs) # displays the number of rows and columns&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 26  9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now have a “clean” dataset of 26 observations and 9 &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;quantitative continuous variables&lt;/a&gt; on which we can base the classification. Note that in this case it is not necessary to standardize the data because they are all expressed in the same unit (in percentage). If this was not the case, we would have had to standardize the data via the &lt;code&gt;scale()&lt;/code&gt; function (do not forget it otherwise your results may be completely different!).&lt;/p&gt;
&lt;p&gt;The so-called &lt;em&gt;k&lt;/em&gt;-means clustering is done via the &lt;code&gt;kmeans()&lt;/code&gt; function, with the argument &lt;code&gt;centers&lt;/code&gt; that corresponds to the number of desired clusters. In the following we apply the classification with 2 classes and then 3 classes as examples.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;kmeans-with-2-groups&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;&lt;code&gt;kmeans()&lt;/code&gt; with 2 groups&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- kmeans(Eurojobs, centers = 2)

# displays the class determined by
# the model for all observations:
model$cluster&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        Belgium        Denmark         France     W. Germany        Ireland 
##              1              1              1              1              2 
##          Italy     Luxembourg    Netherlands United Kingdom        Austria 
##              1              1              1              1              1 
##        Finland         Greece         Norway       Portugal          Spain 
##              1              2              1              2              2 
##         Sweden    Switzerland         Turkey       Bulgaria Czechoslovakia 
##              1              1              2              2              1 
##     E. Germany        Hungary         Poland        Rumania           USSR 
##              1              2              2              2              2 
##     Yugoslavia 
##              2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the argument &lt;code&gt;centers = 2&lt;/code&gt; is used to set the number of clusters, determined in advance. In this exercise the number of clusters has been determined arbitrarily.&lt;/p&gt;
&lt;p&gt;This number of clusters should be determined according to the context and goal of your analysis (so according to your expectations or hypotheses), or based on methods explained in this &lt;a href=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/#optimal-number-of-clusters&#34;&gt;section&lt;/a&gt;. The output &lt;code&gt;model$cluster&lt;/code&gt; specifies the group (i.e., 1 or 2) to which each country belongs to.&lt;/p&gt;
&lt;p&gt;The cluster for each observation can be stored directly in the dataset as a column:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Eurojobs_cluster &amp;lt;- data.frame(Eurojobs,
  cluster = as.factor(model$cluster)
)

head(Eurojobs_cluster)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             Agr Min  Man  PS  Con   SI Fin  SPS  TC cluster
## Belgium     3.3 0.9 27.6 0.9  8.2 19.1 6.2 26.6 7.2       1
## Denmark     9.2 0.1 21.8 0.6  8.3 14.6 6.5 32.2 7.1       1
## France     10.8 0.8 27.5 0.9  8.9 16.8 6.0 22.6 5.7       1
## W. Germany  6.7 1.3 35.8 0.9  7.3 14.4 5.0 22.3 6.1       1
## Ireland    23.2 1.0 20.7 1.3  7.5 16.8 2.8 20.8 6.1       2
## Italy      15.9 0.6 27.6 0.5 10.0 18.1 1.6 20.1 5.7       1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;quality-of-a-k-means-partition&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Quality of a &lt;em&gt;k&lt;/em&gt;-means partition&lt;/h3&gt;
&lt;p&gt;The quality of a &lt;em&gt;k&lt;/em&gt;-means partition is found by calculating the percentage of the &lt;em&gt;TSS&lt;/em&gt; “explained” by the partition using the following formula:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{equation}
\dfrac{\operatorname{BSS}}{\operatorname{TSS}} \times 100\%
\end{equation}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;em&gt;BSS&lt;/em&gt; and &lt;em&gt;TSS&lt;/em&gt; stand for &lt;em&gt;Between Sum of Squares&lt;/em&gt; and &lt;em&gt;Total Sum of Squares&lt;/em&gt;, respectively. The higher the percentage, the better the score (and thus the quality) because it means that &lt;em&gt;BSS&lt;/em&gt; is large and/or &lt;em&gt;WSS&lt;/em&gt; is small.&lt;/p&gt;
&lt;p&gt;Here is how you can check the quality of the partition in R:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# BSS and TSS are extracted from the model and stored
(BSS &amp;lt;- model$betweenss)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4823.535&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;(TSS &amp;lt;- model$totss)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 9299.59&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# We calculate the quality of the partition
BSS / TSS * 100&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 51.86826&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The quality of the partition is 51.87%. This value has no real interpretation in absolute terms except that a higher quality means a higher explained percentage. However, it is more insightful when it is compared to the quality of other partitions (with the same number of clusters! see why at the end of this &lt;a href=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r/#kmeans-with-3-groups&#34;&gt;section&lt;/a&gt;) in order to determine the best partition among the ones considered.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;nstart-for-several-initial-centers-and-better-stability&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;&lt;code&gt;nstart&lt;/code&gt; for several initial centers and better stability&lt;/h3&gt;
&lt;p&gt;Note that &lt;em&gt;k&lt;/em&gt;-means is a non-deterministic algorithm so running it multiple times may result in different classification. This is the case because the &lt;em&gt;k&lt;/em&gt;-means algorithm uses a &lt;strong&gt;random&lt;/strong&gt; set of initial points to arrive at the final classification. Due to the fact that the initial centers are randomly chosen, the same command &lt;code&gt;kmeans(Eurojobs, centers = 2)&lt;/code&gt; may give different results every time it is run, and thus slight differences in the quality of the partitions. The &lt;code&gt;nstart&lt;/code&gt; argument in the &lt;code&gt;kmeans()&lt;/code&gt; function allows to run the algorithm several times with different initial centers, in order to obtain a potentially better partition:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model2 &amp;lt;- kmeans(Eurojobs, centers = 2, nstart = 10)
100 * model2$betweenss / model2$totss&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 54.2503&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Depending on the initial random choices, this new partition will be better or not compared to the first one. In our example, the partition is better as the quality increased to 54.25%.&lt;/p&gt;
&lt;p&gt;One of the main limitation often cited regarding &lt;em&gt;k&lt;/em&gt;-means is the stability of the results. As the initial centers are randomly chosen, running the same command may yield different results. Adding the &lt;code&gt;nstart&lt;/code&gt; argument in the &lt;code&gt;kmeans()&lt;/code&gt; function limits this issue as it will generate several different initializations and take the most optimal one, leading to a better stability of the classification.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;kmeans-with-3-groups&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;&lt;code&gt;kmeans()&lt;/code&gt; with 3 groups&lt;/h3&gt;
&lt;p&gt;We now perform the &lt;em&gt;k&lt;/em&gt;-means classification with 3 clusters and compute its quality:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model3 &amp;lt;- kmeans(Eurojobs, centers = 3)

BSS3 &amp;lt;- model3$betweenss
TSS3 &amp;lt;- model3$totss
BSS3 / TSS3 * 100&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 74.59455&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It can be seen that the classification into three groups allows for a higher explained percentage and a higher quality.&lt;/p&gt;
&lt;p&gt;This will always be the case: with more classes, the partition will be finer, and the &lt;em&gt;BSS&lt;/em&gt; contribution will be higher. On the other hand, the “model” will be more complex, requiring more classes. In the extreme case where &lt;em&gt;k = n&lt;/em&gt; (each observation is a singleton class), we have &lt;em&gt;BSS = TSS&lt;/em&gt;, but the partition has lost all interest.&lt;/p&gt;
&lt;p&gt;This is the reason we compare partitions via their quality only for partitions that have the same number of clusters.&lt;/p&gt;
&lt;p&gt;An alternative method to perform a &lt;em&gt;k&lt;/em&gt;-means is to use the &lt;code&gt;cluster_analysis()&lt;/code&gt; function from the &lt;code&gt;{parameters}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(parameters)

res_kmeans &amp;lt;- cluster_analysis(Eurojobs,
  n = 3,
  method = &amp;quot;kmeans&amp;quot;
)

predict(res_kmeans) # get clusters&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 1 3 3 3 3 3 3 3 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;An advantage of this method is that it is possible to visualize the centers (i.e., the average of each variable for each cluster):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(summary(res_kmeans))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-14-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;optimal-number-of-clusters&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Optimal number of clusters&lt;/h3&gt;
&lt;p&gt;In order to find the optimal number of clusters for a &lt;em&gt;k&lt;/em&gt;-means, it is recommended to choose it based on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the context of the problem at hand, for instance if you know that there is a specific number of groups in your data (you have strong expectations or hypotheses, this is option is however subjective), or&lt;/li&gt;
&lt;li&gt;the following four approaches:
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Elbow method (which uses the within cluster sums of squares)&lt;/li&gt;
&lt;li&gt;Average silhouette method&lt;/li&gt;
&lt;li&gt;Gap statistic method&lt;/li&gt;
&lt;li&gt;Consensus-based algorithm&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We show the R code for these 4 methods below, more theoretical information can be found &lt;a href=&#34;https://www.datanovia.com/en/lessons/determining-the-optimal-number-of-clusters-3-must-know-methods/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;elbow-method&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Elbow method&lt;/h4&gt;
&lt;p&gt;The Elbow method looks at the total within-cluster sum of square (WSS) as a function of the number of clusters.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load required packages
library(factoextra)
library(NbClust)

# Elbow method
fviz_nbclust(Eurojobs, kmeans, method = &amp;quot;wss&amp;quot;) +
  geom_vline(xintercept = 4, linetype = 2) + # add line for better visualisation
  labs(subtitle = &amp;quot;Elbow method&amp;quot;) # add subtitle&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-15-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The location of a knee in the plot is usually considered as an indicator of the appropriate number of clusters because it means that adding another cluster does not improve much better the partition. This method seems to suggest 4 clusters.&lt;/p&gt;
&lt;p&gt;The Elbow method is sometimes ambiguous and an alternative is the average silhouette method.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;silhouette-method&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Silhouette method&lt;/h4&gt;
&lt;p&gt;The Silhouette method measures the quality of a clustering and determines how well each point lies within its cluster.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Silhouette method
fviz_nbclust(Eurojobs, kmeans, method = &amp;quot;silhouette&amp;quot;) +
  labs(subtitle = &amp;quot;Silhouette method&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-16-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The Silhouette method suggests 2 clusters.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;gap-statistic-method&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Gap statistic method&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Gap statistic
set.seed(42)
fviz_nbclust(Eurojobs, kmeans,
  nstart = 25,
  method = &amp;quot;gap_stat&amp;quot;,
  nboot = 500 # reduce it for lower computation time (but less precise results)
) +
  labs(subtitle = &amp;quot;Gap statistic method&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-17-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The optimal number of clusters is the one that maximizes the gap statistic. This method suggests only 1 cluster (which is therefore a useless clustering).&lt;/p&gt;
&lt;p&gt;As you can see these three methods do not necessarily lead to the same result. Here, the 3 approaches suggest a different number of clusters.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;consensus-based-algorithm&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Consensus-based algorithm&lt;/h4&gt;
&lt;p&gt;Because no method is clearly better, a fourth alternative is to run many methods and take the number of clusters that is the most agreed upon (i.e., find the consensus).&lt;/p&gt;
&lt;p&gt;This can easily be done with the &lt;code&gt;n_clusters()&lt;/code&gt; function from the &lt;code&gt;{parameters}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(parameters)

n_clust &amp;lt;- n_clusters(Eurojobs,
  package = c(&amp;quot;easystats&amp;quot;, &amp;quot;NbClust&amp;quot;, &amp;quot;mclust&amp;quot;),
  standardize = FALSE
)
n_clust&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Method Agreement Procedure:
## 
## The choice of 3 clusters is supported by 15 (51.72%) methods out of 29 (kl, Ch, Hartigan, CCC, Scott, Marriot, trcovw, Tracew, Rubin, Beale, Ratkowsky, Ball, PtBiserial, Dunn, SDindex).&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The optimal number of clusters to retain can also be visualized:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(n_clust)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-19-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Based on all indices, most methods suggest to retain 3 clusters.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;visualizations&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Visualizations&lt;/h3&gt;
&lt;p&gt;To confirm that your number of classes is indeed optimal, there is a way to evaluate the quality of your clustering via the silhouette plot (which shows the silhouette coefficient on the &lt;em&gt;y&lt;/em&gt; axis).&lt;/p&gt;
&lt;p&gt;We draw the silhouette plot for 2 clusters, as suggested by the average silhouette method:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(cluster)

set.seed(42)
km_res &amp;lt;- kmeans(Eurojobs, centers = 2, nstart = 20)

sil &amp;lt;- silhouette(km_res$cluster, dist(Eurojobs))
fviz_silhouette(sil)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   cluster size ave.sil.width
## 1       1    5          0.33
## 2       2   21          0.54&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-20-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As a reminder, the interpretation of the silhouette coefficient is as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(&amp;gt; 0\)&lt;/span&gt; means that the observation is well grouped. The closer the coefficient is to 1, the better the observation is grouped.&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(&amp;lt; 0\)&lt;/span&gt; means that the observation has been placed in the wrong cluster.&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(= 0\)&lt;/span&gt; means that the observation is between two clusters.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The silhouette plot above and the average silhouette coefficient help to determine whether your clustering is good or not. If a large majority of the silhouette coefficients are positive, it indicates that the observations are placed in the correct group. This silhouette plot can therefore be used in the choice of the optimal number of classes.&lt;/p&gt;
&lt;p&gt;It is also possible to plot clusters by using the &lt;code&gt;fviz_cluster()&lt;/code&gt; function. Note that a principal component analysis is performed to represent the variables in a 2 dimensions plane.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(factoextra)

fviz_cluster(km_res, Eurojobs, ellipse.type = &amp;quot;norm&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-21-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now that the &lt;em&gt;k&lt;/em&gt;-means clustering has been detailed in R, see how to do the algorithm by hand in the following sections.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;manual-application-and-verification-in-r&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Manual application and verification in R&lt;/h3&gt;
&lt;p&gt;Perform &lt;strong&gt;by hand&lt;/strong&gt; the &lt;em&gt;k&lt;/em&gt;-means algorithm for the points shown in the graph below, with &lt;em&gt;k&lt;/em&gt; = 2 and with the points &lt;em&gt;i&lt;/em&gt; = 5 and &lt;em&gt;i&lt;/em&gt; = 6 as initial centers. Compute the quality of the partition you just found and then &lt;strong&gt;check&lt;/strong&gt; your answers &lt;strong&gt;in R&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Assume that the variables have the same units so there is no need to scale the data.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-22-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;solution-by-hand&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Solution by hand&lt;/h4&gt;
&lt;p&gt;Step 1. Here are the coordinates of the 6 points:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
.tg .tg-0lax{text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
point
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
x
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
y
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
7
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
3
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
3
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
2
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
4
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
4
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
1
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
9
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
7
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
6
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
6
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
8
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;And the initial centers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Group 1: point 5 with center &lt;em&gt;(9, 7)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Group 2: point 6 with center &lt;em&gt;(6, 8)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 2. Compute the distance matrix point by point with the Pythagorean theorem. Remind that the distance between point &lt;em&gt;a&lt;/em&gt; and point &lt;em&gt;b&lt;/em&gt; is found with:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\sqrt{(x_a - x_b)^2 + (y_a - y_b)^2}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We apply this theorem to each pair of points, to finally have the following distance matrix (rounded to two decimals):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round(dist(X), 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       1     2     3     4     5
## 2  3.61                        
## 3  5.10  2.24                  
## 4  7.28  5.66  3.61            
## 5  4.47  5.39  7.62 10.82      
## 6  5.10  3.61  5.66  9.22  3.16&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Step 3. Based on the distance matrix computed in step 2, we can put each point to its closest group and compute the coordinates of the center.&lt;/p&gt;
&lt;p&gt;We first put each point in its closest group:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;point 1 is closer to point 5 than to point 6 because the distance between points 1 and 5 is 4.47 while the distance between points 1 and 6 is 5.10&lt;/li&gt;
&lt;li&gt;point 2 is closer to point 6 than to point 5 because the distance between points 2 and 5 is 5.39 while the distance between points 2 and 6 is 3.61&lt;/li&gt;
&lt;li&gt;point 3 is closer to point 6 than to point 5 because the distance between points 3 and 5 is 7.62 while the distance between points 3 and 6 is 5.66&lt;/li&gt;
&lt;li&gt;point 4 is closer to point 6 than to point 5 because the distance between points 4 and 5 is 10.82 while the distance between points 4 and 6 is 9.22&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that computing the distances between each point and the points 5 and 6 is sufficient. There is no need to compute the distance between the points 1 and 2 for example, as we compare each point to the initial centers (which are points 5 and 6).&lt;/p&gt;
&lt;p&gt;We then compute the coordinates of the centers of the two groups by taking the mean of the coordinates &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Group 1 includes the points 5 and 1 with &lt;em&gt;(8, 5)&lt;/em&gt; as center (&lt;span class=&#34;math inline&#34;&gt;\(8 = \frac{9+7}{2}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(5 = \frac{7+3}{2}\)&lt;/span&gt;)&lt;/li&gt;
&lt;li&gt;Group 2 includes the points 6, 2, 3 and 4 with &lt;em&gt;(3, 4.5)&lt;/em&gt; as center (&lt;span class=&#34;math inline&#34;&gt;\(3 = \frac{6+4+2+0}{4}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(4.5 = \frac{8+5+4+1}{4}\)&lt;/span&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We thus have:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
.tg .tg-0lax{text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
points
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
center
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
cluster 1
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
5 &amp;amp; 1
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
(8, 5)
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
cluster 2
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
6, 2, 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
(3, 4.5)
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Step 4. We make sure that the allocation is optimal by checking that each point is in the nearest cluster. The distance between a point and the center of a cluster is again computed thanks to the Pythagorean theorem. Thus, we have:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
.tg .tg-scde{color:#009901;text-align:left;vertical-align:middle}
.tg .tg-0lax{text-align:left;vertical-align:top}
.tg .tg-yi9q{color:#009901;text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
points
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
Distance to cluster 1
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
Distance to cluster 2
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-scde&#34;&gt;
2.24
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
4.27
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
4
&lt;/td&gt;
&lt;td class=&#34;tg-scde&#34;&gt;
1.12
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
3
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
6.08
&lt;/td&gt;
&lt;td class=&#34;tg-yi9q&#34;&gt;
1.12
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
4
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
8.94
&lt;/td&gt;
&lt;td class=&#34;tg-yi9q&#34;&gt;
4.61
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-yi9q&#34;&gt;
2.24
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
6.5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
6
&lt;/td&gt;
&lt;td class=&#34;tg-yi9q&#34;&gt;
3.61
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
4.61
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The minimum distance between the points and the two clusters is colored in green.&lt;/p&gt;
&lt;p&gt;We check that each point is in the correct group (i.e., the closest cluster). According to the distance in the table above, point 6 seems to be closer to the cluster 1 than to the cluster 2. Therefore, the allocation is not optimal and point 6 should be reallocated to cluster 1.&lt;/p&gt;
&lt;p&gt;Step 5. We compute again the centers of the clusters after this reallocation. The centers are found by taking the mean of the coordinates &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt; of the points belonging to the cluster. We thus have:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
.tg .tg-0lax{text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
points
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
center
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
cluster 1
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1, 5 &amp;amp; 6
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
(7.33, 6)
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
cluster 2
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
2, 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-0lax&#34;&gt;
(2, 3.33)
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;where, for instance, 3.33 is simply &lt;span class=&#34;math inline&#34;&gt;\(\frac{5+4+1}{3}\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Step 6. Repeat step 4 until the allocation is optimal. If the allocation is optimal, the algorithm stops. In our example we have:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
.tg .tg-scde{color:#009901;text-align:left;vertical-align:middle}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
points
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
Distance to cluster 1
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
Distance to cluster 2
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-scde&#34;&gt;
3.02
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
5.01
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
3.48
&lt;/td&gt;
&lt;td class=&#34;tg-scde&#34;&gt;
2.61
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
3
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
5.69
&lt;/td&gt;
&lt;td class=&#34;tg-scde&#34;&gt;
0.67
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
8.87
&lt;/td&gt;
&lt;td class=&#34;tg-scde&#34;&gt;
3.07
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-scde&#34;&gt;
1.95
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
7.9
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
6
&lt;/td&gt;
&lt;td class=&#34;tg-scde&#34;&gt;
2.4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
6.15
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;All points are correctly allocated to its nearest cluster, so the allocation is optimal and the algorithm stops.&lt;/p&gt;
&lt;p&gt;Step 7. State the final partition and the centers. In our example:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
points
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
center
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
cluster 1
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1, 5 &amp;amp; 6
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
(7.33, 6)
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
cluster 2
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2, 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
(2, 3.33)
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Now that we have the clusters and the final centers, we compute the quality of the partition we just found. Remember that we need to compute the BSS and TSS to find the quality. Below the steps to compute the quality of this partition by &lt;em&gt;k&lt;/em&gt;-means, based on this summary table:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
.tg .tg-0lax{text-align:left;vertical-align:top}
.tg .tg-0a7q{border-color:#000000;text-align:left;vertical-align:middle}
.tg .tg-73oq{border-color:#000000;text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-0pky&#34; colspan=&#34;3&#34;&gt;
cluster 1
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34; colspan=&#34;3&#34;&gt;
cluster 2
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
point
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
x
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
y
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
point
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
x
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
y
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
7
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
3
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
4
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
9
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
7
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
3
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
4
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
6
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
6
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
8
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
4
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
mean
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
7.33
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
6
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
3.33
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Step 1. Compute the overall mean of the &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt; coordinates:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\overline{\overline{x}} = \frac{7+4+2+0+9+6}{12} \\
\frac{+3+5+4+1+7+8}{12} \\ = 4.67\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Step 2. Compute TSS and WSS:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[TSS = (7-4.67)^2 + (4-4.67)^2 + (2-4.67)^2 \\ + (0-4.67)^2 + (9-4.67)^2 + (6-4.67)^2 \\ + (3-4.67)^2 + (5-4.67)^2 + (4-4.67)^2 \\ + (1-4.67)^2 + (7-4.67)^2 + (8-4.67)^2 \\ = 88.67\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regarding WSS, it is splitted between cluster 1 and cluster 2. For cluster 1:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[WSS[1] = (7-7.33)^2 + (9 - 7.33)^2 \\ + (6 - 7.33)^2 + (3-6)^2 \\ + (7-6)^2 + (8-6)^2 \\ = 18.67\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For cluster 2:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[WSS[2] = (4-2)^2 + (2-2)^2 + (0-2)^2 \\ + (5-3.33)^2 + (4-3.33)^2 + (1-3.33)^2 \\ = 16.67\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;And the total WSS is&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
WSS &amp;amp;= WSS[1] + WSS[2] \\
&amp;amp;= 18.67 + 16.67 \\
&amp;amp;= 35.34
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To find the BSS:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{align}
BSS &amp;amp;= TSS - WSS \\
&amp;amp;= 88.67 - 35.34 \\
&amp;amp;= 53.33
\end{align}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Finally, the quality of the partition is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[Quality = \frac{BSS}{TSS} = \frac{53.33}{88.67} = 0.6014\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;So the quality of the partition is 60.14%.&lt;/p&gt;
&lt;p&gt;We are now going to verify all these solutions (the partition, the final centers and the quality) in R.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;solution-in-r&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Solution in R&lt;/h4&gt;
&lt;p&gt;As you can imagine, the solution in R us much shorter and requires much less computation on the user side. We first need to enter the data as a matrix or dataframe:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;X &amp;lt;- matrix(c(7, 3, 4, 5, 2, 4, 0, 1, 9, 7, 6, 8),
  nrow = 6, byrow = TRUE
)
X # display the coordinates of the points&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2]
## [1,]    7    3
## [2,]    4    5
## [3,]    2    4
## [4,]    0    1
## [5,]    9    7
## [6,]    6    8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now perform the &lt;em&gt;k&lt;/em&gt;-means via the &lt;code&gt;kmeans()&lt;/code&gt; function with the point 5 and 6 as initial centers:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# take rows 5 and 6 of the X matrix as initial centers
res.k &amp;lt;- kmeans(X,
  centers = X[c(5, 6), ],
  algorithm = &amp;quot;Lloyd&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Unlike in the previous application with the dataset &lt;code&gt;Eurojobs.csv&lt;/code&gt; where the initial centers are randomly chosen by R, in this second application we want to specify which points are going to be the two initial centers. For this, we need to set &lt;code&gt;centers = X[c(5,6), ]&lt;/code&gt; to indicate that that there are 2 centers, and that they are going to be the points 5 and 6 (see a reminder on &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;how to subset a dataframe&lt;/a&gt; if needed).&lt;/p&gt;
&lt;p&gt;The reason for adding the argument &lt;code&gt;algorithm = &#34;Lloyd&#34;&lt;/code&gt; can be found in the usage of the R function &lt;code&gt;kmeans()&lt;/code&gt;. In fact, there are several variants of the &lt;em&gt;k&lt;/em&gt;-means algorithm. The default choice is the &lt;span class=&#34;citation&#34;&gt;Hartigan and Wong (&lt;a href=&#34;#ref-jaaw28m&#34;&gt;1979&lt;/a&gt;)&lt;/span&gt; version, which is more sophisticated than the basic version detailed in the solution by hand. By using the original version of &lt;span class=&#34;citation&#34;&gt;Lloyd (&lt;a href=&#34;#ref-lloyd1982least&#34;&gt;1982&lt;/a&gt;)&lt;/span&gt;, we find the same solution in R and by hand. For more information, you can consult the documentation of the &lt;code&gt;kmeans()&lt;/code&gt; function (via &lt;code&gt;?kmeans&lt;/code&gt; or &lt;code&gt;help(kmeans)&lt;/code&gt;) and read the articles mentioned.&lt;/p&gt;
&lt;p&gt;The solution in R is then found by extracting&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the partition with &lt;code&gt;$cluster&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;res.k$cluster&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 2 2 1 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Points 1, 5 and 6 belong to cluster 1, points 2, 3 and 4 belong to cluster 2.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the coordinates of the final centers with &lt;code&gt;$centers&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# We extract the coordinates of the 2 final centers, rounded to 2 decimals
round(res.k$centers, digits = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   [,1] [,2]
## 1 7.33 6.00
## 2 2.00 3.33&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;and then the quality of the partition by dividing the BSS to the TSS:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;res.k$betweenss / res.k$totss&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.6015038&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The 3 results are equal to what we found by hand (except the quality which is slightly different due to rounding).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;hierarchical-clustering&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Hierarchical clustering&lt;/h1&gt;
&lt;p&gt;Remind that the difference with the partition by &lt;em&gt;k&lt;/em&gt;-means is that for hierarchical clustering, the number of classes is &lt;strong&gt;not&lt;/strong&gt; specified in advance. Hierarchical clustering will help to determine the optimal number of clusters.&lt;/p&gt;
&lt;p&gt;Before applying hierarchical clustering by hand and in R, let’s see how the ascending hierarchical clustering works step by step:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;It starts by putting every point in its own cluster, so each cluster is a singleton&lt;/li&gt;
&lt;li&gt;It then merges the 2 points that are closest to each other based on the distances from the distance matrix. The consequence is that there is one less cluster&lt;/li&gt;
&lt;li&gt;It then recalculates the distances between the new and old clusters and save them in a new distance matrix which will be used in the next step&lt;/li&gt;
&lt;li&gt;Finally, steps 1 and 2 are repeated until all clusters are merged into one single cluster including all points.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There are 5 main methods to measure the distance between clusters, referred as linkage methods:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Single linkage: computes the minimum distance between clusters before merging them.&lt;/li&gt;
&lt;li&gt;Complete linkage: computes the maximum distance between clusters before merging them.&lt;/li&gt;
&lt;li&gt;Average linkage: computes the average distance between clusters before merging them.&lt;/li&gt;
&lt;li&gt;Centroid linkage: calculates centroids for both clusters, then computes the distance between the two before merging them.&lt;/li&gt;
&lt;li&gt;Ward’s (minimum variance) criterion: minimizes the total within-cluster variance and find the pair of clusters that leads to minimum increase in total within-cluster variance after merging.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the following sections, only the three first linkage methods are presented (first by hand and then the results are verified in R).&lt;/p&gt;
&lt;div id=&#34;application-3-hierarchical-clustering&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Application 3: hierarchical clustering&lt;/h2&gt;
&lt;div id=&#34;data-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;p&gt;Using the data from the graph and the table below, we perform &lt;strong&gt;by hand&lt;/strong&gt; the 3 algorithms (single, complete and average linkage) and we draw the dendrograms. Then we &lt;strong&gt;check&lt;/strong&gt; our answers &lt;strong&gt;in R&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-29-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;##      V1    V2
## 1  2.03  0.06
## 2 -0.64 -0.10
## 3 -0.42 -0.53
## 4 -0.36  0.07
## 5  1.14  0.37&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;We assume that the variables have the same units so there is no need to scale the data.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;solution-by-hand-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution by hand&lt;/h3&gt;
&lt;p&gt;Step 1. For all 3 algorithms, we first need to compute the distance matrix between the 5 points thanks to the Pythagorean theorem. Remind that the distance between point &lt;em&gt;a&lt;/em&gt; and point &lt;em&gt;b&lt;/em&gt; is found with:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\sqrt{(x_a - x_b)^2 + (y_a - y_b)^2}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We apply this theorem to each pair of points, to finally have the following distance matrix (rounded to three decimals):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;##       1     2     3     4
## 2 2.675                  
## 3 2.520 0.483            
## 4 2.390 0.328 0.603      
## 5 0.942 1.841 1.801 1.530&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;single-linkage&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Single linkage&lt;/h4&gt;
&lt;p&gt;Step 2. From the distance matrix computed in step 1, we see that the &lt;strong&gt;smallest distance&lt;/strong&gt; = 0.328 between points 2 and 4. 0.328 corresponds to the first height (more on this later when drawing the dendrogram). Since points 2 and 4 are the closest to each other, these 2 points are put together to form a single group. The groups are thus: 1, 2 &amp;amp; 4, 3 and 5. The new distances between the group 2 &amp;amp; 4 and all other points are now:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
1
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
2 &amp;amp; 4
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
3
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
5
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2.390
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
3
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2.520
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0.483
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0.942
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1.530
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1.801
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To construct this new distance matrix, proceed point by point:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the distance between points 1 and 3 has not changed, so the distance is unchanged compared to the initial distance matrix (found in step 1), which was 2.520&lt;/li&gt;
&lt;li&gt;same goes for the distance between points 1 and 5 and points 3 and 5; the distances are the same than in the initial distance matrix since the points have not changed&lt;/li&gt;
&lt;li&gt;the distance between points 1 and 2 &amp;amp; 4 has changed since points 2 &amp;amp; 4 are now together&lt;/li&gt;
&lt;li&gt;since we are applying the &lt;strong&gt;single linkage&lt;/strong&gt; criterion, the new distance between points 1 and 2 &amp;amp; 4 corresponds to the &lt;strong&gt;minimum distance&lt;/strong&gt; between the distance between points 1 and 2 and the distance between points 1 and 4&lt;/li&gt;
&lt;li&gt;the initial distance between points 1 and 2 is 2.675 and the initial distance between points 1 and 4 is 2.390&lt;/li&gt;
&lt;li&gt;therefore, the minimum distance between these two distances is 2.390&lt;/li&gt;
&lt;li&gt;2.390 is thus the new distance between points 1 and 2 &amp;amp; 4&lt;/li&gt;
&lt;li&gt;we apply the same process for points 3 and 2 &amp;amp; 4: the initial distance between points 3 and 2 is 0.483 and the initial distance between points 3 and 4 is 0.603. The minimum distance between these 2 distances is 0.483 so the new distance between points 3 and 2 &amp;amp; 4 is 0.483&lt;/li&gt;
&lt;li&gt;follow the same process for all other points&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 3. Based on the distance matrix in step 2, the smallest distance is 0.483 between points 3 and 2 &amp;amp; 4 (the second height for the dendrogram). Since points 3 and 2 &amp;amp; 4 are the closest to each other, they are combined to form a new group, the group 2 &amp;amp; 3 &amp;amp; 4. The groups are thus: 1, 2 &amp;amp; 3 &amp;amp; 4 and 5. We construct the new distance matrix based on the same process detailed in step 2:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
1
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
5
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2.390
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0.942
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1.530
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;points 1 and 5 have not change, so the distance between these two points are the same than in previous step&lt;/li&gt;
&lt;li&gt;from step 2 we see that the distance between points 1 and 2 &amp;amp; 4 is 2.390 and the distance between points 1 and 3 is 2.520&lt;/li&gt;
&lt;li&gt;since we apply the single linkage criterion, we take the minimum distance, which is 2.390&lt;/li&gt;
&lt;li&gt;the distance between points 1 and 2 &amp;amp; 3 &amp;amp; 4 is thus 2.390&lt;/li&gt;
&lt;li&gt;same process for points 5 and 2 &amp;amp; 3 &amp;amp; 4&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 4. Based on the distance matrix in step 3, the smallest distance is 0.942 between points 1 and 5 (the third height in the dendrogram). Since points 1 and 5 are the closest to each other, they are combined to form a new group, the group 1 &amp;amp; 5. The groups are thus: 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4. We construct the new distance matrix based on the same process detailed in steps 2 and 3:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
1 &amp;amp; 5
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1 &amp;amp; 5
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1.530
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the only distance left to compute is the distance between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4&lt;/li&gt;
&lt;li&gt;from the previous step we see that the distance between points 1 and 2 &amp;amp; 3 &amp;amp; 4 is 2.390 and the distance between points 5 and 2 &amp;amp; 3 &amp;amp; 4 is 1.530&lt;/li&gt;
&lt;li&gt;since we apply the single linkage criterion, we take the minimum distance, which is 1.530&lt;/li&gt;
&lt;li&gt;the distance between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4 is thus 1.530&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 5. The final combination of points is the combination of points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4, with a final height of 1.530. Heights are used to draw the dendrogram in the sixth and final step.&lt;/p&gt;
&lt;p&gt;Step 6. Draw the dendrogram thanks to the combination of points and heights found above. Remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the first combination of points was between points 2 and 4, with a height of 0.328&lt;/li&gt;
&lt;li&gt;the second combination was between points 3 and 2 &amp;amp; 4 with a height of 0.483&lt;/li&gt;
&lt;li&gt;the third combination was between points 1 and 5 with a height of 0.942&lt;/li&gt;
&lt;li&gt;the final combination was between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4 with a height of 1.530&lt;/li&gt;
&lt;li&gt;this is exactly what is illustrated in the following dendrogram:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-31-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In hierarchical clustering, dendrograms are used to show the sequence of combinations of the clusters. The distances of merge between clusters, called heights, are illustrated on the y-axis.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;complete-linkage&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Complete linkage&lt;/h4&gt;
&lt;p&gt;Complete linkage is quite similar to single linkage, except that instead of taking the smallest distance when computing the new distance between points that have been grouped, the &lt;strong&gt;maximum distance&lt;/strong&gt; is taken.&lt;/p&gt;
&lt;p&gt;The steps to perform the hierarchical clustering with the complete linkage (maximum) are detailed below.&lt;/p&gt;
&lt;p&gt;Step 1. Step 1 is exactly the same than for single linkage, that is, we compute the distance matrix of the 5 points thanks to the Pythagorean theorem. This gives us the following distance matrix:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;##       1     2     3     4
## 2 2.675                  
## 3 2.520 0.483            
## 4 2.390 0.328 0.603      
## 5 0.942 1.841 1.801 1.530&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Step 2. From the distance matrix computed in step 1, we see that the &lt;strong&gt;smallest distance&lt;/strong&gt; = 0.328 between points 2 and 4. It is important to note that even if we apply the complete linkage, in the distance matrix the points are brought together based on the smallest distance. This is the case for all 3 algorithms. The difference between the 3 algorithms lies in how to compute the new distances between the new combination of points (the single linkage takes the minimum between the distances, the complete linkage takes the maximum distance and the average linkage takes the average distance). 0.328 corresponds to the first height (which will be used when drawing the dendrogram). Since points 2 and 4 are the closest to each other, these 2 points are put together to form a single group. The groups are thus: 1, 2 &amp;amp; 4, 3 and 5. The new distances between the group 2 &amp;amp; 4 and all other points are now:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
1
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
2 &amp;amp; 4
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
3
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
5
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2.675
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
3
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2.520
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0.603
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0.942
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1.841
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1.801
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To construct this new distance matrix, proceed point by point as we did for single linkage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the distance between points 1 and 3 has not changed, so the distance is unchanged compared to the initial distance matrix (found in step 1), which was 2.520&lt;/li&gt;
&lt;li&gt;same goes for the distance between points 1 and 5 and points 3 and 5; the distances are the same than in the initial distance matrix since the points have not changed&lt;/li&gt;
&lt;li&gt;the distance between points 1 and 2 &amp;amp; 4 has changed since points 2 &amp;amp; 4 are now together&lt;/li&gt;
&lt;li&gt;since we are applying the &lt;strong&gt;complete linkage&lt;/strong&gt; criterion, the new distance between points 1 and 2 &amp;amp; 4 corresponds to the &lt;strong&gt;maximum distance&lt;/strong&gt; between the distance between points 1 and 2 and the distance between points 1 and 4&lt;/li&gt;
&lt;li&gt;the initial distance between points 1 and 2 is 2.675 and the initial distance between points 1 and 4 is 2.390&lt;/li&gt;
&lt;li&gt;therefore, the maximum distance between these two distances is 2.675&lt;/li&gt;
&lt;li&gt;2.675 is thus the new distance between points 1 and 2 &amp;amp; 4&lt;/li&gt;
&lt;li&gt;we apply the same process for points 3 and 2 &amp;amp; 4: the initial distance between points 3 and 2 is 0.483 and the initial distance between points 3 and 4 is 0.603. The maximum distance between these 2 distances is 0.603 so the new distance between points 3 and 2 &amp;amp; 4 is 0.603&lt;/li&gt;
&lt;li&gt;follow the same process for all other points&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 3. Based on the distance matrix in step 2, the smallest distance is 0.603 between points 3 and 2 &amp;amp; 4 (the second height for the dendrogram). Since points 3 and 2 &amp;amp; 4 are the closest to each other, they are combined to form a new group, the group 2 &amp;amp; 3 &amp;amp; 4. The groups are thus: 1, 2 &amp;amp; 3 &amp;amp; 4 and 5. We construct the new distance matrix based on the same process detailed in step 2:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
1
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
5
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2.675
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0.942
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1.841
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;points 1 and 5 have not change, so the distance between these two points are the same than in previous step&lt;/li&gt;
&lt;li&gt;from step 2 we see that the distance between points 1 and 2 &amp;amp; 4 is 2.675 and the distance between points 1 and 3 is 2.520&lt;/li&gt;
&lt;li&gt;since we apply the complete linkage criterion, we take the maximum distance, which is 2.675&lt;/li&gt;
&lt;li&gt;the distance between points 1 and 2 &amp;amp; 3 &amp;amp; 4 is thus 2.675&lt;/li&gt;
&lt;li&gt;same process for points 5 and 2 &amp;amp; 3 &amp;amp; 4&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 4. Based on the distance matrix in step 3, the smallest distance is 0.942 between points 1 and 5 (the third height in the dendrogram). Since points 1 and 5 are the closest to each other, they are combined to form a new group, the group 1 &amp;amp; 5. The groups are thus: 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4. We construct the new distance matrix based on the same process detailed in steps 2 and 3:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
1 &amp;amp; 5
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1 &amp;amp; 5
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2.675
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the only distance left to compute is the distance between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4&lt;/li&gt;
&lt;li&gt;from the previous step we see that the distance between points 1 and 2 &amp;amp; 3 &amp;amp; 4 is 2.675 and the distance between points 5 and 2 &amp;amp; 3 &amp;amp; 4 is 1.841&lt;/li&gt;
&lt;li&gt;since we apply the complete linkage criterion, we take the maximum distance, which is 2.675&lt;/li&gt;
&lt;li&gt;the distance between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4 is thus 2.675&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 5. The final combination of points is the combination of points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4, with a final height of 2.675. Heights are used to draw the dendrogram in the sixth and final step.&lt;/p&gt;
&lt;p&gt;Step 6. Draw the dendrogram thanks to the combination of points and heights found above. Remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the first combination of points was between points 2 and 4, with a height of 0.328&lt;/li&gt;
&lt;li&gt;the second combination was between points 3 and 2 &amp;amp; 4 with a height of 0.603&lt;/li&gt;
&lt;li&gt;the third combination was between points 1 and 5 with a height of 0.942&lt;/li&gt;
&lt;li&gt;the final combination was between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4 with a height of 2.675&lt;/li&gt;
&lt;li&gt;this is exactly what is illustrated in the following dendrogram:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-33-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;average-linkage&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Average linkage&lt;/h4&gt;
&lt;p&gt;With the average linkage criterion, it is not the minimum nor the maximum distance that is taken when computing the new distance between points that have been grouped, but it is, as you guessed by now, the &lt;strong&gt;average distance&lt;/strong&gt; between the points.&lt;/p&gt;
&lt;p&gt;The steps to perform the hierarchical clustering with the average linkage are detailed below.&lt;/p&gt;
&lt;p&gt;Step 1. Step 1 is exactly the same than for single and complete linkage, that is, we compute the distance matrix of the 5 points thanks to the Pythagorean theorem. This gives us the following distance matrix:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;##       1     2     3     4
## 2 2.675                  
## 3 2.520 0.483            
## 4 2.390 0.328 0.603      
## 5 0.942 1.841 1.801 1.530&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Step 2. From the distance matrix computed in step 1, we see that the &lt;strong&gt;smallest distance&lt;/strong&gt; = 0.328 between points 2 and 4. It is important to note that even if we apply the average linkage, in the distance matrix the points are brought together based on the smallest distance. This is the case for all 3 algorithms. The difference between the 3 algorithms lies in how to compute the new distances between the new combination of points (the single linkage takes the minimum between the distances, the complete linkage takes the maximum distance and the average linkage takes the average distance). 0.328 corresponds to the first height (which will be used when drawing the dendrogram). Since points 2 and 4 are the closest to each other, these 2 points are put together to form a single group. The groups are thus: 1, 2 &amp;amp; 4, 3 and 5. The new distances between the group 2 &amp;amp; 4 and all other points are now:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
1
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
2 &amp;amp; 4
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
3
&lt;/th&gt;
&lt;th class=&#34;tg-0pky&#34;&gt;
5
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2.5325
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
3
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
2.520
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0.543
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0.942
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1.6855
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
1.801
&lt;/td&gt;
&lt;td class=&#34;tg-0pky&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To construct this new distance matrix, proceed point by point as we did for the two previous criteria:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the distance between points 1 and 3 has not changed, so the distance is unchanged compared to the initial distance matrix (found in step 1), which was 2.520&lt;/li&gt;
&lt;li&gt;same goes for the distance between points 1 and 5 and points 3 and 5; the distances are the same than in the initial distance matrix since the points have not changed&lt;/li&gt;
&lt;li&gt;the distance between points 1 and 2 &amp;amp; 4 has changed since points 2 &amp;amp; 4 are now together&lt;/li&gt;
&lt;li&gt;since we are applying the &lt;strong&gt;average linkage&lt;/strong&gt; criterion, the new distance between points 1 and 2 &amp;amp; 4 corresponds to the &lt;strong&gt;average distance&lt;/strong&gt; between the distance between points 1 and 2 and the distance between points 1 and 4&lt;/li&gt;
&lt;li&gt;the initial distance between points 1 and 2 is 2.675 and the initial distance between points 1 and 4 is 2.390&lt;/li&gt;
&lt;li&gt;therefore, the average distance between these two distances is &lt;span class=&#34;math inline&#34;&gt;\(\frac{2.675 + 2.390}{2} = 2.5325\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;2.5325 is thus the new distance between points 1 and 2 &amp;amp; 4&lt;/li&gt;
&lt;li&gt;we apply the same process for points 3 and 2 &amp;amp; 4: the initial distance between points 3 and 2 is 0.483 and the initial distance between points 3 and 4 is 0.603. The average distance between these 2 distances is 0.543 so the new distance between points 3 and 2 &amp;amp; 4 is 0.543&lt;/li&gt;
&lt;li&gt;follow the same process for all other points&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 3. Based on the distance matrix in step 2, the smallest distance is 0.543 between points 3 and 2 &amp;amp; 4 (the second height for the dendrogram). Since points 3 and 2 &amp;amp; 4 are the closest to each other, they are combined to form a new group, the group 2 &amp;amp; 3 &amp;amp; 4. The groups are thus: 1, 2 &amp;amp; 3 &amp;amp; 4 and 5. We construct the new distance matrix based on the same process detailed in step 2:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
1
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
5
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2.528333
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
5
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0.942
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1.724
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;points 1 and 5 have not change, so the distance between these two points are the same than in previous step&lt;/li&gt;
&lt;li&gt;from step 2 we see that the distance between points 1 and 2 &amp;amp; 4 is 2.5325 and the distance between points 1 and 3 is 2.520&lt;/li&gt;
&lt;li&gt;since we apply the average linkage criterion, we take the average distance&lt;/li&gt;
&lt;li&gt;however, we have to take into the consideration that there are 2 points in the group 2 &amp;amp; 4, while there is only one point in the group 3&lt;/li&gt;
&lt;li&gt;the average distance for the distance between 1 and 2 &amp;amp; 3 &amp;amp; 4 is thus: &lt;span class=&#34;math inline&#34;&gt;\(\frac{(2 \cdot 2.5325) + (1 \cdot 2.520)}{3} = 2.528333\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;same process for points 5 and 2 &amp;amp; 3 &amp;amp; 4: &lt;span class=&#34;math inline&#34;&gt;\(\frac{(2 \cdot 1.6855) + (1 \cdot 1.801)}{3} = 1.724\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 4. Based on the distance matrix in step 3, the smallest distance is 0.942 between points 1 and 5 (the third height in the dendrogram). Since points 1 and 5 are the closest to each other, they are combined to form a new group, the group 1 &amp;amp; 5. The groups are thus: 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4. We construct the new distance matrix based on the same process detailed in steps 2 and 3:&lt;/p&gt;
&lt;center&gt;
&lt;style type=&#34;text/css&#34;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-cly1{text-align:left;vertical-align:middle}
&lt;/style&gt;
&lt;table class=&#34;tg&#34;&gt;
&lt;tr&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
1 &amp;amp; 5
&lt;/th&gt;
&lt;th class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
1 &amp;amp; 5
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2 &amp;amp; 3 &amp;amp; 4
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
2.126167
&lt;/td&gt;
&lt;td class=&#34;tg-cly1&#34;&gt;
0
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the only distance left to compute is the distance between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4&lt;/li&gt;
&lt;li&gt;from the previous step we see that the distance between points 1 and 2 &amp;amp; 3 &amp;amp; 4 is 2.528333 and the distance between points 5 and 2 &amp;amp; 3 &amp;amp; 4 is 1.724&lt;/li&gt;
&lt;li&gt;since we apply the average linkage criterion, we take the average distance, which is &lt;span class=&#34;math inline&#34;&gt;\(\frac{2.528333 + 1.724}{2} = 2.126167\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;the distance between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4 is thus 2.126167&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 5. The final combination of points is the combination of points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4, with a final height of 2.126167. Heights are used to draw the dendrogram in the sixth and final step.&lt;/p&gt;
&lt;p&gt;Step 6. Draw the dendrogram thanks to the combination of points and heights found above. Remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the first combination of points was between points 2 and 4, with a height of 0.328&lt;/li&gt;
&lt;li&gt;the second combination was between points 3 and 2 &amp;amp; 4 with a height of 0.543&lt;/li&gt;
&lt;li&gt;the third combination was between points 1 and 5 with a height of 0.942&lt;/li&gt;
&lt;li&gt;the final combination was between points 1 &amp;amp; 5 and 2 &amp;amp; 3 &amp;amp; 4 with a height of 2.126167&lt;/li&gt;
&lt;li&gt;this is exactly what is illustrated in the following dendrogram:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-35-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;solution-in-r-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution in R&lt;/h3&gt;
&lt;p&gt;To perform the hierarchical clustering with any of the 3 criterion in R, we first need to enter the data (in this case as a matrix format, but it can also be entered as a dataframe):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;X &amp;lt;- matrix(c(2.03, 0.06, -0.64, -0.10, -0.42, -0.53, -0.36, 0.07, 1.14, 0.37),
  nrow = 5, byrow = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;single-linkage-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Single linkage&lt;/h4&gt;
&lt;p&gt;We can apply the hierarchical clustering with the single linkage criterion thanks to the &lt;code&gt;hclust()&lt;/code&gt; function with the argument &lt;code&gt;method = &#34;single&#34;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Hierarchical clustering: single linkage
hclust &amp;lt;- hclust(dist(X), method = &amp;quot;single&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the &lt;code&gt;hclust()&lt;/code&gt; function requires a distance matrix. If your data is not already a distance matrix (like in our case, as the matrix &lt;code&gt;X&lt;/code&gt; corresponds to the coordinates of the 5 points), you can transform it into a distance matrix with the &lt;code&gt;dist()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;We can now extract the heights and plot the dendrogram to check our results by hand found above:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round(hclust$height, 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.328 0.483 0.942 1.530&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(hclust)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-38-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see from the dendrogram, the combination of points and the heights are the same than the ones obtained by hand.&lt;/p&gt;
&lt;div id=&#34;optimal-number-of-clusters-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Optimal number of clusters&lt;/h5&gt;
&lt;p&gt;Remember that hierarchical clustering is used to determine the optimal number of clusters. This optimal number of clusters can be determined thanks to the dendrogram. For this, we usually look at the largest difference of heights:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/dendrogram-single-linkage.png&#34; style=&#34;width:100.0%&#34; alt=&#34;How to determine the number of clusters from a dendrogram? Take the largest difference of heights and count how many vertical lines you see&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;How to determine the number of clusters from a dendrogram? Take the largest difference of heights and count how many vertical lines you see&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The largest difference of heights in the dendrogram occurs before the final combination, that is, before the combination of the group 2 &amp;amp; 3 &amp;amp; 4 with the group 1 &amp;amp; 5. To determine the optimal number of clusters, simply count how many vertical lines you see within this largest difference. In our case, the optimal number of clusters is thus 2.&lt;/p&gt;
&lt;p&gt;In R, we can even highlight these two clusters directly in the dendrogram with the &lt;code&gt;rect.hclust()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(hclust)
rect.hclust(hclust,
  k = 2, # k is used to specify the number of clusters
  border = &amp;quot;blue&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-39-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that determining the optimal number of clusters via the dendrogram is not specific to the single linkage, it can be applied to other linkage methods too!&lt;/p&gt;
&lt;p&gt;Below another figure explaining how to determine the optimal number of clusters:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/optimal%20number%20of%20clusters%20hierarchical%20clustering.png&#34; style=&#34;width:100.0%&#34; alt=&#34;How to determine the optimal numbers of cluster in hierarchical clustering? Source: Towards Data Science&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;How to determine the optimal numbers of cluster in hierarchical clustering? Source: Towards Data Science&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;(See this &lt;a href=&#34;https://statsandr.com/blog/files/Hierarchical-clustering-cheatsheet.pdf&#34;&gt;hierarchical clustering cheatsheet&lt;/a&gt; for more visualizations like this.)&lt;/p&gt;
&lt;p&gt;Finally, we could also determine the optimal number of cluster thanks to a barplot of the heights (stored in &lt;code&gt;$height&lt;/code&gt; of the clustering output):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(hclust$height,
  names.arg = (nrow(X) - 1):1 # show the number of cluster below each bars
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-40-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Again, look for the largest jump of heights. In our case, the largest jump is from 1 to 2 classes. Therefore, the optimal number of classes is 2.&lt;/p&gt;
&lt;p&gt;Note that determining the number of clusters using the dendrogram or barplot is not a strict rule. You can also consider other methods such as the &lt;em&gt;silhouette plot&lt;/em&gt;, &lt;em&gt;elbow plot&lt;/em&gt; or some numerical measures like Dunn’s index, Hubert’s gamma, etc., which show the variation of the error with the number of clusters (&lt;em&gt;k&lt;/em&gt;), and you choose the value of &lt;em&gt;k&lt;/em&gt; where the error is smallest. Furthermore, measuring the goodness of clusters can be done thanks to the Dunn’s Index (the higher the index, the better).&lt;/p&gt;
&lt;p&gt;However, these methods are beyond the scope of this article and the method presented with the dendrogram is generally sufficient. See more detailed information in this &lt;a href=&#34;http://www.sthda.com/english/wiki/wiki.php?id_contents=7952&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that hierarchical clustering is a bit different than &lt;em&gt;k&lt;/em&gt;-means in the sense that is does not return a vector containing the information about which cluster the observations belong to. Instead, it creates a hierarchical structure (a dendrogram), a tree from which we can cut branches to get a given number of clusters. This information can be found via the &lt;code&gt;cutree()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;clust &amp;lt;- cutree(hclust,
  k = 2
)
clust&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 2 2 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;points 1 and 5 belong to the cluster 1&lt;/li&gt;
&lt;li&gt;points 2, 3 and 4 belong to the cluster 2&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is exactly what was drawn in the dendrogram above, and if needed, this information can be added to the initial data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;X_clust &amp;lt;- cbind(X, clust)
X_clust&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                  clust
## [1,]  2.03  0.06     1
## [2,] -0.64 -0.10     2
## [3,] -0.42 -0.53     2
## [4,] -0.36  0.07     2
## [5,]  1.14  0.37     1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;complete-linkage-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Complete linkage&lt;/h4&gt;
&lt;p&gt;We can apply the hierarchical clustering with the complete linkage criterion thanks to the &lt;code&gt;hclust()&lt;/code&gt; function with the argument &lt;code&gt;method = &#34;complete&#34;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Hierarchical clustering: complete linkage
hclust &amp;lt;- hclust(dist(X), method = &amp;quot;complete&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the &lt;code&gt;hclust()&lt;/code&gt; function requires a distance matrix. If your data is not already a distance matrix (like in our case, as the matrix &lt;code&gt;X&lt;/code&gt; corresponds to the coordinates of the 5 points), you can transform it into a distance matrix with the &lt;code&gt;dist()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;We can now extract the heights and plot the dendrogram to check our results by hand found above:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round(hclust$height, 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.328 0.603 0.942 2.675&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(hclust)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-44-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see from the dendrogram, the combination of points and the heights are the same than the ones obtained by hand.&lt;/p&gt;
&lt;p&gt;Similar to the single linkage, the largest difference of heights in the dendrogram occurs before the final combination, that is, before the combination of the group 2 &amp;amp; 3 &amp;amp; 4 with the group 1 &amp;amp; 5. In this case, the optimal number of clusters is thus 2. In R, we can even highlight these two clusters directly in the dendrogram with the &lt;code&gt;rect.hclust()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(hclust)
rect.hclust(hclust,
  k = 2, # k is used to specify the number of clusters
  border = &amp;quot;blue&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-45-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;average-linkage-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Average linkage&lt;/h4&gt;
&lt;p&gt;We can apply the hierarchical clustering with the average linkage criterion thanks to the &lt;code&gt;hclust()&lt;/code&gt; function with the argument &lt;code&gt;method = &#34;average&#34;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Hierarchical clustering: average linkage
hclust &amp;lt;- hclust(dist(X), method = &amp;quot;average&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the &lt;code&gt;hclust()&lt;/code&gt; function requires a distance matrix. If your data is not already a distance matrix (like in our case, as the matrix &lt;code&gt;X&lt;/code&gt; corresponds to the coordinates of the 5 points), you can transform it into a distance matrix with the &lt;code&gt;dist()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;We can now extract the heights and plot the dendrogram to check our results by hand found above:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round(hclust$height, 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.328 0.543 0.942 2.126&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(hclust)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-47-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see from the dendrogram, the combination of points and the heights are the same than the ones obtained by hand.&lt;/p&gt;
&lt;p&gt;Like the single and complete linkages, the largest difference of heights in the dendrogram occurs before the final combination, that is, before the combination of the group 2 &amp;amp; 3 &amp;amp; 4 with the group 1 &amp;amp; 5. In this case, the optimal number of clusters is thus 2. In R, we can even highlight these two clusters directly in the dendrogram with the &lt;code&gt;rect.hclust()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(hclust)
rect.hclust(hclust,
  k = 2, # k is used to specify the number of clusters
  border = &amp;quot;blue&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/clustering-analysis-k-means-and-hierarchical-clustering-by-hand-and-in-r_files/figure-html/unnamed-chunk-48-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;k-means-versus-hierarchical-clustering&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;&lt;em&gt;k&lt;/em&gt;-means versus hierarchical clustering&lt;/h1&gt;
&lt;p&gt;Clustering is rather a subjective statistical analysis and there can be more than one appropriate algorithm, depending on the dataset at hand or the type of problem to be solved. So choosing between &lt;em&gt;k&lt;/em&gt;-means and hierarchical clustering is not always easy. Moreover, no method is better than the other, each come with their sets of limitations and benefits.&lt;/p&gt;
&lt;p&gt;If you have a good reason to think that there is a &lt;strong&gt;specific number of clusters&lt;/strong&gt; in your dataset (for example if you would like to distinguish diseased and healthy patients depending on some characteristics but you do not know in which group patients belong to), you should probably opt for the &lt;em&gt;k&lt;/em&gt;-means clustering as this technique is used when the number of groups is specified in advance. If you do not have any reason to believe there is a certain number of groups in your dataset (for instance in marketing when trying to distinguish clients without any prior belief on the number of different types of customers), then you should probably opt for the hierarchical clustering to determine in how many clusters your data should be divided.&lt;/p&gt;
&lt;p&gt;In addition to this, if you are still undecided note that, on the one hand, with a large number of variables, &lt;em&gt;k&lt;/em&gt;-means may be computationally faster than hierarchical clustering if the number of clusters is small. On the other hand, the result of a hierarchical clustering is a structure that is more informative and interpretable than the unstructured set of flat clusters returned by &lt;em&gt;k&lt;/em&gt;-means. Therefore, it is easier to determine the optimal number of clusters by looking at the dendrogram of a hierarchical clustering than trying to predict this optimal number in advance in case of &lt;em&gt;k&lt;/em&gt;-means.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;whats-next&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What’s next?&lt;/h1&gt;
&lt;p&gt;We have seen that clustering is a nice tool to identify homogeneous observations with respect to the measured variables. Following your clustering, you may want to get a sense of the characteristics of each cluster. This can be done through some &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; for each cluster.&lt;/p&gt;
&lt;p&gt;For example, for &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;categorical&lt;/a&gt; variables, you could start to compute, for each cluster, the proportion of responses for each level of your categorical variables. You could also visualize this information via a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt;. For &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative&lt;/a&gt; variables, the mean or median response for each variable in each cluster is usually a good starting point.&lt;/p&gt;
&lt;p&gt;If your clustering performs well, you will see that within each cluster observations share a common pattern of responses across the variables. This is both a nice way to see what makes each cluster unique, and what makes clusters different.&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 helped you understand the different clustering methods and how to compute them by hand and in R.&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-jaaw28m&#34; class=&#34;csl-entry&#34;&gt;
Hartigan, J. A., and M. A. Wong. 1979. &lt;span&gt;“A k-Means Clustering Algorithm.”&lt;/span&gt; &lt;em&gt;Applied Statistics&lt;/em&gt; 28: 100–108.
&lt;/div&gt;
&lt;div id=&#34;ref-lloyd1982least&#34; class=&#34;csl-entry&#34;&gt;
Lloyd, Stuart. 1982. &lt;span&gt;“Least Squares Quantization in PCM.”&lt;/span&gt; &lt;em&gt;IEEE Transactions on Information Theory&lt;/em&gt; 28 (2): 129–37.
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>An efficient way to install and load R packages</title>
      <link>https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/</link>
      <pubDate>Fri, 31 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-is-an-r-package-and-how-to-use-it&#34; id=&#34;toc-what-is-an-r-package-and-how-to-use-it&#34;&gt;What is an R package and how to use it?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#inefficient-way-to-install-and-load-r-packages&#34; id=&#34;toc-inefficient-way-to-install-and-load-r-packages&#34;&gt;Inefficient way to install and load R packages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#more-efficient-way&#34; id=&#34;toc-more-efficient-way&#34;&gt;More efficient way&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#most-efficient-way&#34; id=&#34;toc-most-efficient-way&#34;&gt;Most efficient way&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#pacman-package&#34; id=&#34;toc-pacman-package&#34;&gt;&lt;code&gt;{pacman}&lt;/code&gt; package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#librarian-package&#34; id=&#34;toc-librarian-package&#34;&gt;&lt;code&gt;{librarian}&lt;/code&gt; package&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/an-efficient-way-to-install-and-load-r-packages_files/0_6wKnVe1op_A5stKw.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;what-is-an-r-package-and-how-to-use-it&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What is an R package and how to use it?&lt;/h1&gt;
&lt;p&gt;Unlike other programs, only fundamental functionalities come by default with R. You will thus often need to install some “extensions” to perform the analyses you want. These extensions which are collections of functions and datasets developed and published by R users are called &lt;strong&gt;packages&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Packages extend existing base R functionalities by adding new ones. R is open source so everyone can write code and publish it as a package, and everyone can install a package and start using the functions or datasets built inside the package, all this for free.&lt;/p&gt;
&lt;p&gt;In order to use a package, it needs to be installed on your computer by running &lt;code&gt;install.packages(&#34;name_of_package&#34;)&lt;/code&gt; (do not forget &lt;code&gt;&#34;&#34;&lt;/code&gt; around the name of the package, otherwise R will look for an object saved under that name!). Once the package is installed, you must load the package and only after it has been loaded you can use all the functions and datasets it contains. To load a package, run &lt;code&gt;library(name_of_package)&lt;/code&gt; (this time &lt;code&gt;&#34;&#34;&lt;/code&gt; around the name of the package are optional, but can still be used if you wish).&lt;/p&gt;
&lt;p&gt;Note that packages must be &lt;strong&gt;installed only once&lt;/strong&gt; (until you update your R, then you have to install them again), whereas packages must be &lt;strong&gt;loaded every time you open R&lt;/strong&gt;.&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;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;inefficient-way-to-install-and-load-r-packages&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Inefficient way to install and load R packages&lt;/h1&gt;
&lt;p&gt;Depending on how long you have been using R, you may use a limited amount of packages or, on the contrary, a large amount of them. As you use more and more packages you will soon start to have (too) many lines of code just for installing and loading them.&lt;/p&gt;
&lt;p&gt;Here is a preview of the code from my PhD thesis showing how the installation and loading of R packages looked like when I started working on R (only a fraction of them are displayed to shorten the code):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Installation of required packages
install.packages(&amp;quot;tidyverse&amp;quot;)
install.packages(&amp;quot;ggplot2&amp;quot;)
install.packages(&amp;quot;readxl&amp;quot;)
install.packages(&amp;quot;dplyr&amp;quot;)
install.packages(&amp;quot;tidyr&amp;quot;)
install.packages(&amp;quot;ggfortify&amp;quot;)
install.packages(&amp;quot;DT&amp;quot;)
install.packages(&amp;quot;reshape2&amp;quot;)
install.packages(&amp;quot;knitr&amp;quot;)
install.packages(&amp;quot;lubridate&amp;quot;)

# Load packages
library(&amp;quot;tidyverse&amp;quot;)
library(&amp;quot;ggplot2&amp;quot;)
library(&amp;quot;readxl&amp;quot;)
library(&amp;quot;dplyr&amp;quot;)
library(&amp;quot;tidyr&amp;quot;)
library(&amp;quot;ggfortify&amp;quot;)
library(&amp;quot;DT&amp;quot;)
library(&amp;quot;reshape2&amp;quot;)
library(&amp;quot;knitr&amp;quot;)
library(&amp;quot;lubridate&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can guess the code became longer and longer as I needed more and more packages for my analyses. Moreover, I tended to reinstall all packages as I was working on 4 different computers and I could not remember which packages were already installed on which machine. Reinstalling all packages every time I opened my script or R Markdown document was a waste of time.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;more-efficient-way&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;More efficient way&lt;/h1&gt;
&lt;p&gt;Then one day, a colleague of mine shared some of his code with me. I am glad he did as he introduced me to a much more efficient way to install and load R packages. He gave me the permission to share the tip, so here is the code I now use to perform the task of installing and loading R packages:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Package names
packages &amp;lt;- c(&amp;quot;ggplot2&amp;quot;, &amp;quot;readxl&amp;quot;, &amp;quot;dplyr&amp;quot;, &amp;quot;tidyr&amp;quot;, &amp;quot;ggfortify&amp;quot;, &amp;quot;DT&amp;quot;, &amp;quot;reshape2&amp;quot;, &amp;quot;knitr&amp;quot;, &amp;quot;lubridate&amp;quot;, &amp;quot;pwr&amp;quot;, &amp;quot;psy&amp;quot;, &amp;quot;car&amp;quot;, &amp;quot;doBy&amp;quot;, &amp;quot;imputeMissings&amp;quot;, &amp;quot;RcmdrMisc&amp;quot;, &amp;quot;questionr&amp;quot;, &amp;quot;vcd&amp;quot;, &amp;quot;multcomp&amp;quot;, &amp;quot;KappaGUI&amp;quot;, &amp;quot;rcompanion&amp;quot;, &amp;quot;FactoMineR&amp;quot;, &amp;quot;factoextra&amp;quot;, &amp;quot;corrplot&amp;quot;, &amp;quot;ltm&amp;quot;, &amp;quot;goeveg&amp;quot;, &amp;quot;corrplot&amp;quot;, &amp;quot;FSA&amp;quot;, &amp;quot;MASS&amp;quot;, &amp;quot;scales&amp;quot;, &amp;quot;nlme&amp;quot;, &amp;quot;psych&amp;quot;, &amp;quot;ordinal&amp;quot;, &amp;quot;lmtest&amp;quot;, &amp;quot;ggpubr&amp;quot;, &amp;quot;dslabs&amp;quot;, &amp;quot;stringr&amp;quot;, &amp;quot;assist&amp;quot;, &amp;quot;ggstatsplot&amp;quot;, &amp;quot;forcats&amp;quot;, &amp;quot;styler&amp;quot;, &amp;quot;remedy&amp;quot;, &amp;quot;snakecaser&amp;quot;, &amp;quot;addinslist&amp;quot;, &amp;quot;esquisse&amp;quot;, &amp;quot;here&amp;quot;, &amp;quot;summarytools&amp;quot;, &amp;quot;magrittr&amp;quot;, &amp;quot;tidyverse&amp;quot;, &amp;quot;funModeling&amp;quot;, &amp;quot;pander&amp;quot;, &amp;quot;cluster&amp;quot;, &amp;quot;abind&amp;quot;)

# Install packages not yet installed
installed_packages &amp;lt;- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
  install.packages(packages[!installed_packages])
}

# Packages loading
invisible(lapply(packages, library, character.only = TRUE))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code for installing and loading R packages is more efficient in several ways:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The function &lt;code&gt;install.packages()&lt;/code&gt; accepts a vector as argument, so one line of code for each package in the past is now one line including all packages&lt;/li&gt;
&lt;li&gt;In the second part of the code, it checks whether a package is already installed or not, and then install only the missing ones&lt;/li&gt;
&lt;li&gt;Regarding the packages loading (the last part of the code), the &lt;code&gt;lapply()&lt;/code&gt; function is used to call the &lt;code&gt;library()&lt;/code&gt; function on all packages at once, which makes the code more condense.&lt;/li&gt;
&lt;li&gt;The output when loading a package is rarely useful. The &lt;code&gt;invisible()&lt;/code&gt; function removes this output.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;From that day on, every time I need to use a new package, I simply add it to the vector &lt;code&gt;packages&lt;/code&gt; at the top of the code, which is located at the top of my scripts and R Markdown documents. No matter on which computer I am working on, running the entire code will install only the missing packages and will load all of them. This greatly reduced the running time for the installation and loading of my R packages.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;most-efficient-way&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Most efficient way&lt;/h1&gt;
&lt;div id=&#34;pacman-package&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{pacman}&lt;/code&gt; package&lt;/h2&gt;
&lt;p&gt;After this article was published, a reader informed me about the &lt;code&gt;{pacman}&lt;/code&gt; package. After having read the documentation and try it out myself, I learned that the function &lt;code&gt;p_load()&lt;/code&gt; from &lt;code&gt;{pacman}&lt;/code&gt; checks to see if a package is installed, if not it attempts to install the package and then loads it. It can also be applied to several packages at once, all this in a very condensed way:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;pacman&amp;quot;)

pacman::p_load(ggplot2, tidyr, dplyr)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Find more about this package on &lt;a href=&#34;https://cran.r-project.org/web/packages/pacman/index.html&#34; target=&#34;_blank&#34;&gt;CRAN&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;librarian-package&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{librarian}&lt;/code&gt; package&lt;/h2&gt;
&lt;p&gt;Like &lt;code&gt;{pacman}&lt;/code&gt;, the &lt;code&gt;shelf()&lt;/code&gt; function from the &lt;code&gt;{librarian}&lt;/code&gt; package automatically installs, updates, and loads R packages that are not yet installed in a single function. The function accepts packages from CRAN, GitHub, and Bioconductor (only if Bioconductor’s &lt;code&gt;Biobase&lt;/code&gt; package is installed). The function also accepts multiple package entries, provided as a comma-separated list of unquoted names (so no &lt;code&gt;&#34;&#34;&lt;/code&gt; around package names).&lt;/p&gt;
&lt;p&gt;Last but not least, the &lt;code&gt;{librarian}&lt;/code&gt; package allows to load packages automatically at the start of every R session (thanks to the &lt;code&gt;lib_startup()&lt;/code&gt; function) and search for new packages on CRAN by keywords or regular expressions (thanks to the &lt;code&gt;browse_cran()&lt;/code&gt; function).&lt;/p&gt;
&lt;p&gt;Here is an example of how to install missing packages and load them with the &lt;code&gt;shelf()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# From CRAN:
install.packages(&amp;quot;librarian&amp;quot;)

librarian::shelf(ggplot2, DesiQuintans / desiderata, pander)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For CRAN packages, provide the package name as normal without &lt;code&gt;&#34;&#34;&lt;/code&gt; and for GitHub packages, provide the username and package name separated by &lt;code&gt;/&lt;/code&gt; (i.e., &lt;code&gt;UserName/RepoName&lt;/code&gt; as shown for the &lt;code&gt;desiderata&lt;/code&gt; package).&lt;/p&gt;
&lt;p&gt;Find more about this package on &lt;a href=&#34;https://cran.r-project.org/web/packages/librarian/index.html&#34; target=&#34;_blank&#34;&gt;CRAN&lt;/a&gt;.&lt;/p&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 the article helped you to install and load R packages in a more efficient way.&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;p&gt;&lt;em&gt;A special thanks Danilo and James for informing me about the &lt;code&gt;{pacman}&lt;/code&gt; and &lt;code&gt;{librarian}&lt;/code&gt; packages.&lt;/em&gt;&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;As suggested by Patrick, it is a good practice to &lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/#insert-a-comment-in-r-and-r-markdown&#34;&gt;comment&lt;/a&gt; (with a &lt;code&gt;#&lt;/code&gt; in front of the line of code) the installation of your packages after they have been installed on your computer. This avoids installing packages on someone else’s computer when you share your code. If they want to install them before running your code, they will need to do it by themselves.&lt;a href=&#34;#fnref1&#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>Do my data follow a normal distribution? A note on the most widely used distribution and how to test for normality in R</title>
      <link>https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/</link>
      <pubDate>Wed, 29 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-is-a-normal-distribution&#34; id=&#34;toc-what-is-a-normal-distribution&#34;&gt;What is a normal distribution?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#empirical-rule&#34; id=&#34;toc-empirical-rule&#34;&gt;Empirical rule&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#parameters&#34; id=&#34;toc-parameters&#34;&gt;Parameters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#probabilities-and-standard-normal-distribution&#34; id=&#34;toc-probabilities-and-standard-normal-distribution&#34;&gt;Probabilities and standard normal distribution&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#areas-under-the-normal-distribution-in-r-and-by-hand&#34; id=&#34;toc-areas-under-the-normal-distribution-in-r-and-by-hand&#34;&gt;Areas under the normal distribution in R and by hand&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#ex.-1&#34; id=&#34;toc-ex.-1&#34;&gt;Ex. 1&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#in-r&#34; id=&#34;toc-in-r&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand&#34; id=&#34;toc-by-hand&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ex.-2&#34; id=&#34;toc-ex.-2&#34;&gt;Ex. 2&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#in-r-1&#34; id=&#34;toc-in-r-1&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand-1&#34; id=&#34;toc-by-hand-1&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ex.-3&#34; id=&#34;toc-ex.-3&#34;&gt;Ex. 3&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#in-r-2&#34; id=&#34;toc-in-r-2&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand-2&#34; id=&#34;toc-by-hand-2&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ex.-4&#34; id=&#34;toc-ex.-4&#34;&gt;Ex. 4&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#in-r-3&#34; id=&#34;toc-in-r-3&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand-3&#34; id=&#34;toc-by-hand-3&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ex.-5&#34; id=&#34;toc-ex.-5&#34;&gt;Ex. 5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#why-is-the-normal-distribution-so-crucial-in-statistics&#34; id=&#34;toc-why-is-the-normal-distribution-so-crucial-in-statistics&#34;&gt;Why is the normal distribution so crucial in statistics?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-test-the-normality-assumption&#34; id=&#34;toc-how-to-test-the-normality-assumption&#34;&gt;How to test the normality assumption&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#histogram&#34; id=&#34;toc-histogram&#34;&gt;Histogram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#density-plot&#34; id=&#34;toc-density-plot&#34;&gt;Density plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#qq-plot&#34; id=&#34;toc-qq-plot&#34;&gt;QQ-plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#normality-test&#34; id=&#34;toc-normality-test&#34;&gt;Normality test&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/Do-my-data-follow-a-normal-distribution.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;what-is-a-normal-distribution&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What is a normal distribution?&lt;/h1&gt;
&lt;p&gt;The normal distribution is a function that defines how a set of measurements is distributed around the center of these measurements (i.e., the mean). Many natural phenomena in real life can be approximated by a bell-shaped frequency distribution known as the normal distribution or the Gaussian distribution.&lt;/p&gt;
&lt;p&gt;The normal distribution is a mount-shaped, unimodal and symmetric distribution where most measurements gather around the mean. Moreover, the further a measure deviates from the mean, the lower the probability of occurring. In this sense, for a given variable, it is common to find values close to the mean, but less and less likely to find values as we move away from the mean. Last but not least, since the normal distribution is symmetric around its mean, extreme values in both tails of the distribution are equivalently unlikely. For instance, given that adult height follows a normal distribution, most adults are close to the average height and extremely short adults occur as infrequently as extremely tall adults.&lt;/p&gt;
&lt;p&gt;In this article, the focus is on understanding the normal distribution, the associated empirical rule, its parameters and how to compute &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-scores to find probabilities under the curve (illustrated with examples). As it is a requirement in some &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt;, we also show 4 complementary methods to test the normality assumption in R.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;empirical-rule&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Empirical rule&lt;/h1&gt;
&lt;p&gt;Data possessing an approximately normal distribution have a definite variation, as expressed by the following empirical rule:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\mu \pm \sigma\)&lt;/span&gt; includes approximately 68% of the observations&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\mu \pm 2 \cdot \sigma\)&lt;/span&gt; includes approximately 95% of the observations&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(\mu \pm 3 \cdot \sigma\)&lt;/span&gt; includes almost all of the observations (99.7% to be more precise)&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/empirical-rule-normal-distribution.png&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;Normal distribution &amp;amp; empirical rule (68-95-99.7% rule)&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\sigma\)&lt;/span&gt; correspond to the population mean and population standard deviation, respectively.&lt;/p&gt;
&lt;p&gt;The empirical rule, also known as the 68-95-99.7% rule, is illustrated by the following 2 examples.&lt;/p&gt;
&lt;p&gt;Suppose that the scores of an exam in statistics given to all students in a Belgian university are known to have, approximately, a normal distribution with mean &lt;span class=&#34;math inline&#34;&gt;\(\mu = 67\)&lt;/span&gt; and standard deviation &lt;span class=&#34;math inline&#34;&gt;\(\sigma = 9\)&lt;/span&gt;. It can then be deduced that approximately 68% of the scores are between 58 and 76, that approximately 95% of the scores are between 49 and 85, and that almost all of the scores (99.7%) are between 40 and 94. Thus, knowing the mean and the standard deviation gives us a fairly good picture of the distribution of scores.&lt;/p&gt;
&lt;p&gt;Now suppose that a single university student is randomly selected from those who took the exam. What is the probability that her score will be between 49 and 85? Based on the empirical rule, we find that 0.95 is a reasonable answer to this probability question.&lt;/p&gt;
&lt;p&gt;The utility and value of the empirical rule are due to the common occurrence of approximately normal distributions of measurements in nature. For example, IQ, shoe size, height, birth weight, etc. are approximately normally-distributed. You will find that approximately 95% of these measurements will be within &lt;span class=&#34;math inline&#34;&gt;\(2\sigma\)&lt;/span&gt; of their mean &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-wackerly2014mathematical&#34; role=&#34;doc-biblioref&#34;&gt;Wackerly, Mendenhall, and Scheaffer 2014&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;parameters&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Parameters&lt;/h1&gt;
&lt;p&gt;Like many probability distributions, the shape and probabilities of the normal distribution is defined entirely by some parameters. The normal distribution has two parameters:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#mean&#34;&gt;mean &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt;&lt;/a&gt;, and&lt;/li&gt;
&lt;li&gt;the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#variance&#34;&gt;variance &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2\)&lt;/span&gt;&lt;/a&gt; (i.e., the square of the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#standard-deviation&#34;&gt;standard deviation &lt;span class=&#34;math inline&#34;&gt;\(\sigma\)&lt;/span&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The mean &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; locates the center of the distribution, that is, the central tendency of the observations, and the variance &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2\)&lt;/span&gt; defines the width of the distribution, that is, the spread of the observations.&lt;/p&gt;
&lt;p&gt;The mean &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; can take on any finite value (i.e., &lt;span class=&#34;math inline&#34;&gt;\(-\infty &amp;lt; \mu &amp;lt; \infty\)&lt;/span&gt;), whereas the variance &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2\)&lt;/span&gt; can assume any positive finite value (i.e., &lt;span class=&#34;math inline&#34;&gt;\(\sigma^2 &amp;gt; 0\)&lt;/span&gt;). The shape of the normal distribution changes based on these two parameters. Since there is an infinite number of combinations of the mean and variance, there is an infinite number of normal distributions, and thus an infinite number of forms.&lt;/p&gt;
&lt;p&gt;For instance, see how the shapes of the normal distributions vary when the two parameters change:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-1-2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see on the second graph, when the variance (or the standard deviation) decreases, the observations are closer to the mean. On the contrary, when the variance (or standard deviation) increases, it is more likely that observations will be further away from the mean.&lt;/p&gt;
&lt;p&gt;A random variable &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; which follows a normal distribution with a mean of 430 and a variance of 17 is denoted &lt;span class=&#34;math inline&#34;&gt;\(X ~ \sim \mathcal{N}(\mu = 430, \sigma^2 = 17)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;We have seen that, although different normal distributions have different shapes, all normal distributions have common characteristics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They are symmetric, 50% of the population is above the mean and 50% of the population is below the mean&lt;/li&gt;
&lt;li&gt;The mean, median and mode are equal&lt;/li&gt;
&lt;li&gt;The empirical rule detailed earlier is applicable to all normal distributions&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;probabilities-and-standard-normal-distribution&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Probabilities and standard normal distribution&lt;/h1&gt;
&lt;p&gt;Probabilities and quantiles for random variables with normal distributions are easily found using R via the functions &lt;code&gt;pnorm()&lt;/code&gt; and &lt;code&gt;qnorm()&lt;/code&gt;. Probabilities associated with a normal distribution can also be found using this &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/statistics-101/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Shiny app&lt;/a&gt;. However, before computing probabilities, we need to learn more about the standard normal distribution and the &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score.&lt;/p&gt;
&lt;p&gt;Although there are infinitely many normal distributions (since there is a normal distribution for every combination of mean and variance), we need only one table to find the probabilities under the normal curve: the &lt;strong&gt;standard normal distribution&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The normal standard distribution is a special case of the normal distribution where the mean is equal to 0 and the variance is equal to 1. A normal random variable &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; can always be transformed to a standard normal random variable &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;, a process known as “scaling” or “standardization”, by subtracting the mean from the observation, and dividing the result by the standard deviation. Formally:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[Z = \frac{x - \mu}{\sigma}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(x\)&lt;/span&gt; is the observation, &lt;span class=&#34;math inline&#34;&gt;\(\mu\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(\sigma\)&lt;/span&gt; the mean and standard deviation of the population from which the observation was drawn. So the mean of the standard normal distribution is 0, and its variance is 1, denoted &lt;span class=&#34;math inline&#34;&gt;\(Z ~ \sim \mathcal{N}(\mu = 0, \sigma^2 = 1)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;From this formula, we see that &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;, referred as standard score or &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score, allows to see how far away one specific observation is from the mean of all observations, with the distance expressed in standard deviations. In other words, the &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score corresponds to the number of standard deviations an observation is away from the mean. A positive &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score means that the specific observation is above the mean, whereas a negative &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score means that the specific observation is below the mean. &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-scores are often used to compare an individual to her peers, or more generally, a measurement compared to its distribution.&lt;/p&gt;
&lt;p&gt;For instance, suppose a student scoring 60 at a statistics exam with the mean score of the class being 40, and scoring 65 at an economics exam with the mean score of the class being 80. Given the “raw” scores, one would say that the student performed better in economics than in statistics. However, taking into consideration her peers, it is clear that the student performed &lt;em&gt;relatively&lt;/em&gt; better in statistics than in economics.&lt;/p&gt;
&lt;p&gt;Computing &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-scores allows to take into consideration all other students (i.e., the entire distribution) and gives a better measure of comparison. Let’s compute the &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-scores for the two exams, assuming that the score for both exams follow a normal distribution with the following parameters:&lt;/p&gt;
&lt;center&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Statistics&lt;/th&gt;
&lt;th&gt;Economics&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td&gt;Mean&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td&gt;Standard deviation&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;12.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td&gt;Student’s score&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;65&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-scores for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Statistics: &lt;span class=&#34;math inline&#34;&gt;\(z_{stat} = \frac{60 - 40}{8} = 2.5\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Economics: &lt;span class=&#34;math inline&#34;&gt;\(z_{econ} = \frac{65 - 80}{12.5} = -1.2\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On the one hand, the &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score for the exam in statistics is positive (&lt;span class=&#34;math inline&#34;&gt;\(z_{stat} = 2.5\)&lt;/span&gt;) which means that she performed better than average. On the other hand, her score for the exam in economics is negative (&lt;span class=&#34;math inline&#34;&gt;\(z_{econ} = -1.2\)&lt;/span&gt;) which means that she performed worse than average. Below an illustration of her grades in a standard normal distribution for better comparison:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Although the score in economics is better in absolute terms, the score in statistics is actually relatively better when comparing each score within its own distribution.&lt;/p&gt;
&lt;p&gt;Furthermore, &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score also enables to compare observations that would otherwise be impossible because they have different units for example. Suppose you want to compare a salary in € with a weight in kg. Without standardization, there is no way to conclude whether someone is more extreme in terms of her wage or in terms of her weight. Thanks to &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-scores, we can compare two values that were in the first place not comparable to each other.&lt;/p&gt;
&lt;p&gt;Final remark regarding the interpretation of a &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score: a rule of thumb is that an observation with a &lt;span class=&#34;math inline&#34;&gt;\(z\)&lt;/span&gt;-score between -3 and -2 or between 2 and 3 is considered as a rare value. An observation with a &lt;span class=&#34;math inline&#34;&gt;\(z\)&lt;/span&gt;-score smaller than -3 or larger than 3 is considered as an extremely rare value. A value with any other &lt;span class=&#34;math inline&#34;&gt;\(z\)&lt;/span&gt;-score is considered as not rare nor extremely rare.&lt;/p&gt;
&lt;div id=&#34;areas-under-the-normal-distribution-in-r-and-by-hand&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Areas under the normal distribution in R and by hand&lt;/h2&gt;
&lt;p&gt;Now that we have covered the &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;-score, we are going to use it to determine the area under the curve of a normal distribution.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that there are several ways to arrive at the solution in the following exercises. You may therefore use other steps than the ones presented to obtain the same result.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;ex.-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ex. 1&lt;/h3&gt;
&lt;p&gt;Let &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt; denote a normal random variable with mean 0 and standard deviation 1, find &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;We actually look for the shaded area in the following figure:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/Screenshot%202020-01-30%20at%2014.18.54.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;Standard normal distribution: &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1)\)&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;In R&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pnorm(1,
  mean = 0,
  sd = 1, # sd stands for standard deviation
  lower.tail = FALSE
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.1586553&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We look for the probability of &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt; being larger than 1 so we set the argument &lt;code&gt;lower.tail = FALSE&lt;/code&gt;. The default &lt;code&gt;lower.tail = TRUE&lt;/code&gt; would give the result for &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;lt; 1)\)&lt;/span&gt;. Note that &lt;span class=&#34;math inline&#34;&gt;\(P(Z = 1) = 0\)&lt;/span&gt; so writing &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1)\)&lt;/span&gt; or &lt;span class=&#34;math inline&#34;&gt;\(P(Z \ge 1)\)&lt;/span&gt; is equivalent.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;by-hand&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;By hand&lt;/h4&gt;
&lt;p&gt;See that the random variable &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt; has already a mean of 0 and a standard deviation of 1, so no transformation is required. To find the probabilities by hand, we need to refer to the standard normal distribution table shown below:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/Screenshot%202020-01-30%20at%2015.07.44.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;Standard normal distribution table &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-wackerly2014mathematical&#34; role=&#34;doc-biblioref&#34;&gt;Wackerly, Mendenhall, and Scheaffer 2014&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;From the illustration at the top of the table, we see that the values inside the table correspond to the area under the normal curve &lt;strong&gt;above&lt;/strong&gt; a certain &lt;span class=&#34;math inline&#34;&gt;\(z\)&lt;/span&gt;. Since we are looking precisely at the probability above &lt;span class=&#34;math inline&#34;&gt;\(z = 1\)&lt;/span&gt; (since we look for &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1)\)&lt;/span&gt;), we can simply proceed down the first (&lt;span class=&#34;math inline&#34;&gt;\(z\)&lt;/span&gt;) column in the table until &lt;span class=&#34;math inline&#34;&gt;\(z = 1.0\)&lt;/span&gt;. The probability is 0.1587. Thus, &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1) = 0.1587\)&lt;/span&gt;. This is similar to what we found using R, except that values in the table are rounded to 4 digits.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;ex.-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ex. 2&lt;/h3&gt;
&lt;p&gt;Let &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt; denote a normal random variable with mean 0 and standard deviation 1, find &lt;span class=&#34;math inline&#34;&gt;\(P(−1 \le Z \le 1)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;We are looking for the shaded area in the following figure:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/Screenshot%202020-01-30%20at%2014.19.14.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;Standard normal distribution: &lt;span class=&#34;math inline&#34;&gt;\(P(−1 \le Z \le 1)\)&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;In R&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pnorm(1, lower.tail = TRUE) - pnorm(-1, lower.tail = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.6826895&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the arguments by default for the mean and the standard deviation are &lt;code&gt;mean = 0&lt;/code&gt; and &lt;code&gt;sd = 1&lt;/code&gt;. Since this is what we need, we can omit them.&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;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;by-hand-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;By hand&lt;/h4&gt;
&lt;p&gt;For this exercise we proceed by steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The shaded area corresponds to the entire area under the normal curve minus the two white areas in both tails of the curve.&lt;/li&gt;
&lt;li&gt;We know that the normal distribution is symmetric.&lt;/li&gt;
&lt;li&gt;Therefore, the shaded area is the entire area under the curve minus two times the white area in the right tail of the curve, the white area in the right tail of the curve being &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1)\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;We also know that the entire area under the normal curve is 1.&lt;/li&gt;
&lt;li&gt;Thus, the shaded area is 1 minus 2 times &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1)\)&lt;/span&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(−1 \le Z \le 1) = 1 - 2 \cdot P(Z &amp;gt; 1)\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[= 1 - 2 \cdot 0.1587 = 0.6826\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1) = 0.1587\)&lt;/span&gt; has been found in the previous exercise.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;ex.-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ex. 3&lt;/h3&gt;
&lt;p&gt;Let &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt; denote a normal random variable with mean 0 and standard deviation 1, find &lt;span class=&#34;math inline&#34;&gt;\(P(0 \le Z \le 1.37)\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;We are looking for the shaded area in the following figure:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/Screenshot%202020-01-30%20at%2014.19.46.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;Standard normal distribution: &lt;span class=&#34;math inline&#34;&gt;\(P(0 \le Z \le 1.37)\)&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;In R&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pnorm(0, lower.tail = FALSE) - pnorm(1.37, lower.tail = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.4146565&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;by-hand-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;By hand&lt;/h4&gt;
&lt;p&gt;Again we proceed by steps for this exercise:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;We know that &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 0) = 0.5\)&lt;/span&gt; since the entire area under the curve is 1, half of it is 0.5.&lt;/li&gt;
&lt;li&gt;The shaded area is half of the entire area under the curve minus the area from 1.37 to infinity.&lt;/li&gt;
&lt;li&gt;The area under the curve from 1.37 to infinity corresponds to &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1.37)\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;Therefore, the shaded area is &lt;span class=&#34;math inline&#34;&gt;\(0.5 - P(Z &amp;gt; 1.37)\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;To find &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1.37)\)&lt;/span&gt;, proceed down the &lt;span class=&#34;math inline&#34;&gt;\(z\)&lt;/span&gt; column in the table to the entry 1.3 and then across the top of the table to the column labeled .07 to read &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1.37) = .0853\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Thus,&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(0 \le Z \le 1.37) = P(Z &amp;gt; 0) - P(Z &amp;gt; 1.37)\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[ = 0.5 - 0.0853 = 0.4147\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;ex.-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ex. 4&lt;/h3&gt;
&lt;p&gt;Recap the example presented in the empirical rule: Suppose that the scores of an exam in statistics given to all students in a Belgian university are known to have a normal distribution with mean &lt;span class=&#34;math inline&#34;&gt;\(\mu = 67\)&lt;/span&gt; and standard deviation &lt;span class=&#34;math inline&#34;&gt;\(\sigma = 9\)&lt;/span&gt;. What fraction of the scores lies between 70 and 80?&lt;/p&gt;
&lt;p&gt;We are looking for the shaded area in the following figure:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/Screenshot%202020-01-30%20at%2016.24.30.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(P(70 \le X \le 80)\)&lt;/span&gt; where &lt;span class=&#34;math inline&#34;&gt;\(X \sim \mathcal{N}(\mu = 67, \sigma^2 = 9^2)\)&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r-3&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;In R&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pnorm(70, mean = 67, sd = 9, lower.tail = FALSE) - pnorm(80, mean = 67, sd = 9, lower.tail = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.2951343&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;by-hand-3&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;By hand&lt;/h4&gt;
&lt;p&gt;Remind that we are looking for &lt;span class=&#34;math inline&#34;&gt;\(P(70 \le X \le 80)\)&lt;/span&gt; where &lt;span class=&#34;math inline&#34;&gt;\(X \sim \mathcal{N}(\mu = 67, \sigma^2 = 9^2)\)&lt;/span&gt;. The random variable &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; is in its “raw” format, meaning that it has not been standardized yet since the mean is 67 and the variance is &lt;span class=&#34;math inline&#34;&gt;\(9^2\)&lt;/span&gt;. We thus need to first apply the transformation to standardize the endpoints 70 and 80 with the following formula:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[Z = \frac{X - \mu}{\sigma}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;After the standardization, &lt;span class=&#34;math inline&#34;&gt;\(x = 70\)&lt;/span&gt; becomes (in terms of &lt;span class=&#34;math inline&#34;&gt;\(z\)&lt;/span&gt;, so in terms of deviation from the mean expressed in standard deviation):&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[z = \frac{70 - 67}{9} = 0.3333\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and &lt;span class=&#34;math inline&#34;&gt;\(x = 80\)&lt;/span&gt; becomes:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[z = \frac{80 - 67}{9} = 1.4444\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The figure above in terms of &lt;span class=&#34;math inline&#34;&gt;\(X\)&lt;/span&gt; is now in terms of &lt;span class=&#34;math inline&#34;&gt;\(Z\)&lt;/span&gt;:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/Screenshot%202020-01-30%20at%2016.37.13.png&#34; style=&#34;width:100.0%&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(P(0.3333 \le Z \le 1.4444)\)&lt;/span&gt; where &lt;span class=&#34;math inline&#34;&gt;\(Z \sim \mathcal{N}(\mu = 0, \sigma^2 = 1)\)&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Finding the probability &lt;span class=&#34;math inline&#34;&gt;\(P(0.3333 \le Z \le 1.4444)\)&lt;/span&gt; is similar to exercises 1 to 3:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The shaded area corresponds to the area under the curve from &lt;span class=&#34;math inline&#34;&gt;\(z = 0.3333\)&lt;/span&gt; to &lt;span class=&#34;math inline&#34;&gt;\(z = 1.4444\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;In other words, the shaded area is the area under the curve from &lt;span class=&#34;math inline&#34;&gt;\(z = 0.3333\)&lt;/span&gt; to infinity minus the area under the curve from &lt;span class=&#34;math inline&#34;&gt;\(z = 1.4444\)&lt;/span&gt; to infinity.&lt;/li&gt;
&lt;li&gt;From the table, &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 0.3333) = 0.3707\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(P(Z &amp;gt; 1.4444) = 0.0749\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Thus:&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[P(0.3333 \le Z \le 1.4444)\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[= P(Z &amp;gt; 0.3333) - P(Z &amp;gt; 1.4444)\]&lt;/span&gt;
&lt;span class=&#34;math display&#34;&gt;\[= 0.3707 - 0.0749 = 0.2958\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The difference with the probability found using in R comes from the rounding.&lt;/p&gt;
&lt;p&gt;To conclude this exercise, we can say that, given that the mean scores is 67 and the standard deviation is 9, 29.58% of the students scored between 70 and 80.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;ex.-5&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ex. 5&lt;/h3&gt;
&lt;p&gt;See another example in a context &lt;a href=&#34;https://statsandr.com/blog/a-guide-on-how-to-read-statistical-tables/#example&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;why-is-the-normal-distribution-so-crucial-in-statistics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Why is the normal distribution so crucial in statistics?&lt;/h1&gt;
&lt;p&gt;The normal distribution is important for three main reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Some statistical &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt; assume that the data follow a normal distribution&lt;/li&gt;
&lt;li&gt;The central limit theorem states that, for a large number of observations (usually &lt;span class=&#34;math inline&#34;&gt;\(n &amp;gt; 30\)&lt;/span&gt;), no matter what is the underlying distribution of the original variable, the distribution of the sample means (&lt;span class=&#34;math inline&#34;&gt;\(\overline{X}_n\)&lt;/span&gt;) and of the sum (&lt;span class=&#34;math inline&#34;&gt;\(S_n = \sum_{i = 1}^n X_i\)&lt;/span&gt;) may be approached by a normal distribution &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-stevens2013intermediate&#34; role=&#34;doc-biblioref&#34;&gt;Stevens 2013&lt;/a&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Linear and nonlinear &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;regression&lt;/a&gt; assume that the residuals are normally-distributed (for small sample sizes)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is therefore useful to know how to test for normality in R, which is the topic of next sections.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-test-the-normality-assumption&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to test the normality assumption&lt;/h1&gt;
&lt;p&gt;As mentioned above, some &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt; require that the data follow a normal distribution, or the result of the test may be flawed.&lt;/p&gt;
&lt;p&gt;In this section, we show 4 complementary methods to determine whether your data follow a normal distribution in R.&lt;/p&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Histogram&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#histogram&#34;&gt;histogram&lt;/a&gt; displays the spread and shape of a distribution, so it is a good starting point to evaluate normality.&lt;/p&gt;
&lt;p&gt;Let’s have a look at the histogram of a distribution that we would expect to follow a normal distribution, the height of 1,000 adults in cm:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-7-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The normal curve with the corresponding mean and variance has been added to the histogram. The histogram follows the normal curve so the data seems to follow a normal distribution.&lt;/p&gt;
&lt;p&gt;Below the minimal code for a histogram in R with the dataset &lt;code&gt;iris&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data(iris)
hist(iris$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-8-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(iris) +
  aes(x = Sepal.Length) +
  geom_histogram()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-9-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Histograms are however not sufficient, particularly in the case of small samples because the number of bins greatly change its appearance. Histograms are not recommended when the number of observations is less than 20 because it does not always correctly illustrate the distribution. See two examples below with datasets of 10 and 12 observations:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-10-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-10-2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Can you tell whether these datasets follow a normal distribution? Surprisingly, both series are generated from a normal distribution!&lt;/p&gt;
&lt;p&gt;In the remaining of the article, we will use the dataset of the 12 adults. If you would like to follow my code in your own script, here is how I generated the data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;set.seed(42)
dat_hist &amp;lt;- data.frame(
  value = rnorm(12, mean = 165, sd = 5)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;rnorm()&lt;/code&gt; function generates random numbers from a normal distribution (12 random numbers with a mean of 165 and standard deviation of 5 in this case). These 12 observations are then saved in the dataset called &lt;code&gt;dat_hist&lt;/code&gt; under the variable &lt;code&gt;value&lt;/code&gt;. Note that &lt;code&gt;set.seed(42)&lt;/code&gt; is important to obtain the exact same data as me.&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;/div&gt;
&lt;div id=&#34;density-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Density plot&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#density-plot&#34;&gt;Density plots&lt;/a&gt; also provide a visual judgment about whether the data follow a normal distribution.&lt;/p&gt;
&lt;p&gt;They are similar to histograms as they also allow to analyze the spread and the shape of the distribution. However, they are a smoothed version of the histogram.&lt;/p&gt;
&lt;p&gt;Here is the density plot drawn from the dataset on the height of the 12 adults discussed above:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(density(dat_hist$value))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-12-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggpubr}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggpubr) # package must be installed first
ggdensity(dat_hist$value,
  main = &amp;quot;Density plot of adult height&amp;quot;,
  xlab = &amp;quot;Height (cm)&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-13-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Since it is hard to test for normality from histograms and density plots only, it is recommended to corroborate these graphs with a QQ-plot. QQ-plot, also known as normality plot, is the third method presented to evaluate normality.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;qq-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;QQ-plot&lt;/h2&gt;
&lt;p&gt;Like histograms and density plots, &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#qq-plot&#34;&gt;QQ-plots&lt;/a&gt; allow to visually evaluate the normality assumption.&lt;/p&gt;
&lt;p&gt;Here is the QQ-plot drawn from the dataset on the height of the 12 adults discussed above:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(car)
qqPlot(dat_hist$value)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-14-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12  2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In &lt;code&gt;{ggpubr}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggpubr)
ggqqplot(dat_hist$value)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-15-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Instead of looking at the spread of the data (as it is the case with histograms and density plots), with QQ-plots we only need to ascertain whether the data points follow the line (sometimes referred as Henry’s line).&lt;/p&gt;
&lt;p&gt;If points are close to the reference line and within the confidence bands, the normality assumption can be considered as met. The bigger the deviation between the points and the reference line and the more they lie outside the confidence bands, the less likely that the normality condition is met. The height of these 12 adults seem to follow a normal distribution because points follow the line and all of them lie within the confidence bands.&lt;/p&gt;
&lt;p&gt;When facing a non-normal distribution as shown by the QQ-plot below (systematic departure from the reference line), the first step is usually to apply the logarithm transformation on the data and recheck to see whether the log-transformed data are normally distributed.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r_files/figure-html/unnamed-chunk-16-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If this is the case, the data are said to follow a &lt;em&gt;log-normal&lt;/em&gt; distribution. Applying the logarithm transformation can be done in R with the &lt;code&gt;log()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;Note that QQ-plots are also a convenient way to assess whether residuals from &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt; follow a normal distribution.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;normality-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Normality test&lt;/h2&gt;
&lt;p&gt;The 3 tools presented above were a visual inspection of the normality. Nonetheless, visual inspection may sometimes be unreliable so it is also possible to formally test whether the data follow a normal distribution with statistical tests.&lt;/p&gt;
&lt;p&gt;These normality tests compare the distribution of the data to a normal distribution in order to assess whether observations show an important deviation from normality.&lt;/p&gt;
&lt;p&gt;The two most common normality tests are Shapiro-Wilk’s test and Kolmogorov-Smirnov test. Both tests have the same hypotheses, that is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;: the data follow a normal distribution&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt;: the data do not follow a normal distribution&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Shapiro-Wilk test is recommended for normality test as it provides better power than Kolmogorov-Smirnov test.&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt; In R, the Shapiro-Wilk test of normality can be done with the function &lt;code&gt;shapiro.test()&lt;/code&gt;:&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;shapiro.test(dat_hist$value)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Shapiro-Wilk normality test
## 
## data:  dat_hist$value
## W = 0.93968, p-value = 0.4939&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From the output, we see that the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(&amp;gt; 0.05\)&lt;/span&gt; implying that we do not reject the null hypothesis that the data follow a normal distribution. This test goes in the same direction than the QQ-plot, which showed no significant deviation from the normality (as all points lied within the confidence bands).&lt;/p&gt;
&lt;p&gt;It is important to note that, in practice, normality tests are often considered as too conservative in the sense that for large sample size (&lt;span class=&#34;math inline&#34;&gt;\(n &amp;gt; 50\)&lt;/span&gt;), a small deviation from the normality may cause the normality condition to be violated.&lt;/p&gt;
&lt;p&gt;A normality test is a &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis test&lt;/a&gt;, so as the sample size increases, their capacity of detecting smaller differences increases. So as the number of observations increases, the Shapiro-Wilk test becomes very sensitive even to a small deviation from normality. As a consequence, it happens that according to the normality test the data do not follow a normal distribution although the departures from the normal distribution is negligible so the data could in fact be considered to follow approximately a normal distribution. For this reason, it is often the case that the normality condition is verified based on a combination of all methods presented in this article, that is, visual inspections (with histograms and QQ-plots) and a formal inspection (with the Shapiro-Wilk test for instance).&lt;/p&gt;
&lt;p&gt;I personally tend to prefer QQ-plots over histograms and normality tests so I do not have to bother about the sample size. This article showed the different methods that are available, your choice will of course depends on the type of your data and the context of your analyses.&lt;/p&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 the article helped you to learn more about the normal distribution and how to test for normality in R.&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-stevens2013intermediate&#34; class=&#34;csl-entry&#34;&gt;
Stevens, James P. 2013. &lt;em&gt;Intermediate Statistics: A Modern Approach&lt;/em&gt;. Routledge.
&lt;/div&gt;
&lt;div id=&#34;ref-wackerly2014mathematical&#34; class=&#34;csl-entry&#34;&gt;
Wackerly, Dennis, William Mendenhall, and Richard L Scheaffer. 2014. &lt;em&gt;Mathematical Statistics with Applications&lt;/em&gt;. Cengage Learning.
&lt;/div&gt;
&lt;/div&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;The argument &lt;code&gt;lower.tail = TRUE&lt;/code&gt; is also the default so we could omit it as well. However, for clarity and to make sure I compute the propabilities in the correct side of the curve, I used to keep this argument explicit by writing it.&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;The &lt;code&gt;set.seed()&lt;/code&gt; function accepts any numeric as argument. Generating random numbers (via &lt;code&gt;rnorm()&lt;/code&gt; for instance) implies that R will generates different random numbers every time you generate these random numbers (so every time you run the function &lt;code&gt;rnorm()&lt;/code&gt;). To make sure R generates the exact same numbers every time you run the function, a seed can be set with the function &lt;code&gt;set.seed()&lt;/code&gt;. Setting a seed implies that R will generate random numbers, but these numbers will always be the same as long as the seed is the same. This allows to replicate results that are based on a random generation. Change the seed if you want to generate other random values.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;The Shapiro-Wilk test is based on the correlation between the sample and the corresponding normal scores.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;In R, the Kolmogorov-Smirnov test is performed with the function &lt;code&gt;ks.test()&lt;/code&gt;.&lt;a href=&#34;#fnref4&#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>Fisher&#39;s exact test in R: independence test for a small sample</title>
      <link>https://statsandr.com/blog/fisher-s-exact-test-in-r-independence-test-for-a-small-sample/</link>
      <pubDate>Tue, 28 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/fisher-s-exact-test-in-r-independence-test-for-a-small-sample/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hypotheses&#34; id=&#34;toc-hypotheses&#34;&gt;Hypotheses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#example&#34; id=&#34;toc-example&#34;&gt;Example&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#observed-frequencies&#34; id=&#34;toc-observed-frequencies&#34;&gt;Observed frequencies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#expected-frequencies&#34; id=&#34;toc-expected-frequencies&#34;&gt;Expected frequencies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#fishers-exact-test-in-r&#34; id=&#34;toc-fishers-exact-test-in-r&#34;&gt;Fisher’s exact test in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion-and-interpretation&#34; id=&#34;toc-conclusion-and-interpretation&#34;&gt;Conclusion and interpretation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-plot-and-statistical-test&#34; id=&#34;toc-combination-of-plot-and-statistical-test&#34;&gt;Combination of plot and statistical test&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;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/fisher-s-exact-test-in-r-independence-test-for-a-small-sample_files/0_73Z2pBxY4UbGaVXz.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;After presenting the &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-by-hand/&#34;&gt;Chi-square test of independence by hand&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;in R&lt;/a&gt;, this article focuses on the Fisher’s exact test.&lt;/p&gt;
&lt;p&gt;Independence tests are used to determine if there is a significant relationship between two categorical variables. There exists two different types of independence test:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the Chi-square test (the most common)&lt;/li&gt;
&lt;li&gt;the Fisher’s exact test&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On the one hand, the Chi-square test is used when the sample is large enough (in this case the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value is an approximation that becomes exact when the sample becomes infinite, which is the case for many statistical tests). On the other hand, the Fisher’s exact test is used when the sample is small (and in this case the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value is exact and is not an approximation).&lt;/p&gt;
&lt;p&gt;The literature indicates that the usual rule for deciding whether the &lt;span class=&#34;math inline&#34;&gt;\(\chi^2\)&lt;/span&gt; approximation is good enough is that the Chi-square test is not appropriate when the &lt;strong&gt;expected&lt;/strong&gt; values in one of the cells of the contingency table is less than 5, and in this case the Fisher’s exact test is preferred &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-mccrum2008correct&#34; role=&#34;doc-biblioref&#34;&gt;McCrum-Gardner 2008&lt;/a&gt;; &lt;a href=&#34;#ref-bower2003use&#34; role=&#34;doc-biblioref&#34;&gt;Bower 2003&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;hypotheses&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Hypotheses&lt;/h1&gt;
&lt;p&gt;The hypotheses of the Fisher’s exact test are the same than for the Chi-square test, that is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; : the variables are independent, there is &lt;strong&gt;no&lt;/strong&gt; relationship between the two categorical variables. Knowing the value of one variable does not help to predict the value of the other variable&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt; : the variables are dependent, there is a relationship between the two categorical variables. Knowing the value of one variable helps to predict the value of the other variable&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;example&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Example&lt;/h1&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;For our example, we want to determine whether there is a statistically significant association between smoking and being a professional athlete. Smoking can only be “yes” or “no” and being a professional athlete can only be “yes” or “no”. The two variables of interest are qualitative variables and we collected data on 14 persons.&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;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;observed-frequencies&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Observed frequencies&lt;/h2&gt;
&lt;p&gt;Our data are summarized in the contingency table below reporting the number of people in each subgroup:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- data.frame(
  &amp;quot;smoke_no&amp;quot; = c(7, 0),
  &amp;quot;smoke_yes&amp;quot; = c(2, 5),
  row.names = c(&amp;quot;Athlete&amp;quot;, &amp;quot;Non-athlete&amp;quot;),
  stringsAsFactors = FALSE
)
colnames(dat) &amp;lt;- c(&amp;quot;Non-smoker&amp;quot;, &amp;quot;Smoker&amp;quot;)

dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             Non-smoker Smoker
## Athlete              7      2
## Non-athlete          0      5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is also a good practice to draw a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#mosaic-plot&#34;&gt;mosaic plot&lt;/a&gt; to visually represent the data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mosaicplot(dat,
  main = &amp;quot;Mosaic plot&amp;quot;,
  color = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/fisher-s-exact-test-in-r-independence-test-for-a-small-sample_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We can already see from the plot that the proportion of smokers in the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt; is higher among non-athletes than athlete. The plot is however not sufficient to conclude that there is such a significant association in the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;population&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Like many &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt;, this can be done via a &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis test&lt;/a&gt;. But before seeing how to do it in R, let’s see the concept of expected frequencies.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;expected-frequencies&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Expected frequencies&lt;/h2&gt;
&lt;p&gt;Remember that the Fisher’s exact test is used when there is at least one cell in the contingency table of the expected frequencies below 5. To retrieve the expected frequencies, use the &lt;code&gt;chisq.test()&lt;/code&gt; function together with &lt;code&gt;$expected&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;chisq.test(dat)$expected&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning in chisq.test(dat): Chi-squared approximation may be incorrect&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             Non-smoker Smoker
## Athlete            4.5    4.5
## Non-athlete        2.5    2.5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The contingency table above confirms that we should use the Fisher’s exact test instead of the Chi-square test because there is at least one cell below 5.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Tip&lt;/em&gt;: although it is a good practice to check the expected frequencies &lt;strong&gt;before&lt;/strong&gt; deciding between the Chi-square and the Fisher test, it is not a big issue if you forget. As you can see above, when doing the Chi-square test in R (with &lt;code&gt;chisq.test()&lt;/code&gt;), a &lt;a href=&#34;https://statsandr.com/blog/top-10-errors-in-r/#warnings&#34;&gt;warning&lt;/a&gt; such as “Chi-squared approximation may be incorrect” will appear. This warning means that the smallest expected frequencies is lower than 5. Therefore, do not worry if you forgot to check the expected frequencies before applying the appropriate test to your data, R will warn you that you should use the Fisher’s exact test instead of the Chi-square test if that is the case.&lt;/p&gt;
&lt;p&gt;(Remember that, as for the Chi-square test of independence, the observations must be independent in order for the Fisher’s exact test to be valid. See more details about the independence assumption in this &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/#chi-square-test-of-independence-in-r&#34;&gt;section&lt;/a&gt;.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;fishers-exact-test-in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Fisher’s exact test in R&lt;/h2&gt;
&lt;p&gt;To perform the Fisher’s exact test in R, use the &lt;code&gt;fisher.test()&lt;/code&gt; function as you would do for the Chi-square test:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- fisher.test(dat)
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Fisher&amp;#39;s Exact Test for Count Data
## 
## data:  dat
## p-value = 0.02098
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  1.449481      Inf
## sample estimates:
## odds ratio 
##        Inf&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The most important in the output is the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value. You can also retrieve the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.02097902&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that if your data is not already presented as a contingency table, you can simply use the following code:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fisher.test(table(dat$variable1, dat$variable2))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where &lt;code&gt;dat&lt;/code&gt; is the name of your dataset, &lt;code&gt;variable1&lt;/code&gt; and &lt;code&gt;variable2&lt;/code&gt; correspond to the names of the two variables of interest.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion-and-interpretation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Conclusion and interpretation&lt;/h2&gt;
&lt;p&gt;From the output and from &lt;code&gt;test$p.value&lt;/code&gt; we see that the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value is less than the significance level of 5%. Like any other &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt;, if the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value is less than the significance level, we can reject the null hypothesis. If you are not familiar with &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values, I invite you to read this &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;section&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(\Rightarrow\)&lt;/span&gt; In our context, rejecting the null hypothesis for the Fisher’s exact test of independence means that there is a significant relationship between the two categorical variables (smoking habits and being an athlete or not). Therefore, knowing the value of one variable helps to predict the value of the other variable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-plot-and-statistical-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Combination of plot and statistical test&lt;/h1&gt;
&lt;p&gt;It is possible print the results of the Fisher’s exact test directly on a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt; thanks to the &lt;code&gt;ggbarstats()&lt;/code&gt; function from the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package (the function has been slightly edited to match our needs).&lt;/p&gt;
&lt;p&gt;It is easier to work with the package when our data is not already in the form of a contingency table so we transform it to a data frame before plotting the results:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create dataframe from contingency table
x &amp;lt;- c()
for (row in rownames(dat)) {
  for (col in colnames(dat)) {
    x &amp;lt;- rbind(x, matrix(rep(c(row, col), dat[row, col]), ncol = 2, byrow = TRUE))
  }
}
df &amp;lt;- as.data.frame(x)
colnames(df) &amp;lt;- c(&amp;quot;Sport_habits&amp;quot;, &amp;quot;Smoking_habits&amp;quot;)
df&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    Sport_habits Smoking_habits
## 1       Athlete     Non-smoker
## 2       Athlete     Non-smoker
## 3       Athlete     Non-smoker
## 4       Athlete     Non-smoker
## 5       Athlete     Non-smoker
## 6       Athlete     Non-smoker
## 7       Athlete     Non-smoker
## 8       Athlete         Smoker
## 9       Athlete         Smoker
## 10  Non-athlete         Smoker
## 11  Non-athlete         Smoker
## 12  Non-athlete         Smoker
## 13  Non-athlete         Smoker
## 14  Non-athlete         Smoker&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Fisher&amp;#39;s exact test with raw data
test &amp;lt;- fisher.test(table(df))

# combine plot and statistical test with ggbarstats
library(ggstatsplot)
ggbarstats(
  df, Smoking_habits, Sport_habits,
  results.subtitle = FALSE,
  subtitle = paste0(
    &amp;quot;Fisher&amp;#39;s exact test&amp;quot;, &amp;quot;, p-value = &amp;quot;,
    ifelse(test$p.value &amp;lt; 0.001, &amp;quot;&amp;lt; 0.001&amp;quot;, round(test$p.value, 3))
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/fisher-s-exact-test-in-r-independence-test-for-a-small-sample_files/figure-html/unnamed-chunk-7-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the plot, it is clear that the proportion of smokers among non-athletes is higher than among athletes, suggesting that there is a relationship between the two variables.&lt;/p&gt;
&lt;p&gt;This is confirmed thanks to the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value displayed in the subtitle of the plot. As previously, we reject the null hypothesis and we conclude that the variables smoking habits and being an athlete or not are dependent (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.021).&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 the article helped you to perform the Fisher’s exact test of independence in R and interpret its results. Learn more about the Chi-square test of independence &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-by-hand/&#34;&gt;by hand&lt;/a&gt; or &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;in R&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 id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-bower2003use&#34; class=&#34;csl-entry&#34;&gt;
Bower, Keith M. 2003. &lt;span&gt;“When to Use Fisher’s Exact Test.”&lt;/span&gt; In &lt;em&gt;American Society for Quality, Six Sigma Forum Magazine&lt;/em&gt;, 2:35–37. 4.
&lt;/div&gt;
&lt;div id=&#34;ref-mccrum2008correct&#34; class=&#34;csl-entry&#34;&gt;
McCrum-Gardner, Evie. 2008. &lt;span&gt;“Which Is the Correct Statistical Test to Use?”&lt;/span&gt; &lt;em&gt;British Journal of Oral and Maxillofacial Surgery&lt;/em&gt; 46 (1): 38–41.
&lt;/div&gt;
&lt;/div&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;The data are the same than for the article covering the &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-by-hand/&#34;&gt;Chi-square test by hand&lt;/a&gt;, except that some observations have been removed to decrease the sample size.&lt;a href=&#34;#fnref1&#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>Chi-square test of independence in R</title>
      <link>https://statsandr.com/blog/chi-square-test-of-independence-in-r/</link>
      <pubDate>Mon, 27 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/chi-square-test-of-independence-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#chi-square-test-of-independence-in-r&#34; id=&#34;toc-chi-square-test-of-independence-in-r&#34;&gt;Chi-square test of independence in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion-and-interpretation&#34; id=&#34;toc-conclusion-and-interpretation&#34;&gt;Conclusion and interpretation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#combination-of-plot-and-statistical-test&#34; id=&#34;toc-combination-of-plot-and-statistical-test&#34;&gt;Combination of plot and statistical test&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r_files/Chi-square-test-independence-in-R.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;This article explains how to perform the Chi-square test of independence in R and how to interpret its results. To learn more about how the test works and how to do it by hand, I invite you to read the article “&lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-by-hand/&#34;&gt;Chi-square test of independence by hand&lt;/a&gt;”.&lt;/p&gt;
&lt;p&gt;To briefly recap what have been said in that article, the Chi-square test of independence tests whether there is a relationship between two &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;categorical variables&lt;/a&gt;. The null and alternative hypotheses are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; : the variables are independent, there is &lt;strong&gt;no&lt;/strong&gt; relationship between the two categorical variables. Knowing the value of one variable does not help to predict the value of the other variable&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1\)&lt;/span&gt; : the variables are dependent, there is a relationship between the two categorical variables. Knowing the value of one variable helps to predict the value of the other variable&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The Chi-square test of independence works by comparing the observed frequencies (so the frequencies observed in your sample) to the expected frequencies if there was no relationship between the two categorical variables (so the expected frequencies if the null hypothesis was true).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;For our example, let’s reuse the dataset introduced in the article “&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;Descriptive statistics in R&lt;/a&gt;”. This dataset is the well-known &lt;code&gt;iris&lt;/code&gt; dataset slightly enhanced. Since there is only one categorical variable and the Chi-square test of independence requires two categorical variables, we add the variable &lt;code&gt;size&lt;/code&gt; which corresponds to &lt;code&gt;small&lt;/code&gt; if the length of the petal is smaller than the median of all flowers, &lt;code&gt;big&lt;/code&gt; otherwise:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iris

dat$size &amp;lt;- ifelse(dat$Sepal.Length &amp;lt; median(dat$Sepal.Length),
  &amp;quot;small&amp;quot;, &amp;quot;big&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now create a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#contingency-table&#34;&gt;contingency table&lt;/a&gt; of the two variables &lt;code&gt;Species&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt; with the &lt;code&gt;table()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(dat$Species, dat$size)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             
##              big small
##   setosa       1    49
##   versicolor  29    21
##   virginica   47     3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The contingency table gives the observed number of cases in each subgroup. For instance, there is only one big setosa flower, while there are 49 small setosa flowers in the dataset.&lt;/p&gt;
&lt;p&gt;It is also a good practice to draw a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt; to visually represent the data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)

ggplot(dat) +
  aes(x = Species, fill = size) +
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you prefer to visualize it in terms of proportions (so that bars all have a height of 1, or 100%):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Species, fill = size) +
  geom_bar(position = &amp;quot;fill&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This second barplot is particularly useful if there are a different number of observations in each level of the variable drawn on the &lt;span class=&#34;math inline&#34;&gt;\(x\)&lt;/span&gt;-axis because it allows to compare the two variables on the same ground.&lt;/p&gt;
&lt;p&gt;If you prefer to have the bars next to each other:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Species, fill = size) +
  geom_bar(position = &amp;quot;dodge&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r_files/figure-html/unnamed-chunk-5-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;See the article “&lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;Graphics in R with ggplot2&lt;/a&gt;” to learn how to create this kind of barplot in &lt;code&gt;{ggplot2}&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;chi-square-test-of-independence-in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Chi-square test of independence in R&lt;/h1&gt;
&lt;p&gt;For this example, we are going to test in R if there is a relationship between the variables &lt;code&gt;Species&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt;. For this, the &lt;code&gt;chisq.test()&lt;/code&gt; function is used:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- chisq.test(table(dat$Species, dat$size))
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Pearson&amp;#39;s Chi-squared test
## 
## data:  table(dat$Species, dat$size)
## X-squared = 86.035, df = 2, p-value &amp;lt; 2.2e-16&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Everything you need appears in this output:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the title of the test,&lt;/li&gt;
&lt;li&gt;which variables have been used,&lt;/li&gt;
&lt;li&gt;the test statistic,&lt;/li&gt;
&lt;li&gt;the degrees of freedom and&lt;/li&gt;
&lt;li&gt;the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value of the test.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also retrieve the &lt;span class=&#34;math inline&#34;&gt;\(\chi^2\)&lt;/span&gt; test statistic and the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$statistic # test statistic&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## X-squared 
##  86.03451&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test$p.value # p-value&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2.078944e-19&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you need to find the expected frequencies, use &lt;code&gt;test$expected&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If a warning such as “Chi-squared approximation may be incorrect” appears, it means that the smallest expected frequencies is lower than 5. To avoid this issue, you can either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;gather some levels (especially those with a small number of observations) to increase the number of observations in the subgroups, or&lt;/li&gt;
&lt;li&gt;use the &lt;a href=&#34;https://statsandr.com/blog/fisher-s-exact-test-in-r-independence-test-for-a-small-sample/&#34;&gt;Fisher’s exact test&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The Fisher’s exact test does not require the assumption of a minimum of 5 expected counts in the contingency table. It can be applied in R thanks to the function &lt;code&gt;fisher.test()&lt;/code&gt;. This test is similar to the Chi-square test in terms of hypothesis and interpretation of the results. Learn more about this test in this &lt;a href=&#34;https://statsandr.com/blog/fisher-s-exact-test-in-r-independence-test-for-a-small-sample/&#34;&gt;article&lt;/a&gt; dedicated to this type of test.&lt;/p&gt;
&lt;p&gt;Talking about assumptions, the Chi-square test of independence requires that the observations are independent. This is usually not tested formally, but rather verified based on the design of the experiment and on the good control of experimental conditions. If you are not sure, ask yourself if one observation is related to another (if one observation has an impact on another). If not, it is most likely that you have independent observations.&lt;/p&gt;
&lt;p&gt;If you have dependent observations (paired samples), the McNemar’s or Cochran’s Q tests should be used instead. The McNemar’s test is used when we want to know if there is a significant change in two paired samples (typically in a study with a measure before and after on the same subject) when the variables have only two categories. The Cochran’s Q tests is an extension of the McNemar’s test when we have more than two related measures.&lt;/p&gt;
&lt;p&gt;For your information, there are three other methods to perform the Chi-square test of independence in R:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;with the &lt;code&gt;summary()&lt;/code&gt; function&lt;/li&gt;
&lt;li&gt;with the &lt;code&gt;assocstats()&lt;/code&gt; function from the &lt;code&gt;{vcd}&lt;/code&gt; package&lt;/li&gt;
&lt;li&gt;with the &lt;code&gt;ctable()&lt;/code&gt; function from the &lt;code&gt;{summarytools}&lt;/code&gt; package&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# second method:
summary(table(dat$Species, dat$size))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Number of cases in table: 150 
## Number of factors: 2 
## Test for independence of all factors:
## 	Chisq = 86.03, df = 2, p-value = 2.079e-19&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# third method:
library(vcd)

assocstats(table(dat$Species, dat$size))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                      X^2 df P(&amp;gt; X^2)
## Likelihood Ratio 107.308  2        0
## Pearson           86.035  2        0
## 
## Phi-Coefficient   : NA 
## Contingency Coeff.: 0.604 
## Cramer&amp;#39;s V        : 0.757&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(summarytools)
library(dplyr)

# fourth method:
dat %$%
  ctable(Species, size,
    prop = &amp;quot;r&amp;quot;, chisq = TRUE, headings = FALSE
  ) %&amp;gt;%
  print(
    method = &amp;quot;render&amp;quot;,
    style = &amp;quot;rmarkdown&amp;quot;,
    footnote = NA
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r_files/chi-square-test-of-independence-in-R-summarytools.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see all four methods give the same results.&lt;/p&gt;
&lt;p&gt;If you do not have the same &lt;em&gt;p&lt;/em&gt;-values with your data across the different methods, make sure to add the &lt;code&gt;correct = FALSE&lt;/code&gt; argument in the &lt;code&gt;chisq.test()&lt;/code&gt; function to prevent from applying the Yate’s continuity correction, which is applied by default in this method.&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;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion-and-interpretation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion and interpretation&lt;/h1&gt;
&lt;p&gt;From the output and from &lt;code&gt;test$p.value&lt;/code&gt; we see that the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value is less than the significance level of 5%. Like any other &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt;, if the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value is less than the significance level, we can reject the null hypothesis. If you are not familiar with &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values, I invite you to read this &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/#a-note-on-p-value-and-significance-level-alpha&#34;&gt;section&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(\Rightarrow\)&lt;/span&gt; In our context, rejecting the null hypothesis for the Chi-square test of independence means that there is a significant relationship between the species and the size. Therefore, knowing the value of one variable helps to predict the value of the other variable.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;combination-of-plot-and-statistical-test&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Combination of plot and statistical test&lt;/h1&gt;
&lt;p&gt;I recently discovered the &lt;code&gt;mosaic()&lt;/code&gt; function from the &lt;code&gt;{vcd}&lt;/code&gt; package. This function has the advantage that it combines a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#mosaic-plot&#34;&gt;mosaic plot&lt;/a&gt; (to visualize a contingency table) and the result of the Chi-square test of independence:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(vcd)

mosaic(~ Species + size,
  direction = c(&amp;quot;v&amp;quot;, &amp;quot;h&amp;quot;),
  data = dat,
  shade = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r_files/figure-html/unnamed-chunk-10-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the mosaic plot is similar to the barplot presented above, but the &lt;em&gt;p&lt;/em&gt;-value of the Chi-square test is also displayed at the bottom right.&lt;/p&gt;
&lt;p&gt;Moreover, this mosaic plot with colored cases shows where the observed frequencies deviates from the expected frequencies if the variables were independent. The red cases means that the observed frequencies are &lt;em&gt;smaller&lt;/em&gt; than the expected frequencies, whereas the blue cases means that the observed frequencies are &lt;em&gt;larger&lt;/em&gt; than the expected frequencies.&lt;/p&gt;
&lt;p&gt;An alternative is the &lt;code&gt;ggbarstats()&lt;/code&gt; function from the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load packages
library(ggstatsplot)
library(ggplot2)

# plot
ggbarstats(
  data = dat,
  x = size,
  y = Species
) +
  labs(caption = NULL) # remove caption&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r_files/figure-html/unnamed-chunk-11-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the plot, it seems that big flowers are more likely to belong to the &lt;code&gt;virginica&lt;/code&gt; species, while small flowers tend to belong to the &lt;code&gt;setosa&lt;/code&gt; species. Species and size are thus expected to be dependent.&lt;/p&gt;
&lt;p&gt;This is confirmed thanks to the statistical results displayed in the subtitle of the plot. There are several results, but we can in this case focus on the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value which is displayed after &lt;code&gt;p =&lt;/code&gt; at the top (in the subtitle of the plot).&lt;/p&gt;
&lt;p&gt;As with the previous tests, we reject the null hypothesis and we conclude that species and size are dependent (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; 0.001).&lt;/p&gt;
&lt;p&gt;Thanks for reading. I hope the article helped you to perform the Chi-square test of independence in R and interpret its results. If you would like to learn how to do this test by hand and how it works, read the article “&lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-by-hand/&#34;&gt;Chi-square test of independence by hand&lt;/a&gt;”. If you want to go further and &lt;em&gt;estimate&lt;/em&gt; the strength of the relationship between two categorical variables, see the &lt;a href=&#34;https://statsandr.com/blog/binary-logistic-regression-in-r/&#34;&gt;binary logistic regression&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;p&gt;&lt;em&gt;(Note that this article is available for download on my &lt;a href=&#34;https://statsandr.gumroad.com/&#34;&gt;Gumroad page&lt;/a&gt;.)&lt;/em&gt;&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;Thanks Herivelto for pointing it out.&lt;a href=&#34;#fnref1&#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>How to create a timeline of your CV in R?</title>
      <link>https://statsandr.com/blog/how-to-create-a-timeline-of-your-cv-in-r/</link>
      <pubDate>Sun, 26 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-create-a-timeline-of-your-cv-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#minimal-reproducible-example&#34; id=&#34;toc-minimal-reproducible-example&#34;&gt;Minimal reproducible example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-personalize-it&#34; id=&#34;toc-how-to-personalize-it&#34;&gt;How to personalize it&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#additional-note&#34; id=&#34;toc-additional-note&#34;&gt;Additional note&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/how-to-construct-a-timeline-of-your-cv-in-r_files/how-to-create-a-timeline-of-your-cv.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In this article, I show how to create a timeline of your CV in R. A CV timeline illustrates key information about your education, work experiences and extra activities. The main advantage of CV timelines compared to regular CV is that they make you stand out immediately by being visually appealing and easier to scan. It also allows you to better present your “story” by showing the chronology of your jobs and activities and thus explain how you got to where you are today. (It can also be part of your portfolio to show your R skills.)&lt;/p&gt;
&lt;p&gt;We show below how to create such CV in R with a minimal reproducible example. Feel free to use the code and adapt it to you. For a more complete example (together with the code) you can check my own &lt;a href=&#34;https://www.antoinesoetewey.com/files/CV_timeline_antoinesoetewey.html&#34; target=&#34;_blank&#34;&gt;CV timeline&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that I wrote this article after reading this &lt;a href=&#34;https://datascienceplus.com/visualize-your-cvs-timeline-with-r-gantt-style/&#34; target=&#34;_blank&#34;&gt;original post&lt;/a&gt; by Bernardo Lares, and in particular his package, i.e., &lt;a href=&#34;https://github.com/laresbernardo/lares&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{lares}&lt;/code&gt; package&lt;/a&gt;. A special thanks for his amazing work which was used to create a slightly modified version of the &lt;code&gt;plot_timeline()&lt;/code&gt; function!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;minimal-reproducible-example&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Minimal reproducible example&lt;/h1&gt;
&lt;p&gt;Here is the code and the result of a minimal reproducible example:&lt;/p&gt;
&lt;!-- &lt;script src=&#34;https://gist.github.com/AntoineSoetewey/c6e83ad501a4b8c12b32cf9d5c06e9f9.js&#34;&gt;&lt;/script&gt; --&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# All packages used below must be installed first
library(devtools)
# devtools::install_github(&amp;quot;laresbernardo/lares&amp;quot;)
library(lares)
library(ggplot2)


today &amp;lt;- as.character(Sys.Date())


### Edit from here ###
cv &amp;lt;- data.frame(rbind(
  c(&amp;quot;PhD in Statistics&amp;quot;, &amp;quot;University3&amp;quot;, &amp;quot;Academic&amp;quot;, &amp;quot;2017-09-01&amp;quot;, today),
  c(&amp;quot;MSc in Econometrics&amp;quot;, &amp;quot;University2&amp;quot;, &amp;quot;Academic&amp;quot;, &amp;quot;2015-09-01&amp;quot;, &amp;quot;2017-08-31&amp;quot;),
  c(&amp;quot;BSc in Economics&amp;quot;, &amp;quot;University1&amp;quot;, &amp;quot;Academic&amp;quot;, &amp;quot;2010-09-01&amp;quot;, &amp;quot;2013-08-31&amp;quot;),
  c(&amp;quot;Job title2&amp;quot;, &amp;quot;Company2&amp;quot;, &amp;quot;Work Experience&amp;quot;, &amp;quot;2016-09-01&amp;quot;, today),
  c(&amp;quot;Job title1&amp;quot;, &amp;quot;Company1&amp;quot;, &amp;quot;Work Experience&amp;quot;, &amp;quot;2013-08-31&amp;quot;, &amp;quot;2015-08-31&amp;quot;),
  c(&amp;quot;Extra1&amp;quot;, &amp;quot;Place1&amp;quot;, &amp;quot;Extra&amp;quot;, &amp;quot;2015-05-01&amp;quot;, today),
  c(&amp;quot;Extra2&amp;quot;, &amp;quot;Place2&amp;quot;, &amp;quot;Extra&amp;quot;, &amp;quot;2019-01-01&amp;quot;, today),
  c(&amp;quot;Extra3&amp;quot;, NA, &amp;quot;Extra&amp;quot;, &amp;quot;2019-12-01&amp;quot;, today)
))
### Edit until here ###


order &amp;lt;- c(&amp;quot;Role&amp;quot;, &amp;quot;Place&amp;quot;, &amp;quot;Type&amp;quot;, &amp;quot;Start&amp;quot;, &amp;quot;End&amp;quot;)
colnames(cv) &amp;lt;- order


plot_timeline2 &amp;lt;- function(event, start, end = start + 1, label = NA, group = NA,
                           title = &amp;quot;Curriculum Vitae Timeline&amp;quot;, subtitle = &amp;quot;Antoine Soetewey&amp;quot;,
                           size = 7, colour = &amp;quot;orange&amp;quot;, save = FALSE, subdir = NA) {
  df &amp;lt;- data.frame(
    Role = as.character(event), Place = as.character(label),
    Start = lubridate::date(start), End = lubridate::date(end),
    Type = group
  )
  cvlong &amp;lt;- data.frame(pos = rep(
    as.numeric(rownames(df)),
    2
  ), name = rep(as.character(df$Role), 2), type = rep(factor(df$Type,
    ordered = TRUE
  ), 2), where = rep(
    as.character(df$Place),
    2
  ), value = c(df$Start, df$End), label_pos = rep(df$Start +
    floor((df$End - df$Start) / 2), 2))
  maxdate &amp;lt;- max(df$End)
  p &amp;lt;- ggplot(cvlong, aes(
    x = value, y = reorder(name, -pos),
    label = where, group = pos
  )) +
    geom_vline(
      xintercept = maxdate,
      alpha = 0.8, linetype = &amp;quot;dotted&amp;quot;
    ) +
    labs(
      title = title,
      subtitle = subtitle, x = NULL, y = NULL, colour = NULL
    ) +
    theme_minimal() +
    theme(panel.background = element_rect(
      fill = &amp;quot;white&amp;quot;,
      colour = NA
    ), axis.ticks = element_blank(), panel.grid.major.x = element_line(
      linewidth = 0.25,
      colour = &amp;quot;grey80&amp;quot;
    ))
  if (!is.na(cvlong$type)[1] | length(unique(cvlong$type)) &amp;gt;
    1) {
    p &amp;lt;- p + geom_line(aes(color = type), linewidth = size) +
      facet_grid(type ~ ., scales = &amp;quot;free&amp;quot;, space = &amp;quot;free&amp;quot;) +
      guides(colour = &amp;quot;none&amp;quot;) +
      scale_colour_manual(values = c(&amp;quot;#F8766D&amp;quot;, &amp;quot;#00BA38&amp;quot;, &amp;quot;#619CFF&amp;quot;)) +
      theme(strip.text.y = element_text(size = 10))
  } else {
    p &amp;lt;- p + geom_line(linewidth = size)
  }
  p &amp;lt;- p + geom_label(aes(x = label_pos),
    colour = &amp;quot;black&amp;quot;,
    size = 2, alpha = 0.7
  )
  if (save) {
    file_name &amp;lt;- &amp;quot;cv_timeline.png&amp;quot;
    if (!is.na(subdir)) {
      dir.create(file.path(getwd(), subdir), recursive = T)
      file_name &amp;lt;- paste(subdir, file_name, sep = &amp;quot;/&amp;quot;)
    }
    p &amp;lt;- p + ggsave(file_name, width = 8, height = 6)
    message(paste(&amp;quot;Saved plot as&amp;quot;, file_name))
  }
  return(p)
}




plot_timeline2(
  event = cv$Role,
  start = cv$Start,
  end = cv$End,
  label = cv$Place,
  group = cv$Type,
  save = FALSE,
  subtitle = &amp;quot;Antoine Soetewey&amp;quot; # replace with your name
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/how-to-construct-a-timeline-of-your-cv-in-r_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-personalize-it&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to personalize it&lt;/h1&gt;
&lt;p&gt;If you want to edit the example with your own academic, extra and work experiences you basically just have to edit the dataframe called &lt;code&gt;cv&lt;/code&gt; in the code above. Each row of the dataset &lt;code&gt;cv&lt;/code&gt; is a different academic program, job or activity. Rows should include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the name of the academic program, job title or activity&lt;/li&gt;
&lt;li&gt;the name of the university, school, company or workplace&lt;/li&gt;
&lt;li&gt;the category: academic, work experience or extra&lt;/li&gt;
&lt;li&gt;the starting date (dates must be in format &lt;code&gt;yyyy-mm-dd&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the ending date. If the role has not yet ended, type &lt;code&gt;today&lt;/code&gt; instead of the date. By using &lt;code&gt;today&lt;/code&gt; your CV timeline will automatically adapt to today’s date&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Add or remove a row in the dataframe if you want to add or remove a role. Indicate &lt;code&gt;NA&lt;/code&gt; if you do not want to specify any workplace (as it has been done for &lt;code&gt;Extra3&lt;/code&gt;). Last, do not forget to replace my name with yours for the subtitle of the timeline at the end of the code.&lt;/p&gt;
&lt;p&gt;Experienced R users may wish to edit the &lt;code&gt;plot_timeline2&lt;/code&gt; function to their needs. However, if you are happy with the template and design of the example, you only have to change things mentioned above.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-note&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Additional note&lt;/h1&gt;
&lt;p&gt;Instead of editing the code according to your roles directly in the script, you can also create an Excel file with the required data (job title, workplace, type, start date, end date) and then &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;import it into R&lt;/a&gt;. Editing the Excel file is easier and less prone to coding errors. Moreover, if you have a long career, the code may become long while if you import the Excel file, it will always stay short and concise.&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 helped you to create a timeline of your CV in R. If you would like to see a more complete and live example, see &lt;a href=&#34;https://www.antoinesoetewey.com/files/CV_timeline_antoinesoetewey.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;my timeline CV&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;p&gt;&lt;em&gt;A special thanks to Prof. Job N Nmadu for the suggestion about creating the file that holds the data.&lt;/em&gt;&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>Descriptive statistics in R</title>
      <link>https://statsandr.com/blog/descriptive-statistics-in-r/</link>
      <pubDate>Wed, 22 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/descriptive-statistics-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34; id=&#34;toc-data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#minimum-and-maximum&#34; id=&#34;toc-minimum-and-maximum&#34;&gt;Minimum and maximum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#range&#34; id=&#34;toc-range&#34;&gt;Range&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#mean&#34; id=&#34;toc-mean&#34;&gt;Mean&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#median&#34; id=&#34;toc-median&#34;&gt;Median&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#first-and-third-quartile&#34; id=&#34;toc-first-and-third-quartile&#34;&gt;First and third quartile&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#other-quantiles&#34; id=&#34;toc-other-quantiles&#34;&gt;Other quantiles&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#interquartile-range&#34; id=&#34;toc-interquartile-range&#34;&gt;Interquartile range&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#standard-deviation-and-variance&#34; id=&#34;toc-standard-deviation-and-variance&#34;&gt;Standard deviation and variance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#summary&#34; id=&#34;toc-summary&#34;&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#coefficient-of-variation&#34; id=&#34;toc-coefficient-of-variation&#34;&gt;Coefficient of variation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#mode&#34; id=&#34;toc-mode&#34;&gt;Mode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation&#34; id=&#34;toc-correlation&#34;&gt;Correlation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#contingency-table&#34; id=&#34;toc-contingency-table&#34;&gt;Contingency table&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#mosaic-plot&#34; id=&#34;toc-mosaic-plot&#34;&gt;Mosaic plot&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#barplot&#34; id=&#34;toc-barplot&#34;&gt;Barplot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#histogram&#34; id=&#34;toc-histogram&#34;&gt;Histogram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#boxplot&#34; id=&#34;toc-boxplot&#34;&gt;Boxplot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#dotplot&#34; id=&#34;toc-dotplot&#34;&gt;Dotplot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scatterplot&#34; id=&#34;toc-scatterplot&#34;&gt;Scatterplot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#line-plot&#34; id=&#34;toc-line-plot&#34;&gt;Line plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#qq-plot&#34; id=&#34;toc-qq-plot&#34;&gt;QQ-plot&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#for-a-single-variable&#34; id=&#34;toc-for-a-single-variable&#34;&gt;For a single variable&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#by-groups&#34; id=&#34;toc-by-groups&#34;&gt;By groups&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#density-plot&#34; id=&#34;toc-density-plot&#34;&gt;Density plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#correlation-plot&#34; id=&#34;toc-correlation-plot&#34;&gt;Correlation plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#advanced-descriptive-statistics&#34; id=&#34;toc-advanced-descriptive-statistics&#34;&gt;Advanced descriptive statistics&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#summarytools-package&#34; id=&#34;toc-summarytools-package&#34;&gt;&lt;code&gt;{summarytools}&lt;/code&gt; package&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#frequency-tables-with-freq&#34; id=&#34;toc-frequency-tables-with-freq&#34;&gt;Frequency tables with &lt;code&gt;freq()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#cross-tabulations-with-ctable&#34; id=&#34;toc-cross-tabulations-with-ctable&#34;&gt;Cross-tabulations with &lt;code&gt;ctable()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#descriptive-statistics-with-descr&#34; id=&#34;toc-descriptive-statistics-with-descr&#34;&gt;Descriptive statistics with &lt;code&gt;descr()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data-frame-summaries-with-dfsummary&#34; id=&#34;toc-data-frame-summaries-with-dfsummary&#34;&gt;Data frame summaries with &lt;code&gt;dfSummary()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#describeby-from-the-psych-package&#34; id=&#34;toc-describeby-from-the-psych-package&#34;&gt;&lt;code&gt;describeBy()&lt;/code&gt; from the &lt;code&gt;{psych}&lt;/code&gt; package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#aggregate-function&#34; id=&#34;toc-aggregate-function&#34;&gt;&lt;code&gt;aggregate()&lt;/code&gt; function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#summaryby-from-doby&#34; id=&#34;toc-summaryby-from-doby&#34;&gt;&lt;code&gt;summaryBy()&lt;/code&gt; from &lt;code&gt;{doBy}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#group_by-and-summarise-from-dplyr&#34; id=&#34;toc-group_by-and-summarise-from-dplyr&#34;&gt;&lt;code&gt;group_by()&lt;/code&gt; and &lt;code&gt;summarise()&lt;/code&gt; from &lt;code&gt;{dplyr}&lt;/code&gt;&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/descriptive-statistics-in-r_files/descriptive-statistics-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;This article explains how to compute the main descriptive statistics in R and how to present them graphically. To learn more about the reasoning behind each descriptive statistics, how to compute them by hand and how to interpret them, read the article “&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;Descriptive statistics by hand&lt;/a&gt;”.&lt;/p&gt;
&lt;p&gt;To briefly recap what have been said in that article, descriptive statistics (in the broad sense of the term) is a branch of statistics aiming at summarizing, describing and presenting a series of values or a dataset. Descriptive statistics is often the first step and an important part in any statistical analysis. It allows to check the quality of the data and it helps to “understand” the data by having a clear overview of it. If well presented, descriptive statistics is already a good starting point for further analyses. There exists many measures to summarize a dataset. They are divided into two types:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;location measures and&lt;/li&gt;
&lt;li&gt;dispersion measures&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Location measures give an understanding about the central tendency of the data, whereas dispersion measures give an understanding about the spread of the data. In this article, we focus only on the implementation in R of the most common descriptive statistics and their visualizations (when deemed appropriate). See online or in the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;above mentioned article&lt;/a&gt; for more information about the purpose and usage of each measure.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data&lt;/h1&gt;
&lt;p&gt;We use the dataset &lt;code&gt;iris&lt;/code&gt; throughout the article. This dataset is imported by default in R, you only need to load it by running &lt;code&gt;iris&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iris # load the iris dataset and renamed it dat&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Below a preview of this dataset and its structure:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(dat) # first 6 observations&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa
## 4          4.6         3.1          1.5         0.2  setosa
## 5          5.0         3.6          1.4         0.2  setosa
## 6          5.4         3.9          1.7         0.4  setosa&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(dat) # structure of dataset&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;#39;data.frame&amp;#39;:	150 obs. of  5 variables:
##  $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
##  $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
##  $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
##  $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
##  $ Species     : Factor w/ 3 levels &amp;quot;setosa&amp;quot;,&amp;quot;versicolor&amp;quot;,..: 1 1 1 1 1 1 1 1 1 1 ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The dataset contains 150 observations and 5 variables, representing the length and width of the sepal and petal and the species of 150 flowers. Length and width of the sepal and petal are numeric variables and the species is a factor with 3 levels (indicated by &lt;code&gt;num&lt;/code&gt; and &lt;code&gt;Factor w/ 3 levels&lt;/code&gt; after the name of the variables). See the &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/&#34;&gt;different variables types in R&lt;/a&gt; if you need a refresh.&lt;/p&gt;
&lt;p&gt;Regarding plots, we present the default graphs and the graphs from the well-known &lt;code&gt;{ggplot2}&lt;/code&gt; package. Graphs from the &lt;code&gt;{ggplot2}&lt;/code&gt; package usually have a better look but it requires more advanced coding skills (see the article “&lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;Graphics in R with ggplot2&lt;/a&gt;” to learn more). If you need to publish or share your graphs, I suggest using &lt;code&gt;{ggplot2}&lt;/code&gt; if you can, otherwise the default graphics will do the job.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Tip:&lt;/em&gt; I recently discovered the ggplot2 builder from the &lt;code&gt;{esquisse}&lt;/code&gt; addins. See how you can easily &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/&#34;&gt;draw graphs from the &lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt; without having to code it yourself.&lt;/p&gt;
&lt;p&gt;All plots displayed in this article can be customized. For instance, it is possible to edit the title, x and y-axis labels, color, etc. However, customizing plots is beyond the scope of this article so all plots are presented without any customization. Interested readers will find numerous resources online.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;minimum-and-maximum&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Minimum and maximum&lt;/h1&gt;
&lt;p&gt;Minimum and maximum can be found thanks to the &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;min(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4.3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;max(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7.9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively the &lt;code&gt;range()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rng &amp;lt;- range(dat$Sepal.Length)
rng&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4.3 7.9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;gives you the minimum and maximum directly. Note that the output of the &lt;code&gt;range()&lt;/code&gt; function is actually an object containing the minimum and maximum (in that order). This means you can actually access the minimum with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rng[1] # rng = name of the object specified above&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4.3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and the maximum with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rng[2]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7.9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This reminds us that, in R, there are often several ways to arrive at the same result. The method that uses the shortest piece of code is usually preferred as a shorter piece of code is less prone to coding errors and more readable.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;range&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Range&lt;/h1&gt;
&lt;p&gt;The range can then be easily computed, as you have guessed, by subtracting the minimum from the maximum:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;max(dat$Sepal.Length) - min(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3.6&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To my knowledge, there is no default function to compute the range. However, if you are familiar with writing functions in R
&lt;!-- (if not, see this article on [how to write a function in R](/blog/xxx/)) --&gt;
, you can create your own function to compute the range:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;range2 &amp;lt;- function(x) {
  range &amp;lt;- max(x) - min(x)
  return(range)
}

range2(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3.6&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which is equivalent than &lt;span class=&#34;math inline&#34;&gt;\(max - min\)&lt;/span&gt; presented above.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;mean&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Mean&lt;/h1&gt;
&lt;p&gt;The mean can be computed with the &lt;code&gt;mean()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 5.843333&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Tips:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;if there is at least one missing value in your dataset, use &lt;code&gt;mean(dat$Sepal.Length, na.rm = TRUE)&lt;/code&gt; to compute the mean with the NA excluded. This argument can be used for most functions presented in this article, not only the mean&lt;/li&gt;
&lt;li&gt;for a truncated mean, use &lt;code&gt;mean(dat$Sepal.Length, trim = 0.10)&lt;/code&gt; and change the &lt;code&gt;trim&lt;/code&gt; argument to your needs&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;median&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Median&lt;/h1&gt;
&lt;p&gt;The median can be computed thanks to the &lt;code&gt;median()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;median(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 5.8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or with the &lt;code&gt;quantile()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quantile(dat$Sepal.Length, 0.5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 50% 
## 5.8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;since the quantile of order 0.5 (&lt;span class=&#34;math inline&#34;&gt;\(q_{0.5}\)&lt;/span&gt;) corresponds to the median.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;first-and-third-quartile&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;First and third quartile&lt;/h1&gt;
&lt;p&gt;As the median, the first and third quartiles can be computed thanks to the &lt;code&gt;quantile()&lt;/code&gt; function and by setting the second argument to 0.25 or 0.75:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quantile(dat$Sepal.Length, 0.25) # first quartile&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 25% 
## 5.1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quantile(dat$Sepal.Length, 0.75) # third quartile&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 75% 
## 6.4&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You may have seen that the results above are slightly different than the results you would have found if you compute the first and third quartiles &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;by hand&lt;/a&gt;. It is normal, there are many methods to compute them (R actually has 7 methods to compute the quantiles!). However, the methods presented here and in the article “&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;descriptive statistics by hand&lt;/a&gt;” are the easiest and most “standard” ones. Furthermore, results do not dramatically change between the two methods.&lt;/p&gt;
&lt;div id=&#34;other-quantiles&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Other quantiles&lt;/h2&gt;
&lt;p&gt;As you have guessed, any quantile can also be computed with the &lt;code&gt;quantile()&lt;/code&gt; function. For instance, the &lt;span class=&#34;math inline&#34;&gt;\(4^{th}\)&lt;/span&gt; decile or the &lt;span class=&#34;math inline&#34;&gt;\(98^{th}\)&lt;/span&gt; percentile:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quantile(dat$Sepal.Length, 0.4) # 4th decile&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 40% 
## 5.6&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quantile(dat$Sepal.Length, 0.98) # 98th percentile&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 98% 
## 7.7&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;interquartile-range&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Interquartile range&lt;/h1&gt;
&lt;p&gt;The interquartile range (i.e., the difference between the first and third quartile) can be computed with the &lt;code&gt;IQR()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;IQR(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1.3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or alternatively with the &lt;code&gt;quantile()&lt;/code&gt; function again:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quantile(dat$Sepal.Length, 0.75) - quantile(dat$Sepal.Length, 0.25)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 75% 
## 1.3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As mentioned earlier, when possible it is usually recommended to use the shortest piece of code to arrive at the result. For this reason, the &lt;code&gt;IQR()&lt;/code&gt; function is preferred to compute the interquartile range.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;standard-deviation-and-variance&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Standard deviation and variance&lt;/h1&gt;
&lt;p&gt;The standard deviation and the variance is computed with the &lt;code&gt;sd()&lt;/code&gt; and &lt;code&gt;var()&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sd(dat$Sepal.Length) # standard deviation&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.8280661&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;var(dat$Sepal.Length) # variance&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.6856935&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember from the article &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;descriptive statistics by hand&lt;/a&gt; that the standard deviation and the variance are different whether we compute it for a sample or a population (see the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;difference between sample and population&lt;/a&gt;). In R, the standard deviation and the variance are computed as if the data represent a sample (so the denominator is &lt;span class=&#34;math inline&#34;&gt;\(n - 1\)&lt;/span&gt;, where &lt;span class=&#34;math inline&#34;&gt;\(n\)&lt;/span&gt; is the number of observations). To my knowledge, there is no function by default in R that computes the standard deviation or variance for a population.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Tip:&lt;/em&gt; to compute the standard deviation (or variance) of multiple variables at the same time, use &lt;code&gt;lapply()&lt;/code&gt; with the appropriate statistics as second argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lapply(dat[, 1:4], sd)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $Sepal.Length
## [1] 0.8280661
## 
## $Sepal.Width
## [1] 0.4358663
## 
## $Petal.Length
## [1] 1.765298
## 
## $Petal.Width
## [1] 0.7622377&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The command &lt;code&gt;dat[, 1:4]&lt;/code&gt; selects the variables 1 to 4 as the fifth variable is a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative variable&lt;/a&gt; and the standard deviation cannot be computed on such type of variable. See a recap of the different &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/&#34;&gt;data types in R&lt;/a&gt; if needed.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Summary&lt;/h1&gt;
&lt;p&gt;You can compute the minimum, &lt;span class=&#34;math inline&#34;&gt;\(1^{st}\)&lt;/span&gt; quartile, median, mean, &lt;span class=&#34;math inline&#34;&gt;\(3^{rd}\)&lt;/span&gt; quartile and the maximum for all numeric variables of a dataset at once using &lt;code&gt;summary()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(dat)&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;p&gt;&lt;em&gt;Tip:&lt;/em&gt; if you need these descriptive statistics by group use the &lt;code&gt;by()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;by(dat, dat$Species, summary)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## dat$Species: setosa
##   Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
##  Min.   :4.300   Min.   :2.300   Min.   :1.000   Min.   :0.100  
##  1st Qu.:4.800   1st Qu.:3.200   1st Qu.:1.400   1st Qu.:0.200  
##  Median :5.000   Median :3.400   Median :1.500   Median :0.200  
##  Mean   :5.006   Mean   :3.428   Mean   :1.462   Mean   :0.246  
##  3rd Qu.:5.200   3rd Qu.:3.675   3rd Qu.:1.575   3rd Qu.:0.300  
##  Max.   :5.800   Max.   :4.400   Max.   :1.900   Max.   :0.600  
##        Species  
##  setosa    :50  
##  versicolor: 0  
##  virginica : 0  
##                 
##                 
##                 
## ------------------------------------------------------------ 
## dat$Species: versicolor
##   Sepal.Length    Sepal.Width     Petal.Length   Petal.Width          Species  
##  Min.   :4.900   Min.   :2.000   Min.   :3.00   Min.   :1.000   setosa    : 0  
##  1st Qu.:5.600   1st Qu.:2.525   1st Qu.:4.00   1st Qu.:1.200   versicolor:50  
##  Median :5.900   Median :2.800   Median :4.35   Median :1.300   virginica : 0  
##  Mean   :5.936   Mean   :2.770   Mean   :4.26   Mean   :1.326                  
##  3rd Qu.:6.300   3rd Qu.:3.000   3rd Qu.:4.60   3rd Qu.:1.500                  
##  Max.   :7.000   Max.   :3.400   Max.   :5.10   Max.   :1.800                  
## ------------------------------------------------------------ 
## dat$Species: virginica
##   Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
##  Min.   :4.900   Min.   :2.200   Min.   :4.500   Min.   :1.400  
##  1st Qu.:6.225   1st Qu.:2.800   1st Qu.:5.100   1st Qu.:1.800  
##  Median :6.500   Median :3.000   Median :5.550   Median :2.000  
##  Mean   :6.588   Mean   :2.974   Mean   :5.552   Mean   :2.026  
##  3rd Qu.:6.900   3rd Qu.:3.175   3rd Qu.:5.875   3rd Qu.:2.300  
##  Max.   :7.900   Max.   :3.800   Max.   :6.900   Max.   :2.500  
##        Species  
##  setosa    : 0  
##  versicolor: 0  
##  virginica :50  
##                 
##                 
## &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where the arguments are the name of the dataset, the grouping variable and the summary function. Follow this order, or specify the name of the arguments if you do not follow this order.&lt;/p&gt;
&lt;p&gt;If you need more descriptive statistics, use &lt;code&gt;stat.desc()&lt;/code&gt; from the package &lt;code&gt;{pastecs}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(pastecs)
stat.desc(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##              Sepal.Length  Sepal.Width Petal.Length  Petal.Width Species
## nbr.val      150.00000000 150.00000000  150.0000000 150.00000000      NA
## nbr.null       0.00000000   0.00000000    0.0000000   0.00000000      NA
## nbr.na         0.00000000   0.00000000    0.0000000   0.00000000      NA
## min            4.30000000   2.00000000    1.0000000   0.10000000      NA
## max            7.90000000   4.40000000    6.9000000   2.50000000      NA
## range          3.60000000   2.40000000    5.9000000   2.40000000      NA
## sum          876.50000000 458.60000000  563.7000000 179.90000000      NA
## median         5.80000000   3.00000000    4.3500000   1.30000000      NA
## mean           5.84333333   3.05733333    3.7580000   1.19933333      NA
## SE.mean        0.06761132   0.03558833    0.1441360   0.06223645      NA
## CI.mean.0.95   0.13360085   0.07032302    0.2848146   0.12298004      NA
## var            0.68569351   0.18997942    3.1162779   0.58100626      NA
## std.dev        0.82806613   0.43586628    1.7652982   0.76223767      NA
## coef.var       0.14171126   0.14256420    0.4697441   0.63555114      NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can have even more statistics (i.e., skewness, kurtosis and &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normality test&lt;/a&gt;) by adding the argument &lt;code&gt;norm = TRUE&lt;/code&gt; in the previous function. Note that the variable &lt;code&gt;Species&lt;/code&gt; is not numeric, so descriptive statistics cannot be computed for this variable and NA are displayed.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coefficient-of-variation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Coefficient of variation&lt;/h1&gt;
&lt;p&gt;The coefficient of variation can be found with &lt;code&gt;stat.desc()&lt;/code&gt; (see the line &lt;code&gt;coef.var&lt;/code&gt; in the table above) or by computing manually (remember that the coefficient of variation is the standard deviation divided by the mean):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sd(dat$Sepal.Length) / mean(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.1417113&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;mode&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Mode&lt;/h1&gt;
&lt;p&gt;To my knowledge there is no function to find the mode of a variable. However, we can easily find it thanks to the functions &lt;code&gt;table()&lt;/code&gt; and &lt;code&gt;sort()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab &amp;lt;- table(dat$Sepal.Length) # number of occurrences for each unique value
sort(tab, decreasing = TRUE) # sort highest to lowest&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##   5 5.1 6.3 5.7 6.7 5.5 5.8 6.4 4.9 5.4 5.6   6 6.1 4.8 6.5 4.6 5.2 6.2 6.9 7.7 
##  10   9   9   8   8   7   7   7   6   6   6   6   6   5   5   4   4   4   4   4 
## 4.4 5.9 6.8 7.2 4.7 6.6 4.3 4.5 5.3   7 7.1 7.3 7.4 7.6 7.9 
##   3   3   3   3   2   2   1   1   1   1   1   1   1   1   1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;table()&lt;/code&gt; gives the number of occurrences for each unique value, then &lt;code&gt;sort()&lt;/code&gt; with the argument &lt;code&gt;decreasing = TRUE&lt;/code&gt; displays the number of occurrences from highest to lowest. The mode of the variable &lt;code&gt;Sepal.Length&lt;/code&gt; is thus 5. This code to find the mode can also be applied to qualitative variables such as &lt;code&gt;Species&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sort(table(dat$Species), decreasing = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##     setosa versicolor  virginica 
##         50         50         50&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(dat$Species)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     setosa versicolor  virginica 
##         50         50         50&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Correlation&lt;/h1&gt;
&lt;p&gt;Another descriptive statistics is the correlation coefficient.&lt;/p&gt;
&lt;p&gt;The correlation measures the &lt;em&gt;linear&lt;/em&gt; relationship between two variables, and it can be computed with the &lt;code&gt;cor()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;cor(dat$Sepal.Length, dat$Sepal.Width)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.1175698&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Computing correlation in R and interpreting the results deserve a detailed explanation, so I wrote an article covering &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation and correlation test&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;contingency-table&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Contingency table&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;table()&lt;/code&gt; introduced above can also be used on two qualitative variables to create a contingency table. The dataset &lt;code&gt;iris&lt;/code&gt; has only one qualitative variable so we create a new qualitative variable just for this example. We create the variable &lt;code&gt;size&lt;/code&gt; which corresponds to &lt;code&gt;small&lt;/code&gt; if the length of the petal is smaller than the median of all flowers, &lt;code&gt;big&lt;/code&gt; otherwise:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$size &amp;lt;- ifelse(dat$Sepal.Length &amp;lt; median(dat$Sepal.Length),
  &amp;quot;small&amp;quot;, &amp;quot;big&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is a recap of the occurrences by size:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(dat$size)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##   big small 
##    77    73&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now create a contingency table of the two variables &lt;code&gt;Species&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt; with the &lt;code&gt;table()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(dat$Species, dat$size)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             
##              big small
##   setosa       1    49
##   versicolor  29    21
##   virginica   47     3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or with the &lt;code&gt;xtabs()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;xtabs(~ dat$Species + dat$size)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             dat$size
## dat$Species  big small
##   setosa       1    49
##   versicolor  29    21
##   virginica   47     3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The contingency table gives the number of cases in each subgroup. For instance, there is only one big setosa flower, while there are 49 small setosa flowers in the dataset.&lt;/p&gt;
&lt;p&gt;To go further, we can see from the table that setosa flowers seem to be smaller in size than virginica flowers. In order to check whether size is significantly associated with species, we could perform a Chi-square test of independence since both variables are categorical variables. See how to do this test &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-by-hand/&#34;&gt;by hand&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;in R&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that &lt;code&gt;Species&lt;/code&gt; are in rows and &lt;code&gt;size&lt;/code&gt; in column because we specified &lt;code&gt;Species&lt;/code&gt; and then &lt;code&gt;size&lt;/code&gt; in &lt;code&gt;table()&lt;/code&gt;. Change the order if you want to switch the two variables.&lt;/p&gt;
&lt;p&gt;Instead of having the frequencies (i.e.. the number of cases) you can also have the relative frequencies (i.e., proportions) in each subgroup by adding the &lt;code&gt;table()&lt;/code&gt; function inside the &lt;code&gt;prop.table()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;prop.table(table(dat$Species, dat$size))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             
##                      big       small
##   setosa     0.006666667 0.326666667
##   versicolor 0.193333333 0.140000000
##   virginica  0.313333333 0.020000000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that you can also compute the percentages by row or by column by adding a second argument to the &lt;code&gt;prop.table()&lt;/code&gt; function: &lt;code&gt;1&lt;/code&gt; for row, or &lt;code&gt;2&lt;/code&gt; for column:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# percentages by row:
round(prop.table(table(dat$Species, dat$size), 1), 2) # round to 2 digits with round()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             
##               big small
##   setosa     0.02  0.98
##   versicolor 0.58  0.42
##   virginica  0.94  0.06&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# percentages by column:
round(prop.table(table(dat$Species, dat$size), 2), 2) # round to 2 digits with round()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             
##               big small
##   setosa     0.01  0.67
##   versicolor 0.38  0.29
##   virginica  0.61  0.04&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See the section on &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#cross-tabulations-with-ctable&#34;&gt;advanced descriptive statistics&lt;/a&gt; for more advanced contingency tables.&lt;/p&gt;
&lt;div id=&#34;mosaic-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Mosaic plot&lt;/h2&gt;
&lt;p&gt;A mosaic plot allows to visualize a contingency table of two qualitative variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mosaicplot(table(dat$Species, dat$size),
  color = TRUE,
  xlab = &amp;quot;Species&amp;quot;, # label for x-axis
  ylab = &amp;quot;Size&amp;quot; # label for y-axis
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-32-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The mosaic plot shows that, for our sample, the proportion of big and small flowers is clearly different between the three species. In particular, the virginica species is the biggest, and the setosa species is the smallest of the three species (in terms of sepal length since the variable &lt;code&gt;size&lt;/code&gt; is based on the variable &lt;code&gt;Sepal.Length&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;For your information, a mosaic plot can also be done via the &lt;code&gt;mosaic()&lt;/code&gt; function from the &lt;code&gt;{vcd}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(vcd)

mosaic(~ Species + size,
  data = dat,
  direction = c(&amp;quot;v&amp;quot;, &amp;quot;h&amp;quot;)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-33-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;barplot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Barplot&lt;/h1&gt;
&lt;p&gt;Barplots can only be done on qualitative variables (see the difference with a quantitative variable &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;here&lt;/a&gt;). A barplot is a tool to visualize the distribution of a qualitative variable. We draw a barplot of the qualitative variable &lt;code&gt;size&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(dat$size)) # table() is mandatory&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-34-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You can also draw a barplot of the relative frequencies instead of the frequencies by adding &lt;code&gt;prop.table()&lt;/code&gt; as we did earlier:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(prop.table(table(dat$size)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-35-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggplot2}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2) # needed each time you open RStudio
# The package ggplot2 must be installed first

ggplot(dat) +
  aes(x = size) +
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-36-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Histogram&lt;/h1&gt;
&lt;p&gt;A histogram gives an idea about the distribution of a quantitative variable. The idea is to break the range of values into intervals and count how many observations fall into each interval. Histograms are a bit similar to barplots, but histograms are used for quantitative variables whereas barplots are used for qualitative variables. To draw a histogram in R, use &lt;code&gt;hist()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hist(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-37-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Add the arguments &lt;code&gt;breaks =&lt;/code&gt; inside the &lt;code&gt;hist()&lt;/code&gt; function if you want to change the number of bins. A rule of thumb (known as the square-root rule) is that the number of bins should be the rounded value of the square root of the number of observations. The dataset includes 150 observations so in this case the number of bins can be set to 12.&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggplot2}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Sepal.Length) +
  geom_histogram()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-38-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;By default, the number of bins is 30. You can change this value with &lt;code&gt;geom_histogram(bins = 12)&lt;/code&gt; for instance.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;boxplot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Boxplot&lt;/h1&gt;
&lt;p&gt;Boxplots are really useful in descriptive statistics and are often underused (mostly because it is not well understood by the public). A boxplot graphically represents the distribution of a quantitative variable by visually displaying five common location summary (minimum, median, first/third quartiles and maximum) and any observation that was classified as a suspected &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outlier&lt;/a&gt; using the interquartile range (IQR) criterion.&lt;/p&gt;
&lt;p&gt;The IQR criterion means that all observations above &lt;span class=&#34;math inline&#34;&gt;\(q_{0.75} + 1.5 \cdot IQR\)&lt;/span&gt; or below &lt;span class=&#34;math inline&#34;&gt;\(q_{0.25} - 1.5 \cdot IQR\)&lt;/span&gt; (where &lt;span class=&#34;math inline&#34;&gt;\(q_{0.25}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(q_{0.75}\)&lt;/span&gt; correspond to first and third quartile respectively) are considered as potential outliers by R. The minimum and maximum in the boxplot are represented without these suspected outliers.&lt;/p&gt;
&lt;p&gt;Seeing all these information on the same plot help to have a good first overview of the dispersion and the location of the data. Before drawing a boxplot of our data, see below a graph explaining the information present on a boxplot:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/how-to-interpret-boxplot.png&#34; style=&#34;width:100.0%&#34; alt=&#34;How to interpret a boxplot? Source: LFSAB1105&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;How to interpret a boxplot? Source: LFSAB1105&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now an example with our dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-39-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Boxplots are even more informative when presented side-by-side for comparing and contrasting distributions from two or more groups. For instance, we compare the length of the sepal across the different species:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(dat$Sepal.Length ~ dat$Species)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-40-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggplot2}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Species, y = Sepal.Length) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-41-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dotplot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Dotplot&lt;/h1&gt;
&lt;p&gt;A dotplot is more or less similar than a boxplot, except that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;observations are represented as points&lt;/li&gt;
&lt;li&gt;it does not easily tell us about the median, first and third quartiles.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(lattice)

dotplot(dat$Sepal.Length ~ dat$Species)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-42-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggplot2}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Species, y = Sepal.Length) +
  geom_dotplot(binaxis = &amp;quot;y&amp;quot;, stackdir = &amp;quot;center&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-43-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The advantage of using &lt;code&gt;{ggplot2}&lt;/code&gt; over &lt;code&gt;{lattice}&lt;/code&gt; for this plot is that we can easily see the mode.&lt;/p&gt;
&lt;p&gt;Note that a dotplot is particularly useful when there are a limited number of observations, whereas a boxplot is more appropriate with large datasets.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scatterplot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Scatterplot&lt;/h1&gt;
&lt;p&gt;Scatterplots allow to check whether there is a potential link between two quantitative variables. For this reason, scatterplots are often used to visualize a potential &lt;a href=&#34;https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/&#34;&gt;correlation&lt;/a&gt; between two variables. For instance, when drawing a scatterplot of the length of the sepal and the length of the petal:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(dat$Sepal.Length, dat$Petal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-44-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;There seems to be a positive association between the two variables.&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggplot2}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Sepal.Length, y = Petal.Length) +
  geom_point()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-45-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Like boxplots, scatterplots are even more informative when differentiating the points according to a factor, in this case the species:&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() +
  scale_color_hue()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-46-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-plot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Line plot&lt;/h1&gt;
&lt;p&gt;Line plots, particularly useful in time series or finance, can be created by adding the &lt;code&gt;type = &#34;l&#34;&lt;/code&gt; argument in the &lt;code&gt;plot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(dat$Sepal.Length,
  type = &amp;quot;l&amp;quot;
) # &amp;quot;l&amp;quot; for line&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-47-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;qq-plot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;QQ-plot&lt;/h1&gt;
&lt;div id=&#34;for-a-single-variable&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;For a single variable&lt;/h2&gt;
&lt;p&gt;In order to check the normality assumption of a variable (normality means that the data follow a normal distribution, also known as a Gaussian distribution), we usually use histograms and/or QQ-plots.&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; See an article discussing about the &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution and how to evaluate the normality assumption in R&lt;/a&gt; if you need a refresh on that subject.&lt;/p&gt;
&lt;p&gt;Histograms have been presented earlier, so here is how to draw a QQ-plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Draw points on the qq-plot:
qqnorm(dat$Sepal.Length)
# Draw the reference line:
qqline(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-48-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Or a QQ-plot with confidence bands with the &lt;code&gt;qqPlot()&lt;/code&gt; function from the &lt;code&gt;{car}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(car) # package must be installed first
qqPlot(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-49-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## [1] 132 118&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If points are close to the reference line (sometimes referred as Henry’s line) and within the confidence bands, the normality assumption can be considered as met. The bigger the deviation between the points and the reference line and the more they lie outside the confidence bands, the less likely that the normality condition is met. The variable &lt;code&gt;Sepal.Length&lt;/code&gt; does not seem to follow a normal distribution because several points lie outside the confidence bands. When facing a non-normal distribution, the first step is usually to apply the logarithm transformation on the data and recheck to see whether the log-transformed data are normally distributed. Applying the logarithm transformation can be done with the &lt;code&gt;log()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggpubr}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggpubr)
ggqqplot(dat$Sepal.Length)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-50-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;by-groups&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;By groups&lt;/h2&gt;
&lt;p&gt;For some &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical tests&lt;/a&gt;, the normality assumption is required in all groups. One solution is to draw a QQ-plot for each group by manually splitting the dataset into different groups and then draw a QQ-plot for each subset of the data (with the methods shown above). Another (easier) solution is to draw a QQ-plot for each group automatically with the argument &lt;code&gt;groups =&lt;/code&gt; in the function &lt;code&gt;qqPlot()&lt;/code&gt; from the &lt;code&gt;{car}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qqPlot(dat$Sepal.Length, groups = dat$size)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-51-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggplot2}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(
  sample = Sepal.Length, data = dat,
  col = size, shape = size
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-52-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;It is also possible to differentiate groups by only shape or color. For this, remove one of the argument &lt;code&gt;col&lt;/code&gt; or &lt;code&gt;shape&lt;/code&gt; in the &lt;code&gt;qplot()&lt;/code&gt; function above.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;density-plot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Density plot&lt;/h1&gt;
&lt;p&gt;Density plot is a smoothed version of the histogram and is used in the same concept, that is, to represent the distribution of a numeric variable. The functions &lt;code&gt;plot()&lt;/code&gt; and &lt;code&gt;density()&lt;/code&gt; are used together to draw a density plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(density(dat$Sepal.Length))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-53-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;{ggplot2}&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Sepal.Length) +
  geom_density()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/descriptive-statistics-in-r_files/figure-html/unnamed-chunk-54-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation-plot&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Correlation plot&lt;/h1&gt;
&lt;p&gt;The last type of descriptive plot is a correlation plot, also called a correlogram. This type of graph is more complex than the ones presented above, so it is detailed in a separate article. See &lt;a href=&#34;https://statsandr.com/blog/correlogram-in-r-how-to-highlight-the-most-correlated-variables-in-a-dataset/&#34;&gt;how to draw a correlogram to highlight the most correlated variables in a dataset&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;advanced-descriptive-statistics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Advanced descriptive statistics&lt;/h1&gt;
&lt;p&gt;We covered the main functions to compute the most common and basic descriptive statistics. There are, however, many more functions and packages to perform more advanced descriptive statistics in R. In this section, I present some of them with applications to our dataset.&lt;/p&gt;
&lt;div id=&#34;summarytools-package&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{summarytools}&lt;/code&gt; package&lt;/h2&gt;
&lt;p&gt;One package for descriptive statistics I often use for my projects in R is the &lt;a href=&#34;https://cran.r-project.org/web/packages/summarytools/index.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{summarytools}&lt;/code&gt;&lt;/a&gt; package. The package is centered around 4 functions:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;freq()&lt;/code&gt; for frequencies tables&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ctable()&lt;/code&gt; for cross-tabulations&lt;/li&gt;
&lt;li&gt;&lt;code&gt;descr()&lt;/code&gt; for descriptive statistics&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dfSummary()&lt;/code&gt; for dataframe summaries&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A combination of these 4 functions is usually more than enough for most descriptive analyses. Moreover, the package has been built with &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt; in mind, meaning that outputs render well in HTML reports. And for non-English speakers, built-in translations exist for French, Portuguese, Spanish, Russian and Turkish.&lt;/p&gt;
&lt;p&gt;I illustrate each of the 4 functions in the following sections. Outputs that follow display much better in R Markdown reports, but in this article I limit myself to the raw outputs as the goal is to show how the functions work, not how to make them render well. See the setup settings in the &lt;a href=&#34;https://cran.r-project.org/web/packages/summarytools/vignettes/introduction.html&#34; target=&#34;_blank&#34;&gt;vignette&lt;/a&gt; of the package if you want to print the outputs in a nice way in R Markdown.&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;div id=&#34;frequency-tables-with-freq&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency tables with &lt;code&gt;freq()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;freq()&lt;/code&gt; function produces frequency tables with frequencies, proportions, as well as missing data information.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(summarytools)
freq(dat$Species)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Frequencies  
## dat$Species  
## Type: Factor  
## 
##                    Freq   % Valid   % Valid Cum.   % Total   % Total Cum.
## ---------------- ------ --------- -------------- --------- --------------
##           setosa     50     33.33          33.33     33.33          33.33
##       versicolor     50     33.33          66.67     33.33          66.67
##        virginica     50     33.33         100.00     33.33         100.00
##             &amp;lt;NA&amp;gt;      0                               0.00         100.00
##            Total    150    100.00         100.00    100.00         100.00&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not need information about missing values, add the &lt;code&gt;report.nas = FALSE&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;freq(dat$Species,
  report.nas = FALSE # remove NA information
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Frequencies  
## dat$Species  
## Type: Factor  
## 
##                    Freq        %   % Cum.
## ---------------- ------ -------- --------
##           setosa     50    33.33    33.33
##       versicolor     50    33.33    66.67
##        virginica     50    33.33   100.00
##            Total    150   100.00   100.00&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And for a minimalist output with only counts and proportions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;freq(dat$Species,
  report.nas = FALSE, # remove NA information
  totals = FALSE, # remove totals
  cumul = FALSE, # remove cumuls
  headings = FALSE # remove headings
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##                    Freq       %
## ---------------- ------ -------
##           setosa     50   33.33
##       versicolor     50   33.33
##        virginica     50   33.33&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;cross-tabulations-with-ctable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Cross-tabulations with &lt;code&gt;ctable()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ctable()&lt;/code&gt; function produces cross-tabulations (also known as contingency tables) for pairs of categorical variables. Using the two categorical variables in our dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ctable(
  x = dat$Species,
  y = dat$size
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Cross-Tabulation, Row Proportions  
## Species * size  
## Data Frame: dat  
## 
## ------------ ------ ------------ ------------ --------------
##                size          big        small          Total
##      Species                                                
##       setosa           1 ( 2.0%)   49 (98.0%)    50 (100.0%)
##   versicolor          29 (58.0%)   21 (42.0%)    50 (100.0%)
##    virginica          47 (94.0%)    3 ( 6.0%)    50 (100.0%)
##        Total          77 (51.3%)   73 (48.7%)   150 (100.0%)
## ------------ ------ ------------ ------------ --------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Row proportions are shown by default. To display column or total proportions, add the &lt;code&gt;prop = &#34;c&#34;&lt;/code&gt; or &lt;code&gt;prop = &#34;t&#34;&lt;/code&gt; arguments, respectively:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ctable(
  x = dat$Species,
  y = dat$size,
  prop = &amp;quot;t&amp;quot; # total proportions
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Cross-Tabulation, Total Proportions  
## Species * size  
## Data Frame: dat  
## 
## ------------ ------ ------------ ------------ --------------
##                size          big        small          Total
##      Species                                                
##       setosa           1 ( 0.7%)   49 (32.7%)    50 ( 33.3%)
##   versicolor          29 (19.3%)   21 (14.0%)    50 ( 33.3%)
##    virginica          47 (31.3%)    3 ( 2.0%)    50 ( 33.3%)
##        Total          77 (51.3%)   73 (48.7%)   150 (100.0%)
## ------------ ------ ------------ ------------ --------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To remove proportions altogether, add the argument &lt;code&gt;prop = &#34;n&#34;&lt;/code&gt;. Furthermore, to display only the bare minimum, add the &lt;code&gt;totals = FALSE&lt;/code&gt; and &lt;code&gt;headings = FALSE&lt;/code&gt; arguments:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ctable(
  x = dat$Species,
  y = dat$size,
  prop = &amp;quot;n&amp;quot;, # remove proportions
  totals = FALSE, # remove totals
  headings = FALSE # remove headings
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## ------------ ------ ----- -------
##                size   big   small
##      Species                     
##       setosa            1      49
##   versicolor           29      21
##    virginica           47       3
## ------------ ------ ----- -------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is equivalent than &lt;code&gt;table(dat$Species, dat$size)&lt;/code&gt; and &lt;code&gt;xtabs(~ dat$Species + dat$size)&lt;/code&gt; performed in the section on &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#contingency-table&#34;&gt;contingency tables&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To display results of the &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;, add the &lt;code&gt;chisq = TRUE&lt;/code&gt; argument:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ctable(
  x = dat$Species,
  y = dat$size,
  chisq = TRUE, # display results of Chi-square test of independence
  headings = FALSE # remove headings
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## ------------ ------ ------------ ------------ --------------
##                size          big        small          Total
##      Species                                                
##       setosa           1 ( 2.0%)   49 (98.0%)    50 (100.0%)
##   versicolor          29 (58.0%)   21 (42.0%)    50 (100.0%)
##    virginica          47 (94.0%)    3 ( 6.0%)    50 (100.0%)
##        Total          77 (51.3%)   73 (48.7%)   150 (100.0%)
## ------------ ------ ------------ ------------ --------------
## 
## ----------------------------
##  Chi.squared   df   p.value 
## ------------- ---- ---------
##    86.0345     2       0    
## ----------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;p&lt;/em&gt;-value is close to 0 so we reject the null hypothesis of independence between the two variables. In our context, this indicates that species and size are dependent and that there is a significant relationship between the two variables.&lt;/p&gt;
&lt;p&gt;It is also possible to create a contingency table for each level of a third categorical variable thanks to the combination of the &lt;code&gt;stby()&lt;/code&gt; and &lt;code&gt;ctable()&lt;/code&gt; functions. There are only 2 categorical variables in our dataset, so let’s use the &lt;code&gt;tabacco&lt;/code&gt; dataset which has 4 categorical variables (i.e., gender, age group, smoker, diseased). For this example, we would like to create a contingency table of the variables &lt;code&gt;smoker&lt;/code&gt; and &lt;code&gt;diseased&lt;/code&gt;, and this for each &lt;code&gt;gender&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;stby(
  list(
    x = tobacco$smoker, # smoker and diseased
    y = tobacco$diseased
  ),
  INDICES = tobacco$gender, # for each gender
  FUN = ctable # ctable for cross-tabulation
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Cross-Tabulation, Row Proportions  
## smoker * diseased  
## Data Frame: tobacco  
## Group: gender = F  
## 
## -------- ---------- ------------- ------------- --------------
##            diseased           Yes            No          Total
##   smoker                                                      
##      Yes               62 (42.2%)    85 (57.8%)   147 (100.0%)
##       No               49 (14.3%)   293 (85.7%)   342 (100.0%)
##    Total              111 (22.7%)   378 (77.3%)   489 (100.0%)
## -------- ---------- ------------- ------------- --------------
## 
## Group: gender = M  
## 
## -------- ---------- ------------- ------------- --------------
##            diseased           Yes            No          Total
##   smoker                                                      
##      Yes               63 (44.1%)    80 (55.9%)   143 (100.0%)
##       No               47 (13.6%)   299 (86.4%)   346 (100.0%)
##    Total              110 (22.5%)   379 (77.5%)   489 (100.0%)
## -------- ---------- ------------- ------------- --------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;descriptive-statistics-with-descr&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Descriptive statistics with &lt;code&gt;descr()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;descr()&lt;/code&gt; function produces descriptive (univariate) statistics with common central tendency statistics and measures of dispersion. (See the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#location-versus-dispersion-measures&#34;&gt;difference between a measure of central tendency and dispersion&lt;/a&gt; if you need a reminder.)&lt;/p&gt;
&lt;p&gt;A major advantage of this function is that it accepts single vectors as well as data frames. If a data frame is provided, all non-numerical columns are ignored so you do not have to remove them yourself before running the function.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;descr()&lt;/code&gt; function allows to display:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;only a selection of descriptive statistics of your choice, with the &lt;code&gt;stats = c(&#34;mean&#34;, &#34;sd&#34;)&lt;/code&gt; argument for mean and standard deviation for example&lt;/li&gt;
&lt;li&gt;the minimum, first quartile, median, third quartile and maximum with &lt;code&gt;stats = &#34;fivenum&#34;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the most common descriptive statistics (mean, standard deviation, minimum, median, maximum, number and percentage of valid observations), with &lt;code&gt;stats = &#34;common&#34;&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;descr(dat,
  headings = FALSE, # remove headings
  stats = &amp;quot;common&amp;quot; # most common descriptive statistics
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##                   Petal.Length   Petal.Width   Sepal.Length   Sepal.Width
## --------------- -------------- ------------- -------------- -------------
##            Mean           3.76          1.20           5.84          3.06
##         Std.Dev           1.77          0.76           0.83          0.44
##             Min           1.00          0.10           4.30          2.00
##          Median           4.35          1.30           5.80          3.00
##             Max           6.90          2.50           7.90          4.40
##         N.Valid         150.00        150.00         150.00        150.00
##               N         150.00        150.00         150.00        150.00
##       Pct.Valid         100.00        100.00         100.00        100.00&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Tip:&lt;/em&gt; if you have a large number of variables, add the &lt;code&gt;transpose = TRUE&lt;/code&gt; argument for a better display.&lt;/p&gt;
&lt;p&gt;In order to compute these descriptive statistics by group (e.g., &lt;code&gt;Species&lt;/code&gt; in our dataset), use the &lt;code&gt;descr()&lt;/code&gt; function in combination with the &lt;code&gt;stby()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;stby(
  data = dat,
  INDICES = dat$Species, # by Species
  FUN = descr, # descriptive statistics
  stats = &amp;quot;common&amp;quot; # most common descr. stats
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Descriptive Statistics  
## dat  
## Group: Species = setosa  
## N: 50  
## 
##                   Petal.Length   Petal.Width   Sepal.Length   Sepal.Width
## --------------- -------------- ------------- -------------- -------------
##            Mean           1.46          0.25           5.01          3.43
##         Std.Dev           0.17          0.11           0.35          0.38
##             Min           1.00          0.10           4.30          2.30
##          Median           1.50          0.20           5.00          3.40
##             Max           1.90          0.60           5.80          4.40
##         N.Valid          50.00         50.00          50.00         50.00
##               N          50.00         50.00          50.00         50.00
##       Pct.Valid         100.00        100.00         100.00        100.00
## 
## Group: Species = versicolor  
## N: 50  
## 
##                   Petal.Length   Petal.Width   Sepal.Length   Sepal.Width
## --------------- -------------- ------------- -------------- -------------
##            Mean           4.26          1.33           5.94          2.77
##         Std.Dev           0.47          0.20           0.52          0.31
##             Min           3.00          1.00           4.90          2.00
##          Median           4.35          1.30           5.90          2.80
##             Max           5.10          1.80           7.00          3.40
##         N.Valid          50.00         50.00          50.00         50.00
##               N          50.00         50.00          50.00         50.00
##       Pct.Valid         100.00        100.00         100.00        100.00
## 
## Group: Species = virginica  
## N: 50  
## 
##                   Petal.Length   Petal.Width   Sepal.Length   Sepal.Width
## --------------- -------------- ------------- -------------- -------------
##            Mean           5.55          2.03           6.59          2.97
##         Std.Dev           0.55          0.27           0.64          0.32
##             Min           4.50          1.40           4.90          2.20
##          Median           5.55          2.00           6.50          3.00
##             Max           6.90          2.50           7.90          3.80
##         N.Valid          50.00         50.00          50.00         50.00
##               N          50.00         50.00          50.00         50.00
##       Pct.Valid         100.00        100.00         100.00        100.00&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-frame-summaries-with-dfsummary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data frame summaries with &lt;code&gt;dfSummary()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;dfSummary()&lt;/code&gt; function generates a summary table with statistics, frequencies and graphs for all variables in a dataset. The information shown depends on the type of the variables (character, factor, numeric, date) and also varies according to the number of distinct values.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dfSummary(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Data Frame Summary  
## dat  
## Dimensions: 150 x 6  
## Duplicates: 1  
## 
## -----------------------------------------------------------------------------------------------------------
## No   Variable       Stats / Values          Freqs (% of Valid)   Graph                 Valid      Missing  
## ---- -------------- ----------------------- -------------------- --------------------- ---------- ---------
## 1    Sepal.Length   Mean (sd) : 5.8 (0.8)   35 distinct values     . . : :             150        0        
##      [numeric]      min &amp;lt; med &amp;lt; max:                               : : : :             (100.0%)   (0.0%)   
##                     4.3 &amp;lt; 5.8 &amp;lt; 7.9                                : : : : :                               
##                     IQR (CV) : 1.3 (0.1)                           : : : : :                               
##                                                                  : : : : : : : :                           
## 
## 2    Sepal.Width    Mean (sd) : 3.1 (0.4)   23 distinct values           :             150        0        
##      [numeric]      min &amp;lt; med &amp;lt; max:                                     :             (100.0%)   (0.0%)   
##                     2 &amp;lt; 3 &amp;lt; 4.4                                        . :                                 
##                     IQR (CV) : 0.5 (0.1)                             : : : :                               
##                                                                  . . : : : : : :                           
## 
## 3    Petal.Length   Mean (sd) : 3.8 (1.8)   43 distinct values   :                     150        0        
##      [numeric]      min &amp;lt; med &amp;lt; max:                             :         . :         (100.0%)   (0.0%)   
##                     1 &amp;lt; 4.3 &amp;lt; 6.9                                :         : : .                           
##                     IQR (CV) : 3.5 (0.5)                         : :       : : : .                         
##                                                                  : :   . : : : : : .                       
## 
## 4    Petal.Width    Mean (sd) : 1.2 (0.8)   22 distinct values   :                     150        0        
##      [numeric]      min &amp;lt; med &amp;lt; max:                             :                     (100.0%)   (0.0%)   
##                     0.1 &amp;lt; 1.3 &amp;lt; 2.5                              :       . .   :                           
##                     IQR (CV) : 1.5 (0.6)                         :       : :   :   .                       
##                                                                  : :   : : : . : : :                       
## 
## 5    Species        1. setosa               50 (33.3%)           IIIIII                150        0        
##      [factor]       2. versicolor           50 (33.3%)           IIIIII                (100.0%)   (0.0%)   
##                     3. virginica            50 (33.3%)           IIIIII                                    
## 
## 6    size           1. big                  77 (51.3%)           IIIIIIIIII            150        0        
##      [character]    2. small                73 (48.7%)           IIIIIIIII             (100.0%)   (0.0%)   
## -----------------------------------------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;describeby-from-the-psych-package&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;describeBy()&lt;/code&gt; from the &lt;code&gt;{psych}&lt;/code&gt; package&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;describeBy()&lt;/code&gt; function from the &lt;code&gt;{psych}&lt;/code&gt; package allows to report several summary statistics (i.e., number of valid cases, mean, standard deviation, median, trimmed mean, mad: median absolute deviation (from the median), minimum, maximum, range, skewness and kurtosis) by a grouping variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(psych)
describeBy(
  dat,
  dat$Species # grouping variable
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Descriptive statistics by group 
## group: setosa
##              vars  n mean   sd median trimmed  mad min max range  skew kurtosis
## Sepal.Length    1 50 5.01 0.35    5.0    5.00 0.30 4.3 5.8   1.5  0.11    -0.45
## Sepal.Width     2 50 3.43 0.38    3.4    3.42 0.37 2.3 4.4   2.1  0.04     0.60
## Petal.Length    3 50 1.46 0.17    1.5    1.46 0.15 1.0 1.9   0.9  0.10     0.65
## Petal.Width     4 50 0.25 0.11    0.2    0.24 0.00 0.1 0.6   0.5  1.18     1.26
## Species         5 50 1.00 0.00    1.0    1.00 0.00 1.0 1.0   0.0   NaN      NaN
## size            6 50 1.98 0.14    2.0    2.00 0.00 1.0 2.0   1.0 -6.65    43.12
##                se
## Sepal.Length 0.05
## Sepal.Width  0.05
## Petal.Length 0.02
## Petal.Width  0.01
## Species      0.00
## size         0.02
## ------------------------------------------------------------ 
## group: versicolor
##              vars  n mean   sd median trimmed  mad min max range  skew kurtosis
## Sepal.Length    1 50 5.94 0.52   5.90    5.94 0.52 4.9 7.0   2.1  0.10    -0.69
## Sepal.Width     2 50 2.77 0.31   2.80    2.78 0.30 2.0 3.4   1.4 -0.34    -0.55
## Petal.Length    3 50 4.26 0.47   4.35    4.29 0.52 3.0 5.1   2.1 -0.57    -0.19
## Petal.Width     4 50 1.33 0.20   1.30    1.32 0.22 1.0 1.8   0.8 -0.03    -0.59
## Species         5 50 2.00 0.00   2.00    2.00 0.00 2.0 2.0   0.0   NaN      NaN
## size            6 50 1.42 0.50   1.00    1.40 0.00 1.0 2.0   1.0  0.31    -1.94
##                se
## Sepal.Length 0.07
## Sepal.Width  0.04
## Petal.Length 0.07
## Petal.Width  0.03
## Species      0.00
## size         0.07
## ------------------------------------------------------------ 
## group: virginica
##              vars  n mean   sd median trimmed  mad min max range  skew kurtosis
## Sepal.Length    1 50 6.59 0.64   6.50    6.57 0.59 4.9 7.9   3.0  0.11    -0.20
## Sepal.Width     2 50 2.97 0.32   3.00    2.96 0.30 2.2 3.8   1.6  0.34     0.38
## Petal.Length    3 50 5.55 0.55   5.55    5.51 0.67 4.5 6.9   2.4  0.52    -0.37
## Petal.Width     4 50 2.03 0.27   2.00    2.03 0.30 1.4 2.5   1.1 -0.12    -0.75
## Species         5 50 3.00 0.00   3.00    3.00 0.00 3.0 3.0   0.0   NaN      NaN
## size            6 50 1.06 0.24   1.00    1.00 0.00 1.0 2.0   1.0  3.59    11.15
##                se
## Sepal.Length 0.09
## Sepal.Width  0.05
## Petal.Length 0.08
## Petal.Width  0.04
## Species      0.00
## size         0.03&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;aggregate-function&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;aggregate()&lt;/code&gt; function&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;aggregate()&lt;/code&gt; function allows to split the data into subsets and then to compute summary statistics for each. For instance, if we want to compute the mean for the variables &lt;code&gt;Sepal.Length&lt;/code&gt; and &lt;code&gt;Sepal.Width&lt;/code&gt; by &lt;code&gt;Species&lt;/code&gt; and &lt;code&gt;Size&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aggregate(cbind(Sepal.Length, Sepal.Width) ~ Species + size,
  data = dat,
  mean
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      Species  size Sepal.Length Sepal.Width
## 1     setosa   big     5.800000    4.000000
## 2 versicolor   big     6.282759    2.868966
## 3  virginica   big     6.663830    2.997872
## 4     setosa small     4.989796    3.416327
## 5 versicolor small     5.457143    2.633333
## 6  virginica small     5.400000    2.600000&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;summaryby-from-doby&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;summaryBy()&lt;/code&gt; from &lt;code&gt;{doBy}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;An alternative is the &lt;code&gt;summaryBy()&lt;/code&gt; function from the &lt;code&gt;{doBy}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# summary statistics by group
library(doBy)
summaryBy(Sepal.Length + Sepal.Width ~ Species,
  data = dat,
  FUN = summary
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      Species Sepal.Length.Min. Sepal.Length.1st Qu. Sepal.Length.Median
## 1     setosa               4.3                4.800                 5.0
## 2 versicolor               4.9                5.600                 5.9
## 3  virginica               4.9                6.225                 6.5
##   Sepal.Length.Mean Sepal.Length.3rd Qu. Sepal.Length.Max. Sepal.Width.Min.
## 1             5.006                  5.2               5.8              2.3
## 2             5.936                  6.3               7.0              2.0
## 3             6.588                  6.9               7.9              2.2
##   Sepal.Width.1st Qu. Sepal.Width.Median Sepal.Width.Mean Sepal.Width.3rd Qu.
## 1               3.200                3.4            3.428               3.675
## 2               2.525                2.8            2.770               3.000
## 3               2.800                3.0            2.974               3.175
##   Sepal.Width.Max.
## 1              4.4
## 2              3.4
## 3              3.8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are interested in some specific descriptive statistics, you can easily specify them via the &lt;code&gt;FUN&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summaryBy(Sepal.Length + Sepal.Width ~ Species,
  data = dat,
  FUN = c(mean, var)
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      Species Sepal.Length.mean Sepal.Width.mean Sepal.Length.var
## 1     setosa             5.006            3.428        0.1242490
## 2 versicolor             5.936            2.770        0.2664327
## 3  virginica             6.588            2.974        0.4043429
##   Sepal.Width.var
## 1      0.14368980
## 2      0.09846939
## 3      0.10400408&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;group_by-and-summarise-from-dplyr&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;group_by()&lt;/code&gt; and &lt;code&gt;summarise()&lt;/code&gt; from &lt;code&gt;{dplyr}&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Another alternative is with the &lt;code&gt;summarise()&lt;/code&gt; and &lt;code&gt;group_by()&lt;/code&gt; functions from the &lt;code&gt;{dplyr}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(dplyr)

group_by(dat, Species) %&amp;gt;%
  summarise(
    mean = mean(Sepal.Length, na.rm = TRUE),
    sd = sd(Sepal.Length, na.rm = TRUE)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 × 3
##   Species     mean    sd
##   &amp;lt;fct&amp;gt;      &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1 setosa      5.01 0.352
## 2 versicolor  5.94 0.516
## 3 virginica   6.59 0.636&lt;/code&gt;&lt;/pre&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 this article helped you to do descriptive statistics in R. If you would like to do the same by hand or understand what these statistics represent, I invite you to read the article “&lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/&#34;&gt;Descriptive statistics by hand&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;p&gt;&lt;em&gt;(Note that this article is available for download on my &lt;a href=&#34;https://statsandr.gumroad.com/&#34;&gt;Gumroad page&lt;/a&gt;.)&lt;/em&gt;&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;Normality tests such as Shapiro-Wilk or Kolmogorov-Smirnov tests can also be used to test whether the data follow a normal distribution or not. However, in practice, normality tests are often considered as too conservative in the sense that for large sample size, a small deviation from the normality may cause the normality condition to be violated. For this reason, it is often the case that the normality condition is verified based on a combination of visual inspections (with histograms and QQ-plots) and formal test (Shapiro-Wilk test for instance).&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;Note that the &lt;code&gt;plain.ascii&lt;/code&gt; and &lt;code&gt;style&lt;/code&gt; arguments are needed for this package. In our examples, these arguments are added in the settings of each chunk so they are not visible.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Note that it is also possible to compute odds ratio and risk ratio. See the vignette of the package for more information on this matter as these ratios are beyond the scope of this article.&lt;a href=&#34;#fnref3&#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>
    
    <item>
      <title>A Shiny app for simple linear regression by hand and in R</title>
      <link>https://statsandr.com/blog/a-shiny-app-for-simple-linear-regression-by-hand-and-in-r/</link>
      <pubDate>Wed, 15 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/a-shiny-app-for-simple-linear-regression-by-hand-and-in-r/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/a-shiny-app-for-simple-linear-regression_files/Screenshot%202020-02-04%20at%2011.45.09.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Simple linear regression is a statistical method to summarize and study relationships between two variables. When more than two variables are of interest, it is referred as multiple linear regression. See this article on &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt; for more details.&lt;/p&gt;
&lt;p&gt;In this article, we focus only on a Shiny app which allows to perform simple linear regression by hand and in R:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://antoinesoetewey.shinyapps.io/statistics-202/&#34; target=&#34;_blank&#34;&gt;Statistics-202&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;how-to-use-this-app&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to use this app?&lt;/h1&gt;
&lt;p&gt;Follow these steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Open the app via this &lt;a href=&#34;https://antoinesoetewey.shinyapps.io/statistics-202/&#34; target=&#34;_blank&#34;&gt;link&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Enter your data in the x and y fields. The x field corresponds to the independent variable, while the y field corresponds to the dependent variable&lt;/li&gt;
&lt;li&gt;If you do not want to display the confidence interval around the regression line, uncheck the checkbox under Plot&lt;/li&gt;
&lt;li&gt;Change the x and y-axis labels for the regression plot if needed&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the results panel (on the right side or below depending on the size of your screen), you will see:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a recap of your dataset together with some appropriate descriptive statistics&lt;/li&gt;
&lt;li&gt;the estimates &lt;span class=&#34;math inline&#34;&gt;\(\beta_0\)&lt;/span&gt;, &lt;span class=&#34;math inline&#34;&gt;\(\beta_1\)&lt;/span&gt; and the regression model computed by hand&lt;/li&gt;
&lt;li&gt;the results of the model computed in R&lt;/li&gt;
&lt;li&gt;the regression plot with some key measures&lt;/li&gt;
&lt;li&gt;the interpretations&lt;/li&gt;
&lt;li&gt;and the assumptions to check the validity of the model&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All formulas, steps and computations to arrive at the final results are also provided.&lt;/p&gt;
&lt;p&gt;Note that although the assumptions are displayed, it is your responsibility to check them to assess the validity of the linear model.&lt;/p&gt;
&lt;p&gt;Last but not least, you can download a report of the results (in HTML) by clicking on the Download button, and you can choose whether you want to include the R code or not.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;code&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Code&lt;/h1&gt;
&lt;p&gt;See the last version on &lt;a href=&#34;https://github.com/AntoineSoetewey/statistics-202&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that the link may not work if the app has hit the monthly usage limit. Try again later if that is the case.&lt;/em&gt;&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;For further details about what is linear regression and when it is used, please see:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;this &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;post&lt;/a&gt;, and&lt;/li&gt;
&lt;li&gt;the numerous resources on the topic available in textbooks and online.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope you will find this app useful to do simple linear regression by hand and in R.&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>World map of visited countries in R</title>
      <link>https://statsandr.com/blog/world-map-of-visited-countries-in-r/</link>
      <pubDate>Thu, 09 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/world-map-of-visited-countries-in-r/</guid>
      <description>
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/htmltools-fill/fill.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/jquery/jquery.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/proj4js/proj4.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/highcharts/css/motion.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/highcharts.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/highcharts-3d.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/highcharts-more.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/stock.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/map.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/data.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/exporting.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/offline-exporting.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/drilldown.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/item-series.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/overlapping-datalabels.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/annotations.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/export-data.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/funnel.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/heatmap.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/treemap.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/sankey.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/dependency-wheel.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/organization.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/solid-gauge.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/streamgraph.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/sunburst.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/vector.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/wordcloud.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/xrange.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/tilemap.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/venn.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/gantt.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/timeline.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/parallel-coordinates.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/bullet.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/coloraxis.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/dumbbell.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/lollipop.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/series-label.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/plugins/motion.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/custom/reset.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highcharts/modules/boost.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/highchart-binding/highchart.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;Like me, if you like traveling as much as R you might want to draw a world map of the countries you have visited in R. Below an example with the countries I have visited as of January 2020:&lt;/p&gt;
&lt;div class=&#34;highchart html-widget html-fill-item&#34; id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:480px;&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;hc_opts&#34;:{&#34;chart&#34;:{&#34;reflow&#34;:true},&#34;title&#34;:{&#34;text&#34;:&#34;World map&#34;},&#34;yAxis&#34;:{&#34;title&#34;:{&#34;text&#34;:null}},&#34;credits&#34;:{&#34;enabled&#34;:true},&#34;exporting&#34;:{&#34;enabled&#34;:false},&#34;boost&#34;:{&#34;enabled&#34;:false},&#34;plotOptions&#34;:{&#34;series&#34;:{&#34;label&#34;:{&#34;enabled&#34;:false},&#34;turboThreshold&#34;:0},&#34;treemap&#34;:{&#34;layoutAlgorithm&#34;:&#34;squarified&#34;}},&#34;series&#34;:[{&#34;mapData&#34;:{&#34;title&#34;:&#34;World, Miller projection, ultra high resolution&#34;,&#34;version&#34;:&#34;2.3.0&#34;,&#34;type&#34;:&#34;FeatureCollection&#34;,&#34;copyright&#34;:&#34;Copyright (c) 2024 Highsoft AS, Based on data from Natural Earth&#34;,&#34;copyrightShort&#34;:&#34;Natural Earth&#34;,&#34;copyrightUrl&#34;:&#34;http://www.naturalearthdata.com&#34;,&#34;crs&#34;:{&#34;type&#34;:&#34;name&#34;,&#34;properties&#34;:{&#34;name&#34;:&#34;urn:ogc:def:crs:EPSG:54003&#34;}},&#34;hc-transform&#34;:{&#34;default&#34;:{&#34;crs&#34;:&#34;+proj=mill +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +R_A +datum=WGS84 +units=m +no_defs&#34;,&#34;scale&#34;:1.70833333518e-05,&#34;jsonres&#34;:15.5,&#34;jsonmarginX&#34;:-999,&#34;jsonmarginY&#34;:9851,&#34;xoffset&#34;:-19816494.5204,&#34;yoffset&#34;:12635908.1982}},&#34;features&#34;:[{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;FO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.51,&#34;hc-middle-y&#34;:0.3,&#34;hc-key&#34;:&#34;fo&#34;,&#34;hc-a2&#34;:&#34;FO&#34;,&#34;name&#34;:&#34;Faroe Islands&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Faeroe Is.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;FRO&#34;,&#34;iso-a2&#34;:&#34;FO&#34;,&#34;woe-id&#34;:&#34;23424816&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4050,8587],[4046,8584],[4047,8602],[4052,8600],[4050,8587]]],[[[4053,8617],[4057,8624],[4061,8618],[4051,8610],[4050,8604],[4042,8611],[4036,8607],[4023,8611],[4035,8614],[4037,8620],[4053,8617]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;UM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.57,&#34;hc-middle-y&#34;:0.58,&#34;hc-key&#34;:&#34;um&#34;,&#34;hc-a2&#34;:&#34;UM&#34;,&#34;name&#34;:&#34;United States Minor Outlying Islands&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;U.S. MOI&#34;,&#34;subregion&#34;:&#34;Seven seas (open ocean)&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;UMI&#34;,&#34;iso-a2&#34;:&#34;UM&#34;,&#34;woe-id&#34;:&#34;28289407&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[-523,6677],[-524,6677],[-524,6677],[-524,6677],[-523,6677]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;US&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.7,&#34;hc-middle-y&#34;:0.68,&#34;hc-key&#34;:&#34;us&#34;,&#34;hc-a2&#34;:&#34;US&#34;,&#34;name&#34;:&#34;United States of America&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;U.S.A.&#34;,&#34;subregion&#34;:&#34;Northern America&#34;,&#34;region-wb&#34;:&#34;North America&#34;,&#34;iso-a3&#34;:&#34;USA&#34;,&#34;iso-a2&#34;:&#34;US&#34;,&#34;woe-id&#34;:&#34;23424977&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[-600,8557],[-621,8570],[-621,8564],[-628,8568],[-628,8574],[-637,8579],[-633,8584],[-643,8584],[-643,8590],[-633,8592],[-642,8598],[-628,8600],[-632,8607],[-619,8626],[-603,8635],[-606,8645],[-598,8658],[-585,8664],[-574,8663],[-561,8654],[-554,8655],[-539,8665],[-533,8672],[-543,8679],[-523,8675],[-527,8672],[-498,8676],[-486,8687],[-491,8711],[-506,8719],[-506,8723],[-495,8723],[-486,8729],[-489,8738],[-498,8743],[-505,8736],[-513,8737],[-527,8731],[-539,8723],[-545,8715],[-546,8723],[-558,8730],[-563,8727],[-552,8723],[-555,8718],[-567,8726],[-592,8726],[-611,8720],[-645,8727],[-654,8733],[-651,8741],[-660,8745],[-668,8754],[-655,8753],[-650,8760],[-644,8760],[-667,8765],[-681,8766],[-700,8774],[-700,8780],[-677,8790],[-674,8788],[-665,8792],[-662,8798],[-619,8816],[-602,8822],[-589,8824],[-573,8824],[-579,8806],[-571,8798],[-555,8798],[-544,8800],[-541,8797],[-527,8798],[-517,8795],[-509,8807],[-492,8806],[-496,8811],[-507,8815],[-520,8812],[-518,8818],[-528,8829],[-536,8832],[-540,8839],[-531,8842],[-522,8833],[-524,8828],[-518,8821],[-510,8817],[-498,8821],[-486,8813],[-470,8814],[-469,8821],[-489,8828],[-497,8826],[-507,8821],[-518,8829],[-518,8835],[-512,8845],[-521,8846],[-534,8843],[-532,8851],[-539,8845],[-572,8849],[-575,8862],[-585,8875],[-623,8897],[-637,8901],[-648,8909],[-658,8912],[-650,8917],[-646,8923],[-646,8939],[-630,8938],[-591,8942],[-569,8951],[-555,8966],[-556,8980],[-552,8989],[-538,9002],[-532,9001],[-519,9016],[-518,9007],[-511,9011],[-502,9011],[-488,9016],[-468,9030],[-461,9029],[-466,9015],[-459,9018],[-459,9029],[-466,9032],[-453,9040],[-438,9043],[-446,9039],[-433,9039],[-405,9042],[-391,9048],[-381,9055],[-369,9067],[-363,9070],[-358,9065],[-334,9061],[-332,9055],[-340,9050],[-348,9049],[-342,9042],[-332,9043],[-331,9048],[-321,9053],[-319,9058],[-304,9052],[-307,9045],[-303,9042],[-290,9040],[-283,9045],[-266,9047],[-237,9043],[-234,9041],[-242,9035],[-246,9027],[-219,9027],[-227,9021],[-211,9021],[-204,9017],[-203,9021],[-192,9024],[-179,9024],[-181,9020],[-165,9025],[-146,9027],[-138,9020],[-129,9020],[-121,9014],[-114,9016],[-103,9013],[-104,9010],[-84,9006],[-76,9008],[-47,9007],[-30,8998],[-9,8997],[16,9003],[29,9004],[50,8998],[59,8990],[73,8988],[85,8982],[97,8979],[97,8530],[110,8526],[114,8530],[126,8525],[136,8531],[153,8532],[150,8520],[164,8512],[167,8506],[196,8484],[202,8469],[213,8476],[213,8476],[213,8476],[217,8470],[227,8467],[241,8452],[241,8445],[233,8443],[227,8445],[224,8440],[218,8447],[211,8447],[195,8457],[185,8470],[177,8477],[150,8487],[130,8497],[142,8504],[137,8512],[140,8519],[131,8509],[119,8504],[108,8504],[83,8512],[85,8518],[77,8515],[68,8518],[44,8522],[7,8518],[-8,8511],[1,8518],[8,8519],[1,8524],[-8,8525],[-19,8530],[-15,8537],[-14,8547],[-24,8536],[-25,8531],[-38,8537],[-49,8537],[-40,8547],[-48,8548],[-58,8545],[-51,8550],[-70,8548],[-53,8554],[-57,8556],[-66,8553],[-75,8554],[-68,8567],[-77,8560],[-89,8561],[-84,8555],[-96,8557],[-106,8554],[-108,8546],[-113,8552],[-114,8546],[-105,8533],[-100,8539],[-98,8534],[-107,8527],[-117,8534],[-117,8527],[-105,8520],[-109,8515],[-119,8524],[-121,8516],[-135,8514],[-145,8517],[-147,8511],[-150,8517],[-157,8509],[-161,8515],[-161,8502],[-166,8507],[-169,8501],[-199,8486],[-202,8482],[-210,8484],[-224,8479],[-226,8487],[-217,8494],[-203,8499],[-198,8507],[-212,8501],[-223,8506],[-219,8518],[-210,8526],[-206,8541],[-210,8548],[-200,8552],[-182,8563],[-170,8557],[-164,8560],[-143,8556],[-157,8561],[-177,8573],[-185,8576],[-199,8569],[-203,8564],[-212,8562],[-237,8539],[-234,8534],[-245,8527],[-254,8527],[-244,8522],[-248,8513],[-264,8511],[-257,8509],[-258,8504],[-266,8501],[-270,8508],[-279,8492],[-289,8490],[-292,8475],[-278,8476],[-266,8470],[-269,8462],[-277,8457],[-283,8457],[-289,8451],[-286,8446],[-296,8434],[-303,8431],[-316,8431],[-318,8426],[-325,8423],[-327,8418],[-351,8408],[-361,8400],[-355,8401],[-355,8395],[-361,8387],[-368,8390],[-380,8378],[-384,8368],[-397,8374],[-407,8370],[-400,8370],[-399,8359],[-403,8366],[-414,8366],[-418,8360],[-410,8358],[-419,8350],[-425,8350],[-424,8344],[-429,8340],[-436,8343],[-447,8338],[-451,8331],[-452,8338],[-458,8340],[-479,8325],[-490,8326],[-500,8319],[-507,8320],[-508,8315],[-514,8307],[-519,8311],[-531,8308],[-528,8301],[-533,8299],[-541,8307],[-545,8302],[-556,8310],[-553,8302],[-560,8297],[-561,8310],[-540,8321],[-528,8333],[-516,8341],[-504,8344],[-492,8343],[-486,8334],[-486,8341],[-470,8339],[-480,8345],[-474,8357],[-455,8370],[-447,8372],[-432,8381],[-423,8378],[-424,8389],[-413,8401],[-397,8412],[-392,8435],[-389,8440],[-389,8450],[-376,8461],[-377,8468],[-408,8456],[-420,8466],[-417,8477],[-429,8461],[-427,8452],[-428,8447],[-435,8448],[-451,8469],[-455,8470],[-460,8463],[-464,8468],[-472,8471],[-473,8476],[-487,8467],[-483,8465],[-489,8455],[-494,8454],[-494,8460],[-488,8462],[-491,8468],[-503,8461],[-503,8458],[-515,8454],[-518,8458],[-513,8463],[-516,8474],[-523,8485],[-513,8495],[-531,8522],[-534,8534],[-539,8530],[-535,8525],[-537,8517],[-544,8517],[-554,8511],[-569,8508],[-584,8510],[-584,8517],[-595,8525],[-610,8532],[-623,8541],[-610,8548],[-611,8552],[-600,8557]],[[-600,8557],[-600,8556],[-600,8556],[-600,8556],[-600,8553],[-588,8552],[-584,8546],[-580,8551],[-575,8549],[-574,8543],[-563,8550],[-576,8555],[-568,8556],[-575,8560],[-579,8555],[-597,8555],[-600,8556],[-600,8556],[-600,8556],[-599,8557],[-600,8557]]],[[[-333,7102],[-318,7094],[-318,7090],[-310,7082],[-315,7078],[-330,7072],[-335,7065],[-341,7069],[-342,7079],[-347,7090],[-340,7099],[-342,7105],[-333,7102]]],[[[-361,7115],[-359,7122],[-365,7126],[-352,7127],[-345,7119],[-361,7115]]],[[[-371,7126],[-372,7120],[-377,7132],[-382,7135],[-366,7133],[-371,7126]]],[[[-401,7147],[-393,7138],[-407,7138],[-412,7146],[-403,7150],[-401,7147]]],[[[-445,7166],[-442,7164],[-446,7155],[-456,7159],[-454,7164],[-445,7166]]],[[[2223,7886],[2221,7890],[2228,7892],[2228,7886],[2223,7886]]],[[[2235,7890],[2233,7895],[2236,7899],[2241,7897],[2235,7890]]],[[[628,8049],[632,8046],[622,8050],[623,8054],[628,8049]]],[[[631,8057],[634,8056],[631,8053],[626,8055],[631,8057]]],[[[-987,8172],[-999,8179],[-991,8181],[-982,8177],[-982,8174],[-972,8176],[-965,8180],[-967,8174],[-987,8172]]],[[[-940,8187],[-933,8185],[-937,8180],[-961,8169],[-960,8177],[-944,8178],[-940,8187]]],[[[-868,8189],[-853,8187],[-870,8186],[-876,8190],[-887,8189],[-889,8186],[-901,8186],[-885,8192],[-885,8199],[-879,8200],[-868,8189]]],[[[-699,8247],[-693,8245],[-694,8239],[-707,8234],[-713,8226],[-727,8219],[-717,8235],[-711,8234],[-709,8243],[-699,8247]]],[[[-629,8269],[-636,8265],[-643,8269],[-628,8276],[-609,8267],[-617,8267],[-622,8272],[-629,8269]]],[[[340,8301],[343,8301],[342,8295],[338,8301],[340,8301]]],[[[-573,8307],[-568,8307],[-561,8296],[-569,8289],[-584,8289],[-591,8283],[-604,8280],[-609,8288],[-601,8292],[-596,8300],[-587,8300],[-573,8307]]],[[[338,8312],[342,8307],[340,8305],[336,8306],[338,8312]]],[[[330,8312],[334,8303],[342,8292],[328,8302],[327,8314],[330,8312]]],[[[381,8310],[380,8305],[373,8305],[375,8316],[381,8310]]],[[[-449,8315],[-449,8307],[-453,8308],[-465,8313],[-449,8315]]],[[[324,8318],[325,8314],[320,8313],[320,8318],[324,8318]]],[[[-478,8318],[-473,8321],[-473,8315],[-479,8310],[-487,8310],[-488,8318],[-483,8321],[-478,8318]]],[[[367,8322],[372,8317],[369,8311],[366,8320],[367,8322]]],[[[314,8323],[320,8325],[319,8320],[313,8316],[314,8323]]],[[[324,8323],[323,8322],[319,8326],[324,8326],[324,8323]]],[[[385,8344],[393,8331],[392,8321],[385,8312],[379,8315],[383,8323],[376,8317],[367,8324],[376,8335],[374,8342],[385,8344]]],[[[308,8342],[312,8349],[324,8352],[321,8347],[308,8342]]],[[[347,8354],[359,8350],[353,8342],[348,8349],[343,8348],[341,8355],[346,8360],[347,8354]]],[[[343,8364],[343,8358],[336,8356],[331,8360],[334,8365],[343,8364]]],[[[357,8361],[364,8355],[360,8351],[351,8357],[351,8367],[357,8361]]],[[[336,8379],[346,8370],[339,8367],[334,8367],[336,8379]]],[[[257,8398],[255,8388],[249,8387],[252,8395],[249,8401],[257,8398]]],[[[234,8431],[231,8424],[228,8427],[230,8434],[234,8431]]],[[[292,8442],[295,8438],[285,8440],[286,8445],[292,8442]]],[[[-247,8454],[-238,8457],[-241,8446],[-231,8447],[-226,8440],[-231,8436],[-236,8441],[-237,8435],[-257,8429],[-269,8433],[-260,8442],[-250,8442],[-253,8448],[-247,8454]]],[[[-94,8527],[-86,8528],[-86,8533],[-78,8531],[-94,8514],[-94,8511],[-105,8507],[-101,8517],[-91,8523],[-94,8527]]],[[[-642,8534],[-630,8530],[-631,8520],[-626,8516],[-644,8509],[-658,8511],[-674,8518],[-682,8525],[-665,8526],[-653,8534],[-642,8534]]],[[[-55,8536],[-68,8528],[-72,8534],[-69,8538],[-44,8543],[-55,8536]]],[[[1665,8009],[1650,8000],[1645,7993],[1639,8002],[1645,8007],[1656,8011],[1665,8009]]],[[[1642,8037],[1638,8032],[1624,8025],[1621,8028],[1642,8037]]],[[[1688,7933],[1685,7924],[1678,7914],[1675,7919],[1679,7926],[1688,7933]]],[[[1731,7949],[1731,7943],[1727,7942],[1729,7948],[1731,7949]]],[[[1788,7959],[1789,7954],[1781,7954],[1784,7958],[1788,7959]]],[[[2124,7781],[2125,7778],[2116,7773],[2102,7769],[2070,7763],[2072,7770],[2085,7776],[2110,7777],[2118,7782],[2124,7781]]],[[[-645,8263],[-656,8253],[-642,8258],[-657,8245],[-682,8237],[-694,8236],[-673,8243],[-673,8249],[-666,8253],[-674,8258],[-670,8262],[-658,8264],[-657,8257],[-650,8264],[-645,8263]]],[[[268,8389],[262,8392],[264,8398],[258,8398],[253,8403],[262,8411],[269,8408],[278,8399],[285,8376],[283,8353],[272,8368],[275,8370],[270,8381],[263,8381],[262,8385],[268,8389]]],[[[258,8423],[263,8418],[276,8420],[279,8408],[272,8407],[251,8420],[257,8412],[253,8403],[244,8410],[241,8417],[232,8423],[235,8430],[232,8434],[245,8437],[249,8442],[276,8431],[275,8422],[266,8421],[248,8430],[258,8423]]],[[[275,8442],[275,8447],[282,8437],[297,8436],[306,8422],[304,8417],[298,8430],[294,8434],[294,8423],[305,8414],[304,8401],[298,8404],[298,8396],[285,8388],[285,8397],[289,8404],[284,8413],[280,8435],[275,8442]]],[[[-743,8670],[-719,8667],[-722,8660],[-736,8661],[-750,8651],[-752,8658],[-764,8665],[-778,8671],[-790,8672],[-799,8667],[-808,8670],[-812,8676],[-808,8689],[-801,8680],[-785,8679],[-776,8684],[-766,8685],[-760,8681],[-760,8675],[-743,8670]]],[[[626,8068],[624,8067],[624,8068],[626,8068]]],[[[1328,7301],[1327,7313],[1320,7316],[1318,7333],[1308,7340],[1302,7351],[1296,7355],[1284,7382],[1273,7393],[1270,7395],[1268,7397],[1263,7403],[1242,7404],[1236,7407],[1225,7402],[1219,7387],[1211,7378],[1207,7378],[1192,7387],[1184,7389],[1171,7399],[1166,7408],[1166,7416],[1160,7428],[1146,7437],[1127,7455],[1122,7457],[1117,7466],[1112,7467],[1062,7467],[1062,7453],[978,7453],[867,7491],[870,7498],[800,7492],[796,7497],[794,7511],[788,7518],[770,7532],[765,7530],[763,7521],[758,7523],[762,7535],[758,7541],[750,7540],[738,7545],[723,7539],[712,7537],[706,7541],[720,7542],[719,7554],[702,7555],[696,7560],[696,7578],[689,7581],[688,7588],[677,7595],[666,7612],[659,7617],[657,7626],[662,7634],[658,7640],[650,7641],[644,7647],[641,7667],[653,7656],[641,7678],[641,7668],[629,7675],[632,7677],[623,7689],[605,7706],[602,7720],[604,7728],[602,7737],[587,7752],[585,7758],[594,7778],[595,7793],[591,7812],[585,7824],[585,7836],[581,7842],[593,7880],[595,7914],[600,7940],[598,7964],[605,7963],[613,7967],[595,7966],[595,7980],[597,7973],[600,7984],[594,7984],[594,7990],[603,7992],[592,7995],[585,8021],[578,8027],[576,8037],[580,8045],[596,8037],[619,8035],[627,8032],[635,8034],[642,8022],[640,8008],[643,8012],[647,8029],[650,8030],[645,8042],[639,8045],[635,8039],[646,8029],[640,8030],[634,8039],[639,8045],[637,8046],[643,8054],[634,8064],[634,8068],[1446,8068],[1446,8082],[1456,8080],[1460,8061],[1465,8057],[1484,8055],[1487,8050],[1502,8054],[1520,8051],[1528,8039],[1538,8043],[1548,8034],[1556,8032],[1571,8039],[1576,8034],[1595,8035],[1601,8030],[1611,8031],[1596,8024],[1583,8020],[1569,8012],[1554,7998],[1537,7986],[1541,7982],[1563,7988],[1570,7992],[1583,7992],[1575,7989],[1577,7982],[1586,7978],[1597,7982],[1604,7987],[1616,7988],[1629,7994],[1638,8002],[1644,7993],[1644,7986],[1650,7991],[1668,7987],[1676,7976],[1688,7976],[1699,7974],[1712,7982],[1730,7982],[1747,7985],[1744,7976],[1761,7973],[1772,7976],[1772,7969],[1767,7964],[1778,7957],[1774,7955],[1756,7959],[1753,7951],[1745,7957],[1729,7960],[1726,7956],[1709,7955],[1705,7949],[1695,7945],[1699,7953],[1687,7946],[1687,7953],[1670,7927],[1668,7920],[1662,7918],[1656,7904],[1664,7908],[1668,7914],[1677,7913],[1670,7895],[1672,7892],[1665,7881],[1666,7873],[1660,7858],[1664,7841],[1662,7823],[1670,7805],[1678,7800],[1686,7801],[1697,7808],[1705,7822],[1710,7838],[1710,7847],[1700,7870],[1703,7876],[1701,7887],[1708,7897],[1708,7909],[1714,7917],[1721,7918],[1727,7927],[1726,7915],[1733,7917],[1734,7928],[1746,7934],[1743,7943],[1752,7949],[1758,7950],[1772,7938],[1789,7933],[1795,7923],[1791,7920],[1796,7909],[1794,7896],[1789,7893],[1787,7886],[1779,7883],[1778,7872],[1784,7870],[1790,7873],[1797,7883],[1807,7886],[1814,7881],[1818,7858],[1822,7849],[1819,7836],[1815,7832],[1810,7836],[1808,7827],[1802,7823],[1797,7810],[1791,7803],[1819,7791],[1833,7795],[1844,7796],[1853,7803],[1882,7813],[1908,7827],[1918,7833],[1926,7843],[1925,7846],[1920,7852],[1920,7858],[1931,7861],[1949,7862],[1965,7857],[1990,7860],[1998,7867],[2005,7869],[2004,7879],[2000,7889],[2005,7892],[2005,7893],[2017,7902],[2032,7915],[2043,7920],[2048,7920],[2048,7920],[2143,7920],[2149,7931],[2163,7934],[2179,7952],[2178,7959],[2185,7972],[2187,7982],[2210,8010],[2215,8009],[2219,8000],[2236,8007],[2240,8006],[2252,7996],[2252,7955],[2252,7948],[2256,7942],[2263,7942],[2262,7930],[2270,7926],[2276,7913],[2267,7907],[2260,7907],[2250,7903],[2244,7896],[2243,7901],[2236,7901],[2231,7893],[2222,7897],[2224,7903],[2217,7899],[2215,7887],[2206,7883],[2192,7873],[2191,7878],[2180,7873],[2181,7868],[2170,7859],[2164,7845],[2164,7838],[2170,7835],[2156,7824],[2165,7821],[2171,7806],[2179,7803],[2189,7807],[2189,7801],[2176,7800],[2172,7791],[2163,7787],[2163,7793],[2169,7803],[2160,7797],[2145,7794],[2141,7784],[2140,7790],[2127,7786],[2127,7789],[2102,7786],[2081,7778],[2069,7769],[2063,7758],[2070,7757],[2067,7734],[2062,7726],[2057,7727],[2057,7721],[2041,7706],[2043,7713],[2036,7715],[2024,7725],[2028,7710],[2037,7701],[2037,7684],[2030,7670],[2025,7668],[2014,7652],[2012,7660],[2021,7673],[2014,7674],[2018,7678],[2009,7682],[2001,7690],[2010,7693],[2001,7700],[2007,7704],[2003,7714],[2012,7729],[1999,7716],[1995,7699],[1995,7687],[2001,7676],[1986,7683],[2003,7671],[2001,7661],[1994,7661],[2003,7655],[1996,7649],[2003,7644],[1998,7639],[1991,7648],[1981,7650],[1989,7645],[1997,7637],[2010,7638],[2011,7623],[2017,7609],[2009,7612],[1989,7605],[2015,7606],[2018,7594],[2014,7595],[2009,7586],[2008,7576],[1995,7561],[1991,7563],[1977,7563],[1961,7553],[1957,7547],[1953,7535],[1944,7538],[1935,7536],[1924,7528],[1918,7521],[1917,7513],[1883,7491],[1866,7477],[1868,7475],[1858,7466],[1855,7451],[1852,7447],[1850,7434],[1856,7403],[1864,7383],[1877,7361],[1876,7348],[1879,7343],[1892,7309],[1889,7280],[1884,7269],[1887,7268],[1882,7257],[1860,7256],[1855,7274],[1840,7286],[1838,7297],[1829,7298],[1824,7313],[1812,7331],[1817,7332],[1822,7340],[1816,7343],[1814,7337],[1809,7343],[1814,7361],[1815,7375],[1809,7383],[1803,7384],[1793,7395],[1793,7399],[1784,7408],[1774,7414],[1764,7411],[1765,7407],[1746,7398],[1735,7400],[1735,7407],[1726,7414],[1714,7420],[1701,7423],[1667,7418],[1654,7419],[1645,7423],[1642,7417],[1632,7424],[1610,7415],[1591,7422],[1586,7415],[1593,7411],[1602,7415],[1609,7415],[1604,7408],[1610,7407],[1615,7410],[1615,7410],[1615,7410],[1618,7404],[1607,7401],[1612,7391],[1622,7389],[1626,7385],[1623,7378],[1613,7386],[1604,7388],[1599,7392],[1594,7382],[1588,7388],[1580,7386],[1579,7380],[1559,7388],[1565,7389],[1550,7402],[1542,7399],[1545,7394],[1536,7398],[1530,7395],[1504,7403],[1478,7400],[1454,7390],[1446,7380],[1425,7366],[1402,7356],[1398,7362],[1398,7352],[1407,7357],[1391,7342],[1377,7342],[1387,7335],[1380,7323],[1376,7310],[1381,7309],[1386,7296],[1388,7282],[1380,7279],[1373,7284],[1356,7286],[1339,7295],[1331,7296],[1328,7301]]],[[[324,8336],[318,8334],[314,8339],[322,8339],[324,8337],[326,8341],[324,8353],[315,8354],[314,8361],[327,8359],[330,8348],[343,8343],[353,8327],[350,8326],[363,8313],[358,8303],[361,8303],[362,8292],[351,8297],[350,8305],[337,8316],[326,8316],[326,8320],[336,8319],[329,8325],[333,8331],[321,8331],[324,8336]]],[[[383,8304],[381,8299],[377,8302],[383,8304],[383,8304],[383,8304]]],[[[311,8374],[311,8371],[305,8372],[307,8360],[300,8352],[300,8343],[295,8361],[301,8361],[302,8366],[294,8369],[291,8381],[295,8385],[302,8383],[307,8376],[311,8378],[310,8380],[302,8388],[310,8391],[333,8385],[334,8373],[329,8372],[328,8365],[313,8365],[311,8374]]],[[[1616,7411],[1615,7410],[1615,7410],[1615,7410],[1615,7411],[1616,7411],[1616,7411]]],[[[1616,7411],[1626,7418],[1621,7411],[1616,7411],[1616,7411]]],[[[213,8476],[213,8476],[213,8476],[213,8476],[213,8476],[213,8476],[213,8476]]],[[[-280,8394],[-297,8394],[-298,8390],[-290,8393],[-293,8383],[-302,8387],[-304,8399],[-310,8402],[-297,8415],[-287,8415],[-283,8405],[-281,8425],[-273,8427],[-271,8429],[-258,8423],[-265,8431],[-249,8423],[-242,8428],[-237,8427],[-242,8415],[-232,8414],[-237,8406],[-256,8410],[-245,8403],[-252,8399],[-261,8401],[-255,8395],[-267,8388],[-269,8391],[-276,8388],[-278,8383],[-289,8371],[-285,8367],[-300,8367],[-308,8362],[-307,8368],[-294,8371],[-280,8394]]],[[[420,8342],[415,8336],[416,8327],[421,8316],[410,8301],[400,8295],[394,8297],[389,8313],[395,8318],[394,8334],[385,8345],[379,8346],[369,8341],[363,8325],[357,8329],[354,8336],[360,8338],[363,8345],[363,8352],[367,8354],[362,8361],[352,8368],[353,8373],[346,8373],[342,8379],[330,8391],[316,8395],[322,8405],[315,8412],[316,8427],[312,8421],[301,8433],[303,8448],[296,8439],[288,8445],[281,8446],[273,8462],[267,8479],[261,8486],[262,8471],[269,8457],[272,8445],[269,8439],[260,8446],[247,8446],[248,8454],[242,8465],[238,8462],[213,8476],[213,8476],[219,8480],[226,8480],[230,8486],[234,8499],[259,8508],[273,8497],[271,8491],[275,8485],[289,8478],[296,8466],[308,8461],[321,8447],[345,8409],[355,8396],[352,8391],[361,8389],[359,8382],[365,8379],[367,8371],[375,8371],[388,8363],[396,8361],[407,8355],[409,8351],[418,8350],[420,8342]]],[[[383,8304],[384,8308],[383,8305],[383,8304],[383,8304],[383,8304]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;JP&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5600000000000001,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;jp&#34;,&#34;hc-a2&#34;:&#34;JP&#34;,&#34;name&#34;:&#34;Japan&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Japan&#34;,&#34;subregion&#34;:&#34;Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;JPN&#34;,&#34;iso-a2&#34;:&#34;JP&#34;,&#34;woe-id&#34;:&#34;23424856&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[8010,7306],[8020,7304],[8025,7311],[8024,7303],[8013,7297],[8012,7289],[8007,7286],[8009,7297],[8016,7302],[8010,7306]]],[[[8047,7339],[8045,7344],[8053,7349],[8051,7354],[8065,7359],[8054,7352],[8057,7349],[8047,7339]]],[[[8093,7418],[8087,7423],[8091,7425],[8102,7421],[8104,7432],[8108,7435],[8104,7422],[8093,7418]]],[[[8052,7506],[8043,7496],[8035,7495],[8049,7508],[8050,7515],[8062,7520],[8052,7506]]],[[[8401,7930],[8402,7932],[8409,7926],[8405,7925],[8401,7930]]],[[[8213,7550],[8223,7560],[8222,7549],[8215,7546],[8211,7540],[8216,7535],[8205,7528],[8199,7515],[8191,7524],[8186,7525],[8172,7519],[8164,7503],[8152,7499],[8156,7504],[8149,7505],[8151,7515],[8144,7523],[8155,7531],[8157,7540],[8163,7545],[8168,7538],[8179,7539],[8184,7548],[8199,7557],[8198,7553],[8207,7547],[8213,7550]]],[[[8119,7462],[8115,7454],[8095,7442],[8099,7453],[8094,7464],[8091,7457],[8095,7451],[8082,7450],[8085,7463],[8081,7468],[8074,7469],[8066,7463],[8071,7471],[8082,7472],[8096,7496],[8087,7491],[8076,7481],[8077,7492],[8081,7492],[8081,7501],[8072,7498],[8065,7505],[8076,7502],[8074,7508],[8066,7511],[8064,7520],[8071,7518],[8072,7525],[8076,7522],[8082,7528],[8087,7527],[8090,7535],[8103,7537],[8108,7528],[8118,7526],[8121,7530],[8127,7526],[8126,7521],[8120,7516],[8132,7516],[8129,7511],[8136,7506],[8125,7492],[8119,7471],[8119,7462]]],[[[8393,7783],[8397,7797],[8408,7790],[8413,7793],[8411,7783],[8414,7762],[8420,7758],[8428,7743],[8430,7723],[8426,7720],[8427,7712],[8419,7708],[8413,7697],[8415,7683],[8410,7688],[8403,7687],[8398,7676],[8401,7653],[8399,7639],[8394,7636],[8387,7616],[8389,7607],[8395,7598],[8385,7592],[8382,7580],[8374,7577],[8369,7571],[8365,7584],[8373,7593],[8364,7591],[8359,7578],[8357,7584],[8345,7581],[8345,7571],[8339,7562],[8334,7562],[8335,7577],[8328,7576],[8318,7564],[8313,7562],[8295,7562],[8282,7559],[8291,7564],[8289,7567],[8278,7565],[8274,7574],[8268,7565],[8269,7560],[8279,7557],[8279,7549],[8268,7549],[8259,7543],[8251,7527],[8246,7523],[8236,7525],[8235,7530],[8225,7536],[8229,7545],[8226,7551],[8234,7556],[8235,7562],[8224,7561],[8216,7566],[8202,7563],[8188,7555],[8186,7558],[8165,7547],[8159,7550],[8152,7539],[8148,7543],[8149,7552],[8141,7548],[8142,7533],[8127,7542],[8117,7541],[8111,7538],[8101,7544],[8104,7553],[8118,7554],[8123,7562],[8131,7564],[8147,7579],[8154,7583],[8153,7588],[8167,7593],[8177,7588],[8201,7591],[8209,7596],[8221,7595],[8230,7599],[8229,7592],[8244,7590],[8255,7599],[8251,7606],[8257,7614],[8264,7620],[8275,7636],[8272,7646],[8275,7652],[8291,7658],[8289,7650],[8283,7646],[8282,7636],[8292,7632],[8295,7638],[8319,7646],[8328,7653],[8333,7660],[8326,7671],[8319,7667],[8321,7680],[8327,7685],[8324,7676],[8328,7677],[8337,7668],[8353,7679],[8359,7696],[8364,7702],[8370,7720],[8372,7733],[8369,7739],[8363,7738],[8370,7747],[8371,7755],[8366,7763],[8370,7769],[8378,7771],[8380,7787],[8389,7784],[8391,7772],[8397,7778],[8403,7773],[8408,7783],[8406,7787],[8393,7783]]],[[[8399,7825],[8392,7833],[8385,7833],[8379,7822],[8386,7816],[8391,7817],[8406,7806],[8400,7803],[8391,7806],[8384,7801],[8376,7792],[8370,7798],[8375,7812],[8364,7821],[8367,7836],[8378,7840],[8386,7848],[8380,7856],[8384,7861],[8394,7855],[8405,7853],[8413,7861],[8410,7874],[8418,7880],[8419,7894],[8423,7907],[8422,7916],[8417,7926],[8419,7935],[8428,7939],[8445,7921],[8458,7905],[8471,7895],[8483,7890],[8494,7888],[8499,7882],[8510,7881],[8523,7891],[8529,7893],[8520,7876],[8526,7867],[8527,7861],[8533,7854],[8526,7854],[8518,7848],[8512,7850],[8510,7845],[8494,7847],[8485,7843],[8476,7834],[8469,7824],[8466,7810],[8457,7816],[8443,7822],[8424,7834],[8412,7833],[8399,7825]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SC&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.58,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;sc&#34;,&#34;hc-a2&#34;:&#34;SC&#34;,&#34;name&#34;:&#34;Seychelles&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Syc.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;SYC&#34;,&#34;iso-a2&#34;:&#34;SC&#34;,&#34;woe-id&#34;:&#34;23424941&#34;,&#34;continent&#34;:&#34;Seven seas (open ocean)&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5881,6372],[5883,6368],[5882,6365],[5874,6375],[5881,6372]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.97,&#34;hc-middle-y&#34;:0.8,&#34;hc-key&#34;:&#34;nz&#34;,&#34;hc-a2&#34;:&#34;NZ&#34;,&#34;name&#34;:&#34;New Zealand&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;N.Z.&#34;,&#34;subregion&#34;:&#34;Australia and New Zealand&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;NZL&#34;,&#34;iso-a2&#34;:&#34;NZ&#34;,&#34;woe-id&#34;:&#34;23424916&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[9186,5025],[9194,5028],[9202,5018],[9199,5013],[9188,5012],[9181,5007],[9189,5021],[9186,5025]]],[[[-950,5137],[-943,5125],[-951,5122],[-949,5129],[-950,5137]]],[[[9280,5076],[9272,5064],[9277,5058],[9263,5054],[9260,5047],[9243,5032],[9232,5030],[9221,5030],[9220,5033],[9207,5031],[9201,5041],[9190,5039],[9186,5046],[9179,5048],[9177,5044],[9158,5046],[9150,5053],[9150,5061],[9162,5062],[9157,5067],[9158,5075],[9164,5085],[9187,5105],[9206,5125],[9218,5126],[9230,5135],[9245,5142],[9262,5158],[9274,5164],[9287,5177],[9292,5187],[9297,5206],[9308,5209],[9316,5224],[9316,5237],[9327,5247],[9334,5249],[9333,5241],[9342,5240],[9345,5222],[9348,5222],[9366,5235],[9365,5222],[9373,5231],[9381,5233],[9379,5221],[9373,5217],[9378,5207],[9377,5202],[9368,5189],[9358,5180],[9350,5164],[9339,5158],[9334,5153],[9335,5142],[9344,5139],[9345,5132],[9325,5136],[9320,5131],[9293,5116],[9289,5106],[9289,5094],[9283,5085],[9280,5076]]],[[[9463,5279],[9448,5251],[9441,5243],[9432,5228],[9424,5220],[9408,5211],[9406,5218],[9397,5218],[9389,5222],[9399,5233],[9406,5248],[9408,5257],[9400,5270],[9388,5273],[9381,5281],[9371,5283],[9365,5288],[9365,5295],[9389,5308],[9392,5333],[9396,5344],[9388,5368],[9393,5365],[9399,5368],[9391,5372],[9386,5369],[9382,5382],[9386,5384],[9384,5398],[9379,5395],[9371,5400],[9372,5395],[9345,5430],[9347,5439],[9332,5454],[9344,5457],[9343,5452],[9350,5437],[9359,5439],[9368,5437],[9372,5429],[9380,5428],[9388,5417],[9386,5404],[9396,5394],[9405,5396],[9413,5401],[9417,5392],[9412,5388],[9417,5385],[9419,5378],[9426,5378],[9430,5349],[9446,5344],[9464,5337],[9473,5337],[9481,5347],[9489,5352],[9497,5351],[9506,5346],[9499,5336],[9498,5318],[9487,5312],[9486,5299],[9472,5300],[9462,5295],[9457,5287],[9463,5279]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;IN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.34,&#34;hc-middle-y&#34;:0.43,&#34;hc-key&#34;:&#34;in&#34;,&#34;hc-a2&#34;:&#34;IN&#34;,&#34;name&#34;:&#34;India&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;India&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;IND&#34;,&#34;iso-a2&#34;:&#34;IN&#34;,&#34;woe-id&#34;:&#34;23424848&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7005,6718],[7007,6722],[7014,6711],[7011,6703],[7006,6711],[7005,6718]]],[[[6986,6907],[6989,6895],[6985,6883],[6986,6873],[6980,6859],[6979,6844],[6976,6839],[6974,6853],[6980,6878],[6982,6898],[6986,6907]]],[[[6842,7155],[6844,7155],[6843,7148],[6841,7149],[6842,7155]]],[[[6843,7342],[6857,7350],[6863,7346],[6861,7331],[6866,7325],[6861,7319],[6864,7313],[6872,7309],[6879,7310],[6893,7305],[6909,7311],[6915,7308],[6948,7309],[6960,7313],[6957,7319],[6960,7324],[6956,7330],[6950,7328],[6944,7334],[6946,7339],[6956,7338],[6976,7344],[6977,7351],[6989,7358],[7000,7368],[7005,7368],[7026,7379],[7024,7381],[7034,7388],[7039,7383],[7054,7380],[7067,7389],[7079,7390],[7080,7382],[7085,7381],[7092,7369],[7103,7357],[7114,7353],[7114,7343],[7101,7335],[7101,7329],[7107,7320],[7105,7317],[7096,7326],[7079,7323],[7057,7305],[7049,7302],[7047,7298],[7048,7287],[7046,7275],[7034,7264],[7032,7260],[7037,7253],[7025,7231],[7019,7216],[7005,7221],[6995,7221],[6999,7210],[6998,7194],[6991,7190],[6989,7183],[6991,7171],[6983,7158],[6977,7164],[6974,7159],[6972,7181],[6968,7188],[6968,7199],[6961,7213],[6949,7198],[6951,7193],[6945,7188],[6941,7196],[6937,7193],[6932,7209],[6938,7224],[6960,7234],[6964,7245],[6971,7250],[6958,7258],[6940,7256],[6935,7258],[6909,7257],[6892,7264],[6893,7283],[6888,7290],[6885,7282],[6879,7283],[6870,7291],[6864,7290],[6853,7298],[6844,7288],[6841,7280],[6855,7268],[6862,7268],[6866,7257],[6852,7258],[6849,7248],[6845,7250],[6840,7241],[6843,7236],[6853,7231],[6861,7230],[6860,7219],[6855,7210],[6860,7204],[6860,7198],[6868,7196],[6864,7189],[6870,7163],[6871,7152],[6871,7147],[6861,7146],[6861,7160],[6856,7146],[6855,7154],[6847,7146],[6844,7162],[6831,7149],[6816,7145],[6807,7139],[6805,7131],[6810,7118],[6803,7113],[6803,7108],[6795,7104],[6791,7097],[6769,7090],[6764,7095],[6754,7084],[6761,7085],[6747,7074],[6732,7054],[6724,7046],[6710,7039],[6699,7025],[6677,7013],[6671,7008],[6672,6995],[6654,6986],[6640,6987],[6638,6976],[6627,6969],[6623,6974],[6612,6968],[6606,6956],[6605,6948],[6610,6934],[6607,6925],[6611,6911],[6605,6906],[6614,6898],[6609,6874],[6600,6858],[6596,6845],[6599,6838],[6600,6807],[6586,6808],[6582,6800],[6572,6783],[6576,6778],[6557,6772],[6552,6768],[6546,6750],[6530,6742],[6515,6750],[6502,6766],[6495,6784],[6493,6797],[6481,6831],[6472,6849],[6462,6858],[6451,6883],[6445,6912],[6442,6918],[6437,6934],[6425,6950],[6424,6957],[6411,6979],[6407,6993],[6406,7007],[6395,7048],[6392,7065],[6393,7075],[6387,7094],[6390,7107],[6394,7114],[6394,7125],[6385,7140],[6386,7143],[6401,7151],[6384,7150],[6387,7158],[6379,7170],[6373,7153],[6377,7148],[6371,7135],[6352,7125],[6338,7120],[6331,7120],[6319,7126],[6286,7159],[6278,7168],[6279,7172],[6286,7168],[6315,7176],[6321,7188],[6304,7186],[6301,7182],[6286,7185],[6270,7195],[6263,7204],[6262,7209],[6275,7217],[6255,7209],[6256,7216],[6263,7220],[6272,7220],[6272,7230],[6275,7228],[6296,7230],[6308,7226],[6312,7230],[6326,7234],[6332,7228],[6341,7234],[6341,7242],[6334,7257],[6329,7264],[6329,7273],[6317,7274],[6311,7283],[6314,7300],[6304,7301],[6294,7309],[6297,7321],[6310,7334],[6312,7340],[6323,7348],[6330,7338],[6336,7337],[6345,7341],[6364,7345],[6365,7349],[6373,7358],[6379,7371],[6396,7380],[6404,7395],[6409,7408],[6425,7416],[6422,7421],[6436,7439],[6446,7445],[6443,7446],[6445,7457],[6441,7465],[6451,7476],[6465,7480],[6467,7484],[6457,7490],[6448,7490],[6446,7494],[6447,7502],[6437,7500],[6436,7507],[6427,7513],[6431,7525],[6426,7529],[6434,7541],[6425,7540],[6425,7550],[6420,7552],[6425,7561],[6437,7566],[6467,7559],[6479,7557],[6487,7563],[6505,7565],[6517,7577],[6539,7590],[6546,7588],[6545,7582],[6553,7562],[6572,7552],[6574,7547],[6566,7543],[6568,7525],[6573,7517],[6585,7513],[6584,7506],[6589,7499],[6583,7491],[6572,7486],[6567,7495],[6556,7492],[6558,7482],[6567,7474],[6565,7467],[6569,7462],[6567,7453],[6580,7453],[6583,7447],[6591,7440],[6599,7441],[6611,7433],[6609,7428],[6621,7425],[6633,7416],[6615,7402],[6610,7391],[6612,7388],[6605,7373],[6618,7364],[6620,7368],[6642,7352],[6659,7342],[6662,7344],[6676,7336],[6682,7337],[6685,7330],[6696,7329],[6700,7325],[6703,7330],[6717,7326],[6724,7331],[6738,7325],[6740,7316],[6746,7315],[6759,7306],[6769,7310],[6775,7301],[6781,7304],[6789,7302],[6801,7296],[6811,7301],[6813,7296],[6819,7294],[6835,7298],[6839,7295],[6844,7306],[6838,7318],[6843,7342]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.43,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;kr&#34;,&#34;hc-a2&#34;:&#34;KR&#34;,&#34;name&#34;:&#34;South Korea&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;S.K.&#34;,&#34;subregion&#34;:&#34;Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;KOR&#34;,&#34;iso-a2&#34;:&#34;KR&#34;,&#34;woe-id&#34;:&#34;23424868&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7982,7526],[7986,7521],[7975,7515],[7963,7516],[7967,7523],[7982,7526]]],[[[8028,7695],[8036,7679],[8048,7663],[8056,7650],[8060,7631],[8058,7613],[8063,7609],[8060,7590],[8052,7578],[8042,7575],[8035,7564],[8035,7572],[8030,7573],[8030,7566],[8019,7571],[8019,7563],[8012,7569],[8006,7561],[8003,7570],[7998,7566],[8002,7554],[7988,7560],[7983,7551],[7981,7556],[7976,7547],[7972,7552],[7974,7559],[7968,7553],[7959,7551],[7965,7558],[7956,7562],[7960,7571],[7963,7563],[7969,7560],[7969,7574],[7962,7576],[7968,7578],[7973,7592],[7972,7595],[7982,7602],[7973,7612],[7975,7617],[7971,7627],[7962,7632],[7972,7635],[7974,7642],[7980,7642],[7978,7649],[7983,7650],[7970,7661],[7965,7667],[7978,7668],[7987,7682],[7992,7685],[8022,7686],[8028,7695]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;FR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.29,&#34;hc-middle-y&#34;:0.05,&#34;hc-key&#34;:&#34;fr&#34;,&#34;hc-a2&#34;:&#34;FR&#34;,&#34;name&#34;:&#34;France&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Fr.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;FRA&#34;,&#34;iso-a2&#34;:&#34;FR&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[2595,7986],[2589,7985],[2588,7998],[2590,7990],[2595,7986]]],[[[5882,5886],[5887,5885],[5893,5877],[5892,5871],[5878,5873],[5874,5880],[5882,5886]]],[[[2436,6980],[2434,6973],[2430,6980],[2430,6988],[2436,6984],[2439,6993],[2442,6987],[2449,6986],[2439,6983],[2436,6980]]],[[[4527,7836],[4529,7832],[4530,7817],[4525,7811],[4525,7802],[4519,7790],[4507,7797],[4511,7802],[4504,7803],[4508,7809],[4500,7821],[4505,7833],[4522,7837],[4523,7848],[4527,7848],[4527,7836]]],[[[9174,5890],[9177,5876],[9170,5879],[9166,5884],[9174,5890]]],[[[9076,5910],[9082,5910],[9108,5890],[9113,5889],[9125,5873],[9133,5871],[9147,5862],[9166,5844],[9161,5838],[9149,5846],[9142,5846],[9136,5852],[9115,5864],[9106,5871],[9100,5880],[9088,5889],[9076,5910]]],[[[6284,4943],[6295,4947],[6286,4939],[6297,4944],[6301,4932],[6317,4939],[6325,4938],[6323,4928],[6304,4928],[6303,4923],[6318,4922],[6313,4915],[6305,4916],[6303,4922],[6299,4916],[6282,4921],[6282,4915],[6274,4915],[6277,4925],[6274,4929],[6274,4948],[6278,4952],[6274,4956],[6282,4955],[6284,4943]]],[[[2390,7039],[2393,7041],[2393,7038],[2390,7039]]],[[[4432,7967],[4434,7970],[4448,7972],[4448,7961],[4455,7954],[4448,7950],[4449,7945],[4459,7935],[4456,7928],[4443,7924],[4446,7917],[4454,7914],[4450,7903],[4454,7892],[4464,7888],[4474,7890],[4475,7887],[4469,7876],[4468,7875],[4467,7875],[4466,7875],[4465,7874],[4459,7871],[4442,7858],[4445,7855],[4428,7851],[4406,7856],[4401,7863],[4390,7860],[4365,7867],[4348,7858],[4340,7852],[4338,7846],[4338,7832],[4342,7828],[4335,7829],[4322,7824],[4315,7828],[4306,7826],[4299,7830],[4299,7834],[4290,7834],[4288,7838],[4268,7842],[4267,7837],[4247,7837],[4239,7842],[4231,7840],[4226,7846],[4209,7851],[4207,7857],[4197,7858],[4195,7862],[4205,7869],[4213,7908],[4211,7906],[4215,7938],[4216,7941],[4226,7932],[4225,7937],[4213,7946],[4217,7958],[4213,7967],[4195,7975],[4186,7989],[4190,7995],[4173,8008],[4174,8013],[4165,8012],[4167,8017],[4158,8015],[4144,8022],[4135,8023],[4132,8027],[4120,8023],[4118,8030],[4110,8033],[4122,8038],[4114,8042],[4122,8047],[4108,8044],[4109,8052],[4131,8058],[4143,8057],[4145,8062],[4157,8064],[4169,8050],[4180,8057],[4183,8053],[4194,8058],[4194,8054],[4207,8055],[4202,8059],[4203,8070],[4195,8083],[4191,8096],[4204,8094],[4211,8095],[4214,8084],[4236,8081],[4242,8079],[4253,8084],[4254,8095],[4266,8101],[4284,8106],[4294,8115],[4295,8140],[4305,8145],[4322,8149],[4324,8139],[4333,8133],[4340,8137],[4345,8127],[4356,8124],[4356,8119],[4366,8120],[4372,8116],[4370,8106],[4379,8104],[4391,8112],[4389,8105],[4409,8087],[4419,8089],[4424,8085],[4435,8086],[4440,8085],[4446,8074],[4449,8076],[4462,8072],[4468,8074],[4473,8070],[4490,8067],[4478,8054],[4476,8044],[4472,8036],[4470,8023],[4472,8015],[4465,8009],[4455,8012],[4450,8007],[4456,8006],[4443,7993],[4438,7991],[4438,7985],[4428,7978],[4429,7970],[4424,7961],[4432,7967]],[[4306,7828],[4307,7828],[4306,7830],[4306,7829],[4306,7828]]],[[[2653,6662],[2660,6673],[2673,6668],[2689,6664],[2717,6641],[2719,6635],[2723,6640],[2727,6623],[2718,6614],[2707,6597],[2700,6578],[2688,6569],[2678,6574],[2672,6571],[2663,6573],[2654,6567],[2640,6573],[2647,6578],[2653,6589],[2652,6597],[2658,6606],[2657,6611],[2648,6623],[2644,6649],[2653,6662]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;FM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.52,&#34;hc-key&#34;:&#34;fm&#34;,&#34;hc-a2&#34;:&#34;FM&#34;,&#34;name&#34;:&#34;Federated States of Micronesia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;F.S.M.&#34;,&#34;subregion&#34;:&#34;Micronesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;FSM&#34;,&#34;iso-a2&#34;:&#34;FM&#34;,&#34;woe-id&#34;:&#34;23424815&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[8906,6709],[8910,6708],[8909,6704],[8906,6704],[8906,6709]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.67,&#34;hc-middle-y&#34;:0.64,&#34;hc-key&#34;:&#34;cu&#34;,&#34;hc-a2&#34;:&#34;CU&#34;,&#34;name&#34;:&#34;Cuba&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Cuba&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;CUB&#34;,&#34;iso-a2&#34;:&#34;CU&#34;,&#34;woe-id&#34;:&#34;23424793&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[1815,7157],[1818,7147],[1809,7142],[1802,7143],[1805,7147],[1802,7154],[1815,7157]]],[[[2005,7098],[1972,7095],[1960,7093],[1963,7099],[1976,7107],[1979,7112],[1971,7120],[1950,7120],[1937,7130],[1935,7140],[1930,7148],[1916,7145],[1903,7150],[1896,7150],[1885,7156],[1879,7161],[1866,7161],[1856,7164],[1839,7165],[1830,7172],[1843,7173],[1837,7180],[1812,7181],[1792,7165],[1777,7164],[1774,7157],[1760,7153],[1759,7157],[1766,7160],[1763,7170],[1775,7180],[1793,7186],[1798,7190],[1817,7192],[1833,7196],[1855,7195],[1858,7192],[1876,7196],[1891,7192],[1911,7180],[1903,7183],[1907,7176],[1915,7171],[1929,7171],[1930,7175],[1941,7176],[1948,7172],[1950,7165],[1956,7167],[1963,7160],[1959,7153],[1971,7152],[1995,7134],[1999,7137],[2007,7131],[2016,7133],[2023,7129],[2021,7125],[2026,7120],[2040,7119],[2048,7117],[2058,7107],[2063,7107],[2062,7100],[2045,7099],[2041,7096],[2022,7095],[2005,7098]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.42,&#34;hc-middle-y&#34;:0.55,&#34;hc-key&#34;:&#34;cn&#34;,&#34;hc-a2&#34;:&#34;CN&#34;,&#34;name&#34;:&#34;China&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;China&#34;,&#34;subregion&#34;:&#34;Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;CHN&#34;,&#34;iso-a2&#34;:&#34;CN&#34;,&#34;woe-id&#34;:&#34;23424781&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7838,7457],[7820,7463],[7819,7470],[7838,7461],[7838,7457]]],[[[7448,7072],[7446,7074],[7458,7086],[7467,7089],[7475,7098],[7482,7096],[7498,7100],[7505,7097],[7507,7103],[7515,7098],[7516,7089],[7508,7080],[7499,7058],[7491,7054],[7489,7049],[7480,7049],[7478,7044],[7457,7048],[7448,7053],[7446,7071],[7448,7072]]],[[[6866,7325],[6861,7331],[6863,7346],[6857,7350],[6843,7342],[6834,7343],[6831,7340],[6814,7341],[6802,7349],[6797,7350],[6793,7343],[6786,7346],[6780,7343],[6771,7357],[6769,7354],[6754,7356],[6756,7365],[6741,7366],[6728,7375],[6724,7386],[6707,7384],[6697,7398],[6687,7399],[6679,7408],[6667,7412],[6665,7421],[6651,7423],[6645,7422],[6639,7410],[6633,7416],[6621,7425],[6609,7428],[6611,7433],[6599,7441],[6591,7440],[6583,7447],[6580,7453],[6567,7453],[6569,7462],[6565,7467],[6567,7474],[6558,7482],[6556,7492],[6567,7495],[6572,7486],[6583,7491],[6589,7499],[6584,7506],[6585,7513],[6573,7517],[6568,7525],[6566,7543],[6574,7547],[6572,7552],[6553,7562],[6545,7582],[6546,7588],[6539,7590],[6527,7589],[6509,7595],[6502,7603],[6491,7600],[6483,7610],[6486,7614],[6485,7622],[6480,7630],[6469,7632],[6460,7640],[6453,7637],[6443,7641],[6438,7645],[6448,7650],[6453,7648],[6461,7654],[6453,7661],[6455,7666],[6450,7677],[6449,7692],[6437,7697],[6431,7697],[6428,7692],[6422,7694],[6418,7704],[6422,7708],[6415,7716],[6416,7724],[6425,7728],[6422,7737],[6426,7744],[6437,7746],[6448,7754],[6452,7761],[6462,7758],[6473,7765],[6477,7753],[6493,7758],[6496,7755],[6504,7764],[6509,7776],[6516,7779],[6530,7777],[6547,7779],[6555,7791],[6583,7805],[6596,7808],[6599,7813],[6609,7813],[6610,7819],[6612,7821],[6608,7835],[6611,7842],[6620,7844],[6615,7849],[6627,7853],[6623,7860],[6625,7864],[6616,7886],[6614,7907],[6618,7910],[6603,7913],[6600,7916],[6607,7921],[6629,7925],[6653,7933],[6661,7925],[6670,7928],[6677,7924],[6681,7936],[6671,7939],[6677,7953],[6687,7983],[6692,7991],[6693,8001],[6696,8001],[6719,7992],[6741,7993],[6743,7987],[6758,7995],[6766,7995],[6771,8008],[6766,8028],[6774,8046],[6786,8046],[6797,8051],[6803,8058],[6802,8065],[6806,8072],[6819,8072],[6825,8073],[6834,8075],[6836,8067],[6832,8063],[6841,8056],[6838,8053],[6856,8044],[6857,8038],[6870,8030],[6886,8031],[6891,8024],[6899,8026],[6901,8022],[6908,8018],[6912,8005],[6919,7994],[6924,7991],[6929,7977],[6925,7968],[6928,7957],[6919,7947],[6917,7938],[6924,7927],[6941,7925],[6943,7923],[6958,7923],[6963,7920],[6979,7921],[7002,7918],[7014,7908],[7021,7908],[7026,7902],[7046,7893],[7057,7894],[7055,7884],[7060,7883],[7071,7857],[7084,7845],[7085,7838],[7110,7841],[7177,7833],[7193,7837],[7228,7831],[7241,7831],[7252,7819],[7283,7813],[7302,7804],[7325,7808],[7325,7801],[7340,7798],[7346,7804],[7392,7823],[7433,7829],[7452,7827],[7472,7829],[7477,7832],[7499,7840],[7516,7859],[7533,7866],[7544,7873],[7541,7882],[7535,7886],[7529,7900],[7538,7919],[7546,7923],[7558,7922],[7563,7917],[7578,7913],[7593,7911],[7605,7917],[7617,7927],[7621,7934],[7632,7934],[7654,7937],[7669,7946],[7670,7953],[7681,7968],[7688,7971],[7702,7969],[7705,7978],[7713,7975],[7730,7983],[7744,7981],[7747,7984],[7761,7979],[7772,7978],[7779,7983],[7778,7990],[7771,8001],[7756,8013],[7754,8018],[7745,8022],[7739,8029],[7728,8032],[7715,8030],[7713,8029],[7708,8022],[7702,8018],[7689,8026],[7671,8026],[7659,8020],[7651,8028],[7649,8036],[7658,8041],[7658,8050],[7684,8100],[7695,8094],[7715,8088],[7737,8100],[7742,8105],[7758,8107],[7763,8120],[7756,8121],[7767,8135],[7767,8142],[7774,8148],[7784,8171],[7798,8181],[7804,8189],[7800,8198],[7803,8206],[7795,8210],[7787,8207],[7782,8214],[7790,8219],[7806,8235],[7817,8235],[7850,8244],[7866,8243],[7878,8247],[7898,8242],[7903,8238],[7920,8230],[7932,8232],[7950,8223],[7958,8210],[7964,8205],[7974,8190],[7971,8184],[7977,8174],[7978,8168],[7986,8158],[7986,8148],[7996,8136],[7998,8118],[8005,8115],[8002,8108],[8003,8099],[8013,8091],[8019,8089],[8041,8090],[8040,8086],[8050,8082],[8058,8085],[8067,8079],[8073,8070],[8083,8063],[8096,8064],[8091,8054],[8098,8049],[8100,8042],[8096,8033],[8107,8019],[8118,8021],[8123,8018],[8145,8021],[8149,8020],[8156,8029],[8167,8035],[8178,8034],[8186,8040],[8205,8045],[8215,8041],[8210,8031],[8216,8020],[8208,8009],[8198,8003],[8193,7980],[8189,7974],[8191,7966],[8184,7962],[8184,7954],[8179,7952],[8178,7943],[8168,7935],[8168,7924],[8159,7922],[8152,7931],[8141,7932],[8135,7928],[8129,7932],[8118,7919],[8103,7914],[8107,7908],[8113,7886],[8110,7867],[8113,7864],[8111,7852],[8105,7843],[8099,7843],[8088,7839],[8092,7831],[8083,7839],[8079,7847],[8072,7847],[8067,7828],[8056,7828],[8053,7820],[8044,7814],[8018,7812],[8018,7808],[8026,7798],[8021,7791],[7995,7795],[7986,7806],[7976,7801],[7973,7793],[7958,7774],[7951,7774],[7941,7765],[7926,7760],[7910,7746],[7903,7737],[7881,7735],[7870,7732],[7854,7723],[7856,7718],[7847,7718],[7836,7706],[7815,7699],[7814,7706],[7831,7711],[7828,7715],[7834,7721],[7820,7722],[7820,7729],[7827,7731],[7827,7738],[7837,7742],[7849,7760],[7836,7772],[7816,7775],[7798,7757],[7794,7750],[7768,7739],[7762,7733],[7761,7723],[7752,7715],[7738,7713],[7730,7710],[7724,7716],[7715,7712],[7709,7695],[7714,7687],[7725,7679],[7739,7676],[7747,7679],[7760,7663],[7753,7665],[7751,7650],[7765,7644],[7775,7645],[7777,7652],[7790,7663],[7803,7668],[7822,7661],[7828,7655],[7844,7659],[7846,7654],[7861,7654],[7859,7647],[7850,7634],[7842,7640],[7804,7622],[7802,7611],[7792,7608],[7792,7613],[7785,7614],[7787,7605],[7779,7594],[7771,7593],[7758,7575],[7758,7564],[7762,7566],[7771,7558],[7789,7550],[7796,7529],[7808,7508],[7807,7497],[7822,7487],[7824,7478],[7835,7473],[7835,7465],[7819,7471],[7810,7469],[7805,7475],[7804,7468],[7815,7464],[7832,7451],[7840,7440],[7823,7435],[7810,7428],[7803,7418],[7808,7416],[7815,7421],[7822,7421],[7831,7410],[7842,7405],[7851,7407],[7841,7410],[7843,7419],[7848,7425],[7853,7423],[7849,7418],[7852,7405],[7846,7400],[7840,7404],[7828,7393],[7838,7399],[7838,7380],[7828,7387],[7823,7381],[7829,7382],[7831,7373],[7826,7367],[7830,7357],[7823,7355],[7814,7346],[7810,7346],[7799,7333],[7797,7321],[7788,7316],[7792,7314],[7782,7310],[7777,7304],[7776,7310],[7768,7307],[7770,7301],[7775,7301],[7778,7293],[7772,7292],[7766,7283],[7773,7283],[7769,7273],[7778,7269],[7774,7265],[7763,7268],[7755,7265],[7766,7260],[7748,7255],[7752,7251],[7744,7247],[7742,7239],[7735,7241],[7724,7233],[7726,7229],[7719,7222],[7714,7222],[7705,7211],[7696,7207],[7692,7209],[7686,7201],[7679,7203],[7682,7197],[7678,7188],[7672,7189],[7659,7182],[7654,7187],[7650,7182],[7636,7184],[7631,7176],[7628,7184],[7621,7182],[7620,7173],[7613,7177],[7616,7170],[7611,7166],[7602,7172],[7594,7191],[7588,7188],[7593,7183],[7592,7164],[7587,7165],[7576,7158],[7565,7148],[7559,7154],[7542,7150],[7535,7145],[7519,7143],[7508,7139],[7502,7131],[7505,7127],[7495,7128],[7496,7118],[7503,7113],[7499,7107],[7485,7106],[7480,7123],[7477,7126],[7479,7143],[7472,7150],[7473,7144],[7462,7141],[7462,7147],[7454,7152],[7450,7148],[7441,7155],[7443,7147],[7438,7150],[7428,7143],[7423,7148],[7409,7147],[7391,7159],[7385,7170],[7386,7178],[7391,7182],[7384,7188],[7379,7185],[7369,7189],[7365,7187],[7349,7201],[7334,7193],[7335,7188],[7320,7180],[7313,7184],[7309,7175],[7300,7184],[7296,7177],[7290,7184],[7281,7172],[7265,7183],[7255,7171],[7241,7173],[7237,7167],[7244,7154],[7243,7133],[7237,7136],[7230,7134],[7227,7145],[7226,7152],[7213,7144],[7198,7142],[7197,7149],[7191,7151],[7191,7161],[7167,7164],[7174,7174],[7172,7182],[7178,7192],[7170,7192],[7159,7196],[7160,7203],[7153,7220],[7159,7225],[7151,7223],[7139,7225],[7123,7216],[7119,7219],[7125,7225],[7123,7234],[7119,7235],[7120,7244],[7127,7247],[7125,7254],[7137,7264],[7138,7271],[7144,7270],[7148,7278],[7154,7280],[7150,7287],[7156,7303],[7154,7320],[7154,7333],[7146,7336],[7142,7332],[7137,7345],[7137,7350],[7124,7363],[7120,7363],[7114,7353],[7103,7357],[7092,7369],[7085,7381],[7080,7382],[7079,7390],[7067,7389],[7054,7380],[7039,7383],[7034,7388],[7024,7381],[7026,7379],[7005,7368],[7000,7368],[6989,7358],[6977,7351],[6976,7344],[6956,7338],[6946,7339],[6947,7344],[6936,7349],[6930,7345],[6918,7349],[6915,7354],[6905,7358],[6894,7356],[6886,7351],[6866,7325]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.92,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;pt&#34;,&#34;hc-a2&#34;:&#34;PT&#34;,&#34;name&#34;:&#34;Portugal&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Port.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;PRT&#34;,&#34;iso-a2&#34;:&#34;PT&#34;,&#34;woe-id&#34;:&#34;23424925&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[3422,7689],[3410,7688],[3399,7695],[3413,7693],[3417,7699],[3430,7693],[3422,7689]]],[[[4030,7647],[4014,7639],[4007,7643],[3996,7644],[3983,7641],[3989,7654],[3990,7680],[3985,7691],[3977,7688],[3976,7697],[3969,7698],[3973,7721],[3979,7726],[3987,7747],[3992,7771],[3991,7786],[3987,7807],[3991,7812],[4006,7818],[4010,7814],[4007,7806],[4021,7809],[4029,7806],[4041,7811],[4055,7811],[4055,7803],[4066,7798],[4062,7792],[4053,7787],[4044,7778],[4047,7772],[4048,7755],[4042,7751],[4046,7743],[4042,7732],[4026,7732],[4033,7724],[4038,7712],[4043,7709],[4034,7699],[4032,7689],[4041,7675],[4034,7673],[4027,7659],[4030,7647]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.86,&#34;hc-middle-y&#34;:0.57,&#34;hc-key&#34;:&#34;sw&#34;,&#34;hc-a2&#34;:&#34;SW&#34;,&#34;name&#34;:&#34;Serranilla Bank&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;S.B.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;-99&#34;,&#34;iso-a2&#34;:&#34;SW&#34;,&#34;woe-id&#34;:&#34;-99&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1933,6973],[1933,6973],[1933,6973],[1933,6973]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.54,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;sh&#34;,&#34;hc-a2&#34;:&#34;SH&#34;,&#34;name&#34;:&#34;Scarborough Reef&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;S.R.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;-99&#34;,&#34;iso-a2&#34;:&#34;SH&#34;,&#34;woe-id&#34;:&#34;-99&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[7715,6952],[7715,6952],[7715,6952],[7715,6952],[7715,6952]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.54,&#34;hc-middle-y&#34;:0.34,&#34;hc-key&#34;:&#34;br&#34;,&#34;hc-a2&#34;:&#34;BR&#34;,&#34;name&#34;:&#34;Brazil&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Brazil&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;BRA&#34;,&#34;iso-a2&#34;:&#34;BR&#34;,&#34;woe-id&#34;:&#34;23424768&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[2740,6489],[2742,6486],[2739,6475],[2723,6463],[2719,6464],[2725,6472],[2727,6480],[2732,6487],[2740,6489]]],[[[2767,6520],[2774,6524],[2775,6520],[2765,6511],[2786,6516],[2790,6514],[2781,6505],[2759,6505],[2763,6521],[2767,6520]]],[[[2784,6501],[2787,6507],[2795,6505],[2796,6501],[2822,6498],[2819,6479],[2811,6470],[2810,6463],[2782,6452],[2769,6458],[2767,6452],[2758,6453],[2752,6466],[2753,6485],[2744,6481],[2752,6488],[2757,6497],[2766,6502],[2786,6498],[2784,6501]]],[[[2672,5485],[2674,5494],[2683,5503],[2684,5509],[2691,5506],[2696,5508],[2700,5517],[2696,5525],[2698,5530],[2683,5514],[2669,5524],[2665,5534],[2654,5538],[2645,5546],[2640,5553],[2622,5560],[2611,5573],[2604,5566],[2599,5565],[2600,5573],[2593,5581],[2575,5597],[2568,5597],[2565,5592],[2554,5591],[2552,5594],[2560,5601],[2587,5630],[2606,5657],[2616,5661],[2620,5667],[2628,5669],[2632,5676],[2663,5690],[2667,5699],[2666,5715],[2668,5719],[2663,5728],[2661,5739],[2655,5743],[2644,5739],[2641,5740],[2641,5742],[2640,5745],[2647,5752],[2647,5763],[2651,5768],[2650,5787],[2639,5795],[2624,5789],[2616,5791],[2613,5802],[2613,5813],[2610,5820],[2610,5831],[2603,5841],[2593,5843],[2587,5849],[2580,5844],[2552,5846],[2541,5849],[2544,5861],[2546,5883],[2541,5891],[2541,5899],[2536,5907],[2545,5913],[2537,5920],[2547,5941],[2554,5967],[2546,5987],[2540,5988],[2529,5995],[2526,6013],[2531,6024],[2527,6023],[2477,6025],[2474,6049],[2464,6060],[2474,6060],[2473,6074],[2468,6089],[2468,6099],[2451,6109],[2428,6107],[2418,6119],[2413,6118],[2399,6123],[2391,6133],[2384,6132],[2374,6138],[2366,6136],[2352,6139],[2349,6145],[2334,6153],[2329,6160],[2323,6178],[2326,6183],[2321,6198],[2326,6206],[2326,6216],[2321,6221],[2286,6214],[2270,6202],[2258,6197],[2254,6191],[2243,6191],[2237,6183],[2223,6178],[2224,6182],[2200,6184],[2188,6184],[2179,6180],[2168,6182],[2168,6216],[2172,6228],[2152,6213],[2146,6211],[2123,6212],[2119,6225],[2104,6229],[2093,6229],[2100,6239],[2088,6257],[2083,6260],[2078,6277],[2069,6284],[2078,6291],[2077,6303],[2095,6318],[2092,6327],[2099,6338],[2101,6355],[2110,6358],[2131,6373],[2159,6377],[2164,6383],[2178,6383],[2181,6378],[2188,6381],[2204,6464],[2204,6476],[2198,6484],[2198,6490],[2185,6500],[2186,6522],[2203,6527],[2213,6524],[2212,6530],[2206,6536],[2192,6536],[2191,6555],[2241,6555],[2240,6564],[2245,6557],[2251,6557],[2258,6565],[2265,6566],[2272,6555],[2273,6540],[2279,6541],[2293,6529],[2301,6526],[2312,6534],[2319,6530],[2318,6524],[2330,6538],[2342,6542],[2352,6549],[2360,6551],[2362,6561],[2381,6568],[2383,6576],[2362,6577],[2364,6585],[2357,6597],[2358,6610],[2345,6621],[2340,6630],[2346,6626],[2360,6625],[2362,6620],[2381,6621],[2393,6610],[2400,6611],[2401,6623],[2410,6628],[2418,6625],[2436,6630],[2439,6634],[2453,6638],[2464,6650],[2460,6657],[2475,6659],[2482,6654],[2478,6637],[2491,6633],[2490,6627],[2496,6620],[2486,6611],[2482,6584],[2484,6574],[2489,6571],[2489,6560],[2503,6546],[2516,6540],[2525,6542],[2531,6552],[2540,6549],[2541,6554],[2553,6555],[2557,6561],[2567,6564],[2576,6560],[2585,6562],[2599,6559],[2602,6565],[2597,6571],[2600,6579],[2608,6575],[2629,6580],[2640,6573],[2654,6567],[2663,6573],[2672,6571],[2678,6574],[2688,6569],[2700,6578],[2707,6597],[2718,6614],[2727,6623],[2731,6635],[2740,6627],[2741,6612],[2744,6619],[2744,6604],[2746,6594],[2756,6569],[2762,6569],[2767,6562],[2762,6558],[2771,6558],[2779,6554],[2779,6539],[2773,6527],[2763,6525],[2753,6510],[2758,6502],[2750,6496],[2743,6501],[2742,6496],[2726,6483],[2726,6475],[2715,6464],[2710,6466],[2696,6458],[2709,6461],[2710,6456],[2718,6459],[2738,6469],[2751,6478],[2748,6472],[2757,6452],[2763,6448],[2777,6452],[2784,6449],[2796,6455],[2789,6432],[2790,6428],[2799,6448],[2807,6458],[2807,6453],[2816,6465],[2819,6459],[2821,6471],[2828,6475],[2828,6480],[2843,6489],[2850,6484],[2851,6488],[2863,6481],[2879,6479],[2880,6475],[2889,6478],[2899,6466],[2902,6472],[2905,6465],[2914,6466],[2914,6454],[2923,6466],[2929,6455],[2937,6450],[2941,6435],[2938,6436],[2934,6426],[2941,6421],[2942,6431],[2951,6435],[2951,6430],[2944,6424],[2948,6422],[2962,6439],[2969,6431],[2973,6436],[2991,6430],[2998,6425],[3004,6427],[3016,6425],[3023,6420],[3046,6421],[3056,6424],[3071,6422],[3092,6411],[3110,6398],[3115,6397],[3126,6383],[3141,6370],[3150,6367],[3153,6361],[3165,6357],[3202,6355],[3210,6345],[3218,6318],[3224,6295],[3223,6273],[3213,6244],[3209,6235],[3176,6197],[3162,6189],[3146,6165],[3140,6151],[3128,6133],[3114,6122],[3114,6131],[3108,6134],[3104,6127],[3112,6123],[3101,6115],[3101,6098],[3102,6093],[3098,6073],[3102,6042],[3104,6037],[3098,6020],[3094,5998],[3096,5983],[3082,5967],[3079,5957],[3079,5931],[3077,5924],[3070,5919],[3058,5893],[3048,5886],[3039,5866],[3042,5853],[3034,5847],[3021,5842],[3013,5835],[3015,5827],[3010,5822],[2981,5821],[2980,5831],[2974,5828],[2976,5820],[2964,5820],[2957,5824],[2947,5817],[2943,5822],[2932,5817],[2936,5809],[2926,5810],[2917,5803],[2911,5801],[2917,5796],[2911,5795],[2898,5797],[2890,5794],[2866,5781],[2859,5773],[2840,5760],[2836,5752],[2826,5743],[2817,5726],[2821,5720],[2815,5704],[2819,5690],[2816,5680],[2822,5683],[2823,5677],[2818,5668],[2813,5648],[2795,5635],[2782,5618],[2775,5606],[2767,5585],[2755,5567],[2742,5552],[2721,5538],[2715,5530],[2717,5537],[2726,5542],[2741,5556],[2742,5566],[2755,5575],[2755,5588],[2740,5594],[2741,5589],[2734,5565],[2728,5560],[2719,5558],[2717,5547],[2711,5544],[2710,5526],[2699,5500],[2693,5492],[2677,5479],[2672,5482],[2672,5485]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;EC&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.75,&#34;hc-middle-y&#34;:0.18,&#34;hc-key&#34;:&#34;ec&#34;,&#34;hc-a2&#34;:&#34;EC&#34;,&#34;name&#34;:&#34;Ecuador&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Ecu.&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;ECU&#34;,&#34;iso-a2&#34;:&#34;EC&#34;,&#34;woe-id&#34;:&#34;23424801&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[1591,6490],[1588,6482],[1582,6485],[1581,6494],[1574,6495],[1575,6501],[1591,6490]]],[[[1557,6492],[1551,6492],[1549,6497],[1558,6497],[1556,6504],[1551,6505],[1559,6510],[1564,6498],[1570,6493],[1575,6484],[1571,6477],[1557,6475],[1555,6481],[1566,6488],[1562,6494],[1557,6492]]],[[[1927,6547],[1935,6540],[1956,6529],[1960,6530],[1967,6524],[1969,6516],[1985,6512],[1999,6513],[2002,6519],[2012,6511],[2032,6502],[2022,6502],[2032,6489],[2033,6477],[2028,6478],[2023,6460],[2008,6443],[1990,6430],[1956,6418],[1946,6407],[1941,6406],[1939,6394],[1932,6378],[1932,6372],[1924,6366],[1920,6358],[1909,6364],[1907,6372],[1898,6374],[1889,6380],[1881,6374],[1883,6382],[1878,6386],[1888,6391],[1883,6406],[1894,6412],[1899,6427],[1897,6443],[1896,6432],[1891,6427],[1896,6426],[1889,6417],[1885,6417],[1887,6425],[1873,6434],[1866,6437],[1871,6449],[1868,6459],[1871,6466],[1866,6474],[1877,6479],[1880,6489],[1878,6494],[1891,6507],[1892,6521],[1890,6527],[1909,6537],[1917,6537],[1927,6547]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.55,&#34;hc-middle-y&#34;:0.43,&#34;hc-key&#34;:&#34;au&#34;,&#34;hc-a2&#34;:&#34;AU&#34;,&#34;name&#34;:&#34;Australia&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Auz.&#34;,&#34;subregion&#34;:&#34;Australia and New Zealand&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;AUS&#34;,&#34;iso-a2&#34;:&#34;AU&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[8616,5257],[8620,5253],[8613,5250],[8608,5255],[8602,5271],[8605,5277],[8615,5269],[8616,5257]]],[[[8490,5266],[8485,5263],[8484,5278],[8491,5280],[8490,5266]]],[[[8300,5418],[8299,5413],[8313,5412],[8313,5406],[8301,5407],[8296,5401],[8274,5402],[8268,5407],[8270,5412],[8292,5418],[8300,5418]]],[[[8276,6099],[8273,6091],[8281,6085],[8265,6087],[8265,6098],[8273,6103],[8276,6099]]],[[[8087,6168],[8089,6161],[8094,6158],[8077,6158],[8086,6173],[8087,6168]]],[[[8091,6174],[8097,6171],[8112,6176],[8118,6175],[8119,6164],[8104,6154],[8091,6163],[8087,6176],[8091,6174]]],[[[8752,5740],[8751,5735],[8759,5729],[8755,5717],[8759,5693],[8766,5695],[8766,5684],[8769,5682],[8766,5662],[8771,5655],[8771,5636],[8763,5622],[8763,5610],[8753,5577],[8756,5571],[8751,5552],[8739,5530],[8740,5521],[8727,5510],[8718,5506],[8704,5483],[8702,5470],[8692,5459],[8687,5431],[8681,5430],[8672,5409],[8669,5407],[8669,5393],[8662,5372],[8666,5361],[8664,5353],[8658,5351],[8650,5343],[8615,5342],[8603,5339],[8594,5333],[8573,5314],[8561,5311],[8559,5297],[8550,5308],[8545,5305],[8539,5314],[8525,5318],[8521,5322],[8516,5319],[8512,5323],[8521,5331],[8517,5340],[8512,5340],[8503,5332],[8507,5326],[8500,5326],[8490,5320],[8474,5307],[8453,5316],[8441,5324],[8436,5322],[8422,5327],[8419,5322],[8398,5334],[8391,5334],[8381,5340],[8377,5347],[8370,5354],[8363,5364],[8361,5372],[8366,5382],[8358,5401],[8358,5403],[8342,5417],[8351,5417],[8349,5426],[8340,5423],[8341,5419],[8327,5415],[8315,5416],[8324,5426],[8327,5446],[8319,5456],[8314,5466],[8302,5431],[8295,5433],[8278,5427],[8283,5440],[8295,5440],[8297,5450],[8292,5453],[8296,5458],[8295,5465],[8300,5474],[8310,5486],[8306,5494],[8313,5498],[8305,5519],[8305,5503],[8295,5498],[8289,5481],[8270,5473],[8263,5468],[8259,5460],[8251,5452],[8249,5443],[8242,5439],[8235,5449],[8233,5461],[8229,5474],[8218,5482],[8218,5491],[8213,5496],[8202,5498],[8196,5512],[8202,5513],[8198,5521],[8189,5518],[8192,5523],[8185,5529],[8169,5529],[8158,5537],[8142,5534],[8128,5544],[8109,5553],[8099,5548],[8081,5549],[8046,5546],[8018,5533],[7996,5527],[7978,5525],[7964,5528],[7954,5525],[7945,5518],[7929,5512],[7920,5506],[7910,5504],[7902,5498],[7898,5484],[7885,5472],[7874,5470],[7870,5475],[7851,5473],[7848,5469],[7841,5476],[7834,5473],[7827,5476],[7798,5474],[7793,5471],[7782,5473],[7771,5467],[7766,5457],[7747,5455],[7744,5449],[7736,5446],[7734,5440],[7713,5435],[7711,5432],[7703,5436],[7697,5435],[7663,5442],[7656,5452],[7644,5460],[7638,5458],[7633,5467],[7634,5486],[7643,5482],[7647,5483],[7654,5493],[7652,5514],[7656,5515],[7656,5538],[7654,5547],[7640,5574],[7634,5593],[7634,5617],[7630,5629],[7622,5639],[7620,5647],[7610,5661],[7609,5674],[7605,5686],[7593,5706],[7585,5714],[7584,5727],[7582,5724],[7574,5734],[7588,5735],[7591,5742],[7597,5733],[7596,5722],[7602,5728],[7604,5717],[7608,5713],[7612,5732],[7609,5734],[7599,5753],[7596,5755],[7593,5767],[7588,5773],[7588,5788],[7593,5801],[7597,5804],[7599,5819],[7594,5833],[7605,5855],[7609,5857],[7607,5846],[7610,5835],[7616,5836],[7624,5856],[7648,5866],[7669,5886],[7684,5892],[7689,5890],[7698,5894],[7704,5890],[7715,5892],[7727,5901],[7746,5904],[7755,5913],[7769,5910],[7774,5913],[7788,5915],[7810,5923],[7820,5932],[7838,5959],[7850,5968],[7845,5974],[7845,5995],[7857,6010],[7870,6022],[7869,6016],[7886,5987],[7889,6003],[7895,5997],[7891,6011],[7882,6018],[7889,6019],[7887,6028],[7899,6022],[7897,6027],[7906,6021],[7922,6022],[7911,6023],[7912,6056],[7926,6053],[7926,6060],[7931,6064],[7938,6059],[7941,6062],[7934,6065],[7931,6074],[7939,6078],[7942,6074],[7949,6078],[7959,6078],[7958,6082],[7964,6092],[7976,6096],[7971,6091],[7976,6086],[7983,6093],[7980,6099],[7986,6101],[7991,6094],[7997,6096],[8022,6072],[8018,6054],[8028,6069],[8033,6070],[8052,6064],[8053,6067],[8066,6061],[8061,6069],[8070,6067],[8057,6081],[8068,6097],[8073,6110],[8075,6107],[8083,6113],[8080,6125],[8085,6126],[8086,6133],[8092,6134],[8095,6141],[8102,6133],[8100,6141],[8107,6141],[8106,6148],[8112,6145],[8114,6151],[8119,6144],[8132,6146],[8136,6143],[8145,6150],[8155,6148],[8154,6157],[8149,6168],[8138,6167],[8133,6175],[8152,6181],[8155,6167],[8162,6172],[8169,6161],[8182,6158],[8188,6161],[8206,6151],[8216,6154],[8225,6145],[8249,6158],[8242,6148],[8245,6143],[8249,6148],[8254,6146],[8254,6139],[8261,6140],[8259,6148],[8267,6158],[8262,6164],[8267,6168],[8271,6160],[8267,6154],[8273,6144],[8277,6149],[8280,6144],[8271,6132],[8266,6129],[8269,6122],[8263,6113],[8264,6121],[8257,6111],[8252,6116],[8248,6109],[8250,6101],[8260,6098],[8250,6094],[8250,6087],[8245,6085],[8239,6074],[8236,6066],[8259,6051],[8268,6042],[8279,6045],[8284,6044],[8282,6037],[8293,6029],[8304,6026],[8313,6015],[8320,6011],[8341,6006],[8349,6019],[8358,6021],[8354,6013],[8348,6011],[8345,5998],[8348,5993],[8370,5982],[8385,5984],[8395,5990],[8402,6009],[8406,6012],[8412,6031],[8411,6035],[8419,6060],[8415,6079],[8417,6087],[8414,6094],[8415,6106],[8420,6115],[8417,6123],[8427,6135],[8417,6136],[8423,6151],[8428,6151],[8428,6158],[8433,6172],[8435,6189],[8433,6192],[8433,6206],[8439,6206],[8435,6194],[8438,6191],[8447,6189],[8455,6171],[8455,6157],[8465,6153],[8461,6143],[8471,6134],[8476,6107],[8474,6100],[8479,6093],[8481,6083],[8486,6078],[8502,6088],[8508,6076],[8515,6075],[8518,6069],[8528,6065],[8525,6050],[8531,6031],[8530,6023],[8534,6013],[8544,6001],[8551,5984],[8547,5969],[8554,5966],[8557,5960],[8555,5946],[8561,5940],[8577,5935],[8580,5930],[8589,5930],[8593,5921],[8600,5917],[8614,5913],[8618,5907],[8622,5911],[8631,5902],[8634,5907],[8639,5898],[8625,5895],[8631,5887],[8642,5879],[8649,5859],[8653,5844],[8666,5831],[8661,5846],[8666,5847],[8670,5839],[8683,5832],[8680,5844],[8687,5837],[8689,5830],[8687,5815],[8691,5803],[8701,5805],[8702,5795],[8707,5789],[8721,5785],[8727,5771],[8738,5763],[8742,5752],[8753,5748],[8754,5752],[8760,5760],[8762,5766],[8764,5758],[8755,5733],[8752,5740]]],[[[8564,5227],[8577,5234],[8590,5232],[8596,5239],[8601,5236],[8605,5242],[8616,5233],[8614,5226],[8614,5205],[8617,5194],[8611,5196],[8606,5187],[8605,5175],[8605,5154],[8600,5153],[8595,5162],[8600,5160],[8601,5166],[8591,5167],[8583,5152],[8585,5153],[8585,5144],[8579,5153],[8573,5142],[8568,5140],[8563,5143],[8548,5142],[8544,5151],[8533,5164],[8525,5176],[8523,5191],[8532,5183],[8524,5199],[8515,5208],[8510,5218],[8508,5230],[8509,5251],[8521,5239],[8525,5240],[8539,5235],[8553,5227],[8564,5227]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KI&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.28,&#34;hc-middle-y&#34;:0.65,&#34;hc-key&#34;:&#34;ki&#34;,&#34;hc-a2&#34;:&#34;KI&#34;,&#34;name&#34;:&#34;Kiribati&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Kir.&#34;,&#34;subregion&#34;:&#34;Micronesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;KIR&#34;,&#34;iso-a2&#34;:&#34;KI&#34;,&#34;woe-id&#34;:&#34;23424867&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[-387,6564],[-384,6559],[-380,6555],[-386,6557],[-387,6564]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.43,&#34;hc-middle-y&#34;:0.15,&#34;hc-key&#34;:&#34;ph&#34;,&#34;hc-a2&#34;:&#34;PH&#34;,&#34;name&#34;:&#34;Philippines&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Phil.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;PHL&#34;,&#34;iso-a2&#34;:&#34;PH&#34;,&#34;woe-id&#34;:&#34;23424934&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7829,6697],[7842,6703],[7850,6699],[7839,6693],[7835,6698],[7829,6697]]],[[[7915,6802],[7914,6792],[7908,6787],[7895,6788],[7896,6796],[7904,6803],[7915,6802]]],[[[7884,6775],[7889,6772],[7871,6770],[7866,6778],[7858,6782],[7852,6794],[7854,6798],[7866,6802],[7864,6814],[7869,6824],[7876,6828],[7887,6823],[7874,6795],[7874,6787],[7884,6775]]],[[[7892,6832],[7901,6836],[7900,6810],[7889,6800],[7884,6785],[7879,6784],[7882,6800],[7895,6821],[7898,6831],[7892,6832]]],[[[7910,6848],[7916,6848],[7913,6842],[7918,6837],[7924,6841],[7930,6835],[7929,6821],[7934,6816],[7937,6807],[7933,6807],[7938,6797],[7928,6810],[7930,6799],[7922,6803],[7922,6823],[7915,6828],[7913,6820],[7911,6826],[7910,6848]]],[[[7840,6865],[7840,6875],[7859,6872],[7859,6866],[7844,6874],[7841,6861],[7843,6853],[7860,6844],[7862,6846],[7875,6842],[7873,6833],[7863,6827],[7859,6812],[7855,6813],[7858,6819],[7847,6818],[7839,6811],[7838,6821],[7842,6829],[7844,6848],[7836,6851],[7840,6865]]],[[[7784,6854],[7778,6867],[7792,6860],[7790,6853],[7786,6859],[7784,6854]]],[[[7924,6844],[7930,6851],[7926,6851],[7919,6859],[7911,6864],[7907,6874],[7930,6874],[7934,6875],[7943,6865],[7942,6846],[7949,6832],[7936,6831],[7924,6844]]],[[[7887,6876],[7891,6876],[7893,6863],[7901,6857],[7901,6850],[7882,6864],[7874,6855],[7878,6870],[7887,6876]]],[[[7789,6908],[7793,6903],[7804,6901],[7809,6903],[7817,6901],[7824,6892],[7832,6885],[7825,6885],[7827,6876],[7818,6864],[7814,6867],[7805,6879],[7801,6892],[7792,6899],[7789,6908]]],[[[7906,6919],[7911,6907],[7905,6903],[7900,6907],[7903,6919],[7906,6919]]],[[[7940,6701],[7946,6693],[7950,6684],[7941,6669],[7939,6662],[7937,6680],[7933,6684],[7931,6677],[7917,6681],[7906,6686],[7901,6694],[7900,6714],[7907,6722],[7901,6728],[7891,6734],[7883,6734],[7880,6727],[7882,6721],[7874,6727],[7873,6732],[7868,6720],[7864,6719],[7864,6732],[7855,6731],[7843,6707],[7838,6710],[7843,6732],[7851,6741],[7868,6744],[7872,6755],[7879,6755],[7881,6761],[7892,6758],[7896,6744],[7906,6746],[7911,6757],[7921,6754],[7922,6771],[7932,6764],[7935,6772],[7944,6770],[7940,6789],[7944,6800],[7944,6808],[7949,6810],[7949,6801],[7947,6788],[7956,6787],[7960,6800],[7963,6792],[7957,6791],[7960,6776],[7968,6765],[7961,6757],[7969,6756],[7969,6745],[7972,6747],[7970,6735],[7975,6731],[7976,6718],[7966,6703],[7964,6689],[7960,6706],[7952,6721],[7952,6707],[7948,6713],[7944,6711],[7940,6701]]],[[[7767,6841],[7771,6829],[7767,6828],[7769,6818],[7774,6815],[7776,6812],[7763,6808],[7759,6801],[7745,6795],[7745,6791],[7737,6778],[7727,6773],[7723,6766],[7703,6753],[7703,6745],[7693,6734],[7692,6741],[7699,6747],[7700,6754],[7712,6771],[7723,6776],[7738,6792],[7747,6804],[7756,6810],[7762,6820],[7759,6824],[7767,6841]]],[[[7855,6928],[7866,6925],[7872,6917],[7873,6909],[7879,6912],[7876,6917],[7897,6911],[7887,6909],[7885,6906],[7894,6895],[7894,6898],[7905,6893],[7902,6874],[7899,6874],[7893,6882],[7883,6889],[7878,6884],[7880,6879],[7868,6891],[7858,6893],[7850,6905],[7846,6906],[7840,6893],[7835,6898],[7837,6904],[7844,6910],[7832,6916],[7824,6911],[7824,6907],[7816,6907],[7808,6914],[7800,6912],[7798,6922],[7810,6933],[7808,6939],[7798,6942],[7799,6932],[7795,6930],[7792,6936],[7784,6941],[7782,6955],[7778,6960],[7778,6973],[7775,6975],[7776,6988],[7781,6988],[7785,6979],[7793,6982],[7790,6995],[7794,7007],[7791,7024],[7799,7047],[7798,7052],[7807,7057],[7809,7054],[7820,7063],[7814,7057],[7828,7049],[7840,7046],[7847,7053],[7849,7045],[7845,7040],[7844,7029],[7848,7018],[7856,7010],[7846,6990],[7846,6984],[7833,6979],[7828,6975],[7829,6967],[7822,6958],[7826,6949],[7841,6948],[7839,6936],[7829,6938],[7832,6923],[7838,6917],[7847,6914],[7839,6922],[7849,6920],[7855,6928]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MX&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.51,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;mx&#34;,&#34;hc-a2&#34;:&#34;MX&#34;,&#34;name&#34;:&#34;Mexico&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Mex.&#34;,&#34;subregion&#34;:&#34;Central America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;MEX&#34;,&#34;iso-a2&#34;:&#34;MX&#34;,&#34;woe-id&#34;:&#34;23424900&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[1694,7115],[1687,7106],[1686,7110],[1689,7115],[1694,7115]]],[[[1107,7151],[1111,7149],[1121,7137],[1113,7142],[1107,7151]]],[[[951,7237],[955,7237],[960,7233],[959,7230],[951,7237]]],[[[946,7252],[944,7247],[942,7246],[944,7253],[946,7252]]],[[[857,7349],[855,7347],[852,7350],[857,7358],[857,7349]]],[[[767,7375],[766,7375],[763,7383],[767,7380],[767,7375]]],[[[935,7369],[933,7374],[937,7384],[942,7385],[945,7379],[941,7370],[935,7369]]],[[[906,7395],[910,7388],[916,7387],[918,7378],[904,7391],[906,7395]]],[[[1268,7397],[1267,7394],[1273,7393],[1284,7382],[1296,7355],[1302,7351],[1308,7340],[1318,7333],[1320,7316],[1326,7308],[1328,7301],[1331,7296],[1339,7295],[1356,7286],[1373,7284],[1380,7279],[1388,7282],[1387,7275],[1379,7258],[1373,7237],[1370,7198],[1370,7189],[1367,7176],[1373,7148],[1380,7136],[1388,7118],[1408,7094],[1413,7078],[1422,7069],[1427,7060],[1446,7059],[1457,7053],[1467,7042],[1494,7050],[1514,7051],[1519,7056],[1538,7059],[1544,7056],[1571,7073],[1577,7079],[1579,7091],[1584,7096],[1585,7120],[1589,7130],[1605,7137],[1624,7140],[1644,7146],[1653,7147],[1679,7142],[1683,7148],[1692,7142],[1695,7136],[1690,7124],[1674,7105],[1673,7094],[1667,7083],[1671,7075],[1664,7050],[1661,7045],[1655,7052],[1656,7064],[1648,7052],[1643,7052],[1632,7034],[1626,7037],[1623,7032],[1569,7032],[1569,7015],[1556,7015],[1567,7004],[1575,7001],[1587,6988],[1584,6979],[1547,6979],[1533,6955],[1537,6949],[1532,6934],[1514,6953],[1491,6972],[1484,6980],[1468,6986],[1482,6977],[1469,6982],[1460,6984],[1455,6990],[1449,6985],[1457,6984],[1444,6982],[1438,6976],[1423,6972],[1415,6968],[1405,6967],[1384,6975],[1369,6976],[1358,6983],[1346,6987],[1340,6994],[1336,6993],[1316,6998],[1304,7004],[1273,7015],[1255,7027],[1251,7034],[1239,7035],[1223,7039],[1201,7047],[1195,7057],[1177,7070],[1157,7078],[1141,7099],[1136,7110],[1147,7114],[1150,7117],[1142,7122],[1150,7130],[1151,7142],[1143,7148],[1138,7158],[1137,7167],[1133,7179],[1115,7196],[1112,7203],[1104,7210],[1101,7216],[1079,7235],[1068,7241],[1064,7248],[1064,7254],[1059,7260],[1048,7264],[1039,7265],[1026,7277],[1026,7284],[1033,7294],[1026,7306],[1018,7305],[1011,7315],[1001,7319],[993,7327],[992,7341],[983,7341],[973,7348],[966,7358],[959,7361],[953,7372],[946,7378],[944,7388],[931,7407],[928,7416],[917,7436],[920,7447],[905,7452],[902,7458],[893,7462],[887,7458],[874,7467],[867,7459],[866,7446],[871,7440],[873,7426],[872,7416],[880,7403],[886,7402],[902,7387],[911,7372],[913,7373],[918,7362],[928,7365],[925,7355],[928,7342],[933,7335],[940,7332],[956,7306],[957,7311],[964,7305],[963,7301],[971,7286],[970,7278],[978,7286],[973,7276],[982,7261],[988,7261],[994,7248],[988,7238],[991,7229],[1000,7226],[999,7235],[1004,7229],[1015,7226],[1015,7218],[1018,7211],[1025,7207],[1026,7197],[1013,7186],[1007,7191],[1000,7207],[992,7211],[979,7224],[963,7232],[960,7239],[956,7238],[946,7248],[947,7277],[944,7285],[921,7301],[916,7308],[904,7305],[897,7313],[877,7322],[877,7328],[862,7338],[861,7341],[877,7339],[882,7342],[889,7334],[887,7345],[891,7347],[888,7354],[890,7361],[878,7376],[874,7377],[863,7390],[857,7392],[842,7402],[838,7409],[838,7421],[830,7426],[831,7436],[823,7441],[824,7447],[813,7460],[815,7470],[807,7475],[800,7492],[870,7498],[867,7491],[978,7453],[1062,7453],[1062,7467],[1112,7467],[1117,7466],[1122,7457],[1127,7455],[1146,7437],[1160,7428],[1166,7416],[1166,7408],[1171,7399],[1184,7389],[1192,7387],[1207,7378],[1211,7378],[1219,7387],[1225,7402],[1236,7407],[1242,7404],[1263,7403],[1268,7397]],[[1376,7266],[1372,7264],[1370,7251],[1372,7240],[1369,7220],[1370,7215],[1373,7238],[1380,7265],[1376,7266]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ES&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.76,&#34;hc-middle-y&#34;:0.27,&#34;hc-key&#34;:&#34;es&#34;,&#34;hc-a2&#34;:&#34;ES&#34;,&#34;name&#34;:&#34;Spain&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Sp.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;ESP&#34;,&#34;iso-a2&#34;:&#34;ES&#34;,&#34;woe-id&#34;:&#34;23424950&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[3794,7351],[3795,7342],[3790,7338],[3784,7341],[3786,7352],[3794,7351]]],[[[3745,7350],[3738,7349],[3750,7358],[3762,7360],[3774,7364],[3767,7358],[3765,7351],[3757,7346],[3745,7350]]],[[[3840,7374],[3842,7380],[3853,7385],[3852,7379],[3843,7373],[3841,7359],[3837,7354],[3826,7348],[3836,7369],[3840,7374]]],[[[4336,7715],[4337,7719],[4330,7722],[4326,7728],[4322,7724],[4318,7729],[4331,7738],[4342,7742],[4343,7734],[4351,7734],[4344,7722],[4336,7715]]],[[[4306,7828],[4306,7829],[4306,7830],[4307,7828],[4306,7828]]],[[[4161,7584],[4162,7582],[4162,7582],[4161,7584],[4161,7584]]],[[[4089,7604],[4092,7603],[4091,7602],[4090,7603],[4089,7604]]],[[[4090,7611],[4083,7607],[4067,7617],[4065,7626],[4060,7628],[4057,7639],[4045,7646],[4030,7647],[4027,7659],[4034,7673],[4041,7675],[4032,7689],[4034,7699],[4043,7709],[4038,7712],[4033,7724],[4026,7732],[4042,7732],[4046,7743],[4042,7751],[4048,7755],[4047,7772],[4044,7778],[4053,7787],[4062,7792],[4066,7798],[4055,7803],[4055,7811],[4041,7811],[4029,7806],[4021,7809],[4007,7806],[4010,7814],[4006,7818],[3991,7812],[3987,7809],[3986,7817],[3994,7823],[3987,7822],[3988,7837],[3981,7834],[3986,7841],[3980,7839],[3975,7844],[3977,7854],[4003,7863],[4003,7868],[4015,7875],[4031,7872],[4034,7868],[4065,7869],[4089,7868],[4109,7863],[4125,7863],[4143,7867],[4145,7863],[4160,7860],[4167,7864],[4186,7858],[4195,7862],[4197,7858],[4207,7857],[4209,7851],[4226,7846],[4231,7840],[4239,7842],[4247,7837],[4267,7837],[4268,7842],[4288,7838],[4290,7834],[4293,7828],[4299,7830],[4306,7826],[4315,7828],[4322,7824],[4335,7829],[4342,7828],[4346,7824],[4340,7818],[4344,7811],[4335,7803],[4316,7794],[4309,7787],[4294,7784],[4277,7779],[4269,7771],[4273,7766],[4266,7764],[4259,7753],[4250,7744],[4239,7726],[4245,7707],[4255,7700],[4246,7693],[4233,7686],[4226,7667],[4227,7661],[4216,7658],[4209,7659],[4199,7653],[4187,7633],[4172,7634],[4170,7630],[4153,7632],[4118,7630],[4109,7623],[4096,7620],[4091,7611],[4090,7611]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.73,&#34;hc-key&#34;:&#34;bu&#34;,&#34;hc-a2&#34;:&#34;BU&#34;,&#34;name&#34;:&#34;Bajo Nuevo Bank (Petrel Is.)&#34;,&#34;labelrank&#34;:&#34;8&#34;,&#34;country-abbrev&#34;:null,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;-99&#34;,&#34;iso-a2&#34;:&#34;BU&#34;,&#34;woe-id&#34;:&#34;-99&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1893,6971],[1893,6971],[1893,6971],[1893,6971],[1893,6971]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MV&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.27,&#34;hc-middle-y&#34;:0.55,&#34;hc-key&#34;:&#34;mv&#34;,&#34;hc-a2&#34;:&#34;MV&#34;,&#34;name&#34;:&#34;Maldives&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Mald.&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;MDV&#34;,&#34;iso-a2&#34;:&#34;MV&#34;,&#34;woe-id&#34;:&#34;23424899&#34;,&#34;continent&#34;:&#34;Seven seas (open ocean)&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6409,6672],[6417,6662],[6412,6659],[6407,6662],[6411,6667],[6409,6672]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SP&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;sp&#34;,&#34;hc-a2&#34;:&#34;SP&#34;,&#34;name&#34;:&#34;Spratly Islands&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Spratly Is.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;SPI&#34;,&#34;iso-a2&#34;:&#34;SP&#34;,&#34;woe-id&#34;:&#34;23424921&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[7659,6823],[7659,6823],[7659,6823],[7659,6823],[7659,6823]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GB&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.6899999999999999,&#34;hc-middle-y&#34;:0.09,&#34;hc-key&#34;:&#34;gb&#34;,&#34;hc-a2&#34;:&#34;GB&#34;,&#34;name&#34;:&#34;United Kingdom&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;U.K.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;GBR&#34;,&#34;iso-a2&#34;:&#34;GB&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4114,8234],[4114,8240],[4122,8240],[4129,8236],[4120,8229],[4114,8234]]],[[[4071,8333],[4066,8331],[4058,8340],[4069,8342],[4079,8353],[4079,8349],[4071,8333]]],[[[4050,8368],[4054,8373],[4070,8373],[4082,8363],[4062,8357],[4067,8365],[4063,8368],[4050,8368]]],[[[4036,8407],[4031,8403],[4036,8401],[4035,8392],[4026,8386],[4031,8393],[4029,8398],[4031,8408],[4026,8413],[4037,8418],[4036,8407]]],[[[4063,8385],[4064,8389],[4057,8401],[4049,8407],[4058,8409],[4062,8417],[4067,8413],[4069,8399],[4082,8399],[4073,8389],[4063,8385]]],[[[4153,8469],[4155,8465],[4151,8464],[4147,8468],[4153,8469]]],[[[4157,8480],[4156,8473],[4168,8472],[4162,8465],[4160,8471],[4154,8469],[4149,8474],[4157,8480]]],[[[4163,8483],[4158,8488],[4170,8482],[4166,8479],[4163,8483]]],[[[4218,8532],[4215,8530],[4211,8510],[4209,8526],[4205,8524],[4200,8531],[4209,8532],[4212,8536],[4218,8532]]],[[[4221,8545],[4226,8543],[4214,8540],[4216,8549],[4221,8545]]],[[[4225,8552],[4224,8547],[4220,8547],[4221,8552],[4225,8552]]],[[[1853,7077],[1855,7079],[1861,7077],[1855,7076],[1853,7077]]],[[[4113,8268],[4107,8267],[4115,8279],[4120,8281],[4121,8276],[4113,8268]]],[[[2141,7152],[2133,7153],[2133,7155],[2138,7154],[2141,7152]]],[[[2126,7155],[2124,7152],[2119,7152],[2123,7153],[2126,7155]]],[[[4048,8439],[4047,8442],[4064,8452],[4067,8445],[4060,8439],[4061,8432],[4043,8419],[4039,8422],[4047,8427],[4039,8430],[4041,8441],[4048,8439]]],[[[2491,4814],[2491,4826],[2505,4837],[2511,4840],[2506,4843],[2508,4849],[2515,4851],[2512,4855],[2530,4851],[2526,4846],[2535,4841],[2533,4850],[2543,4850],[2546,4844],[2539,4842],[2548,4838],[2528,4830],[2528,4822],[2523,4826],[2513,4822],[2505,4826],[2510,4818],[2500,4821],[2500,4814],[2491,4814]]],[[[3127,4746],[3148,4747],[3145,4745],[3161,4743],[3172,4740],[3188,4726],[3192,4716],[3185,4710],[3175,4724],[3143,4741],[3141,4745],[3127,4746]]],[[[5246,7572],[5245,7571],[5243,7573],[5243,7573],[5242,7573],[5243,7572],[5241,7572],[5241,7573],[5241,7573],[5240,7574],[5242,7574],[5247,7576],[5246,7575],[5243,7575],[5246,7572]],[[5242,7573],[5242,7574],[5242,7574],[5242,7573]]],[[[4091,7611],[4091,7610],[4090,7611],[4091,7611]]],[[[5220,7561],[5217,7562],[5213,7562],[5215,7563],[5220,7561]]],[[[4035,8308],[4040,8306],[4043,8313],[4049,8312],[4063,8317],[4070,8312],[4080,8294],[4085,8291],[4080,8278],[4082,8273],[4076,8273],[4070,8266],[4064,8268],[4053,8266],[4053,8271],[4042,8281],[4033,8269],[4017,8273],[4008,8283],[4021,8289],[4015,8292],[4026,8294],[4030,8305],[4035,8308]]],[[[2464,4852],[2477,4846],[2481,4850],[2487,4848],[2504,4849],[2485,4828],[2473,4825],[2471,4820],[2464,4817],[2451,4824],[2466,4826],[2476,4837],[2465,4834],[2463,4839],[2475,4839],[2464,4849],[2464,4852],[2464,4852],[2464,4852]]],[[[4078,8424],[4088,8424],[4095,8428],[4090,8431],[4094,8436],[4089,8441],[4100,8441],[4096,8445],[4101,8457],[4111,8454],[4136,8455],[4148,8458],[4159,8458],[4157,8448],[4153,8443],[4128,8428],[4129,8422],[4137,8423],[4123,8409],[4143,8415],[4145,8418],[4178,8416],[4191,8417],[4196,8408],[4190,8401],[4184,8384],[4177,8377],[4174,8371],[4163,8365],[4172,8357],[4161,8354],[4155,8349],[4143,8347],[4158,8344],[4171,8348],[4185,8342],[4195,8331],[4200,8329],[4204,8311],[4213,8290],[4232,8283],[4237,8275],[4246,8269],[4242,8265],[4252,8250],[4243,8249],[4253,8243],[4258,8233],[4258,8227],[4249,8219],[4259,8216],[4265,8223],[4286,8221],[4298,8214],[4300,8204],[4295,8188],[4279,8176],[4276,8169],[4269,8164],[4277,8159],[4290,8161],[4288,8150],[4280,8148],[4277,8142],[4272,8143],[4256,8135],[4243,8139],[4214,8137],[4217,8133],[4210,8129],[4204,8134],[4194,8135],[4190,8130],[4178,8131],[4176,8129],[4164,8135],[4148,8131],[4141,8115],[4129,8118],[4124,8123],[4116,8119],[4108,8119],[4099,8114],[4095,8105],[4088,8114],[4107,8130],[4114,8138],[4115,8146],[4121,8145],[4126,8153],[4137,8155],[4149,8152],[4158,8153],[4159,8158],[4168,8165],[4161,8167],[4154,8161],[4143,8161],[4135,8170],[4121,8172],[4120,8176],[4103,8169],[4094,8174],[4092,8179],[4099,8185],[4106,8185],[4125,8195],[4129,8206],[4128,8221],[4118,8220],[4115,8216],[4108,8216],[4120,8225],[4125,8233],[4154,8240],[4163,8253],[4158,8255],[4159,8261],[4166,8269],[4164,8272],[4153,8269],[4141,8285],[4148,8300],[4154,8303],[4143,8305],[4143,8300],[4132,8295],[4119,8301],[4120,8293],[4116,8292],[4105,8299],[4105,8290],[4097,8299],[4101,8310],[4112,8325],[4110,8330],[4101,8335],[4091,8346],[4088,8344],[4092,8334],[4097,8332],[4098,8323],[4091,8325],[4089,8331],[4079,8317],[4081,8332],[4083,8336],[4081,8345],[4086,8354],[4082,8359],[4097,8380],[4081,8367],[4071,8372],[4075,8374],[4065,8376],[4077,8379],[4075,8383],[4084,8403],[4077,8403],[4076,8412],[4082,8410],[4078,8417],[4078,8424]]],[[[2464,4852],[2464,4852],[2464,4855],[2464,4852],[2464,4852],[2464,4852]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.34,&#34;hc-middle-y&#34;:0.44,&#34;hc-key&#34;:&#34;gr&#34;,&#34;hc-a2&#34;:&#34;GR&#34;,&#34;name&#34;:&#34;Greece&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Greece&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;GRC&#34;,&#34;iso-a2&#34;:&#34;GR&#34;,&#34;woe-id&#34;:&#34;23424833&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5043,7587],[5050,7601],[5048,7594],[5050,7589],[5043,7587]]],[[[5061,7614],[5079,7622],[5074,7611],[5066,7603],[5061,7614]]],[[[5049,7627],[5041,7630],[5048,7637],[5047,7632],[5049,7627]]],[[[5040,7643],[5044,7641],[5041,7638],[5042,7641],[5040,7643]]],[[[4990,7640],[4985,7641],[5000,7647],[5007,7644],[5001,7641],[4995,7629],[4990,7640]]],[[[4976,7641],[4975,7640],[4966,7651],[4968,7657],[4976,7641]]],[[[5023,7662],[5015,7658],[5013,7659],[5016,7662],[5023,7662]]],[[[5042,7666],[5045,7664],[5037,7662],[5031,7666],[5042,7666]]],[[[4857,7672],[4866,7665],[4861,7662],[4855,7668],[4850,7684],[4855,7690],[4861,7679],[4857,7672]]],[[[5016,7694],[5019,7684],[5013,7680],[5014,7686],[5009,7694],[5016,7694]]],[[[5026,7719],[5032,7710],[5026,7707],[5009,7714],[5010,7717],[5024,7721],[5026,7719]]],[[[5004,7760],[5002,7757],[4997,7759],[5000,7761],[5004,7760]]],[[[5022,7583],[5018,7573],[4995,7573],[4977,7571],[4976,7576],[4967,7579],[4956,7580],[4941,7583],[4943,7594],[4947,7590],[4961,7591],[4963,7586],[4976,7587],[4987,7585],[5004,7585],[5009,7577],[5022,7583]]],[[[4867,7767],[4870,7769],[4867,7767],[4865,7769],[4866,7770],[4867,7772],[4870,7772],[4889,7775],[4893,7781],[4902,7783],[4917,7783],[4923,7789],[4943,7791],[4956,7796],[4970,7797],[4978,7790],[4981,7792],[4991,7786],[5001,7789],[5017,7790],[5015,7802],[5024,7803],[5031,7798],[5033,7792],[5023,7786],[5024,7776],[5015,7768],[5011,7772],[5000,7773],[4985,7778],[4979,7772],[4978,7764],[4970,7765],[4974,7771],[4972,7776],[4958,7768],[4950,7770],[4946,7766],[4966,7749],[4953,7755],[4947,7755],[4948,7750],[4955,7747],[4954,7742],[4945,7750],[4935,7750],[4946,7740],[4937,7743],[4934,7751],[4922,7756],[4923,7765],[4915,7759],[4913,7745],[4921,7736],[4936,7714],[4943,7715],[4947,7711],[4934,7713],[4924,7721],[4921,7714],[4927,7710],[4919,7701],[4934,7696],[4935,7691],[4943,7690],[4944,7690],[4944,7693],[4935,7700],[4925,7704],[4934,7710],[4940,7703],[4949,7698],[4959,7696],[4968,7705],[4972,7700],[4960,7688],[4965,7680],[4972,7680],[4984,7666],[4992,7661],[4996,7654],[4984,7662],[4975,7672],[4966,7673],[4961,7677],[4956,7688],[4947,7688],[4953,7684],[4957,7664],[4953,7663],[4946,7672],[4932,7673],[4926,7669],[4931,7668],[4930,7661],[4942,7666],[4936,7659],[4943,7653],[4933,7654],[4917,7659],[4918,7654],[4929,7633],[4926,7631],[4931,7621],[4927,7611],[4923,7614],[4925,7624],[4919,7633],[4913,7633],[4911,7622],[4906,7624],[4907,7630],[4901,7641],[4894,7640],[4893,7631],[4887,7635],[4884,7643],[4887,7650],[4883,7659],[4870,7669],[4878,7682],[4885,7679],[4895,7686],[4902,7681],[4921,7675],[4932,7678],[4917,7685],[4913,7684],[4895,7688],[4889,7685],[4876,7688],[4871,7684],[4869,7692],[4862,7702],[4853,7694],[4855,7701],[4867,7709],[4857,7711],[4841,7727],[4840,7721],[4834,7724],[4826,7734],[4833,7737],[4835,7725],[4842,7730],[4837,7732],[4842,7730],[4849,7737],[4846,7742],[4856,7746],[4867,7767]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AS&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5600000000000001,&#34;hc-middle-y&#34;:0.57,&#34;hc-key&#34;:&#34;as&#34;,&#34;hc-a2&#34;:&#34;AS&#34;,&#34;name&#34;:&#34;American Samoa&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Am. Samoa&#34;,&#34;subregion&#34;:&#34;Polynesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;ASM&#34;,&#34;iso-a2&#34;:&#34;AS&#34;,&#34;woe-id&#34;:&#34;23424746&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[-775,6085],[-777,6084],[-779,6082],[-782,6083],[-775,6085]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;DK&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.19,&#34;hc-middle-y&#34;:0.43,&#34;hc-key&#34;:&#34;dk&#34;,&#34;hc-a2&#34;:&#34;DK&#34;,&#34;name&#34;:&#34;Denmark&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Den.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;DNK&#34;,&#34;iso-a2&#34;:&#34;DK&#34;,&#34;woe-id&#34;:&#34;23424796&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4580,8303],[4590,8297],[4593,8300],[4597,8294],[4595,8290],[4585,8290],[4572,8295],[4574,8303],[4580,8303]]],[[[4553,8300],[4558,8299],[4554,8298],[4548,8304],[4553,8300]]],[[[4617,8305],[4608,8300],[4607,8304],[4611,8306],[4617,8305]]],[[[4537,8308],[4543,8303],[4542,8299],[4536,8301],[4537,8308]]],[[[4567,8302],[4564,8295],[4562,8298],[4571,8311],[4567,8302]]],[[[4687,8314],[4694,8310],[4692,8304],[4681,8309],[4683,8317],[4687,8314]]],[[[4558,8337],[4561,8341],[4561,8330],[4565,8325],[4567,8314],[4564,8307],[4549,8309],[4540,8314],[4533,8325],[4553,8330],[4558,8337]]],[[[4619,8334],[4609,8327],[4608,8323],[4615,8317],[4607,8314],[4606,8304],[4599,8305],[4607,8298],[4600,8292],[4593,8302],[4598,8304],[4591,8312],[4580,8313],[4575,8332],[4592,8342],[4596,8333],[4602,8343],[4598,8345],[4609,8351],[4620,8348],[4617,8343],[4619,8334]]],[[[4526,8297],[4508,8301],[4503,8300],[4504,8310],[4502,8323],[4487,8327],[4489,8338],[4495,8342],[4492,8349],[4487,8351],[4487,8369],[4500,8370],[4505,8366],[4506,8372],[4512,8379],[4523,8374],[4518,8383],[4526,8389],[4531,8386],[4537,8392],[4520,8388],[4510,8387],[4510,8380],[4503,8374],[4498,8379],[4499,8371],[4491,8380],[4502,8393],[4525,8395],[4530,8398],[4542,8413],[4548,8413],[4561,8419],[4555,8412],[4559,8406],[4559,8398],[4551,8384],[4553,8369],[4567,8368],[4571,8364],[4565,8355],[4558,8350],[4555,8358],[4549,8352],[4550,8342],[4540,8339],[4544,8336],[4528,8325],[4534,8316],[4528,8311],[4535,8304],[4526,8297]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GL&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.55,&#34;hc-middle-y&#34;:0.42,&#34;hc-key&#34;:&#34;gl&#34;,&#34;hc-a2&#34;:&#34;GL&#34;,&#34;name&#34;:&#34;Greenland&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Grlnd.&#34;,&#34;subregion&#34;:&#34;Northern America&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;GRL&#34;,&#34;iso-a2&#34;:&#34;GL&#34;,&#34;woe-id&#34;:&#34;23424828&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[2951,8524],[2941,8515],[2940,8523],[2939,8522],[2936,8514],[2911,8525],[2913,8534],[2917,8536],[2910,8545],[2906,8538],[2900,8544],[2881,8549],[2888,8550],[2897,8558],[2908,8560],[2913,8565],[2893,8557],[2891,8560],[2903,8565],[2898,8572],[2896,8565],[2887,8560],[2889,8557],[2878,8551],[2862,8554],[2857,8551],[2856,8559],[2851,8554],[2836,8554],[2843,8549],[2833,8548],[2828,8554],[2844,8562],[2833,8560],[2829,8570],[2816,8572],[2818,8575],[2807,8573],[2810,8577],[2804,8579],[2828,8586],[2824,8589],[2806,8582],[2798,8589],[2808,8603],[2795,8596],[2793,8603],[2808,8610],[2803,8611],[2796,8606],[2785,8607],[2788,8612],[2797,8613],[2789,8618],[2779,8618],[2767,8629],[2772,8649],[2758,8651],[2758,8662],[2753,8662],[2756,8653],[2747,8660],[2740,8673],[2735,8674],[2736,8681],[2732,8689],[2734,8697],[2727,8699],[2750,8703],[2756,8707],[2763,8705],[2771,8710],[2760,8707],[2764,8715],[2752,8707],[2734,8703],[2727,8709],[2739,8707],[2746,8725],[2739,8718],[2726,8716],[2727,8713],[2715,8705],[2713,8731],[2721,8738],[2731,8740],[2739,8748],[2726,8741],[2712,8737],[2711,8742],[2717,8745],[2709,8750],[2715,8760],[2709,8756],[2711,8762],[2705,8757],[2700,8762],[2718,8770],[2719,8773],[2703,8765],[2699,8772],[2694,8772],[2697,8781],[2681,8779],[2683,8788],[2674,8796],[2695,8807],[2707,8816],[2716,8819],[2721,8826],[2738,8836],[2757,8845],[2750,8844],[2732,8836],[2718,8827],[2713,8820],[2696,8812],[2688,8804],[2677,8800],[2669,8801],[2671,8807],[2667,8812],[2669,8819],[2683,8819],[2688,8823],[2676,8823],[2682,8831],[2693,8832],[2709,8840],[2694,8839],[2685,8841],[2669,8840],[2659,8848],[2663,8853],[2676,8854],[2713,8862],[2718,8862],[2713,8864],[2684,8858],[2662,8856],[2664,8865],[2690,8878],[2705,8882],[2724,8876],[2734,8878],[2760,8869],[2738,8880],[2747,8880],[2757,8885],[2767,8886],[2754,8890],[2755,8885],[2741,8882],[2736,8888],[2748,8890],[2745,8893],[2730,8891],[2737,8885],[2735,8881],[2726,8879],[2707,8885],[2693,8884],[2668,8869],[2666,8875],[2671,8877],[2667,8885],[2683,8889],[2680,8894],[2687,8897],[2683,8904],[2702,8899],[2700,8904],[2719,8896],[2740,8898],[2758,8890],[2767,8891],[2749,8897],[2734,8905],[2747,8903],[2737,8908],[2742,8909],[2742,8915],[2728,8915],[2740,8909],[2710,8905],[2704,8903],[2700,8912],[2678,8908],[2698,8917],[2705,8918],[2705,8926],[2721,8925],[2718,8921],[2730,8921],[2742,8923],[2747,8932],[2738,8933],[2744,8943],[2744,8952],[2753,8952],[2761,8947],[2761,8943],[2771,8947],[2757,8953],[2767,8952],[2772,8957],[2763,8955],[2762,8961],[2750,8954],[2743,8956],[2751,8960],[2751,8969],[2770,8973],[2763,8974],[2752,8971],[2751,8978],[2762,8979],[2752,8982],[2759,8987],[2769,8986],[2766,8992],[2759,8994],[2768,9000],[2748,8996],[2739,8996],[2746,9001],[2739,9001],[2734,8996],[2728,8998],[2707,9000],[2699,9009],[2681,9016],[2663,9018],[2653,9023],[2641,9036],[2649,9040],[2659,9042],[2675,9038],[2694,9038],[2704,9035],[2730,9020],[2757,9015],[2760,9026],[2753,9020],[2747,9020],[2722,9037],[2732,9033],[2739,9041],[2756,9035],[2750,9041],[2733,9046],[2727,9043],[2714,9043],[2714,9049],[2722,9055],[2741,9049],[2749,9052],[2733,9054],[2737,9059],[2716,9056],[2710,9058],[2731,9068],[2725,9070],[2705,9059],[2701,9061],[2710,9067],[2710,9071],[2721,9075],[2734,9075],[2727,9079],[2705,9071],[2688,9074],[2697,9079],[2724,9084],[2727,9089],[2712,9084],[2698,9088],[2680,9089],[2692,9098],[2694,9106],[2687,9101],[2688,9097],[2677,9094],[2678,9098],[2674,9110],[2667,9112],[2663,9124],[2660,9123],[2663,9114],[2672,9107],[2676,9097],[2668,9091],[2662,9092],[2666,9086],[2656,9090],[2655,9085],[2663,9080],[2660,9075],[2640,9070],[2629,9075],[2620,9072],[2614,9075],[2609,9085],[2602,9088],[2616,9095],[2621,9101],[2611,9105],[2613,9108],[2632,9119],[2628,9129],[2622,9125],[2619,9131],[2615,9127],[2614,9134],[2642,9131],[2635,9136],[2629,9134],[2637,9145],[2631,9149],[2641,9152],[2633,9159],[2615,9165],[2609,9164],[2623,9175],[2615,9176],[2621,9183],[2609,9194],[2598,9197],[2607,9203],[2601,9210],[2609,9212],[2596,9216],[2599,9220],[2587,9222],[2596,9234],[2583,9228],[2561,9224],[2573,9230],[2590,9235],[2578,9238],[2595,9240],[2581,9244],[2592,9247],[2574,9260],[2565,9261],[2576,9266],[2568,9272],[2543,9280],[2536,9281],[2542,9285],[2533,9289],[2521,9299],[2533,9303],[2536,9306],[2528,9310],[2531,9315],[2524,9316],[2527,9320],[2510,9318],[2502,9325],[2503,9329],[2492,9325],[2488,9327],[2494,9331],[2484,9332],[2478,9338],[2461,9336],[2456,9346],[2438,9347],[2418,9350],[2415,9354],[2398,9350],[2398,9355],[2379,9359],[2372,9348],[2363,9345],[2357,9352],[2359,9356],[2351,9358],[2353,9352],[2344,9353],[2343,9344],[2334,9347],[2335,9343],[2324,9347],[2324,9338],[2308,9343],[2318,9351],[2313,9353],[2299,9353],[2293,9342],[2278,9353],[2266,9346],[2273,9345],[2274,9340],[2291,9333],[2233,9341],[2233,9345],[2198,9360],[2200,9363],[2219,9368],[2225,9372],[2245,9372],[2247,9378],[2219,9377],[2190,9382],[2184,9385],[2195,9396],[2175,9385],[2168,9385],[2158,9391],[2164,9394],[2148,9397],[2152,9406],[2167,9407],[2161,9410],[2195,9413],[2228,9408],[2250,9410],[2277,9406],[2286,9407],[2246,9412],[2240,9411],[2214,9415],[2235,9421],[2263,9422],[2282,9420],[2292,9416],[2285,9424],[2301,9425],[2303,9429],[2297,9436],[2284,9440],[2271,9440],[2268,9434],[2258,9431],[2236,9429],[2235,9433],[2227,9439],[2222,9439],[2227,9430],[2210,9426],[2179,9434],[2201,9441],[2202,9445],[2185,9440],[2167,9440],[2167,9442],[2185,9452],[2176,9452],[2167,9447],[2149,9446],[2150,9454],[2139,9452],[2140,9456],[2131,9454],[2121,9457],[2120,9464],[2111,9465],[2102,9471],[2109,9479],[2103,9481],[2109,9486],[2111,9494],[2130,9497],[2141,9502],[2164,9499],[2165,9505],[2188,9509],[2190,9513],[2206,9512],[2216,9524],[2245,9530],[2253,9528],[2255,9532],[2278,9532],[2282,9535],[2306,9532],[2303,9534],[2314,9539],[2322,9548],[2330,9550],[2339,9559],[2340,9565],[2334,9569],[2336,9577],[2331,9581],[2336,9589],[2333,9594],[2354,9597],[2360,9602],[2359,9608],[2350,9599],[2337,9597],[2325,9598],[2309,9593],[2292,9600],[2289,9597],[2274,9596],[2270,9603],[2262,9604],[2262,9615],[2282,9623],[2283,9629],[2301,9633],[2303,9637],[2319,9637],[2316,9642],[2331,9645],[2335,9654],[2341,9654],[2341,9660],[2366,9664],[2376,9671],[2384,9657],[2400,9644],[2388,9657],[2382,9671],[2394,9676],[2417,9674],[2436,9665],[2437,9668],[2450,9669],[2454,9673],[2443,9686],[2457,9693],[2458,9696],[2442,9708],[2439,9713],[2444,9718],[2466,9725],[2480,9727],[2493,9723],[2516,9721],[2521,9714],[2520,9708],[2542,9702],[2549,9702],[2569,9691],[2565,9697],[2548,9706],[2536,9707],[2526,9722],[2497,9731],[2523,9738],[2549,9743],[2569,9744],[2586,9748],[2592,9743],[2601,9751],[2621,9749],[2621,9754],[2645,9758],[2656,9754],[2671,9739],[2669,9733],[2673,9724],[2665,9713],[2664,9699],[2673,9699],[2671,9706],[2690,9721],[2687,9731],[2690,9734],[2712,9729],[2716,9727],[2735,9724],[2768,9711],[2771,9705],[2778,9703],[2778,9711],[2761,9716],[2750,9722],[2746,9728],[2781,9722],[2792,9727],[2759,9742],[2755,9746],[2752,9755],[2743,9768],[2805,9764],[2813,9757],[2846,9748],[2848,9743],[2858,9743],[2894,9733],[2896,9727],[2912,9721],[2919,9716],[2930,9715],[2946,9720],[2927,9729],[2925,9734],[2941,9738],[2930,9744],[2936,9752],[2946,9754],[2964,9750],[2990,9749],[2991,9746],[3002,9748],[2980,9752],[2975,9751],[2958,9756],[2961,9760],[2941,9766],[2935,9772],[2904,9783],[2901,9787],[3010,9786],[3007,9782],[3015,9779],[3015,9771],[3020,9766],[3025,9769],[3023,9777],[3015,9784],[3024,9785],[3048,9775],[3052,9772],[3064,9772],[3070,9766],[3069,9761],[3076,9757],[3078,9767],[3072,9770],[3072,9781],[3061,9784],[3053,9783],[3042,9787],[2932,9793],[2924,9792],[2905,9795],[2895,9792],[2877,9796],[2869,9802],[2894,9798],[2887,9802],[2873,9804],[2893,9811],[2920,9803],[2920,9799],[2931,9801],[2971,9798],[2920,9806],[2909,9812],[2919,9816],[2931,9811],[2934,9817],[2960,9813],[2986,9812],[2953,9819],[2985,9819],[2974,9823],[2992,9825],[2999,9821],[3008,9822],[3030,9812],[3050,9803],[3087,9801],[3100,9796],[3101,9792],[3111,9785],[3115,9791],[3106,9793],[3106,9796],[3097,9804],[3151,9804],[3141,9807],[3107,9807],[3106,9809],[3161,9814],[3140,9815],[3131,9819],[3109,9819],[3105,9830],[3109,9835],[3135,9830],[3128,9836],[3132,9841],[3142,9842],[3164,9836],[3174,9836],[3163,9839],[3167,9844],[3211,9844],[3226,9849],[3232,9844],[3236,9849],[3241,9843],[3252,9838],[3247,9847],[3292,9851],[3300,9849],[3297,9846],[3313,9849],[3317,9848],[3343,9847],[3346,9849],[3387,9843],[3405,9843],[3409,9840],[3398,9838],[3407,9835],[3419,9836],[3412,9839],[3493,9826],[3480,9819],[3343,9814],[3339,9811],[3301,9808],[3293,9811],[3264,9815],[3291,9809],[3292,9806],[3275,9804],[3201,9798],[3206,9790],[3219,9797],[3246,9798],[3256,9791],[3259,9800],[3275,9802],[3311,9803],[3314,9799],[3324,9805],[3357,9811],[3362,9813],[3442,9808],[3467,9810],[3506,9816],[3517,9812],[3513,9809],[3519,9804],[3509,9797],[3508,9793],[3497,9788],[3528,9796],[3541,9794],[3547,9787],[3552,9792],[3565,9792],[3576,9786],[3581,9789],[3620,9776],[3618,9771],[3591,9762],[3588,9755],[3546,9752],[3545,9751],[3369,9741],[3353,9745],[3318,9747],[3317,9746],[3356,9743],[3367,9737],[3334,9731],[3329,9729],[3313,9728],[3289,9723],[3283,9720],[3285,9709],[3302,9708],[3303,9712],[3315,9719],[3341,9721],[3371,9727],[3378,9723],[3393,9731],[3412,9733],[3426,9733],[3431,9735],[3523,9730],[3521,9715],[3473,9704],[3462,9698],[3468,9696],[3471,9690],[3494,9700],[3498,9699],[3526,9706],[3548,9713],[3557,9711],[3562,9716],[3560,9722],[3565,9732],[3572,9734],[3618,9737],[3626,9729],[3629,9715],[3622,9697],[3606,9682],[3598,9679],[3593,9671],[3584,9669],[3568,9655],[3557,9640],[3546,9635],[3546,9632],[3564,9640],[3573,9648],[3572,9652],[3578,9656],[3591,9658],[3594,9662],[3602,9662],[3619,9674],[3631,9677],[3639,9685],[3664,9698],[3658,9702],[3662,9707],[3670,9709],[3670,9705],[3686,9704],[3675,9687],[3699,9696],[3712,9694],[3724,9689],[3723,9693],[3733,9687],[3743,9689],[3741,9694],[3753,9698],[3746,9700],[3752,9704],[3764,9705],[3763,9713],[3782,9715],[3783,9719],[3801,9718],[3838,9717],[3864,9711],[3868,9711],[3894,9705],[3904,9696],[3913,9693],[3906,9688],[3890,9684],[3879,9673],[3861,9666],[3855,9662],[3834,9662],[3820,9660],[3830,9654],[3827,9645],[3797,9641],[3794,9636],[3770,9635],[3746,9637],[3734,9641],[3734,9636],[3723,9635],[3716,9631],[3701,9631],[3690,9635],[3675,9637],[3653,9630],[3636,9630],[3647,9629],[3649,9623],[3674,9635],[3698,9629],[3717,9625],[3739,9627],[3751,9632],[3764,9624],[3783,9622],[3783,9619],[3764,9607],[3744,9604],[3739,9607],[3722,9603],[3699,9605],[3684,9610],[3675,9610],[3666,9602],[3654,9599],[3660,9598],[3653,9594],[3657,9591],[3649,9584],[3649,9580],[3656,9580],[3660,9570],[3675,9577],[3683,9572],[3677,9567],[3678,9562],[3672,9551],[3675,9546],[3671,9537],[3679,9545],[3691,9543],[3690,9535],[3684,9537],[3682,9532],[3673,9533],[3662,9527],[3666,9521],[3662,9514],[3646,9516],[3643,9511],[3631,9511],[3634,9506],[3624,9501],[3633,9501],[3621,9478],[3620,9466],[3611,9461],[3618,9453],[3627,9460],[3637,9459],[3661,9447],[3678,9444],[3689,9436],[3678,9431],[3659,9441],[3635,9439],[3649,9432],[3646,9427],[3653,9424],[3646,9422],[3667,9419],[3674,9416],[3676,9411],[3687,9409],[3686,9418],[3702,9416],[3709,9411],[3710,9393],[3700,9379],[3687,9388],[3677,9387],[3662,9393],[3644,9394],[3636,9390],[3629,9392],[3608,9391],[3633,9388],[3608,9377],[3602,9384],[3593,9389],[3587,9388],[3591,9382],[3579,9379],[3590,9372],[3596,9376],[3610,9369],[3607,9363],[3596,9363],[3590,9367],[3586,9364],[3595,9361],[3612,9364],[3609,9352],[3614,9350],[3633,9355],[3645,9350],[3661,9352],[3669,9344],[3667,9340],[3659,9340],[3651,9336],[3601,9336],[3605,9334],[3642,9334],[3650,9332],[3661,9332],[3672,9323],[3679,9320],[3671,9317],[3678,9309],[3679,9300],[3676,9290],[3671,9285],[3663,9285],[3661,9293],[3654,9297],[3640,9294],[3624,9302],[3622,9306],[3610,9312],[3593,9315],[3612,9308],[3621,9298],[3631,9295],[3643,9288],[3644,9285],[3625,9284],[3608,9276],[3615,9275],[3627,9282],[3641,9280],[3637,9267],[3641,9261],[3636,9257],[3653,9258],[3668,9252],[3676,9258],[3682,9252],[3692,9257],[3695,9255],[3701,9260],[3709,9260],[3694,9250],[3681,9249],[3690,9246],[3678,9234],[3670,9232],[3653,9234],[3649,9244],[3622,9246],[3611,9244],[3597,9253],[3607,9244],[3599,9237],[3594,9224],[3587,9222],[3601,9218],[3606,9209],[3605,9199],[3609,9201],[3603,9219],[3613,9222],[3639,9212],[3651,9211],[3645,9204],[3643,9187],[3622,9187],[3614,9189],[3613,9184],[3591,9175],[3568,9181],[3542,9195],[3541,9202],[3554,9202],[3576,9193],[3573,9196],[3555,9203],[3547,9203],[3540,9208],[3530,9203],[3528,9192],[3514,9196],[3512,9202],[3491,9213],[3496,9207],[3510,9201],[3512,9194],[3520,9189],[3504,9188],[3499,9181],[3491,9177],[3478,9175],[3468,9181],[3458,9181],[3443,9189],[3449,9181],[3470,9177],[3462,9169],[3451,9172],[3435,9171],[3441,9167],[3444,9159],[3446,9168],[3462,9167],[3470,9172],[3483,9173],[3491,9169],[3511,9166],[3513,9163],[3508,9155],[3518,9156],[3515,9149],[3492,9156],[3483,9150],[3475,9149],[3460,9154],[3449,9150],[3462,9152],[3471,9148],[3462,9145],[3474,9146],[3471,9138],[3477,9146],[3486,9147],[3497,9152],[3521,9143],[3524,9135],[3508,9130],[3485,9129],[3504,9127],[3497,9118],[3507,9126],[3526,9129],[3533,9123],[3549,9119],[3553,9114],[3568,9109],[3565,9106],[3580,9103],[3586,9100],[3569,9090],[3571,9086],[3584,9093],[3582,9088],[3589,9085],[3592,9091],[3604,9091],[3587,9082],[3585,9076],[3590,9065],[3592,9074],[3597,9078],[3608,9077],[3606,9071],[3612,9069],[3606,9065],[3610,9061],[3608,9057],[3612,9047],[3608,9040],[3614,9035],[3608,9028],[3616,9026],[3611,9021],[3602,9018],[3600,9024],[3589,9021],[3587,9033],[3588,9043],[3581,9036],[3584,9028],[3581,9021],[3561,9021],[3544,9030],[3536,9040],[3534,9055],[3522,9066],[3523,9070],[3509,9068],[3495,9079],[3487,9082],[3469,9082],[3460,9081],[3449,9087],[3447,9091],[3427,9104],[3418,9105],[3405,9113],[3403,9111],[3413,9106],[3410,9102],[3428,9100],[3425,9098],[3444,9090],[3434,9084],[3450,9082],[3462,9077],[3470,9079],[3491,9077],[3499,9071],[3495,9061],[3470,9050],[3458,9047],[3438,9048],[3430,9059],[3426,9058],[3435,9048],[3423,9051],[3412,9049],[3426,9045],[3415,9027],[3389,9023],[3388,9018],[3401,9022],[3416,9025],[3417,9017],[3461,9023],[3473,9018],[3462,9013],[3454,9015],[3440,9007],[3427,9002],[3421,9005],[3407,9003],[3409,9000],[3421,9001],[3425,8998],[3436,9001],[3439,8995],[3445,8997],[3448,9006],[3458,9011],[3473,9008],[3485,9014],[3503,9019],[3506,9012],[3511,9017],[3527,9011],[3555,9004],[3590,9004],[3597,9006],[3589,8996],[3575,8996],[3569,8991],[3570,8985],[3561,8990],[3564,8979],[3554,8978],[3547,8972],[3539,8973],[3538,8967],[3529,8965],[3520,8968],[3523,8960],[3511,8957],[3506,8949],[3493,8950],[3499,8944],[3484,8934],[3476,8935],[3474,8930],[3464,8927],[3461,8930],[3447,8922],[3431,8921],[3423,8923],[3423,8917],[3413,8920],[3399,8911],[3390,8914],[3383,8904],[3372,8910],[3369,8915],[3363,8909],[3365,8905],[3374,8905],[3370,8902],[3353,8898],[3335,8896],[3323,8900],[3315,8899],[3315,8906],[3306,8907],[3299,8916],[3294,8925],[3289,8920],[3294,8913],[3300,8912],[3306,8897],[3302,8887],[3296,8888],[3267,8872],[3268,8859],[3260,8848],[3247,8837],[3252,8834],[3236,8824],[3234,8828],[3228,8813],[3211,8806],[3200,8809],[3199,8800],[3177,8787],[3178,8799],[3172,8799],[3171,8786],[3166,8790],[3164,8782],[3156,8788],[3153,8784],[3139,8792],[3135,8797],[3152,8812],[3141,8811],[3126,8814],[3125,8811],[3139,8808],[3129,8806],[3130,8792],[3117,8790],[3126,8786],[3122,8777],[3114,8779],[3087,8773],[3081,8779],[3074,8771],[3069,8774],[3067,8768],[3076,8767],[3085,8762],[3076,8762],[3078,8758],[3067,8754],[3070,8751],[3063,8746],[3051,8753],[3049,8748],[3039,8751],[3039,8740],[3053,8731],[3052,8721],[3060,8716],[3046,8717],[3049,8710],[3041,8708],[3054,8704],[3047,8696],[3052,8695],[3055,8686],[3048,8676],[3037,8677],[3041,8671],[3034,8671],[3027,8677],[3020,8678],[3014,8674],[3031,8658],[3026,8649],[3018,8649],[3019,8645],[3011,8646],[3011,8638],[2998,8641],[2997,8638],[2981,8640],[2992,8633],[3007,8633],[3000,8626],[2983,8630],[2994,8622],[3004,8621],[3002,8611],[2996,8608],[3008,8607],[3000,8603],[3008,8596],[2995,8594],[3002,8589],[2994,8586],[2980,8588],[2984,8585],[2996,8585],[3000,8580],[2991,8574],[2995,8570],[2977,8571],[2993,8566],[2967,8568],[2985,8565],[2993,8557],[2984,8552],[2987,8544],[2975,8538],[2964,8542],[2948,8542],[2970,8538],[2979,8527],[2978,8520],[2953,8525],[2952,8524],[2978,8520],[2973,8514],[2971,8518],[2967,8513],[2955,8517],[2951,8524]],[[2940,8523],[2940,8523],[2940,8523],[2941,8523],[2941,8523],[2946,8521],[2953,8530],[2941,8523],[2941,8523],[2940,8523],[2940,8523],[2940,8523],[2940,8523]],[[2718,8862],[2718,8862],[2718,8862],[2718,8862],[2718,8862],[2718,8862],[2730,8860],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2742,8850],[2752,8853],[2764,8853],[2761,8855],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2741,8851],[2732,8862],[2743,8865],[2718,8862],[2718,8862],[2718,8862],[2718,8862],[2718,8862]]],[[[2954,8516],[2961,8513],[2951,8508],[2948,8513],[2941,8513],[2947,8518],[2954,8516]]],[[[3025,8671],[3038,8662],[3029,8663],[3016,8672],[3021,8675],[3025,8671]]],[[[3057,8733],[3056,8726],[3066,8722],[3056,8722],[3053,8733],[3045,8742],[3049,8743],[3057,8733]]],[[[2688,8773],[2683,8773],[2683,8777],[2692,8778],[2688,8773]]],[[[3152,8779],[3162,8778],[3154,8772],[3147,8777],[3138,8778],[3133,8774],[3130,8780],[3135,8788],[3142,8790],[3152,8779]]],[[[2689,8918],[2692,8915],[2685,8912],[2681,8916],[2689,8918]]],[[[2713,8930],[2684,8923],[2687,8927],[2699,8930],[2713,8930]]],[[[2746,8993],[2757,8989],[2747,8983],[2748,8974],[2739,8973],[2737,8984],[2746,8993]]],[[[2639,9018],[2631,9017],[2628,9023],[2635,9022],[2639,9018]]],[[[3433,9037],[3431,9044],[3463,9045],[3495,9057],[3502,9055],[3500,9046],[3503,9032],[3488,9029],[3477,9022],[3471,9024],[3476,9029],[3466,9025],[3422,9020],[3425,9031],[3434,9033],[3433,9037]]],[[[2673,9053],[2659,9057],[2670,9068],[2676,9057],[2673,9053]]],[[[2698,9060],[2685,9062],[2683,9070],[2689,9072],[2705,9070],[2708,9067],[2698,9060]]],[[[2685,9087],[2695,9087],[2681,9080],[2675,9081],[2674,9086],[2685,9087]]],[[[2612,9096],[2606,9100],[2612,9102],[2617,9100],[2612,9096]]],[[[2627,9123],[2615,9114],[2610,9118],[2628,9127],[2627,9123]]],[[[2609,9148],[2602,9142],[2593,9144],[2600,9148],[2609,9148]]],[[[2629,9150],[2613,9136],[2611,9148],[2622,9151],[2629,9150]]],[[[2614,9164],[2627,9159],[2620,9157],[2608,9161],[2614,9164]]],[[[3564,9165],[3593,9160],[3603,9156],[3595,9151],[3604,9144],[3581,9144],[3576,9151],[3566,9154],[3553,9154],[3547,9156],[3526,9156],[3526,9161],[3548,9162],[3564,9165]]],[[[2602,9193],[2615,9186],[2611,9185],[2596,9193],[2602,9193]]],[[[2591,9212],[2600,9210],[2589,9206],[2581,9208],[2581,9214],[2591,9212]]],[[[3632,9243],[3644,9242],[3646,9236],[3655,9228],[3622,9223],[3602,9230],[3605,9239],[3623,9245],[3632,9243]]],[[[2585,9247],[2567,9247],[2554,9247],[2578,9251],[2585,9247]]],[[[3654,9271],[3658,9272],[3667,9268],[3657,9259],[3647,9261],[3640,9265],[3641,9276],[3649,9280],[3660,9277],[3654,9271]]],[[[3724,9295],[3712,9291],[3724,9282],[3730,9286],[3738,9285],[3737,9278],[3730,9276],[3715,9279],[3705,9276],[3692,9277],[3693,9294],[3690,9296],[3702,9299],[3707,9295],[3715,9297],[3715,9301],[3724,9295]]],[[[2199,9369],[2187,9370],[2188,9372],[2200,9374],[2199,9369]]],[[[3699,9375],[3697,9369],[3699,9347],[3702,9333],[3693,9348],[3692,9354],[3686,9365],[3690,9383],[3699,9375]]],[[[2122,9426],[2147,9420],[2137,9417],[2113,9422],[2122,9426]]],[[[2161,9427],[2180,9422],[2155,9421],[2149,9426],[2161,9427]]],[[[3722,9438],[3712,9438],[3720,9451],[3727,9453],[3730,9448],[3722,9438]]],[[[3642,9469],[3635,9472],[3646,9477],[3649,9472],[3646,9459],[3659,9461],[3667,9454],[3678,9454],[3680,9448],[3645,9457],[3642,9469]]],[[[3699,9496],[3707,9502],[3715,9514],[3718,9511],[3712,9501],[3692,9486],[3688,9479],[3692,9476],[3692,9464],[3683,9456],[3685,9465],[3670,9478],[3670,9484],[3678,9474],[3681,9485],[3699,9496]]],[[[3684,9517],[3688,9509],[3677,9506],[3672,9512],[3684,9521],[3684,9517]]],[[[3734,9528],[3721,9523],[3721,9530],[3730,9538],[3736,9533],[3734,9528]]],[[[3738,9590],[3723,9575],[3704,9571],[3677,9582],[3691,9587],[3689,9593],[3696,9590],[3701,9593],[3726,9598],[3740,9593],[3738,9590]]],[[[3697,9601],[3696,9599],[3670,9593],[3671,9603],[3683,9606],[3697,9601]]],[[[2278,9638],[2288,9633],[2282,9633],[2278,9634],[2278,9638]]],[[[3738,9703],[3726,9702],[3712,9709],[3712,9712],[3724,9713],[3738,9703]]],[[[3700,9718],[3687,9718],[3671,9730],[3670,9738],[3677,9739],[3686,9734],[3700,9718]]],[[[2740,9730],[2714,9731],[2699,9736],[2682,9739],[2678,9749],[2686,9755],[2694,9754],[2703,9745],[2740,9732],[2740,9730]]],[[[2849,9788],[2825,9788],[2826,9796],[2849,9791],[2849,9788]]],[[[3062,9830],[3077,9826],[3086,9820],[3105,9817],[3110,9812],[3102,9812],[3075,9818],[3069,9823],[3052,9824],[3056,9831],[3062,9830]]],[[[3595,9112],[3585,9113],[3569,9123],[3543,9132],[3531,9139],[3527,9151],[3544,9154],[3552,9152],[3567,9152],[3579,9141],[3602,9132],[3600,9127],[3582,9131],[3581,9125],[3599,9120],[3595,9112]]],[[[2861,9766],[2844,9777],[2869,9778],[2869,9780],[2884,9780],[2914,9772],[2939,9760],[2940,9757],[2921,9747],[2931,9738],[2921,9735],[2911,9744],[2868,9757],[2861,9766]]],[[[3068,9807],[3075,9802],[3050,9806],[3028,9817],[3045,9816],[3056,9809],[3065,9808],[3061,9809],[3055,9816],[3071,9815],[3076,9813],[3091,9810],[3085,9804],[3075,9805],[3068,9807]]],[[[2722,8978],[2713,8970],[2671,8958],[2666,8959],[2654,8963],[2652,8969],[2676,8968],[2662,8974],[2637,8976],[2629,8982],[2640,8986],[2631,8988],[2636,8996],[2651,8993],[2636,8999],[2634,9008],[2649,9015],[2680,9008],[2687,9004],[2696,8994],[2717,8987],[2716,8980],[2722,8978]]],[[[3528,9185],[3564,9175],[3565,9174],[3563,9174],[3513,9180],[3548,9172],[3569,9171],[3572,9167],[3528,9163],[3510,9168],[3499,9168],[3491,9172],[3504,9180],[3505,9184],[3528,9185]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.45,&#34;hc-middle-y&#34;:0.44,&#34;hc-key&#34;:&#34;gu&#34;,&#34;hc-a2&#34;:&#34;GU&#34;,&#34;name&#34;:&#34;Guam&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Guam&#34;,&#34;subregion&#34;:&#34;Micronesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;GUM&#34;,&#34;iso-a2&#34;:&#34;GU&#34;,&#34;woe-id&#34;:&#34;23424832&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[8512,6901],[8508,6895],[8506,6900],[8514,6907],[8512,6901]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MP&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.45,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;mp&#34;,&#34;hc-a2&#34;:&#34;MP&#34;,&#34;name&#34;:&#34;Northern Mariana Islands&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;N.M.I.&#34;,&#34;subregion&#34;:&#34;Micronesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;MNP&#34;,&#34;iso-a2&#34;:&#34;MP&#34;,&#34;woe-id&#34;:&#34;23424788&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[8537,6948],[8538,6953],[8542,6955],[8540,6950],[8537,6948]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.52,&#34;hc-key&#34;:&#34;pr&#34;,&#34;hc-a2&#34;:&#34;PR&#34;,&#34;name&#34;:&#34;Puerto Rico&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;P.R.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;PRI&#34;,&#34;iso-a2&#34;:&#34;PR&#34;,&#34;woe-id&#34;:&#34;23424935&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2326,7046],[2326,7041],[2318,7040],[2315,7044],[2310,7038],[2299,7035],[2291,7037],[2272,7036],[2268,7048],[2273,7053],[2305,7051],[2316,7049],[2317,7041],[2326,7042],[2326,7046]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;VI&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.19,&#34;hc-key&#34;:&#34;vi&#34;,&#34;hc-a2&#34;:&#34;VI&#34;,&#34;name&#34;:&#34;United States Virgin Islands&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;V.I. (U.S.)&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;VIR&#34;,&#34;iso-a2&#34;:&#34;VI&#34;,&#34;woe-id&#34;:&#34;23424985&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2342,7030],[2347,7030],[2338,7028],[2338,7031],[2342,7030]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.28,&#34;hc-middle-y&#34;:0.63,&#34;hc-key&#34;:&#34;ca&#34;,&#34;hc-a2&#34;:&#34;CA&#34;,&#34;name&#34;:&#34;Canada&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Can.&#34;,&#34;subregion&#34;:&#34;Northern America&#34;,&#34;region-wb&#34;:&#34;North America&#34;,&#34;iso-a3&#34;:&#34;CAN&#34;,&#34;iso-a2&#34;:&#34;CA&#34;,&#34;woe-id&#34;:&#34;23424775&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[1920,7852],[1921,7848],[1925,7846],[1919,7843],[1909,7844],[1887,7841],[1878,7833],[1865,7836],[1853,7836],[1840,7827],[1838,7822],[1822,7817],[1819,7810],[1816,7814],[1807,7812],[1801,7815],[1802,7823],[1821,7825],[1821,7830],[1815,7832],[1819,7836],[1822,7849],[1830,7852],[1841,7861],[1843,7866],[1842,7887],[1846,7896],[1855,7906],[1855,7913],[1848,7924],[1842,7928],[1854,7929],[1856,7920],[1863,7917],[1865,7905],[1870,7910],[1890,7901],[1893,7909],[1887,7913],[1895,7915],[1901,7912],[1890,7924],[1893,7926],[1883,7934],[1871,7954],[1859,7954],[1842,7960],[1823,7963],[1805,7963],[1772,7969],[1772,7976],[1761,7973],[1762,7982],[1752,7993],[1758,8005],[1745,8017],[1750,8028],[1748,8030],[1733,8028],[1720,8030],[1714,8037],[1708,8053],[1703,8060],[1695,8061],[1680,8060],[1656,8068],[1649,8067],[1654,8061],[1651,8054],[1641,8051],[1647,8057],[1643,8063],[1636,8045],[1611,8031],[1601,8030],[1595,8035],[1576,8034],[1571,8039],[1556,8032],[1548,8034],[1538,8043],[1528,8039],[1520,8051],[1502,8054],[1487,8050],[1484,8055],[1465,8057],[1460,8061],[1456,8080],[1446,8082],[1446,8068],[634,8068],[628,8072],[626,8068],[624,8068],[618,8083],[619,8091],[616,8088],[617,8084],[613,8085],[613,8086],[611,8083],[598,8089],[593,8098],[585,8098],[576,8105],[579,8116],[576,8119],[565,8119],[557,8128],[552,8124],[543,8127],[531,8126],[531,8128],[525,8127],[520,8128],[524,8131],[531,8129],[530,8131],[547,8133],[532,8133],[532,8134],[530,8132],[521,8132],[530,8139],[532,8136],[533,8140],[517,8136],[513,8143],[508,8138],[496,8143],[486,8152],[492,8157],[486,8158],[490,8164],[483,8172],[484,8181],[490,8188],[505,8197],[501,8203],[484,8193],[477,8205],[471,8195],[476,8214],[474,8215],[472,8209],[471,8211],[470,8215],[472,8215],[466,8217],[463,8229],[454,8235],[451,8246],[447,8244],[445,8248],[455,8252],[454,8248],[451,8246],[456,8247],[457,8256],[461,8265],[452,8255],[443,8249],[440,8240],[418,8262],[419,8270],[413,8269],[407,8276],[409,8292],[421,8305],[430,8322],[419,8305],[416,8308],[422,8316],[418,8327],[420,8342],[418,8350],[409,8351],[407,8355],[396,8361],[388,8363],[375,8371],[367,8371],[365,8379],[359,8382],[361,8389],[352,8391],[355,8396],[345,8409],[321,8447],[308,8461],[296,8466],[289,8478],[275,8485],[271,8491],[273,8497],[259,8508],[234,8499],[230,8486],[226,8480],[219,8480],[213,8476],[213,8476],[213,8476],[213,8476],[213,8476],[213,8476],[213,8476],[213,8476],[202,8469],[196,8484],[167,8506],[164,8512],[150,8520],[153,8532],[136,8531],[126,8525],[114,8530],[110,8526],[97,8530],[97,8979],[120,8976],[129,8978],[151,8972],[166,8960],[175,8958],[182,8953],[208,8943],[222,8939],[229,8941],[242,8939],[268,8930],[257,8938],[248,8941],[245,8948],[249,8961],[261,8963],[268,8959],[266,8968],[270,8970],[289,8968],[293,8983],[299,8974],[306,8978],[309,8971],[295,8957],[319,8967],[326,8966],[333,8972],[336,8980],[346,8978],[346,8984],[359,8983],[369,8989],[384,8994],[386,8988],[394,9003],[409,9006],[415,9000],[424,9002],[430,9012],[437,9005],[435,8999],[405,8986],[393,8975],[390,8979],[362,8973],[358,8964],[337,8957],[334,8950],[326,8947],[325,8941],[318,8940],[319,8935],[330,8930],[321,8937],[347,8935],[342,8937],[336,8948],[363,8959],[373,8970],[382,8971],[386,8966],[384,8976],[393,8973],[392,8959],[398,8969],[411,8981],[432,8988],[446,8990],[453,8996],[452,8989],[445,8989],[450,8981],[470,8997],[469,9003],[476,9008],[492,9011],[479,9013],[474,9018],[480,9029],[496,9019],[505,9011],[519,8983],[540,8967],[555,8962],[555,8966],[563,8965],[559,8970],[549,8967],[554,8972],[564,8971],[556,8977],[557,8981],[570,8994],[579,8997],[568,8999],[582,9003],[586,9000],[581,8996],[585,8990],[583,8983],[595,8983],[590,8974],[585,8970],[585,8964],[598,8966],[607,8964],[622,8971],[622,8985],[628,8989],[642,8987],[655,8988],[673,8985],[691,8978],[707,8966],[754,8957],[760,8952],[773,8947],[834,8935],[823,8943],[835,8945],[861,8939],[876,8931],[886,8923],[892,8914],[891,8906],[863,8909],[869,8904],[855,8904],[859,8895],[847,8891],[859,8884],[868,8885],[880,8881],[896,8879],[912,8879],[920,8878],[938,8878],[941,8881],[954,8882],[964,8880],[986,8892],[974,8882],[985,8884],[999,8893],[1018,8885],[1024,8879],[1035,8882],[1044,8862],[1047,8875],[1051,8875],[1053,8863],[1059,8866],[1069,8858],[1072,8846],[1064,8847],[1064,8837],[1073,8832],[1081,8821],[1092,8813],[1081,8824],[1074,8845],[1081,8836],[1086,8846],[1092,8850],[1082,8854],[1079,8864],[1081,8869],[1068,8879],[1070,8887],[1078,8891],[1071,8894],[1072,8899],[1085,8896],[1093,8901],[1105,8899],[1109,8907],[1114,8902],[1114,8912],[1135,8916],[1138,8927],[1131,8927],[1112,8921],[1110,8909],[1104,8915],[1094,8908],[1082,8912],[1072,8908],[1080,8903],[1058,8902],[1055,8910],[1044,8908],[1060,8926],[1089,8930],[1119,8941],[1133,8939],[1143,8931],[1141,8927],[1147,8912],[1154,8908],[1160,8912],[1160,8906],[1168,8906],[1166,8901],[1172,8896],[1192,8895],[1203,8903],[1205,8895],[1217,8890],[1223,8885],[1238,8880],[1246,8884],[1259,8878],[1276,8881],[1283,8887],[1321,8884],[1327,8880],[1352,8884],[1341,8892],[1346,8899],[1355,8890],[1360,8882],[1376,8874],[1380,8877],[1377,8875],[1376,8879],[1382,8880],[1382,8878],[1389,8883],[1372,8895],[1361,8889],[1351,8895],[1353,8903],[1342,8912],[1357,8910],[1370,8913],[1363,8922],[1385,8918],[1394,8906],[1407,8910],[1407,8905],[1398,8895],[1410,8903],[1425,8909],[1415,8885],[1416,8875],[1408,8868],[1420,8866],[1414,8856],[1418,8855],[1429,8862],[1434,8859],[1427,8852],[1436,8855],[1441,8842],[1424,8841],[1410,8844],[1426,8832],[1419,8840],[1442,8839],[1441,8852],[1446,8858],[1441,8861],[1441,8872],[1431,8879],[1438,8898],[1448,8899],[1455,8896],[1471,8907],[1482,8918],[1494,8923],[1488,8925],[1493,8937],[1491,8943],[1483,8945],[1478,8933],[1462,8933],[1463,8944],[1469,8943],[1477,8952],[1471,8953],[1474,8963],[1484,8963],[1493,8968],[1494,8973],[1483,8968],[1471,8969],[1462,8981],[1455,8975],[1439,8981],[1431,8986],[1422,8986],[1416,8990],[1407,9003],[1406,9016],[1411,9019],[1415,9028],[1420,9029],[1411,9033],[1404,9042],[1411,9056],[1409,9067],[1422,9073],[1432,9067],[1438,9071],[1437,9077],[1423,9081],[1440,9094],[1444,9103],[1464,9106],[1469,9102],[1466,9096],[1469,9087],[1474,9094],[1489,9093],[1486,9086],[1504,9076],[1509,9071],[1514,9059],[1513,9047],[1509,9043],[1527,9033],[1540,9017],[1548,9016],[1553,9005],[1540,9004],[1533,9007],[1524,9002],[1536,9002],[1541,8999],[1532,8991],[1514,8982],[1529,8981],[1536,8974],[1545,8971],[1556,8980],[1566,8978],[1566,8972],[1578,8973],[1585,8971],[1575,8964],[1575,8959],[1561,8961],[1576,8951],[1580,8941],[1586,8939],[1580,8917],[1589,8913],[1590,8906],[1598,8913],[1607,8927],[1606,8941],[1608,8948],[1618,8958],[1629,8957],[1636,8950],[1650,8942],[1659,8931],[1663,8911],[1659,8904],[1652,8907],[1652,8913],[1645,8908],[1649,8901],[1646,8896],[1653,8877],[1672,8862],[1671,8850],[1684,8855],[1690,8864],[1701,8863],[1701,8878],[1706,8886],[1719,8897],[1726,8931],[1735,8933],[1752,8932],[1751,8936],[1741,8937],[1751,8942],[1747,8946],[1753,8947],[1736,8953],[1732,8960],[1730,8985],[1736,8989],[1744,8986],[1750,8990],[1765,8990],[1783,8982],[1797,8982],[1816,8979],[1819,8971],[1799,8973],[1826,8967],[1830,8961],[1853,8955],[1855,8950],[1849,8949],[1839,8941],[1852,8938],[1856,8934],[1855,8927],[1833,8916],[1815,8917],[1826,8909],[1824,8903],[1833,8901],[1829,8895],[1831,8890],[1850,8875],[1856,8867],[1849,8844],[1835,8843],[1829,8833],[1816,8823],[1804,8822],[1794,8812],[1788,8813],[1784,8820],[1775,8826],[1777,8835],[1771,8830],[1763,8838],[1764,8843],[1745,8842],[1766,8833],[1771,8828],[1769,8824],[1776,8818],[1784,8804],[1776,8805],[1769,8811],[1756,8811],[1763,8805],[1738,8809],[1736,8818],[1732,8823],[1720,8819],[1706,8822],[1692,8817],[1698,8810],[1706,8809],[1720,8803],[1717,8796],[1704,8790],[1702,8782],[1684,8770],[1684,8766],[1675,8762],[1659,8762],[1608,8792],[1597,8789],[1554,8792],[1569,8786],[1567,8791],[1600,8785],[1614,8776],[1616,8770],[1627,8762],[1665,8759],[1666,8761],[1685,8758],[1688,8753],[1679,8739],[1671,8733],[1669,8725],[1663,8723],[1658,8708],[1636,8698],[1623,8701],[1626,8696],[1611,8702],[1611,8699],[1599,8707],[1603,8695],[1596,8697],[1599,8690],[1593,8683],[1570,8679],[1549,8686],[1528,8688],[1516,8694],[1513,8691],[1536,8685],[1526,8677],[1545,8686],[1558,8675],[1568,8674],[1577,8669],[1579,8655],[1574,8649],[1568,8650],[1557,8642],[1535,8646],[1526,8643],[1533,8637],[1542,8636],[1540,8631],[1527,8631],[1521,8635],[1524,8627],[1519,8628],[1519,8618],[1506,8622],[1517,8616],[1506,8612],[1508,8608],[1498,8608],[1502,8602],[1492,8604],[1503,8597],[1481,8582],[1486,8577],[1477,8576],[1481,8571],[1470,8555],[1465,8541],[1459,8541],[1462,8534],[1456,8515],[1457,8496],[1459,8489],[1457,8476],[1468,8461],[1489,8464],[1505,8462],[1506,8452],[1516,8433],[1517,8424],[1526,8407],[1526,8398],[1520,8385],[1525,8389],[1533,8389],[1568,8399],[1581,8397],[1603,8387],[1631,8382],[1648,8368],[1658,8364],[1670,8348],[1688,8343],[1708,8335],[1725,8330],[1733,8322],[1741,8319],[1740,8315],[1747,8317],[1757,8315],[1777,8318],[1784,8315],[1807,8314],[1818,8312],[1824,8308],[1828,8299],[1822,8280],[1821,8273],[1827,8267],[1830,8256],[1828,8245],[1831,8235],[1826,8232],[1825,8223],[1847,8202],[1840,8195],[1848,8194],[1853,8188],[1864,8184],[1875,8173],[1881,8158],[1890,8157],[1900,8150],[1902,8161],[1913,8171],[1914,8166],[1922,8163],[1925,8154],[1928,8169],[1921,8175],[1925,8182],[1934,8189],[1937,8198],[1935,8206],[1927,8215],[1931,8219],[1923,8225],[1924,8240],[1919,8244],[1924,8247],[1921,8253],[1918,8270],[1911,8272],[1908,8283],[1900,8291],[1923,8299],[1940,8306],[1958,8316],[1962,8322],[1975,8332],[1990,8348],[1995,8364],[1991,8371],[1996,8379],[1994,8389],[1990,8391],[1986,8406],[1990,8406],[1987,8416],[1979,8428],[1963,8442],[1953,8444],[1951,8448],[1935,8457],[1938,8460],[1936,8469],[1941,8471],[1949,8482],[1957,8486],[1955,8494],[1958,8503],[1965,8503],[1973,8508],[1969,8513],[1974,8517],[1969,8520],[1959,8536],[1965,8541],[1957,8546],[1963,8550],[1955,8550],[1947,8555],[1961,8571],[1958,8582],[1965,8583],[1958,8593],[1953,8592],[1949,8601],[1947,8620],[1951,8624],[1967,8633],[2012,8623],[2023,8619],[2030,8621],[2040,8619],[2047,8613],[2048,8618],[2057,8618],[2079,8628],[2093,8621],[2097,8615],[2116,8608],[2118,8601],[2127,8600],[2122,8595],[2138,8591],[2141,8586],[2134,8586],[2134,8577],[2144,8571],[2164,8564],[2175,8562],[2183,8565],[2190,8561],[2185,8557],[2197,8556],[2201,8564],[2205,8552],[2195,8547],[2192,8540],[2194,8531],[2199,8527],[2198,8520],[2190,8517],[2177,8518],[2170,8516],[2195,8516],[2200,8511],[2197,8504],[2201,8503],[2195,8496],[2198,8486],[2204,8489],[2210,8484],[2201,8480],[2203,8469],[2197,8465],[2196,8472],[2191,8475],[2193,8466],[2190,8464],[2193,8456],[2199,8463],[2209,8469],[2223,8470],[2235,8464],[2236,8456],[2240,8454],[2236,8436],[2232,8432],[2218,8428],[2210,8424],[2232,8431],[2237,8435],[2242,8453],[2249,8451],[2249,8441],[2252,8450],[2256,8435],[2262,8442],[2277,8451],[2285,8453],[2294,8467],[2307,8456],[2302,8464],[2311,8467],[2308,8473],[2315,8476],[2312,8483],[2323,8485],[2318,8505],[2332,8516],[2339,8533],[2353,8528],[2352,8516],[2360,8516],[2360,8508],[2362,8511],[2364,8507],[2360,8504],[2360,8504],[2360,8503],[2372,8496],[2362,8490],[2382,8486],[2380,8478],[2389,8476],[2389,8470],[2395,8465],[2395,8456],[2383,8450],[2393,8448],[2406,8452],[2403,8438],[2409,8437],[2417,8426],[2425,8426],[2433,8421],[2430,8418],[2423,8421],[2429,8407],[2415,8410],[2412,8406],[2422,8407],[2428,8403],[2422,8398],[2429,8394],[2441,8392],[2442,8385],[2435,8379],[2441,8378],[2441,8372],[2426,8380],[2425,8372],[2445,8365],[2430,8366],[2429,8363],[2440,8361],[2425,8355],[2441,8355],[2448,8345],[2449,8353],[2454,8346],[2461,8343],[2464,8334],[2473,8323],[2466,8313],[2488,8318],[2488,8309],[2496,8313],[2510,8311],[2514,8298],[2529,8294],[2542,8302],[2540,8295],[2550,8290],[2557,8290],[2562,8284],[2550,8279],[2535,8279],[2534,8274],[2499,8266],[2502,8265],[2527,8270],[2522,8266],[2497,8257],[2488,8258],[2480,8254],[2478,8245],[2478,8245],[2478,8245],[2467,8252],[2457,8255],[2478,8245],[2478,8245],[2478,8245],[2478,8245],[2480,8244],[2471,8239],[2481,8238],[2486,8244],[2496,8246],[2510,8253],[2516,8262],[2537,8268],[2530,8273],[2540,8274],[2554,8272],[2560,8276],[2558,8269],[2566,8254],[2555,8249],[2561,8247],[2559,8241],[2566,8246],[2570,8256],[2573,8253],[2585,8256],[2582,8251],[2598,8247],[2605,8242],[2607,8234],[2605,8222],[2602,8223],[2607,8209],[2593,8206],[2607,8204],[2605,8197],[2611,8193],[2602,8182],[2579,8171],[2571,8162],[2563,8165],[2550,8164],[2541,8158],[2523,8152],[2512,8145],[2516,8137],[2508,8138],[2487,8119],[2478,8115],[2460,8116],[2443,8114],[2431,8110],[2427,8115],[2413,8118],[2388,8118],[2380,8115],[2369,8119],[2366,8115],[2351,8119],[2345,8118],[2327,8119],[2302,8114],[2292,8117],[2272,8100],[2268,8086],[2264,8081],[2244,8080],[2241,8073],[2229,8071],[2215,8060],[2203,8042],[2197,8036],[2188,8041],[2173,8044],[2195,8035],[2189,8022],[2183,8018],[2176,8007],[2173,8010],[2166,7998],[2159,7994],[2150,7986],[2153,7988],[2156,7988],[2154,7989],[2161,7994],[2162,7991],[2159,7989],[2171,7994],[2186,8011],[2200,8024],[2204,8030],[2215,8039],[2240,8055],[2259,8063],[2299,8076],[2318,8079],[2335,8077],[2348,8072],[2357,8064],[2352,8062],[2359,8054],[2354,8046],[2343,8043],[2341,8038],[2322,8031],[2308,8039],[2303,8035],[2290,8035],[2283,8030],[2295,8032],[2310,8027],[2316,8018],[2328,8024],[2343,8024],[2349,8032],[2349,8025],[2341,8020],[2331,8001],[2324,7997],[2340,7996],[2337,7989],[2348,7968],[2347,7965],[2356,7965],[2371,7961],[2361,7958],[2370,7952],[2379,7952],[2385,7946],[2390,7950],[2400,7948],[2409,7942],[2425,7952],[2426,7946],[2434,7942],[2438,7945],[2445,7936],[2439,7933],[2452,7932],[2449,7928],[2428,7924],[2423,7920],[2409,7916],[2392,7908],[2390,7912],[2385,7906],[2376,7908],[2378,7903],[2366,7902],[2367,7909],[2355,7904],[2354,7895],[2341,7879],[2331,7872],[2327,7877],[2320,7865],[2316,7863],[2308,7877],[2301,7875],[2299,7887],[2302,7897],[2309,7904],[2305,7905],[2338,7925],[2354,7931],[2353,7926],[2359,7922],[2360,7928],[2383,7933],[2347,7935],[2337,7933],[2339,7938],[2350,7945],[2348,7953],[2341,7942],[2337,7943],[2318,7932],[2308,7928],[2303,7930],[2299,7926],[2285,7923],[2280,7907],[2277,7927],[2270,7926],[2262,7930],[2263,7942],[2255,7944],[2252,7948],[2252,7955],[2252,7996],[2240,8006],[2236,8007],[2219,8000],[2215,8009],[2210,8010],[2187,7982],[2185,7972],[2178,7959],[2179,7952],[2163,7934],[2149,7931],[2143,7920],[2048,7920],[2055,7922],[2079,7936],[2084,7936],[2087,7947],[2094,7958],[2107,7963],[2114,7970],[2132,7981],[2137,7980],[2144,7983],[2132,7982],[2122,7977],[2111,7968],[2099,7964],[2084,7947],[2077,7945],[2068,7938],[2070,7936],[2077,7940],[2073,7940],[2078,7945],[2082,7945],[2080,7942],[2085,7946],[2083,7939],[2081,7936],[2070,7936],[2074,7934],[2065,7932],[2048,7920],[2043,7920],[2032,7915],[2017,7902],[2004,7894],[1986,7890],[1977,7879],[1963,7885],[1923,7879],[1908,7871],[1899,7860],[1912,7855],[1920,7858],[1921,7854],[1920,7852]],[[490,8164],[491,8164],[495,8170],[496,8170],[496,8170],[518,8171],[499,8173],[496,8170],[495,8170],[495,8170],[494,8169],[490,8164]],[[1493,8968],[1493,8967],[1493,8967],[1493,8967],[1484,8958],[1485,8954],[1499,8965],[1493,8964],[1493,8967],[1493,8967],[1493,8967],[1495,8968],[1493,8968]],[[2173,8044],[2173,8044],[2173,8044],[2173,8044],[2173,8044],[2173,8044],[2163,8046],[2162,8043],[2173,8044],[2173,8044],[2173,8044],[2173,8044],[2173,8044]]],[[[2343,8688],[2347,8681],[2350,8666],[2341,8667],[2336,8682],[2331,8678],[2339,8660],[2345,8648],[2338,8646],[2329,8649],[2336,8636],[2329,8632],[2324,8639],[2327,8642],[2317,8644],[2306,8649],[2297,8659],[2302,8650],[2297,8651],[2293,8645],[2289,8652],[2261,8673],[2252,8682],[2256,8671],[2249,8670],[2251,8666],[2247,8656],[2258,8657],[2274,8642],[2275,8636],[2283,8638],[2291,8629],[2290,8626],[2307,8615],[2301,8607],[2306,8601],[2297,8600],[2286,8603],[2283,8607],[2272,8608],[2266,8613],[2230,8618],[2216,8624],[2199,8637],[2205,8641],[2192,8644],[2180,8641],[2173,8646],[2154,8651],[2137,8660],[2135,8671],[2150,8678],[2141,8679],[2133,8689],[2122,8684],[2109,8692],[2101,8701],[2102,8707],[2092,8715],[2090,8706],[2086,8728],[2071,8727],[2070,8714],[2064,8716],[2068,8721],[2068,8733],[2059,8727],[2040,8737],[2056,8725],[2049,8717],[2041,8719],[2016,8728],[2021,8721],[2013,8722],[2019,8717],[2011,8718],[2005,8713],[1990,8711],[1990,8708],[1962,8717],[1956,8716],[1946,8730],[1949,8738],[1947,8744],[1953,8749],[1972,8756],[1966,8762],[1973,8765],[1968,8768],[1991,8766],[2018,8757],[2027,8749],[2028,8745],[2020,8744],[2029,8733],[2029,8747],[2023,8754],[2012,8762],[2034,8759],[2037,8765],[2051,8762],[2064,8771],[2073,8772],[2085,8768],[2080,8781],[2069,8788],[2056,8802],[2085,8822],[2089,8827],[2100,8831],[2099,8835],[2105,8846],[2114,8848],[2123,8858],[2117,8860],[2116,8871],[2109,8880],[2110,8883],[2101,8891],[2099,8906],[2094,8905],[2074,8912],[2071,8915],[2078,8928],[2064,8931],[2073,8922],[2063,8920],[2054,8925],[2048,8934],[2040,8936],[2049,8938],[2047,8942],[2039,8941],[2046,8950],[2038,8946],[2037,8940],[2026,8946],[2022,8939],[2001,8930],[1992,8929],[1995,8939],[1992,8947],[1998,8948],[2011,8946],[2022,8950],[2022,8957],[2012,8965],[1999,8966],[1992,8974],[1975,8979],[1986,8981],[1984,8987],[1967,8990],[1961,8988],[1961,9007],[1955,9012],[1940,9009],[1930,9022],[1906,9018],[1924,9014],[1929,9007],[1932,8996],[1928,8991],[1909,8991],[1902,8990],[1896,8997],[1882,8997],[1861,9003],[1841,9004],[1850,8998],[1853,9000],[1868,8987],[1865,8983],[1846,8996],[1841,8996],[1830,9004],[1809,9011],[1810,9009],[1827,9004],[1842,8994],[1833,8991],[1830,8986],[1807,8995],[1803,8998],[1785,8995],[1773,8997],[1755,8998],[1736,9003],[1722,9003],[1738,8997],[1722,8997],[1708,9004],[1697,9015],[1691,9015],[1687,9023],[1679,9018],[1687,9016],[1687,9013],[1664,9015],[1662,9010],[1649,9015],[1661,9014],[1653,9019],[1637,9022],[1631,9026],[1626,9035],[1615,9046],[1622,9048],[1611,9056],[1624,9053],[1638,9054],[1648,9049],[1676,9048],[1678,9051],[1667,9057],[1660,9066],[1655,9062],[1604,9069],[1598,9076],[1598,9084],[1604,9092],[1595,9101],[1599,9109],[1611,9115],[1601,9116],[1600,9124],[1603,9128],[1606,9139],[1610,9140],[1611,9149],[1616,9152],[1618,9161],[1629,9178],[1645,9191],[1664,9202],[1695,9209],[1716,9210],[1742,9207],[1750,9204],[1747,9199],[1729,9190],[1715,9178],[1708,9166],[1696,9151],[1696,9141],[1706,9133],[1709,9127],[1703,9121],[1704,9106],[1713,9094],[1731,9079],[1747,9074],[1750,9066],[1740,9066],[1730,9061],[1717,9060],[1704,9053],[1708,9051],[1723,9059],[1731,9060],[1750,9060],[1746,9047],[1753,9050],[1751,9066],[1754,9074],[1759,9077],[1756,9088],[1749,9085],[1738,9087],[1728,9094],[1729,9100],[1717,9105],[1729,9109],[1732,9120],[1744,9119],[1760,9112],[1747,9122],[1752,9131],[1745,9126],[1730,9131],[1725,9141],[1725,9155],[1730,9160],[1741,9158],[1768,9150],[1740,9162],[1730,9163],[1733,9169],[1742,9164],[1740,9170],[1761,9165],[1779,9163],[1758,9168],[1740,9174],[1742,9179],[1750,9183],[1763,9174],[1756,9184],[1770,9188],[1781,9186],[1787,9178],[1785,9187],[1775,9190],[1786,9195],[1809,9203],[1848,9202],[1856,9193],[1859,9175],[1874,9171],[1877,9166],[1874,9157],[1885,9147],[1877,9138],[1864,9130],[1856,9120],[1867,9130],[1876,9134],[1878,9127],[1864,9117],[1875,9111],[1863,9111],[1869,9104],[1881,9108],[1879,9115],[1886,9117],[1886,9122],[1895,9115],[1888,9124],[1898,9133],[1905,9124],[1900,9118],[1914,9127],[1924,9116],[1915,9104],[1937,9099],[1925,9106],[1927,9115],[1939,9112],[1926,9118],[1934,9125],[1958,9119],[1936,9129],[1939,9138],[1963,9147],[1984,9147],[1991,9141],[2005,9139],[2008,9132],[2012,9138],[2034,9133],[2042,9120],[2032,9112],[2062,9110],[2066,9104],[2062,9096],[2037,9089],[2042,9087],[2028,9079],[2051,9086],[2042,9076],[2051,9072],[2048,9080],[2061,9091],[2066,9086],[2072,9093],[2081,9092],[2070,9080],[2067,9066],[2073,9080],[2082,9081],[2080,9075],[2086,9070],[2097,9066],[2098,9069],[2091,9071],[2088,9080],[2097,9080],[2094,9074],[2100,9079],[2104,9075],[2098,9073],[2099,9071],[2099,9073],[2106,9075],[2104,9079],[2107,9081],[2099,9081],[2101,9086],[2107,9087],[2107,9081],[2114,9086],[2141,9079],[2154,9066],[2145,9055],[2127,9055],[2118,9044],[2122,9038],[2140,9044],[2148,9045],[2153,9053],[2164,9057],[2172,9048],[2163,9036],[2152,9028],[2142,9031],[2136,9024],[2135,9015],[2143,9028],[2152,9026],[2150,9012],[2142,8999],[2147,9004],[2158,9031],[2190,9044],[2194,9044],[2188,9037],[2173,9030],[2186,9029],[2198,9038],[2211,9039],[2214,9036],[2235,9029],[2238,9024],[2232,9017],[2226,9020],[2225,9015],[2203,9011],[2185,9001],[2191,8999],[2181,8995],[2194,8996],[2197,9005],[2225,9009],[2227,9005],[2221,8999],[2213,8996],[2205,8989],[2219,8995],[2227,8995],[2229,9000],[2236,9001],[2237,9009],[2244,9015],[2259,9005],[2269,8995],[2272,8983],[2265,8983],[2254,8986],[2246,8986],[2236,8978],[2225,8979],[2208,8972],[2229,8976],[2246,8969],[2269,8969],[2282,8963],[2286,8956],[2282,8952],[2265,8955],[2256,8954],[2240,8961],[2216,8964],[2244,8957],[2231,8956],[2221,8950],[2235,8955],[2254,8947],[2245,8944],[2246,8938],[2253,8934],[2234,8937],[2232,8935],[2212,8937],[2220,8933],[2240,8931],[2235,8925],[2261,8921],[2279,8916],[2275,8911],[2282,8906],[2278,8897],[2285,8901],[2296,8901],[2300,8895],[2290,8887],[2294,8883],[2297,8892],[2309,8898],[2304,8892],[2306,8885],[2310,8893],[2321,8894],[2322,8890],[2335,8897],[2343,8893],[2338,8891],[2333,8882],[2345,8886],[2353,8883],[2363,8871],[2354,8867],[2364,8867],[2366,8859],[2357,8859],[2341,8855],[2360,8855],[2346,8851],[2365,8853],[2367,8856],[2381,8855],[2388,8861],[2393,8858],[2392,8852],[2386,8850],[2385,8841],[2377,8839],[2382,8831],[2383,8838],[2394,8842],[2405,8842],[2414,8830],[2410,8840],[2415,8846],[2423,8846],[2420,8840],[2427,8843],[2443,8828],[2439,8821],[2428,8826],[2435,8818],[2429,8816],[2439,8813],[2425,8809],[2417,8811],[2415,8815],[2404,8816],[2413,8809],[2407,8806],[2419,8802],[2424,8796],[2410,8794],[2414,8786],[2398,8783],[2405,8779],[2388,8777],[2381,8787],[2383,8772],[2374,8769],[2380,8766],[2384,8756],[2378,8741],[2368,8748],[2368,8755],[2361,8749],[2356,8751],[2352,8760],[2347,8751],[2320,8783],[2325,8791],[2339,8796],[2343,8808],[2335,8798],[2323,8794],[2308,8792],[2306,8797],[2314,8804],[2305,8800],[2297,8807],[2290,8805],[2291,8812],[2282,8814],[2280,8821],[2264,8822],[2271,8816],[2272,8810],[2264,8809],[2257,8816],[2250,8817],[2253,8807],[2267,8800],[2272,8795],[2269,8790],[2254,8792],[2248,8790],[2245,8798],[2238,8805],[2233,8804],[2245,8795],[2236,8797],[2237,8790],[2246,8784],[2252,8786],[2248,8773],[2261,8780],[2267,8777],[2262,8771],[2273,8769],[2278,8764],[2277,8752],[2281,8749],[2284,8735],[2286,8745],[2301,8740],[2299,8732],[2306,8741],[2317,8735],[2314,8722],[2331,8723],[2332,8719],[2322,8713],[2333,8702],[2329,8700],[2345,8698],[2337,8694],[2337,8691],[2345,8694],[2346,8689],[2351,8684],[2343,8688]],[[2337,8691],[2336,8688],[2343,8688],[2337,8691]]],[[[617,8061],[625,8060],[612,8058],[610,8066],[617,8061]]],[[[606,8073],[611,8068],[617,8065],[611,8066],[606,8073]]],[[[536,8079],[532,8079],[532,8083],[535,8083],[536,8079]]],[[[517,8101],[520,8092],[515,8092],[510,8100],[517,8101]]],[[[2360,8105],[2382,8100],[2407,8091],[2417,8084],[2426,8082],[2431,8072],[2415,8071],[2391,8077],[2376,8083],[2366,8094],[2353,8099],[2351,8103],[2360,8105]]],[[[568,8107],[566,8111],[568,8114],[571,8109],[568,8107]]],[[[563,8107],[558,8112],[560,8118],[563,8115],[563,8107]]],[[[574,8117],[578,8114],[573,8111],[570,8118],[574,8117]]],[[[562,8122],[562,8119],[557,8118],[559,8123],[562,8122]]],[[[483,8164],[477,8164],[475,8170],[479,8173],[483,8164]]],[[[480,8187],[475,8174],[472,8179],[475,8186],[480,8187]]],[[[1920,8189],[1913,8183],[1904,8181],[1903,8185],[1920,8189]]],[[[391,8189],[389,8187],[388,8184],[388,8190],[391,8189]]],[[[483,8191],[481,8188],[478,8187],[476,8190],[483,8191]]],[[[473,8185],[471,8189],[473,8192],[475,8192],[473,8185]]],[[[471,8194],[470,8190],[464,8191],[466,8194],[471,8194]]],[[[481,8196],[482,8192],[477,8192],[479,8194],[481,8196]]],[[[498,8195],[483,8183],[487,8194],[502,8201],[498,8195]]],[[[460,8203],[461,8197],[459,8195],[457,8202],[460,8203]]],[[[464,8208],[466,8204],[464,8202],[458,8208],[464,8208]]],[[[372,8213],[377,8213],[378,8210],[373,8208],[372,8213]]],[[[468,8199],[466,8209],[469,8216],[471,8204],[468,8199]]],[[[440,8216],[452,8209],[452,8204],[447,8207],[440,8216]]],[[[433,8226],[434,8222],[432,8222],[428,8229],[433,8226]]],[[[438,8229],[441,8224],[438,8224],[435,8232],[438,8229]]],[[[1851,8233],[1860,8232],[1870,8221],[1872,8212],[1863,8214],[1832,8225],[1837,8231],[1851,8233]]],[[[1897,8231],[1899,8229],[1895,8228],[1896,8231],[1897,8231]]],[[[452,8238],[447,8237],[446,8238],[450,8246],[452,8238]]],[[[403,8243],[406,8250],[424,8240],[428,8231],[422,8231],[407,8245],[403,8243]]],[[[401,8269],[411,8267],[414,8262],[403,8256],[399,8261],[401,8269]]],[[[389,8288],[399,8289],[400,8279],[392,8282],[389,8288]]],[[[1914,8300],[1904,8298],[1903,8299],[1922,8302],[1914,8300]]],[[[408,8295],[406,8297],[415,8306],[413,8298],[408,8295]]],[[[1924,8349],[1929,8364],[1932,8364],[1932,8353],[1924,8349]]],[[[1906,8372],[1905,8364],[1893,8354],[1891,8359],[1904,8364],[1906,8372]]],[[[1897,8382],[1894,8381],[1897,8385],[1901,8380],[1897,8382]]],[[[2260,8443],[2256,8444],[2257,8447],[2259,8448],[2260,8443]]],[[[2215,8474],[2206,8472],[2206,8479],[2213,8479],[2215,8474]]],[[[1881,8503],[1886,8505],[1888,8503],[1885,8500],[1881,8503]]],[[[1893,8511],[1896,8511],[1892,8507],[1887,8506],[1893,8511]]],[[[2344,8543],[2351,8529],[2342,8533],[2340,8538],[2344,8543]]],[[[2244,8543],[2251,8537],[2247,8530],[2237,8526],[2234,8530],[2239,8543],[2244,8543]]],[[[1945,8554],[1942,8551],[1931,8548],[1934,8551],[1945,8554]]],[[[2341,8589],[2345,8588],[2339,8576],[2320,8588],[2333,8593],[2341,8589]]],[[[2311,8599],[2314,8595],[2307,8597],[2311,8601],[2311,8599]]],[[[1514,8604],[1507,8599],[1504,8603],[1509,8603],[1514,8604]]],[[[2332,8603],[2339,8595],[2330,8597],[2327,8601],[2332,8603]]],[[[1909,8624],[1914,8618],[1913,8606],[1900,8588],[1887,8596],[1884,8603],[1886,8613],[1898,8625],[1909,8624]]],[[[1528,8624],[1530,8625],[1535,8625],[1532,8623],[1528,8624]]],[[[2343,8631],[2352,8631],[2346,8623],[2337,8625],[2343,8631]]],[[[1956,8632],[1949,8633],[1963,8633],[1959,8631],[1956,8632]]],[[[2338,8632],[2331,8631],[2334,8634],[2337,8634],[2338,8632]]],[[[2056,8640],[2068,8637],[2070,8634],[2058,8635],[2056,8640]]],[[[2164,8645],[2173,8641],[2182,8633],[2177,8630],[2165,8632],[2160,8640],[2151,8647],[2164,8645]]],[[[1831,8651],[1838,8649],[1835,8638],[1825,8633],[1812,8620],[1800,8614],[1796,8618],[1785,8613],[1778,8629],[1788,8638],[1789,8643],[1796,8649],[1801,8645],[1812,8649],[1831,8651]]],[[[2282,8650],[2282,8649],[2273,8657],[2278,8655],[2282,8650]]],[[[1939,8675],[1961,8673],[1966,8665],[1965,8661],[1953,8656],[1936,8670],[1939,8675]]],[[[1579,8675],[1577,8673],[1576,8675],[1570,8678],[1579,8675]]],[[[2359,8680],[2355,8675],[2362,8665],[2356,8667],[2349,8681],[2359,8680]]],[[[1977,8683],[1990,8679],[1994,8674],[1990,8669],[1982,8671],[1968,8680],[1970,8685],[1977,8683]]],[[[2356,8688],[2354,8688],[2354,8692],[2359,8690],[2356,8688]]],[[[1965,8700],[1959,8696],[1952,8698],[1953,8699],[1965,8700]]],[[[2336,8709],[2335,8708],[2333,8714],[2338,8711],[2336,8709]]],[[[2084,8722],[2082,8714],[2080,8714],[2079,8724],[2084,8722]]],[[[2326,8733],[2328,8729],[2315,8723],[2321,8731],[2326,8733]]],[[[2409,8782],[2415,8782],[2419,8778],[2409,8778],[2409,8782]]],[[[1796,8787],[1790,8785],[1788,8788],[1794,8788],[1796,8787]]],[[[1743,8797],[1753,8789],[1758,8777],[1755,8773],[1742,8783],[1740,8792],[1743,8797]]],[[[1765,8800],[1783,8793],[1781,8786],[1797,8781],[1793,8776],[1782,8779],[1779,8784],[1771,8783],[1771,8790],[1763,8795],[1765,8800]]],[[[1800,8810],[1807,8808],[1804,8804],[1796,8808],[1800,8810]]],[[[2411,8853],[2412,8852],[2399,8845],[2403,8853],[2411,8853]]],[[[1086,8848],[1082,8848],[1080,8852],[1081,8854],[1086,8848]]],[[[2376,8861],[2383,8859],[2380,8857],[2369,8858],[2376,8861]]],[[[1072,8864],[1070,8860],[1065,8865],[1071,8868],[1072,8864]]],[[[1057,8872],[1060,8871],[1057,8867],[1054,8871],[1057,8872]]],[[[2370,8869],[2363,8870],[2365,8877],[2370,8872],[2370,8869]]],[[[1071,8872],[1064,8871],[1065,8878],[1068,8877],[1071,8872]]],[[[914,8890],[908,8890],[923,8892],[923,8890],[914,8890]]],[[[1066,8889],[1061,8888],[1062,8892],[1065,8893],[1066,8889]]],[[[1034,8893],[1042,8892],[1041,8888],[1035,8891],[1034,8893]]],[[[1029,8896],[1030,8893],[1025,8896],[1025,8899],[1029,8896]]],[[[1014,8902],[1021,8905],[1012,8899],[1002,8896],[1014,8902]]],[[[2061,8898],[2087,8893],[2087,8883],[2058,8883],[2047,8892],[2047,8897],[2061,8898]]],[[[2298,8906],[2297,8902],[2287,8904],[2290,8907],[2298,8906]]],[[[1705,8891],[1699,8880],[1691,8884],[1688,8890],[1689,8903],[1695,8909],[1704,8905],[1705,8891]]],[[[960,8906],[957,8906],[959,8909],[964,8910],[960,8906]]],[[[2022,8910],[2036,8906],[2040,8900],[2035,8892],[2039,8885],[2038,8872],[2028,8862],[2014,8857],[1992,8855],[1982,8856],[1976,8865],[1972,8879],[1975,8888],[1990,8907],[2002,8911],[2022,8910]]],[[[1922,8903],[1917,8905],[1918,8912],[1928,8909],[1922,8903]]],[[[1830,8913],[1834,8912],[1831,8910],[1826,8913],[1830,8913]]],[[[2064,8907],[2058,8917],[2062,8917],[2067,8912],[2064,8907]]],[[[987,8923],[987,8921],[989,8919],[977,8919],[987,8923]]],[[[1171,8915],[1161,8917],[1155,8922],[1166,8924],[1172,8920],[1171,8915]]],[[[1934,8926],[1933,8919],[1923,8918],[1931,8925],[1934,8926]]],[[[2054,8923],[2046,8923],[2043,8926],[2046,8929],[2054,8923]]],[[[2043,8922],[2047,8919],[2045,8912],[2028,8921],[2033,8931],[2040,8928],[2043,8922]]],[[[2234,8935],[2240,8935],[2255,8931],[2249,8930],[2234,8935]]],[[[1252,8934],[1254,8929],[1250,8923],[1235,8929],[1244,8936],[1252,8934]]],[[[1299,8941],[1299,8935],[1292,8931],[1286,8934],[1285,8945],[1292,8947],[1299,8941]]],[[[1304,8943],[1297,8945],[1300,8953],[1303,8950],[1304,8943]]],[[[242,8952],[244,8950],[237,8951],[238,8955],[242,8952]]],[[[1255,8950],[1256,8957],[1259,8956],[1258,8951],[1255,8950]]],[[[1581,8964],[1585,8957],[1581,8956],[1579,8964],[1581,8964]]],[[[1938,8966],[1945,8961],[1938,8957],[1927,8941],[1915,8937],[1910,8942],[1916,8949],[1923,8951],[1930,8963],[1938,8966]]],[[[256,8975],[262,8979],[256,8969],[249,8971],[256,8975]]],[[[1842,8968],[1848,8966],[1849,8963],[1837,8967],[1842,8968]]],[[[1593,8966],[1589,8958],[1583,8963],[1588,8967],[1593,8966]]],[[[1980,8967],[1991,8965],[1983,8957],[1985,8953],[1976,8951],[1970,8959],[1971,8967],[1980,8967]]],[[[1267,8974],[1276,8970],[1268,8965],[1266,8969],[1267,8974]]],[[[1403,8974],[1417,8975],[1417,8964],[1405,8970],[1403,8974]]],[[[2266,8974],[2257,8971],[2253,8973],[2260,8977],[2266,8974]]],[[[1431,8977],[1440,8973],[1439,8965],[1430,8962],[1430,8974],[1425,8963],[1422,8964],[1424,8976],[1431,8977]]],[[[159,8976],[152,8973],[148,8976],[152,8979],[159,8976]]],[[[2250,8982],[2254,8978],[2247,8973],[2237,8976],[2250,8982]]],[[[1953,8981],[1949,8975],[1936,8971],[1926,8972],[1944,8984],[1953,8981]]],[[[1902,8988],[1913,8982],[1907,8978],[1891,8978],[1893,8971],[1886,8978],[1870,8980],[1872,8985],[1886,8987],[1894,8983],[1902,8988]]],[[[1819,8985],[1817,8984],[1810,8986],[1815,8988],[1819,8985]]],[[[1789,8986],[1784,8983],[1779,8985],[1779,8989],[1789,8986]]],[[[1545,8988],[1547,8991],[1554,8988],[1552,8983],[1545,8988]]],[[[1382,8993],[1379,8992],[1378,8995],[1382,8995],[1382,8993]]],[[[1687,9004],[1699,9004],[1703,8998],[1693,8996],[1679,8999],[1675,9003],[1687,9004]]],[[[960,9014],[947,9013],[942,9017],[954,9014],[960,9014]]],[[[820,9026],[829,9026],[815,9023],[810,9027],[820,9026]]],[[[807,9027],[797,9026],[794,9028],[796,9029],[807,9027]]],[[[477,9030],[472,9029],[469,9026],[473,9033],[477,9030]]],[[[1284,9034],[1290,9034],[1297,9022],[1285,9027],[1284,9034]]],[[[2133,9054],[2147,9052],[2145,9046],[2126,9041],[2122,9047],[2133,9054]]],[[[1399,9168],[1405,9164],[1402,9159],[1394,9157],[1388,9165],[1398,9172],[1399,9168]]],[[[1169,9179],[1157,9163],[1147,9156],[1148,9153],[1126,9174],[1112,9185],[1097,9189],[1110,9202],[1152,9204],[1171,9193],[1169,9179]]],[[[1373,9222],[1359,9211],[1335,9207],[1320,9213],[1341,9220],[1371,9225],[1373,9222]]],[[[1194,9294],[1198,9287],[1190,9280],[1179,9278],[1169,9279],[1159,9284],[1165,9296],[1174,9302],[1182,9302],[1191,9298],[1194,9294]]],[[[1413,9315],[1424,9311],[1416,9304],[1407,9309],[1407,9304],[1396,9298],[1391,9306],[1409,9312],[1413,9315]]],[[[1243,9335],[1224,9322],[1206,9321],[1214,9331],[1239,9336],[1243,9335]]],[[[1471,9322],[1461,9321],[1454,9333],[1465,9336],[1471,9322]]],[[[1235,9340],[1235,9337],[1195,9330],[1187,9333],[1206,9338],[1232,9342],[1235,9340]]],[[[784,9344],[790,9342],[779,9328],[775,9320],[766,9312],[756,9307],[732,9312],[756,9332],[769,9335],[771,9339],[784,9344]]],[[[1922,9344],[1928,9342],[1918,9335],[1926,9328],[1914,9329],[1908,9326],[1900,9329],[1922,9344]]],[[[1226,9353],[1229,9346],[1220,9341],[1192,9338],[1175,9341],[1172,9345],[1177,9349],[1224,9356],[1226,9353]]],[[[1188,9374],[1198,9369],[1213,9365],[1215,9362],[1206,9357],[1175,9356],[1174,9365],[1169,9366],[1167,9373],[1176,9377],[1188,9374]]],[[[1294,9380],[1264,9371],[1254,9372],[1267,9376],[1275,9381],[1285,9383],[1294,9380]]],[[[1607,9368],[1596,9366],[1582,9380],[1583,9385],[1599,9388],[1607,9382],[1604,9377],[1607,9368]]],[[[900,9390],[908,9384],[902,9379],[879,9381],[866,9383],[879,9390],[900,9390]]],[[[1589,9437],[1605,9428],[1609,9419],[1596,9410],[1571,9417],[1563,9423],[1564,9436],[1572,9439],[1589,9437]]],[[[1156,9424],[1164,9424],[1174,9417],[1173,9407],[1164,9405],[1150,9408],[1137,9422],[1137,9430],[1125,9444],[1130,9446],[1142,9443],[1157,9431],[1156,9424]]],[[[1276,9444],[1258,9444],[1251,9440],[1232,9444],[1229,9450],[1233,9454],[1255,9454],[1268,9451],[1276,9444]]],[[[882,9462],[899,9454],[904,9449],[887,9442],[883,9442],[866,9452],[859,9458],[868,9460],[882,9466],[882,9462]]],[[[1320,9600],[1330,9601],[1337,9598],[1342,9590],[1340,9585],[1344,9578],[1339,9570],[1335,9574],[1324,9576],[1324,9582],[1316,9585],[1302,9584],[1298,9594],[1310,9602],[1320,9600]]],[[[1437,9640],[1449,9639],[1446,9634],[1433,9637],[1417,9637],[1437,9640]]],[[[1728,8021],[1725,8020],[1718,8020],[1720,8023],[1728,8021]]],[[[1665,8062],[1669,8059],[1658,8059],[1658,8063],[1665,8062]]],[[[1826,7958],[1830,7951],[1835,7956],[1840,7947],[1846,7947],[1839,7939],[1814,7949],[1798,7952],[1810,7956],[1812,7951],[1826,7958]]],[[[1795,7955],[1794,7952],[1790,7953],[1792,7956],[1795,7955]]],[[[1774,7968],[1781,7965],[1777,7959],[1773,7964],[1774,7968]]],[[[1433,9446],[1439,9445],[1453,9447],[1479,9446],[1482,9444],[1492,9447],[1503,9444],[1507,9439],[1500,9438],[1495,9427],[1482,9425],[1471,9428],[1422,9428],[1412,9436],[1415,9442],[1433,9446]]],[[[2376,7964],[2372,7971],[2360,7972],[2360,7979],[2352,7982],[2364,7996],[2361,7985],[2372,7977],[2384,7975],[2386,7971],[2406,7974],[2423,7973],[2412,7970],[2407,7955],[2396,7957],[2397,7961],[2389,7965],[2385,7962],[2376,7964]]],[[[1907,8348],[1906,8351],[1895,8339],[1892,8342],[1906,8357],[1910,8355],[1914,8373],[1921,8364],[1918,8356],[1908,8341],[1904,8342],[1907,8348]]],[[[1027,9481],[1015,9480],[1009,9482],[1000,9479],[985,9481],[975,9486],[967,9478],[957,9478],[945,9485],[919,9478],[911,9482],[914,9486],[946,9497],[956,9496],[968,9500],[975,9506],[997,9510],[1024,9498],[1031,9490],[1027,9481]]],[[[544,8076],[546,8079],[540,8077],[537,8085],[530,8082],[521,8084],[522,8091],[529,8093],[521,8096],[515,8104],[505,8101],[501,8112],[495,8114],[485,8110],[487,8116],[480,8120],[482,8124],[473,8127],[467,8136],[483,8141],[503,8131],[512,8132],[510,8128],[545,8121],[541,8123],[545,8122],[556,8124],[546,8121],[554,8120],[563,8104],[571,8096],[569,8095],[580,8089],[581,8083],[598,8078],[610,8062],[611,8056],[618,8054],[618,8047],[610,8042],[600,8045],[578,8052],[562,8061],[572,8069],[554,8065],[542,8072],[543,8074],[540,8075],[542,8077],[544,8077],[544,8076]]],[[[591,8088],[578,8097],[587,8095],[591,8088],[591,8088],[591,8088]]],[[[445,8228],[440,8229],[440,8233],[445,8236],[446,8229],[447,8236],[461,8230],[464,8223],[462,8209],[457,8208],[460,8220],[453,8210],[448,8214],[444,8224],[445,8228]]],[[[414,8255],[412,8258],[415,8261],[428,8251],[440,8238],[433,8233],[419,8247],[415,8254],[417,8248],[411,8249],[409,8251],[414,8255]]],[[[2005,7893],[2005,7893],[2005,7892],[2000,7891],[1996,7888],[1998,7892],[2005,7893]]],[[[348,8230],[341,8234],[350,8237],[336,8243],[334,8252],[328,8260],[332,8272],[353,8268],[358,8259],[355,8255],[343,8252],[344,8249],[356,8250],[359,8260],[358,8264],[372,8271],[371,8264],[364,8249],[364,8238],[361,8234],[349,8230],[360,8230],[368,8234],[374,8226],[370,8212],[372,8206],[377,8204],[382,8195],[390,8194],[386,8189],[380,8192],[372,8203],[358,8214],[352,8223],[345,8230],[348,8230]]],[[[750,9420],[769,9420],[778,9422],[781,9419],[797,9416],[807,9418],[814,9422],[804,9423],[799,9426],[821,9433],[849,9420],[851,9417],[835,9411],[826,9410],[826,9400],[840,9396],[832,9391],[822,9392],[832,9387],[836,9379],[823,9372],[810,9371],[801,9368],[805,9358],[793,9352],[779,9356],[774,9361],[776,9379],[782,9384],[764,9384],[759,9380],[765,9371],[758,9367],[752,9370],[745,9366],[754,9364],[757,9357],[749,9354],[747,9347],[742,9342],[736,9344],[730,9358],[724,9353],[730,9339],[719,9328],[710,9330],[701,9326],[701,9337],[695,9337],[696,9345],[690,9349],[685,9340],[689,9333],[688,9325],[683,9320],[677,9322],[685,9325],[682,9336],[677,9331],[661,9339],[652,9339],[652,9335],[644,9332],[637,9336],[642,9343],[636,9347],[627,9343],[632,9351],[645,9361],[669,9363],[673,9370],[683,9377],[704,9386],[712,9398],[733,9410],[736,9416],[750,9420]]],[[[2483,7958],[2488,7957],[2490,7956],[2470,7943],[2456,7941],[2452,7937],[2439,7945],[2436,7958],[2444,7966],[2456,7986],[2464,7995],[2470,7993],[2471,7979],[2465,7966],[2469,7967],[2454,7950],[2449,7948],[2460,7945],[2460,7948],[2470,7956],[2459,7955],[2473,7969],[2487,7963],[2483,7958]]],[[[2657,8087],[2674,8078],[2670,8070],[2662,8067],[2659,8062],[2661,8052],[2672,8049],[2675,8054],[2681,8051],[2685,8057],[2686,8047],[2672,8038],[2663,8020],[2672,8014],[2673,8021],[2680,8031],[2690,8034],[2680,8017],[2682,8010],[2690,8014],[2694,8023],[2699,8013],[2694,8003],[2689,7986],[2684,7980],[2680,7984],[2671,7979],[2669,7993],[2672,8000],[2657,7986],[2653,7991],[2658,8002],[2664,8009],[2654,8013],[2654,8007],[2646,8010],[2631,8005],[2621,7990],[2607,7988],[2600,7992],[2606,7997],[2602,8010],[2609,8019],[2579,8017],[2574,8013],[2547,8016],[2539,8019],[2507,8014],[2502,8017],[2499,8026],[2521,8045],[2529,8049],[2520,8052],[2503,8048],[2512,8054],[2520,8052],[2529,8074],[2538,8068],[2534,8083],[2542,8092],[2543,8097],[2552,8113],[2560,8130],[2572,8142],[2578,8158],[2605,8170],[2603,8165],[2617,8168],[2611,8157],[2598,8160],[2599,8154],[2608,8152],[2610,8144],[2613,8134],[2597,8134],[2578,8108],[2575,8090],[2583,8101],[2595,8113],[2595,8106],[2603,8108],[2615,8104],[2597,8095],[2602,8096],[2601,8087],[2609,8083],[2614,8087],[2625,8086],[2621,8076],[2632,8079],[2637,8090],[2650,8091],[2656,8096],[2657,8087]]],[[[1767,8681],[1758,8667],[1737,8658],[1731,8658],[1727,8664],[1727,8684],[1722,8685],[1708,8682],[1697,8683],[1691,8678],[1681,8679],[1681,8686],[1690,8696],[1710,8703],[1705,8713],[1704,8727],[1711,8743],[1712,8765],[1718,8783],[1731,8791],[1731,8785],[1740,8785],[1744,8776],[1736,8772],[1745,8766],[1748,8757],[1751,8757],[1758,8770],[1770,8763],[1768,8759],[1778,8754],[1793,8753],[1798,8744],[1818,8734],[1824,8735],[1841,8723],[1841,8713],[1848,8709],[1845,8705],[1834,8699],[1855,8703],[1864,8699],[1867,8705],[1877,8697],[1874,8693],[1887,8690],[1879,8686],[1863,8673],[1832,8684],[1820,8684],[1823,8695],[1818,8698],[1800,8699],[1805,8705],[1789,8704],[1784,8699],[1785,8688],[1781,8688],[1772,8681],[1767,8681]]],[[[1333,8953],[1342,8956],[1344,8961],[1351,8964],[1345,8969],[1350,8970],[1347,8976],[1363,8969],[1352,8977],[1356,8987],[1362,8992],[1371,8990],[1386,8981],[1396,8971],[1406,8968],[1417,8959],[1415,8949],[1418,8947],[1419,8957],[1426,8940],[1434,8937],[1441,8940],[1445,8938],[1435,8929],[1427,8931],[1413,8919],[1406,8917],[1389,8924],[1388,8921],[1379,8921],[1368,8928],[1360,8929],[1350,8938],[1347,8932],[1337,8937],[1334,8943],[1328,8937],[1320,8940],[1316,8947],[1320,8952],[1333,8953]]],[[[1208,9029],[1211,9025],[1212,9034],[1220,9029],[1220,9025],[1233,9020],[1247,9012],[1254,9014],[1259,9004],[1263,9007],[1275,9007],[1278,8986],[1275,8980],[1265,8981],[1260,8992],[1255,8979],[1244,8987],[1242,8980],[1233,8988],[1228,8984],[1230,8975],[1222,8973],[1207,8981],[1201,8978],[1209,8974],[1216,8967],[1214,8959],[1220,8965],[1231,8970],[1243,8970],[1247,8967],[1240,8964],[1252,8955],[1249,8948],[1231,8939],[1203,8934],[1173,8942],[1169,8938],[1153,8940],[1148,8943],[1159,8948],[1131,8954],[1115,8955],[1119,8960],[1112,8971],[1099,8964],[1100,8958],[1088,8947],[1070,8942],[1052,8943],[1052,8939],[1040,8932],[1021,8927],[992,8926],[981,8922],[969,8924],[964,8922],[933,8920],[929,8918],[914,8917],[918,8921],[911,8924],[901,8936],[905,8948],[901,8955],[893,8959],[880,8960],[857,8958],[834,8961],[814,8969],[808,8978],[796,8985],[790,8997],[804,9004],[832,9009],[886,9014],[921,9010],[915,9013],[934,9008],[935,9011],[965,9012],[963,9017],[956,9016],[945,9024],[929,9028],[925,9026],[915,9032],[905,9032],[892,9036],[886,9033],[861,9030],[841,9030],[831,9027],[826,9032],[804,9030],[786,9030],[782,9035],[768,9042],[763,9052],[780,9060],[789,9061],[830,9071],[827,9074],[840,9079],[850,9075],[849,9080],[838,9081],[809,9074],[787,9071],[769,9071],[765,9076],[770,9080],[784,9081],[777,9084],[782,9088],[772,9087],[768,9083],[757,9087],[743,9085],[740,9093],[742,9101],[752,9108],[754,9113],[770,9118],[770,9123],[761,9125],[756,9129],[768,9141],[778,9144],[792,9157],[806,9159],[827,9168],[845,9173],[874,9183],[884,9180],[893,9169],[890,9159],[891,9150],[881,9147],[884,9144],[874,9139],[881,9136],[888,9141],[900,9140],[909,9146],[903,9148],[910,9156],[921,9162],[948,9155],[974,9146],[971,9137],[963,9130],[955,9127],[960,9122],[969,9128],[979,9121],[977,9128],[992,9139],[1008,9130],[1015,9130],[1002,9136],[1016,9133],[1004,9146],[1014,9143],[1015,9146],[1004,9147],[1003,9151],[994,9153],[989,9162],[1007,9161],[1017,9154],[1050,9137],[1049,9125],[1056,9114],[1056,9105],[1063,9103],[1060,9094],[1069,9085],[1076,9085],[1081,9093],[1090,9095],[1084,9098],[1090,9100],[1080,9106],[1075,9113],[1075,9131],[1066,9148],[1064,9164],[1060,9169],[1063,9173],[1072,9172],[1064,9178],[1069,9192],[1068,9196],[1080,9194],[1078,9180],[1093,9172],[1098,9178],[1113,9174],[1120,9166],[1132,9162],[1146,9149],[1148,9131],[1158,9116],[1162,9098],[1166,9096],[1175,9082],[1178,9071],[1171,9069],[1169,9055],[1183,9045],[1186,9038],[1199,9030],[1208,9029]]],[[[1909,9197],[1948,9199],[1975,9190],[1980,9181],[1990,9178],[1992,9171],[2003,9166],[2003,9158],[2009,9156],[2001,9151],[1947,9155],[1933,9153],[1917,9147],[1905,9148],[1893,9153],[1888,9164],[1888,9174],[1870,9177],[1867,9186],[1867,9204],[1880,9205],[1889,9201],[1892,9203],[1909,9197]]],[[[1303,9098],[1285,9116],[1278,9117],[1268,9124],[1263,9119],[1250,9123],[1246,9131],[1227,9142],[1223,9151],[1231,9163],[1247,9166],[1250,9159],[1259,9154],[1266,9145],[1277,9144],[1279,9148],[1291,9146],[1295,9154],[1302,9155],[1297,9169],[1290,9166],[1288,9174],[1295,9177],[1302,9175],[1293,9184],[1294,9180],[1279,9176],[1266,9182],[1256,9189],[1268,9196],[1277,9195],[1283,9188],[1288,9195],[1277,9197],[1272,9203],[1278,9209],[1292,9209],[1303,9205],[1308,9212],[1301,9208],[1298,9214],[1310,9215],[1313,9209],[1327,9203],[1360,9208],[1366,9213],[1385,9210],[1394,9203],[1392,9197],[1379,9190],[1388,9184],[1371,9178],[1353,9164],[1348,9162],[1349,9155],[1363,9164],[1373,9163],[1385,9159],[1384,9153],[1394,9147],[1399,9155],[1408,9141],[1413,9129],[1402,9123],[1405,9120],[1407,9101],[1404,9096],[1393,9095],[1390,9089],[1379,9084],[1359,9086],[1352,9091],[1357,9099],[1348,9090],[1362,9080],[1356,9073],[1341,9066],[1334,9072],[1326,9070],[1322,9083],[1316,9086],[1308,9098],[1303,9098]]],[[[1593,9213],[1558,9173],[1544,9153],[1537,9147],[1528,9145],[1498,9150],[1476,9148],[1484,9145],[1496,9131],[1486,9123],[1477,9107],[1458,9106],[1447,9104],[1449,9113],[1445,9117],[1447,9131],[1436,9146],[1430,9150],[1433,9157],[1430,9162],[1434,9170],[1433,9183],[1430,9198],[1432,9203],[1444,9204],[1450,9199],[1456,9200],[1442,9211],[1444,9219],[1459,9224],[1483,9226],[1488,9223],[1490,9228],[1502,9228],[1516,9226],[1531,9218],[1552,9220],[1569,9219],[1593,9213]]],[[[638,9245],[668,9250],[682,9248],[687,9243],[710,9234],[725,9231],[723,9225],[730,9231],[741,9230],[742,9223],[739,9218],[745,9219],[753,9231],[772,9234],[791,9232],[807,9223],[835,9203],[844,9199],[853,9188],[840,9181],[819,9176],[797,9165],[792,9164],[773,9155],[753,9147],[740,9140],[734,9125],[721,9118],[707,9119],[710,9114],[702,9103],[704,9088],[696,9078],[673,9071],[665,9076],[653,9066],[638,9060],[633,9056],[624,9055],[614,9064],[607,9078],[595,9089],[578,9095],[560,9103],[541,9103],[544,9112],[559,9133],[569,9137],[567,9151],[583,9157],[572,9165],[578,9170],[584,9185],[595,9192],[595,9198],[604,9205],[593,9210],[584,9222],[579,9236],[575,9238],[618,9244],[638,9245]]],[[[1459,9255],[1448,9258],[1440,9252],[1441,9247],[1425,9252],[1435,9256],[1436,9266],[1425,9266],[1419,9271],[1404,9276],[1408,9288],[1426,9301],[1428,9306],[1442,9313],[1454,9315],[1469,9313],[1495,9292],[1494,9279],[1498,9270],[1496,9259],[1492,9256],[1459,9255]]],[[[1296,9376],[1308,9374],[1314,9375],[1331,9361],[1338,9365],[1332,9369],[1336,9375],[1347,9374],[1373,9366],[1369,9356],[1377,9345],[1373,9335],[1375,9328],[1365,9321],[1381,9317],[1380,9305],[1371,9311],[1362,9305],[1369,9302],[1361,9300],[1361,9294],[1375,9285],[1364,9283],[1362,9278],[1341,9276],[1322,9276],[1324,9284],[1314,9275],[1294,9277],[1292,9293],[1281,9298],[1291,9299],[1283,9303],[1303,9304],[1296,9308],[1313,9312],[1309,9316],[1334,9317],[1335,9319],[1288,9315],[1264,9311],[1261,9313],[1226,9306],[1222,9309],[1228,9320],[1238,9320],[1237,9329],[1250,9331],[1264,9323],[1257,9332],[1262,9337],[1254,9336],[1248,9342],[1253,9348],[1263,9352],[1242,9350],[1251,9364],[1262,9363],[1273,9356],[1271,9351],[1283,9347],[1285,9341],[1293,9340],[1299,9331],[1305,9329],[1320,9335],[1309,9333],[1297,9345],[1313,9344],[1304,9349],[1290,9351],[1291,9354],[1303,9355],[1294,9360],[1284,9360],[1275,9367],[1296,9376]]],[[[797,9305],[832,9305],[845,9312],[854,9312],[861,9319],[829,9311],[798,9311],[797,9314],[807,9324],[866,9328],[866,9331],[827,9328],[812,9330],[819,9335],[812,9340],[817,9346],[828,9349],[849,9348],[867,9345],[854,9351],[839,9351],[835,9358],[847,9364],[878,9367],[886,9365],[888,9356],[893,9348],[911,9353],[921,9353],[938,9347],[940,9338],[957,9333],[957,9330],[945,9327],[966,9327],[968,9313],[973,9308],[994,9311],[1042,9306],[1043,9318],[1019,9325],[1017,9329],[1008,9330],[1026,9337],[1030,9343],[1023,9348],[1012,9348],[998,9355],[998,9363],[1015,9366],[1024,9381],[1033,9387],[1046,9389],[1048,9384],[1055,9381],[1047,9376],[1052,9371],[1053,9362],[1059,9361],[1066,9354],[1058,9348],[1054,9339],[1072,9340],[1079,9335],[1071,9330],[1069,9323],[1077,9329],[1087,9331],[1096,9330],[1102,9322],[1101,9333],[1109,9340],[1117,9340],[1134,9336],[1142,9330],[1145,9315],[1135,9306],[1139,9304],[1137,9298],[1126,9284],[1127,9280],[1105,9277],[1098,9272],[1083,9273],[1077,9281],[1067,9273],[1056,9272],[1044,9281],[1028,9273],[1022,9268],[1007,9266],[1000,9268],[992,9264],[991,9259],[961,9247],[938,9242],[920,9241],[901,9244],[880,9255],[879,9259],[899,9267],[907,9267],[927,9276],[949,9277],[957,9276],[972,9282],[982,9291],[973,9292],[969,9288],[940,9284],[942,9289],[911,9281],[893,9281],[898,9297],[910,9301],[895,9299],[890,9305],[890,9298],[886,9290],[876,9295],[883,9287],[879,9281],[863,9275],[856,9277],[854,9285],[841,9275],[825,9281],[825,9289],[813,9284],[788,9288],[784,9291],[787,9298],[797,9305]]],[[[1894,9282],[1880,9279],[1885,9274],[1899,9278],[1905,9278],[1911,9269],[1886,9262],[1888,9254],[1877,9251],[1854,9251],[1840,9245],[1807,9250],[1801,9259],[1801,9267],[1788,9270],[1795,9263],[1790,9252],[1767,9248],[1748,9248],[1746,9259],[1745,9249],[1736,9247],[1731,9257],[1728,9247],[1712,9246],[1709,9253],[1707,9247],[1693,9250],[1698,9246],[1679,9245],[1675,9249],[1668,9245],[1642,9247],[1644,9259],[1641,9271],[1632,9257],[1630,9264],[1623,9253],[1615,9250],[1600,9249],[1578,9256],[1576,9260],[1568,9259],[1576,9267],[1574,9270],[1562,9261],[1566,9255],[1554,9256],[1551,9260],[1539,9263],[1539,9271],[1533,9281],[1539,9283],[1525,9289],[1526,9299],[1531,9307],[1539,9312],[1534,9321],[1536,9329],[1521,9337],[1520,9345],[1506,9359],[1479,9352],[1463,9353],[1458,9356],[1449,9350],[1440,9351],[1456,9357],[1427,9361],[1418,9367],[1421,9370],[1408,9379],[1396,9379],[1412,9386],[1399,9389],[1398,9397],[1414,9397],[1410,9400],[1428,9403],[1445,9398],[1466,9396],[1477,9391],[1489,9393],[1504,9382],[1501,9370],[1491,9364],[1499,9365],[1508,9375],[1529,9373],[1539,9377],[1556,9379],[1569,9377],[1581,9371],[1579,9364],[1559,9368],[1557,9364],[1585,9361],[1619,9355],[1617,9348],[1585,9347],[1591,9345],[1564,9348],[1562,9346],[1593,9340],[1590,9338],[1566,9338],[1571,9332],[1589,9335],[1595,9333],[1598,9337],[1608,9331],[1605,9324],[1612,9328],[1622,9324],[1620,9314],[1609,9314],[1613,9310],[1622,9311],[1630,9302],[1635,9305],[1631,9313],[1636,9317],[1651,9307],[1650,9305],[1665,9311],[1672,9306],[1676,9313],[1683,9312],[1693,9305],[1704,9302],[1698,9298],[1722,9302],[1712,9307],[1716,9308],[1728,9312],[1736,9311],[1744,9316],[1758,9314],[1755,9318],[1766,9319],[1783,9326],[1792,9322],[1802,9321],[1824,9327],[1860,9323],[1855,9316],[1863,9314],[1878,9316],[1890,9311],[1893,9308],[1882,9304],[1903,9304],[1909,9294],[1904,9287],[1894,9282]]],[[[932,9427],[915,9431],[918,9437],[914,9440],[912,9448],[914,9455],[924,9456],[943,9462],[960,9463],[964,9465],[988,9467],[1018,9467],[1019,9459],[1003,9454],[985,9452],[988,9446],[1006,9447],[1008,9438],[1003,9429],[984,9424],[972,9425],[947,9418],[937,9421],[932,9427]]],[[[1351,9492],[1362,9497],[1353,9503],[1352,9511],[1358,9514],[1379,9512],[1417,9501],[1414,9495],[1424,9492],[1431,9495],[1448,9490],[1456,9484],[1440,9477],[1454,9468],[1448,9458],[1440,9459],[1427,9455],[1411,9452],[1407,9455],[1396,9447],[1389,9448],[1392,9456],[1369,9463],[1373,9467],[1394,9466],[1396,9469],[1385,9473],[1368,9475],[1361,9480],[1362,9486],[1351,9492]]],[[[1173,9523],[1169,9516],[1162,9512],[1156,9514],[1166,9526],[1158,9529],[1140,9527],[1138,9536],[1145,9547],[1152,9545],[1194,9549],[1212,9545],[1227,9532],[1225,9524],[1230,9518],[1233,9526],[1248,9531],[1255,9531],[1275,9521],[1268,9514],[1277,9511],[1292,9514],[1307,9506],[1302,9502],[1317,9499],[1313,9492],[1308,9489],[1311,9480],[1318,9479],[1332,9466],[1333,9454],[1328,9451],[1310,9449],[1306,9447],[1286,9452],[1281,9459],[1281,9466],[1273,9474],[1240,9479],[1222,9474],[1214,9469],[1208,9473],[1214,9477],[1221,9477],[1223,9485],[1196,9481],[1188,9476],[1172,9478],[1163,9483],[1155,9493],[1167,9498],[1185,9494],[1200,9493],[1203,9501],[1186,9501],[1189,9504],[1201,9504],[1205,9507],[1201,9512],[1191,9508],[1180,9512],[1191,9518],[1184,9524],[1173,9523]]],[[[1572,9470],[1539,9474],[1534,9479],[1521,9482],[1510,9491],[1513,9493],[1547,9497],[1516,9502],[1504,9499],[1486,9510],[1493,9511],[1505,9508],[1509,9510],[1494,9515],[1484,9515],[1473,9523],[1474,9526],[1492,9529],[1497,9536],[1503,9537],[1543,9536],[1587,9541],[1568,9542],[1537,9539],[1521,9542],[1523,9546],[1542,9545],[1564,9549],[1565,9551],[1544,9548],[1522,9551],[1533,9554],[1522,9555],[1510,9551],[1495,9549],[1483,9542],[1476,9548],[1485,9552],[1466,9554],[1465,9548],[1444,9544],[1446,9548],[1429,9552],[1433,9562],[1459,9566],[1471,9571],[1472,9576],[1458,9571],[1445,9568],[1426,9569],[1413,9579],[1404,9584],[1418,9586],[1405,9588],[1399,9597],[1401,9602],[1411,9601],[1421,9597],[1446,9594],[1456,9595],[1468,9591],[1457,9598],[1464,9603],[1478,9604],[1462,9607],[1452,9602],[1439,9600],[1432,9604],[1433,9609],[1423,9606],[1405,9611],[1408,9614],[1423,9618],[1438,9615],[1437,9618],[1419,9626],[1421,9632],[1452,9633],[1464,9630],[1472,9630],[1482,9627],[1480,9632],[1465,9633],[1462,9639],[1478,9640],[1465,9641],[1447,9646],[1436,9647],[1447,9652],[1437,9654],[1444,9661],[1455,9665],[1470,9659],[1481,9664],[1470,9668],[1505,9667],[1504,9675],[1487,9675],[1469,9679],[1475,9686],[1495,9683],[1494,9687],[1502,9686],[1532,9678],[1545,9671],[1542,9666],[1553,9659],[1566,9643],[1577,9640],[1577,9630],[1603,9628],[1618,9628],[1626,9624],[1620,9612],[1627,9605],[1639,9600],[1653,9598],[1636,9612],[1637,9618],[1643,9622],[1666,9620],[1670,9604],[1656,9601],[1659,9596],[1680,9597],[1686,9589],[1676,9581],[1688,9586],[1681,9567],[1675,9564],[1677,9559],[1682,9564],[1698,9569],[1707,9568],[1715,9563],[1716,9554],[1720,9565],[1729,9564],[1734,9555],[1748,9545],[1731,9536],[1701,9530],[1694,9523],[1687,9529],[1688,9520],[1678,9513],[1671,9504],[1661,9505],[1657,9513],[1658,9523],[1654,9526],[1650,9513],[1660,9496],[1656,9490],[1652,9481],[1646,9476],[1650,9490],[1641,9499],[1635,9500],[1641,9488],[1633,9471],[1628,9472],[1617,9482],[1608,9489],[1598,9500],[1595,9497],[1599,9489],[1605,9486],[1614,9471],[1601,9475],[1594,9482],[1576,9481],[1587,9479],[1588,9470],[1572,9470]]],[[[2004,9462],[1985,9455],[1977,9457],[1955,9457],[1946,9459],[1939,9455],[1953,9450],[1962,9452],[1964,9449],[1950,9444],[1959,9435],[1952,9433],[1951,9427],[1943,9421],[1927,9417],[1927,9421],[1918,9416],[1903,9418],[1894,9415],[1870,9419],[1846,9430],[1844,9435],[1835,9439],[1844,9431],[1842,9425],[1857,9418],[1838,9416],[1838,9408],[1860,9416],[1889,9411],[1881,9403],[1901,9413],[1909,9413],[1921,9408],[1922,9404],[1911,9393],[1926,9393],[1923,9388],[1942,9399],[1954,9396],[1960,9387],[1958,9377],[1951,9375],[1947,9369],[1937,9364],[1935,9371],[1929,9372],[1922,9362],[1912,9354],[1906,9356],[1890,9350],[1861,9344],[1856,9346],[1865,9353],[1870,9362],[1857,9367],[1836,9367],[1832,9374],[1824,9376],[1817,9384],[1819,9377],[1831,9371],[1826,9361],[1810,9360],[1799,9363],[1783,9363],[1773,9370],[1772,9375],[1768,9369],[1778,9365],[1759,9363],[1748,9371],[1744,9368],[1747,9362],[1763,9357],[1763,9355],[1740,9354],[1738,9356],[1704,9361],[1709,9370],[1697,9365],[1695,9358],[1684,9360],[1675,9364],[1669,9374],[1671,9364],[1668,9357],[1663,9362],[1660,9359],[1645,9360],[1647,9366],[1641,9382],[1636,9380],[1643,9367],[1636,9373],[1630,9361],[1626,9364],[1609,9364],[1615,9367],[1608,9371],[1615,9378],[1612,9389],[1636,9399],[1649,9406],[1669,9404],[1689,9414],[1667,9420],[1668,9428],[1651,9439],[1652,9448],[1681,9455],[1691,9454],[1710,9448],[1717,9442],[1722,9424],[1728,9427],[1734,9423],[1746,9422],[1761,9417],[1757,9422],[1773,9423],[1791,9420],[1781,9427],[1793,9430],[1808,9443],[1819,9458],[1811,9462],[1812,9455],[1806,9453],[1792,9436],[1777,9429],[1765,9431],[1753,9430],[1744,9426],[1738,9431],[1730,9432],[1747,9435],[1737,9439],[1735,9444],[1741,9448],[1736,9453],[1759,9456],[1739,9455],[1732,9453],[1726,9458],[1744,9465],[1746,9471],[1762,9474],[1746,9474],[1753,9483],[1747,9483],[1731,9468],[1709,9465],[1709,9471],[1718,9476],[1721,9483],[1708,9473],[1701,9474],[1693,9468],[1672,9469],[1672,9490],[1682,9496],[1688,9507],[1698,9513],[1723,9514],[1738,9520],[1754,9517],[1782,9515],[1800,9507],[1811,9505],[1817,9500],[1827,9500],[1816,9506],[1824,9510],[1811,9508],[1798,9513],[1798,9516],[1822,9514],[1841,9517],[1843,9524],[1849,9529],[1837,9527],[1830,9520],[1818,9518],[1805,9522],[1785,9521],[1767,9522],[1753,9528],[1760,9535],[1770,9534],[1776,9529],[1791,9527],[1771,9537],[1765,9538],[1761,9553],[1749,9558],[1745,9566],[1727,9572],[1720,9572],[1703,9575],[1703,9588],[1707,9590],[1738,9587],[1730,9590],[1703,9592],[1697,9602],[1703,9614],[1719,9615],[1736,9610],[1757,9611],[1781,9609],[1801,9597],[1829,9583],[1839,9571],[1844,9571],[1844,9565],[1852,9568],[1875,9563],[1875,9565],[1895,9568],[1900,9572],[1867,9569],[1848,9573],[1844,9586],[1850,9589],[1829,9593],[1798,9613],[1800,9615],[1834,9619],[1882,9624],[1891,9628],[1931,9631],[1948,9630],[1951,9633],[1929,9634],[1894,9634],[1911,9639],[1936,9645],[1966,9649],[1994,9650],[1993,9654],[1980,9653],[1952,9654],[1927,9650],[1926,9661],[1938,9668],[1939,9672],[1947,9674],[1963,9683],[1979,9687],[1985,9692],[1946,9682],[1932,9674],[1930,9668],[1924,9668],[1907,9674],[1918,9668],[1912,9660],[1917,9659],[1904,9648],[1857,9635],[1807,9629],[1801,9629],[1802,9636],[1829,9641],[1841,9648],[1835,9649],[1817,9642],[1796,9640],[1789,9644],[1801,9649],[1796,9650],[1784,9643],[1779,9644],[1783,9635],[1781,9630],[1763,9627],[1748,9628],[1742,9626],[1720,9629],[1729,9634],[1713,9628],[1694,9633],[1700,9641],[1722,9657],[1740,9662],[1812,9670],[1823,9673],[1769,9667],[1734,9665],[1713,9660],[1698,9649],[1685,9642],[1679,9635],[1654,9638],[1616,9652],[1620,9657],[1645,9660],[1668,9659],[1696,9661],[1708,9665],[1720,9666],[1718,9668],[1730,9674],[1753,9680],[1738,9681],[1720,9677],[1701,9669],[1675,9665],[1661,9666],[1603,9661],[1593,9665],[1588,9672],[1599,9678],[1611,9675],[1630,9678],[1616,9678],[1601,9684],[1621,9689],[1631,9695],[1659,9698],[1677,9697],[1645,9701],[1628,9698],[1584,9686],[1574,9693],[1611,9705],[1596,9704],[1578,9708],[1571,9705],[1570,9700],[1555,9697],[1555,9702],[1541,9705],[1555,9715],[1568,9714],[1568,9720],[1605,9725],[1617,9718],[1623,9723],[1616,9725],[1628,9726],[1626,9730],[1637,9735],[1655,9739],[1676,9736],[1682,9732],[1678,9728],[1695,9723],[1683,9729],[1691,9730],[1688,9735],[1711,9734],[1733,9721],[1724,9730],[1738,9731],[1752,9723],[1743,9730],[1753,9730],[1695,9741],[1691,9747],[1726,9749],[1735,9752],[1729,9761],[1719,9762],[1723,9765],[1754,9766],[1747,9762],[1785,9756],[1806,9740],[1801,9736],[1831,9735],[1831,9738],[1817,9738],[1804,9747],[1805,9752],[1822,9749],[1846,9739],[1875,9732],[1892,9729],[1907,9718],[1915,9718],[1895,9730],[1897,9733],[1865,9738],[1867,9742],[1855,9743],[1813,9758],[1819,9768],[1849,9767],[1836,9769],[1825,9773],[1824,9779],[1832,9780],[1851,9777],[1867,9770],[1875,9771],[1846,9788],[1849,9791],[1883,9788],[1890,9779],[1899,9778],[1896,9783],[1918,9779],[1937,9781],[1896,9786],[1895,9791],[1902,9791],[1882,9794],[1888,9799],[1912,9802],[1922,9794],[1928,9799],[1937,9798],[1935,9794],[1946,9791],[1946,9795],[1956,9798],[1977,9794],[1994,9780],[2014,9774],[2005,9768],[2005,9764],[2027,9776],[2007,9781],[1991,9795],[1970,9803],[2004,9806],[2007,9808],[2038,9807],[2064,9804],[2074,9794],[2111,9782],[2114,9784],[2095,9788],[2080,9798],[2100,9809],[2111,9811],[2139,9811],[2135,9804],[2141,9800],[2163,9795],[2144,9805],[2163,9812],[2196,9812],[2194,9807],[2202,9807],[2198,9803],[2215,9807],[2218,9802],[2241,9804],[2240,9800],[2258,9802],[2270,9799],[2273,9801],[2293,9799],[2294,9796],[2268,9787],[2233,9780],[2228,9776],[2263,9779],[2309,9792],[2320,9792],[2321,9787],[2331,9796],[2343,9797],[2342,9791],[2351,9786],[2360,9792],[2380,9791],[2382,9787],[2374,9783],[2387,9778],[2382,9775],[2394,9774],[2396,9768],[2414,9769],[2435,9766],[2448,9758],[2449,9749],[2443,9745],[2422,9741],[2426,9739],[2415,9733],[2366,9717],[2355,9718],[2360,9714],[2353,9711],[2323,9714],[2324,9712],[2304,9709],[2323,9708],[2309,9704],[2287,9704],[2256,9702],[2240,9700],[2208,9711],[2235,9700],[2221,9699],[2229,9696],[2268,9700],[2286,9698],[2286,9695],[2245,9686],[2233,9682],[2206,9677],[2185,9672],[2202,9673],[2252,9682],[2270,9687],[2306,9693],[2313,9695],[2348,9699],[2351,9694],[2343,9688],[2323,9679],[2305,9676],[2291,9669],[2285,9663],[2269,9656],[2259,9657],[2260,9653],[2238,9644],[2213,9628],[2206,9619],[2197,9616],[2178,9616],[2177,9624],[2164,9631],[2176,9620],[2174,9615],[2188,9610],[2181,9605],[2165,9606],[2136,9600],[2128,9605],[2116,9606],[2131,9599],[2117,9598],[2123,9596],[2142,9597],[2168,9602],[2173,9596],[2166,9591],[2147,9588],[2160,9585],[2157,9580],[2144,9574],[2121,9569],[2101,9572],[2097,9579],[2088,9581],[2075,9580],[2076,9583],[2063,9585],[2045,9582],[2050,9578],[2059,9579],[2082,9576],[2088,9577],[2094,9569],[2094,9561],[2077,9558],[2072,9562],[2069,9555],[2049,9555],[2038,9558],[2043,9553],[2039,9550],[2025,9552],[2005,9558],[1980,9560],[1985,9557],[2005,9556],[2006,9551],[2013,9548],[1986,9549],[1977,9556],[1969,9555],[1974,9547],[1958,9549],[1971,9543],[2006,9544],[2012,9541],[2056,9540],[2046,9538],[2056,9530],[2055,9528],[2037,9527],[2014,9532],[2008,9539],[1982,9538],[1946,9538],[1950,9537],[2007,9534],[2006,9530],[1990,9531],[1965,9527],[1949,9531],[1926,9529],[1954,9529],[1960,9526],[1953,9523],[1943,9512],[1960,9523],[1989,9528],[2017,9524],[2016,9521],[1998,9517],[2031,9518],[2047,9515],[2051,9511],[2065,9508],[2060,9504],[2045,9506],[2046,9499],[2028,9494],[1996,9496],[2008,9491],[2037,9485],[2036,9480],[2029,9480],[2022,9473],[1993,9477],[1985,9473],[2005,9469],[2023,9468],[2012,9458],[2004,9462]]],[[[591,8088],[592,8087],[592,8086],[591,8088],[591,8088],[591,8088]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ST&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.55,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;st&#34;,&#34;hc-a2&#34;:&#34;ST&#34;,&#34;name&#34;:&#34;Sao Tome and Principe&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;S.T.P.&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;STP&#34;,&#34;iso-a2&#34;:&#34;ST&#34;,&#34;woe-id&#34;:&#34;23424966&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4443,6507],[4438,6512],[4444,6517],[4447,6513],[4443,6507]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.65,&#34;hc-middle-y&#34;:0.61,&#34;hc-key&#34;:&#34;tz&#34;,&#34;hc-a2&#34;:&#34;TZ&#34;,&#34;name&#34;:&#34;United Republic of Tanzania&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Tanz.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;TZA&#34;,&#34;iso-a2&#34;:&#34;TZ&#34;,&#34;woe-id&#34;:&#34;23424973&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5403,6334],[5406,6338],[5412,6324],[5410,6317],[5402,6325],[5403,6334]]],[[[5278,6165],[5278,6167],[5276,6170],[5276,6170],[5272,6172],[5271,6174],[5271,6174],[5271,6175],[5267,6182],[5269,6192],[5264,6213],[5258,6220],[5255,6223],[5255,6223],[5252,6226],[5252,6226],[5252,6226],[5248,6225],[5247,6220],[5242,6224],[5232,6223],[5229,6227],[5218,6229],[5203,6237],[5190,6239],[5189,6243],[5181,6244],[5177,6250],[5166,6253],[5158,6270],[5149,6285],[5148,6301],[5136,6316],[5130,6315],[5124,6321],[5124,6328],[5130,6332],[5124,6346],[5126,6355],[5120,6366],[5121,6375],[5132,6380],[5144,6401],[5156,6410],[5153,6418],[5144,6422],[5148,6435],[5156,6437],[5156,6458],[5148,6467],[5145,6474],[5156,6476],[5184,6476],[5184,6474],[5185,6476],[5186,6476],[5183,6458],[5187,6457],[5179,6445],[5184,6444],[5188,6434],[5182,6432],[5185,6426],[5200,6439],[5207,6431],[5210,6435],[5214,6432],[5220,6435],[5226,6432],[5245,6440],[5225,6442],[5216,6445],[5222,6453],[5234,6451],[5240,6456],[5239,6461],[5246,6461],[5244,6467],[5252,6474],[5357,6416],[5358,6408],[5355,6405],[5360,6398],[5402,6368],[5401,6356],[5390,6329],[5392,6319],[5410,6304],[5413,6297],[5406,6291],[5406,6277],[5423,6278],[5420,6271],[5410,6271],[5405,6262],[5407,6250],[5412,6243],[5411,6238],[5420,6216],[5418,6213],[5433,6206],[5439,6198],[5426,6188],[5411,6182],[5404,6177],[5393,6177],[5382,6170],[5370,6175],[5363,6172],[5362,6166],[5351,6161],[5339,6165],[5330,6162],[5314,6161],[5313,6165],[5303,6170],[5296,6164],[5278,6165]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.45,&#34;hc-middle-y&#34;:0.27,&#34;hc-key&#34;:&#34;ar&#34;,&#34;hc-a2&#34;:&#34;AR&#34;,&#34;name&#34;:&#34;Argentina&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Arg.&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;ARG&#34;,&#34;iso-a2&#34;:&#34;AR&#34;,&#34;woe-id&#34;:&#34;23424747&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[2228,4801],[2238,4787],[2231,4781],[2233,4774],[2243,4773],[2247,4762],[2259,4753],[2267,4744],[2282,4736],[2291,4727],[2310,4720],[2330,4720],[2325,4709],[2313,4709],[2289,4703],[2275,4709],[2248,4711],[2227,4714],[2228,4801]]],[[[2227,4714],[2229,4711],[2227,4710],[2227,4714]]],[[[2552,5594],[2545,5585],[2546,5571],[2543,5560],[2538,5553],[2541,5549],[2535,5539],[2538,5526],[2535,5521],[2536,5501],[2529,5500],[2524,5480],[2529,5464],[2524,5461],[2527,5453],[2536,5445],[2555,5437],[2566,5422],[2558,5408],[2561,5400],[2572,5391],[2579,5390],[2580,5374],[2568,5356],[2556,5342],[2552,5331],[2536,5321],[2509,5312],[2456,5303],[2437,5302],[2421,5305],[2427,5294],[2422,5296],[2419,5273],[2414,5274],[2412,5260],[2408,5257],[2416,5250],[2422,5257],[2422,5252],[2413,5237],[2392,5228],[2369,5227],[2342,5239],[2338,5243],[2329,5234],[2335,5214],[2332,5199],[2339,5191],[2349,5187],[2346,5183],[2361,5182],[2362,5188],[2355,5188],[2371,5195],[2376,5187],[2375,5171],[2361,5166],[2358,5175],[2351,5180],[2336,5174],[2334,5170],[2351,5163],[2351,5160],[2341,5157],[2325,5138],[2328,5121],[2328,5113],[2323,5105],[2315,5102],[2313,5095],[2317,5089],[2299,5091],[2288,5085],[2290,5082],[2279,5082],[2266,5068],[2257,5048],[2263,5033],[2272,5028],[2282,5017],[2299,5014],[2306,5014],[2312,5009],[2313,4998],[2306,4978],[2296,4970],[2272,4954],[2270,4949],[2259,4941],[2254,4912],[2249,4904],[2236,4899],[2227,4913],[2233,4896],[2220,4891],[2214,4882],[2212,4866],[2219,4840],[2226,4826],[2235,4814],[2233,4812],[2233,4814],[2210,4820],[2202,4821],[2189,4826],[2131,4826],[2129,4832],[2115,4843],[2121,4855],[2119,4879],[2106,4880],[2094,4875],[2089,4894],[2083,4898],[2082,4906],[2085,4912],[2082,4921],[2085,4930],[2095,4930],[2099,4942],[2111,4950],[2111,4963],[2120,4967],[2118,4977],[2112,4983],[2118,4994],[2119,5001],[2131,5008],[2128,5015],[2130,5024],[2138,5028],[2135,5045],[2131,5048],[2140,5055],[2134,5064],[2137,5071],[2142,5071],[2149,5079],[2140,5091],[2126,5094],[2127,5099],[2143,5100],[2149,5098],[2154,5107],[2152,5111],[2134,5112],[2132,5123],[2138,5129],[2134,5134],[2137,5141],[2130,5146],[2136,5155],[2124,5162],[2124,5177],[2127,5181],[2125,5188],[2136,5195],[2130,5211],[2133,5235],[2130,5242],[2138,5256],[2133,5260],[2140,5271],[2137,5282],[2142,5281],[2146,5294],[2146,5305],[2161,5313],[2158,5334],[2152,5346],[2154,5354],[2152,5360],[2155,5367],[2152,5371],[2156,5387],[2166,5390],[2166,5395],[2176,5402],[2175,5420],[2171,5430],[2176,5431],[2180,5451],[2186,5460],[2192,5462],[2190,5472],[2193,5490],[2187,5493],[2184,5502],[2187,5507],[2183,5511],[2182,5520],[2176,5534],[2180,5537],[2175,5540],[2170,5550],[2173,5565],[2179,5567],[2178,5574],[2183,5589],[2190,5590],[2192,5595],[2188,5598],[2190,5606],[2186,5621],[2193,5629],[2197,5651],[2211,5665],[2216,5681],[2222,5692],[2229,5690],[2236,5694],[2237,5699],[2229,5710],[2229,5717],[2234,5722],[2228,5745],[2235,5755],[2229,5765],[2239,5777],[2266,5789],[2275,5820],[2270,5826],[2275,5835],[2282,5838],[2283,5844],[2296,5849],[2298,5857],[2312,5848],[2334,5848],[2346,5845],[2354,5824],[2356,5834],[2366,5851],[2399,5851],[2404,5844],[2414,5836],[2424,5819],[2431,5813],[2449,5801],[2452,5795],[2472,5789],[2481,5789],[2497,5778],[2501,5774],[2517,5765],[2534,5760],[2548,5753],[2554,5744],[2538,5723],[2531,5699],[2521,5691],[2523,5686],[2540,5687],[2565,5680],[2573,5682],[2583,5681],[2589,5677],[2596,5686],[2607,5682],[2617,5696],[2625,5697],[2635,5707],[2639,5721],[2641,5740],[2644,5739],[2655,5743],[2661,5739],[2663,5728],[2668,5719],[2666,5715],[2667,5699],[2663,5690],[2632,5676],[2628,5669],[2620,5667],[2616,5661],[2606,5657],[2587,5630],[2560,5601],[2552,5594]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CV&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.08,&#34;hc-middle-y&#34;:0.11,&#34;hc-key&#34;:&#34;cv&#34;,&#34;hc-a2&#34;:&#34;CV&#34;,&#34;name&#34;:&#34;Cape Verde&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;C.Vd.&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;CPV&#34;,&#34;iso-a2&#34;:&#34;CV&#34;,&#34;woe-id&#34;:&#34;23424794&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[3556,6945],[3548,6948],[3549,6957],[3558,6947],[3566,6957],[3568,6953],[3556,6945]]],[[[3514,7005],[3513,7001],[3503,7005],[3503,7010],[3509,7013],[3514,7005]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;DM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.54,&#34;hc-middle-y&#34;:0.47,&#34;hc-key&#34;:&#34;dm&#34;,&#34;hc-a2&#34;:&#34;DM&#34;,&#34;name&#34;:&#34;Dominica&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;D&#39;inca&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;DMA&#34;,&#34;iso-a2&#34;:&#34;DM&#34;,&#34;woe-id&#34;:&#34;23424798&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2440,6965],[2445,6959],[2441,6953],[2438,6962],[2440,6965]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NL&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.99,&#34;hc-middle-y&#34;:0,&#34;hc-key&#34;:&#34;nl&#34;,&#34;hc-a2&#34;:&#34;NL&#34;,&#34;name&#34;:&#34;Netherlands&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Neth.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;NLD&#34;,&#34;iso-a2&#34;:&#34;NL&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4412,8241],[4402,8238],[4403,8240],[4415,8243],[4412,8241]]],[[[2393,7038],[2390,7038],[2390,7039],[2393,7038]]],[[[4347,8160],[4359,8159],[4373,8160],[4360,8153],[4355,8157],[4348,8155],[4347,8160]]],[[[4460,8234],[4460,8224],[4455,8209],[4447,8209],[4446,8203],[4454,8202],[4455,8193],[4445,8186],[4449,8183],[4436,8178],[4429,8180],[4423,8177],[4431,8165],[4429,8151],[4425,8144],[4425,8136],[4416,8136],[4420,8151],[4409,8156],[4402,8155],[4396,8164],[4388,8164],[4374,8160],[4365,8163],[4361,8160],[4350,8167],[4362,8169],[4369,8163],[4374,8165],[4357,8174],[4365,8174],[4365,8178],[4381,8198],[4392,8233],[4398,8222],[4407,8228],[4413,8236],[4438,8246],[4439,8241],[4450,8241],[4460,8234]],[[4419,8204],[4419,8202],[4419,8202],[4419,8202],[4416,8200],[4416,8200],[4416,8200],[4416,8200],[4408,8195],[4399,8200],[4415,8209],[4417,8217],[4408,8218],[4406,8227],[4397,8221],[4404,8212],[4396,8209],[4398,8202],[4395,8199],[4409,8194],[4416,8200],[4416,8200],[4416,8200],[4416,8200],[4418,8201],[4419,8202],[4419,8202],[4419,8202],[4421,8203],[4419,8204],[4419,8204],[4419,8204],[4420,8207],[4415,8208],[4419,8204],[4419,8204],[4419,8204]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;YE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.35,&#34;hc-middle-y&#34;:0.71,&#34;hc-key&#34;:&#34;ye&#34;,&#34;hc-a2&#34;:&#34;YE&#34;,&#34;name&#34;:&#34;Yemen&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Yem.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;YEM&#34;,&#34;iso-a2&#34;:&#34;YE&#34;,&#34;woe-id&#34;:&#34;23425002&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5826,6879],[5831,6876],[5841,6879],[5852,6874],[5842,6868],[5826,6868],[5818,6874],[5826,6879]]],[[[5779,7067],[5801,7016],[5803,7015],[5811,6996],[5795,6991],[5789,6986],[5784,6977],[5786,6966],[5761,6954],[5734,6947],[5726,6942],[5708,6939],[5694,6933],[5691,6927],[5682,6919],[5667,6916],[5662,6919],[5651,6913],[5644,6907],[5623,6900],[5597,6899],[5592,6897],[5585,6890],[5577,6886],[5575,6880],[5560,6881],[5556,6878],[5542,6876],[5528,6883],[5522,6894],[5523,6905],[5517,6920],[5515,6933],[5510,6951],[5501,6956],[5509,6955],[5506,6964],[5509,6975],[5508,6988],[5515,6993],[5521,7001],[5518,7004],[5519,7017],[5526,7023],[5536,7018],[5563,7020],[5578,7020],[5586,7017],[5612,7014],[5624,7015],[5631,7006],[5645,7010],[5649,7021],[5666,7042],[5695,7056],[5779,7067]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;JM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.53,&#34;hc-key&#34;:&#34;jm&#34;,&#34;hc-a2&#34;:&#34;JM&#34;,&#34;name&#34;:&#34;Jamaica&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Jam.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;JAM&#34;,&#34;iso-a2&#34;:&#34;JM&#34;,&#34;woe-id&#34;:&#34;23424858&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1968,7052],[1984,7050],[1987,7046],[2000,7042],[2005,7035],[1993,7033],[1986,7037],[1983,7032],[1977,7034],[1975,7029],[1969,7033],[1960,7033],[1949,7043],[1941,7045],[1946,7051],[1955,7053],[1968,7052]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;WS&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.58,&#34;hc-key&#34;:&#34;ws&#34;,&#34;hc-a2&#34;:&#34;WS&#34;,&#34;name&#34;:&#34;Samoa&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Samoa&#34;,&#34;subregion&#34;:&#34;Polynesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;WSM&#34;,&#34;iso-a2&#34;:&#34;WS&#34;,&#34;woe-id&#34;:&#34;23424992&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[-817,6098],[-804,6096],[-800,6091],[-814,6093],[-825,6100],[-831,6099],[-839,6107],[-827,6109],[-817,6098]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;OM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.88,&#34;hc-middle-y&#34;:0.45,&#34;hc-key&#34;:&#34;om&#34;,&#34;hc-a2&#34;:&#34;OM&#34;,&#34;name&#34;:&#34;Oman&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Oman&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;OMN&#34;,&#34;iso-a2&#34;:&#34;OM&#34;,&#34;woe-id&#34;:&#34;23424898&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5905,7259],[5904,7259],[5904,7262],[5907,7261],[5905,7259]]],[[[5899,7285],[5908,7295],[5911,7286],[5905,7272],[5901,7273],[5902,7284],[5899,7285]]],[[[5811,6996],[5803,7015],[5801,7016],[5779,7067],[5867,7098],[5886,7159],[5873,7181],[5873,7190],[5883,7214],[5881,7220],[5897,7223],[5890,7228],[5891,7248],[5897,7251],[5899,7244],[5908,7251],[5915,7236],[5931,7219],[5965,7209],[5978,7207],[5988,7191],[6002,7176],[6009,7176],[6009,7166],[5996,7142],[5987,7137],[5976,7123],[5984,7114],[5975,7103],[5975,7109],[5962,7110],[5959,7115],[5947,7090],[5951,7069],[5947,7066],[5933,7065],[5924,7062],[5917,7055],[5914,7042],[5908,7036],[5903,7036],[5881,7033],[5875,7025],[5875,7014],[5868,7008],[5862,7006],[5856,7008],[5841,7008],[5827,7000],[5811,6996]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;VC&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;vc&#34;,&#34;hc-a2&#34;:&#34;VC&#34;,&#34;name&#34;:&#34;Saint Vincent and the Grenadines&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;St.V.G.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;VCT&#34;,&#34;iso-a2&#34;:&#34;VC&#34;,&#34;woe-id&#34;:&#34;23424981&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2446,6889],[2444,6894],[2448,6899],[2448,6893],[2446,6889]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.34,&#34;hc-middle-y&#34;:0.48,&#34;hc-key&#34;:&#34;tr&#34;,&#34;hc-a2&#34;:&#34;TR&#34;,&#34;name&#34;:&#34;Turkey&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Tur.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;TUR&#34;,&#34;iso-a2&#34;:&#34;TR&#34;,&#34;woe-id&#34;:&#34;23424969&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5013,7748],[5007,7746],[5004,7747],[5012,7751],[5013,7748]]],[[[5073,7812],[5076,7800],[5084,7793],[5105,7786],[5103,7780],[5097,7776],[5078,7781],[5071,7777],[5059,7777],[5048,7765],[5034,7759],[5018,7745],[5020,7754],[5038,7764],[5016,7764],[5015,7768],[5024,7776],[5023,7786],[5033,7792],[5031,7798],[5024,7803],[5032,7811],[5045,7816],[5053,7815],[5059,7809],[5073,7812]]],[[[5568,7730],[5561,7735],[5557,7732],[5556,7723],[5544,7721],[5549,7713],[5552,7703],[5552,7687],[5557,7686],[5550,7673],[5561,7664],[5560,7655],[5567,7650],[5566,7645],[5562,7646],[5551,7640],[5551,7648],[5528,7648],[5518,7653],[5506,7652],[5501,7645],[5495,7644],[5491,7651],[5485,7646],[5470,7643],[5452,7644],[5438,7640],[5419,7632],[5404,7629],[5387,7631],[5374,7637],[5351,7628],[5338,7628],[5337,7632],[5327,7634],[5324,7623],[5328,7614],[5319,7614],[5319,7606],[5313,7601],[5306,7604],[5308,7607],[5302,7617],[5314,7627],[5314,7634],[5308,7637],[5296,7630],[5297,7627],[5288,7626],[5272,7634],[5266,7632],[5252,7621],[5248,7614],[5246,7617],[5236,7611],[5224,7611],[5214,7608],[5201,7613],[5191,7625],[5171,7634],[5152,7637],[5148,7633],[5148,7624],[5143,7615],[5138,7617],[5122,7611],[5106,7618],[5105,7629],[5091,7630],[5090,7634],[5075,7628],[5074,7632],[5056,7632],[5070,7634],[5082,7642],[5063,7640],[5057,7643],[5061,7650],[5049,7652],[5049,7660],[5044,7663],[5051,7665],[5050,7674],[5039,7675],[5036,7682],[5031,7678],[5021,7683],[5029,7689],[5024,7696],[5029,7696],[5032,7688],[5042,7689],[5035,7699],[5045,7704],[5039,7705],[5039,7710],[5032,7718],[5041,7725],[5040,7728],[5017,7724],[5020,7743],[5035,7757],[5052,7759],[5057,7754],[5069,7756],[5060,7759],[5059,7765],[5074,7759],[5070,7757],[5107,7758],[5095,7761],[5102,7765],[5129,7768],[5113,7769],[5103,7777],[5109,7786],[5128,7783],[5140,7785],[5156,7780],[5168,7781],[5173,7789],[5195,7799],[5198,7803],[5229,7813],[5270,7811],[5277,7816],[5288,7803],[5296,7800],[5307,7803],[5312,7799],[5315,7790],[5321,7786],[5326,7791],[5337,7788],[5339,7784],[5353,7779],[5358,7782],[5365,7777],[5377,7775],[5409,7781],[5415,7778],[5430,7775],[5447,7781],[5467,7791],[5471,7796],[5479,7792],[5483,7795],[5499,7793],[5502,7798],[5508,7798],[5527,7781],[5533,7775],[5536,7766],[5531,7759],[5534,7747],[5545,7743],[5553,7744],[5567,7732],[5568,7730]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BD&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.85,&#34;hc-middle-y&#34;:0.57,&#34;hc-key&#34;:&#34;bd&#34;,&#34;hc-a2&#34;:&#34;BD&#34;,&#34;name&#34;:&#34;Bangladesh&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Bang.&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;BGD&#34;,&#34;iso-a2&#34;:&#34;BD&#34;,&#34;woe-id&#34;:&#34;23424759&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[6916,7162],[6918,7168],[6917,7183],[6923,7173],[6923,7164],[6914,7155],[6916,7162]]],[[[6974,7159],[6976,7138],[6967,7142],[6962,7134],[6965,7130],[6967,7121],[6953,7144],[6955,7155],[6952,7167],[6948,7176],[6944,7172],[6940,7175],[6941,7184],[6935,7180],[6933,7166],[6929,7162],[6931,7173],[6922,7182],[6917,7192],[6913,7181],[6917,7172],[6915,7165],[6904,7153],[6899,7155],[6893,7167],[6895,7156],[6886,7152],[6884,7158],[6875,7149],[6871,7152],[6870,7153],[6870,7163],[6864,7189],[6868,7196],[6860,7198],[6860,7204],[6855,7210],[6860,7219],[6861,7230],[6853,7231],[6843,7236],[6840,7241],[6845,7250],[6849,7248],[6852,7258],[6866,7257],[6862,7268],[6855,7268],[6841,7280],[6844,7288],[6853,7298],[6864,7290],[6870,7291],[6879,7283],[6885,7282],[6888,7290],[6893,7283],[6892,7264],[6909,7257],[6935,7258],[6940,7256],[6958,7258],[6971,7250],[6964,7245],[6960,7234],[6938,7224],[6932,7209],[6937,7193],[6941,7196],[6945,7188],[6951,7193],[6949,7198],[6961,7213],[6968,7199],[6968,7188],[6972,7181],[6974,7159]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SB&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.64,&#34;hc-middle-y&#34;:0.71,&#34;hc-key&#34;:&#34;sb&#34;,&#34;hc-a2&#34;:&#34;SB&#34;,&#34;name&#34;:&#34;Solomon Islands&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;S. Is.&#34;,&#34;subregion&#34;:&#34;Melanesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;SLB&#34;,&#34;iso-a2&#34;:&#34;SB&#34;,&#34;woe-id&#34;:&#34;23424766&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[9011,6204],[9013,6198],[9021,6198],[9026,6188],[9012,6190],[8997,6202],[9000,6206],[9008,6201],[9011,6204]]],[[[8962,6241],[8971,6237],[8970,6229],[8982,6220],[8978,6214],[8969,6217],[8954,6218],[8951,6220],[8948,6232],[8962,6241]]],[[[9001,6229],[9005,6218],[8994,6230],[8985,6236],[8976,6261],[8983,6260],[8989,6252],[8987,6247],[8993,6243],[9000,6226],[9001,6229]]],[[[8866,6267],[8856,6282],[8865,6278],[8862,6274],[8869,6271],[8874,6275],[8877,6271],[8889,6270],[8898,6256],[8907,6251],[8899,6249],[8897,6253],[8888,6258],[8877,6254],[8882,6258],[8866,6267]]],[[[8908,6286],[8920,6284],[8933,6273],[8942,6270],[8955,6261],[8954,6255],[8946,6257],[8946,6261],[8925,6271],[8918,6280],[8908,6286]]],[[[8892,6289],[8892,6286],[8874,6290],[8855,6308],[8856,6312],[8872,6303],[8876,6295],[8892,6289]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LC&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.52,&#34;hc-middle-y&#34;:0.47,&#34;hc-key&#34;:&#34;lc&#34;,&#34;hc-a2&#34;:&#34;LC&#34;,&#34;name&#34;:&#34;Saint Lucia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;S.L.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;LCA&#34;,&#34;iso-a2&#34;:&#34;LC&#34;,&#34;woe-id&#34;:&#34;23424951&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2454,6909],[2450,6914],[2454,6921],[2456,6916],[2454,6909]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.53,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;nr&#34;,&#34;hc-a2&#34;:&#34;NR&#34;,&#34;name&#34;:&#34;Nauru&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Nauru&#34;,&#34;subregion&#34;:&#34;Micronesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;NRU&#34;,&#34;iso-a2&#34;:&#34;NR&#34;,&#34;woe-id&#34;:&#34;23424912&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[9164,6489],[9163,6489],[9163,6490],[9164,6491],[9164,6489]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.38,&#34;hc-middle-y&#34;:0.88,&#34;hc-key&#34;:&#34;no&#34;,&#34;hc-a2&#34;:&#34;NO&#34;,&#34;name&#34;:&#34;Norway&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Nor.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;NOR&#34;,&#34;iso-a2&#34;:&#34;NO&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4405,8506],[4400,8499],[4399,8511],[4403,8517],[4410,8508],[4405,8506]]],[[[4494,8683],[4507,8690],[4508,8686],[4518,8678],[4499,8672],[4492,8673],[4487,8668],[4477,8671],[4496,8678],[4494,8683]]],[[[4643,8897],[4625,8885],[4633,8899],[4636,8897],[4645,8901],[4646,8906],[4660,8911],[4668,8910],[4661,8903],[4646,8896],[4643,8897]]],[[[4688,8909],[4666,8902],[4674,8912],[4683,8916],[4695,8917],[4688,8909]]],[[[4690,8922],[4683,8919],[4679,8926],[4671,8929],[4689,8936],[4694,8946],[4699,8941],[4700,8927],[4690,8922]]],[[[4714,8947],[4703,8939],[4707,8951],[4722,8962],[4722,8953],[4714,8947]]],[[[4803,8991],[4809,8984],[4802,8980],[4802,8976],[4786,8973],[4779,8975],[4787,8979],[4784,8982],[4803,8991]]],[[[4857,8987],[4853,8987],[4854,8992],[4858,8993],[4857,8987]]],[[[5132,8989],[5134,8988],[5123,8985],[5128,8993],[5132,8989]]],[[[4828,8990],[4821,8990],[4830,8998],[4833,8996],[4828,8990]]],[[[4865,8999],[4869,8998],[4863,8994],[4860,8997],[4865,8999]]],[[[4808,9006],[4814,9011],[4815,9001],[4820,9006],[4825,9003],[4825,8997],[4819,8988],[4811,8986],[4800,8995],[4798,9000],[4808,9006]]],[[[4860,9004],[4854,9000],[4849,9003],[4854,9010],[4861,9008],[4860,9004]]],[[[4837,8998],[4830,9002],[4823,9011],[4828,9013],[4832,9007],[4842,9004],[4837,8998]]],[[[4888,9012],[4886,9013],[4888,9018],[4890,9016],[4888,9012]]],[[[4916,9018],[4925,9011],[4909,9013],[4910,9018],[4916,9018]]],[[[4940,9030],[4945,9022],[4937,9014],[4929,9013],[4921,9019],[4929,9025],[4941,9026],[4940,9030]]],[[[4950,9035],[4959,9031],[4948,9025],[4944,9034],[4950,9035]]],[[[4937,9042],[4928,9029],[4922,9026],[4900,9023],[4906,9030],[4896,9029],[4897,9033],[4908,9031],[4912,9036],[4917,9030],[4917,9037],[4930,9036],[4937,9042]]],[[[4957,9052],[4957,9046],[4952,9049],[4954,9052],[4957,9052]]],[[[5004,9060],[5008,9059],[5012,9051],[5001,9047],[4993,9053],[5004,9060]]],[[[4014,9060],[4013,9053],[3992,9048],[3984,9041],[3980,9044],[3997,9052],[4003,9059],[4014,9060]]],[[[4812,9249],[4816,9246],[4810,9238],[4801,9246],[4812,9249]]],[[[4881,9498],[4894,9497],[4898,9499],[4903,9493],[4904,9478],[4868,9474],[4851,9481],[4857,9486],[4843,9493],[4869,9496],[4872,9501],[4881,9498]]],[[[5036,9502],[5027,9506],[5027,9513],[5032,9513],[5038,9507],[5044,9506],[5036,9502]]],[[[4581,9496],[4594,9489],[4606,9474],[4599,9475],[4597,9480],[4581,9490],[4575,9490],[4566,9505],[4558,9512],[4557,9518],[4568,9517],[4578,9508],[4574,9505],[4581,9496]]],[[[5103,9520],[5123,9519],[5109,9516],[5098,9520],[5084,9517],[5076,9514],[5068,9515],[5085,9523],[5096,9523],[5103,9520]]],[[[4843,9533],[4851,9534],[4862,9529],[4849,9525],[4838,9528],[4843,9533]]],[[[4842,9549],[4828,9548],[4826,9551],[4829,9552],[4842,9549]]],[[[5239,9607],[5215,9601],[5179,9597],[5176,9600],[5218,9606],[5229,9609],[5239,9607]]],[[[4966,9618],[4960,9618],[4960,9622],[4961,9623],[4966,9618]]],[[[4960,9627],[4963,9625],[4961,9624],[4955,9625],[4960,9627]]],[[[4837,9625],[4833,9626],[4836,9629],[4841,9627],[4837,9625]]],[[[4876,9639],[4871,9637],[4867,9639],[4873,9640],[4876,9639]]],[[[4860,9636],[4861,9640],[4852,9644],[4866,9641],[4860,9636]]],[[[4727,8944],[4736,8944],[4732,8940],[4736,8930],[4734,8922],[4722,8922],[4718,8914],[4712,8916],[4708,8909],[4700,8912],[4690,8910],[4698,8918],[4697,8923],[4705,8927],[4703,8936],[4709,8943],[4717,8943],[4715,8932],[4717,8929],[4726,8932],[4722,8937],[4729,8939],[4727,8944]]],[[[4754,8956],[4746,8955],[4753,8961],[4747,8966],[4760,8965],[4756,8969],[4759,8973],[4768,8969],[4774,8976],[4774,8969],[4780,8971],[4781,8964],[4775,8962],[4778,8955],[4763,8953],[4744,8948],[4743,8951],[4754,8956]]],[[[5156,8987],[5159,8980],[5157,8973],[5147,8973],[5138,8978],[5135,8968],[5130,8964],[5112,8960],[5109,8950],[5101,8947],[5098,8957],[5112,8969],[5106,8980],[5085,8987],[5070,9001],[5060,8999],[5046,8992],[5029,8993],[5020,8983],[5014,8981],[5010,8965],[5006,8955],[5008,8946],[5003,8939],[4990,8936],[4988,8927],[4981,8922],[4974,8928],[4953,8936],[4947,8931],[4931,8926],[4928,8929],[4908,8931],[4907,8936],[4897,8946],[4886,8959],[4876,8960],[4868,8955],[4869,8947],[4859,8951],[4855,8947],[4840,8946],[4847,8941],[4844,8928],[4836,8922],[4844,8918],[4836,8912],[4809,8920],[4797,8920],[4791,8923],[4783,8921],[4783,8902],[4775,8893],[4758,8899],[4742,8889],[4737,8875],[4723,8865],[4732,8854],[4732,8847],[4720,8838],[4710,8824],[4702,8819],[4704,8808],[4691,8802],[4676,8801],[4680,8785],[4677,8780],[4676,8762],[4670,8750],[4650,8726],[4663,8721],[4665,8709],[4659,8699],[4638,8703],[4622,8697],[4607,8680],[4608,8674],[4601,8666],[4608,8652],[4604,8648],[4604,8633],[4611,8619],[4606,8594],[4620,8586],[4627,8578],[4622,8563],[4609,8561],[4613,8550],[4619,8538],[4616,8530],[4617,8522],[4606,8512],[4597,8511],[4599,8504],[4592,8497],[4596,8484],[4592,8470],[4585,8473],[4583,8477],[4567,8480],[4560,8492],[4562,8499],[4557,8496],[4557,8484],[4541,8471],[4534,8471],[4499,8441],[4487,8434],[4485,8440],[4481,8434],[4471,8431],[4454,8431],[4441,8435],[4445,8440],[4425,8447],[4416,8452],[4410,8463],[4412,8475],[4417,8470],[4426,8469],[4421,8477],[4427,8483],[4421,8488],[4412,8487],[4402,8479],[4400,8482],[4401,8495],[4410,8505],[4417,8503],[4422,8506],[4410,8512],[4409,8519],[4415,8520],[4412,8527],[4408,8524],[4395,8527],[4394,8536],[4400,8529],[4399,8536],[4404,8542],[4389,8558],[4393,8556],[4395,8566],[4385,8564],[4397,8576],[4394,8580],[4406,8586],[4395,8590],[4390,8599],[4399,8600],[4395,8608],[4402,8604],[4405,8608],[4398,8614],[4401,8616],[4409,8609],[4412,8622],[4423,8626],[4426,8620],[4446,8627],[4428,8625],[4441,8631],[4433,8630],[4434,8634],[4443,8632],[4453,8640],[4452,8649],[4466,8655],[4471,8653],[4486,8657],[4482,8660],[4506,8668],[4508,8672],[4517,8672],[4518,8676],[4534,8682],[4542,8672],[4538,8667],[4546,8667],[4545,8673],[4552,8674],[4566,8672],[4570,8674],[4562,8678],[4573,8686],[4586,8690],[4575,8694],[4587,8700],[4580,8701],[4571,8696],[4574,8691],[4569,8686],[4555,8679],[4540,8676],[4537,8684],[4529,8683],[4529,8688],[4548,8696],[4544,8698],[4548,8708],[4561,8716],[4560,8720],[4569,8721],[4571,8727],[4597,8737],[4579,8738],[4576,8745],[4591,8744],[4603,8750],[4607,8769],[4594,8776],[4600,8780],[4613,8771],[4612,8777],[4618,8783],[4623,8793],[4612,8789],[4619,8796],[4610,8795],[4618,8801],[4621,8798],[4627,8801],[4623,8807],[4626,8816],[4631,8812],[4636,8815],[4638,8826],[4645,8828],[4647,8834],[4655,8834],[4648,8841],[4662,8844],[4662,8851],[4683,8855],[4687,8851],[4695,8859],[4680,8855],[4681,8858],[4670,8856],[4678,8863],[4691,8866],[4682,8868],[4690,8872],[4704,8867],[4696,8876],[4707,8881],[4701,8884],[4685,8876],[4684,8880],[4690,8881],[4684,8885],[4689,8893],[4696,8896],[4699,8889],[4716,8893],[4698,8896],[4705,8901],[4722,8903],[4721,8896],[4726,8888],[4728,8894],[4733,8889],[4734,8895],[4730,8898],[4732,8906],[4724,8910],[4731,8916],[4722,8914],[4725,8920],[4737,8921],[4738,8927],[4749,8930],[4744,8934],[4749,8938],[4752,8930],[4756,8931],[4752,8941],[4762,8938],[4764,8943],[4760,8949],[4781,8954],[4778,8960],[4787,8971],[4796,8961],[4806,8963],[4792,8968],[4793,8972],[4803,8974],[4808,8966],[4818,8963],[4817,8957],[4822,8957],[4818,8965],[4812,8965],[4806,8974],[4811,8984],[4816,8986],[4831,8987],[4828,8981],[4833,8978],[4842,8995],[4849,8992],[4843,8967],[4845,8966],[4852,8975],[4852,8985],[4872,8991],[4878,8999],[4888,8995],[4895,8986],[4894,8997],[4891,9000],[4882,9002],[4873,9009],[4884,9014],[4892,9005],[4891,9012],[4904,9013],[4907,9011],[4924,9009],[4926,8999],[4935,8995],[4941,8999],[4931,9002],[4937,9005],[4934,9009],[4942,9013],[4941,9017],[4952,9025],[4964,9023],[4958,9027],[4965,9034],[4973,9031],[4971,9037],[4963,9038],[4967,9044],[4973,9039],[4972,9047],[4980,9056],[4978,9049],[4992,9040],[4997,9043],[5010,9045],[5012,9043],[4986,9024],[4992,9026],[4990,9014],[4984,9010],[4983,9002],[4988,9002],[5000,9013],[4997,9015],[5014,9031],[5025,9044],[5034,9049],[5036,9041],[5033,9035],[5024,9032],[5033,9032],[5029,9017],[5047,9031],[5047,9037],[5059,9043],[5047,9047],[5053,9048],[5051,9052],[5060,9048],[5060,9056],[5069,9053],[5078,9056],[5078,9051],[5089,9050],[5079,9039],[5066,9040],[5077,9037],[5062,9030],[5082,9035],[5080,9030],[5068,9023],[5078,9019],[5078,9005],[5080,9020],[5088,9036],[5096,9044],[5104,9045],[5114,9039],[5112,9035],[5125,9036],[5122,9031],[5131,9035],[5155,9020],[5159,9022],[5163,9013],[5148,9011],[5136,9001],[5109,9004],[5095,9006],[5091,9004],[5122,8996],[5115,8992],[5124,8993],[5122,8984],[5132,8983],[5138,8986],[5136,8991],[5156,8987]]],[[[4986,9367],[4987,9370],[5001,9380],[4986,9367],[4986,9367],[4986,9367]]],[[[4964,9455],[4967,9450],[4955,9436],[4952,9430],[4936,9421],[4932,9414],[4917,9413],[4909,9414],[4908,9425],[4913,9427],[4919,9432],[4909,9434],[4902,9429],[4864,9425],[4863,9433],[4872,9435],[4874,9444],[4886,9455],[4863,9466],[4866,9470],[4887,9474],[4908,9473],[4924,9477],[4939,9471],[4928,9465],[4929,9460],[4944,9452],[4953,9451],[4964,9455]]],[[[4657,9561],[4677,9579],[4686,9577],[4699,9565],[4705,9547],[4713,9540],[4730,9520],[4734,9521],[4725,9534],[4724,9541],[4718,9546],[4715,9563],[4710,9572],[4711,9584],[4722,9582],[4718,9588],[4720,9593],[4728,9596],[4735,9595],[4743,9584],[4748,9589],[4765,9585],[4781,9574],[4771,9565],[4771,9552],[4778,9555],[4781,9564],[4788,9567],[4800,9561],[4804,9554],[4803,9542],[4806,9536],[4816,9538],[4831,9536],[4834,9526],[4850,9522],[4882,9516],[4878,9504],[4868,9502],[4857,9505],[4855,9502],[4844,9502],[4838,9500],[4830,9501],[4825,9498],[4828,9494],[4807,9491],[4810,9485],[4806,9479],[4810,9475],[4805,9472],[4810,9466],[4802,9463],[4795,9464],[4788,9455],[4792,9446],[4784,9428],[4777,9430],[4770,9427],[4763,9418],[4759,9401],[4752,9401],[4758,9396],[4747,9386],[4755,9380],[4743,9371],[4732,9374],[4728,9380],[4718,9383],[4707,9393],[4729,9397],[4722,9399],[4700,9398],[4691,9406],[4671,9410],[4670,9415],[4660,9423],[4658,9431],[4673,9434],[4682,9429],[4683,9432],[4715,9431],[4715,9434],[4689,9437],[4682,9439],[4693,9442],[4745,9449],[4743,9453],[4713,9450],[4706,9453],[4693,9447],[4674,9445],[4664,9446],[4659,9443],[4652,9446],[4651,9460],[4648,9464],[4657,9467],[4671,9459],[4667,9467],[4691,9468],[4699,9475],[4711,9476],[4707,9479],[4713,9483],[4747,9483],[4758,9488],[4744,9485],[4729,9490],[4744,9504],[4735,9507],[4729,9497],[4719,9492],[4703,9490],[4697,9500],[4702,9500],[4705,9508],[4701,9516],[4697,9511],[4698,9504],[4689,9499],[4684,9502],[4684,9508],[4674,9504],[4678,9496],[4672,9493],[4682,9486],[4671,9486],[4670,9480],[4656,9474],[4635,9475],[4631,9474],[4627,9484],[4621,9485],[4612,9492],[4631,9493],[4637,9496],[4614,9496],[4612,9499],[4602,9500],[4591,9509],[4597,9516],[4589,9518],[4582,9524],[4589,9524],[4609,9519],[4616,9520],[4613,9526],[4603,9524],[4592,9530],[4600,9539],[4606,9539],[4604,9545],[4592,9547],[4590,9543],[4593,9536],[4580,9532],[4577,9540],[4567,9550],[4570,9554],[4564,9562],[4578,9563],[4568,9565],[4573,9571],[4564,9575],[4578,9573],[4580,9578],[4596,9581],[4606,9570],[4612,9573],[4608,9581],[4613,9581],[4617,9575],[4633,9580],[4654,9584],[4660,9577],[4653,9572],[4631,9571],[4619,9562],[4632,9565],[4644,9565],[4640,9557],[4648,9558],[4658,9549],[4662,9543],[4665,9548],[4657,9561]]],[[[4913,9613],[4906,9617],[4909,9622],[4921,9620],[4918,9626],[4933,9623],[4929,9618],[4934,9612],[4927,9609],[4926,9603],[4936,9602],[4939,9606],[4942,9601],[4949,9604],[4948,9613],[4965,9611],[4963,9617],[4973,9613],[4979,9616],[4978,9609],[4999,9608],[5005,9604],[5038,9604],[5050,9598],[5046,9590],[5048,9582],[5041,9581],[5028,9573],[5009,9567],[5013,9559],[5003,9552],[4990,9548],[4982,9550],[4963,9546],[4956,9538],[4923,9540],[4915,9549],[4922,9553],[4888,9550],[4881,9552],[4861,9550],[4859,9556],[4843,9556],[4828,9562],[4826,9566],[4843,9568],[4849,9565],[4871,9563],[4856,9567],[4851,9571],[4892,9572],[4893,9580],[4842,9577],[4822,9573],[4801,9573],[4792,9578],[4785,9585],[4787,9588],[4803,9594],[4785,9595],[4789,9598],[4772,9601],[4782,9612],[4788,9617],[4800,9612],[4793,9608],[4798,9603],[4803,9605],[4817,9598],[4825,9602],[4814,9605],[4809,9616],[4818,9614],[4826,9607],[4832,9612],[4835,9618],[4823,9618],[4827,9626],[4838,9624],[4840,9618],[4849,9621],[4863,9606],[4882,9610],[4891,9610],[4891,9602],[4907,9592],[4906,9597],[4913,9613]]],[[[4986,9367],[4984,9363],[4986,9367],[4986,9367],[4986,9367],[4986,9367]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.57,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;kn&#34;,&#34;hc-a2&#34;:&#34;KN&#34;,&#34;name&#34;:&#34;Saint Kitts and Nevis&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;St.K.N.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;KNA&#34;,&#34;iso-a2&#34;:&#34;KN&#34;,&#34;woe-id&#34;:&#34;23424940&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2405,7013],[2397,7018],[2399,7020],[2402,7017],[2405,7013]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.45,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;bh&#34;,&#34;hc-a2&#34;:&#34;BH&#34;,&#34;name&#34;:&#34;Bahrain&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Bahr.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;BHR&#34;,&#34;iso-a2&#34;:&#34;BH&#34;,&#34;woe-id&#34;:&#34;23424753&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5735,7291],[5739,7289],[5737,7277],[5734,7283],[5735,7291]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.54,&#34;hc-middle-y&#34;:0.34,&#34;hc-key&#34;:&#34;to&#34;,&#34;hc-a2&#34;:&#34;TO&#34;,&#34;name&#34;:&#34;Tonga&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Tongo&#34;,&#34;subregion&#34;:&#34;Polynesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;TON&#34;,&#34;iso-a2&#34;:&#34;TO&#34;,&#34;woe-id&#34;:&#34;23424964&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[-902,5873],[-904,5871],[-914,5876],[-907,5878],[-902,5873]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;FI&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.67,&#34;hc-middle-y&#34;:0.55,&#34;hc-key&#34;:&#34;fi&#34;,&#34;hc-a2&#34;:&#34;FI&#34;,&#34;name&#34;:&#34;Finland&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Fin.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;FIN&#34;,&#34;iso-a2&#34;:&#34;FI&#34;,&#34;woe-id&#34;:&#34;23424812&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4856,8523],[4854,8517],[4845,8516],[4850,8519],[4856,8523]]],[[[4843,8521],[4846,8522],[4842,8516],[4838,8519],[4843,8521]]],[[[4848,8529],[4838,8521],[4824,8523],[4825,8528],[4840,8533],[4848,8529]]],[[[4883,8527],[4883,8524],[4894,8525],[4882,8521],[4883,8527]]],[[[4909,8517],[4909,8525],[4920,8527],[4921,8522],[4911,8511],[4909,8517]]],[[[4905,8531],[4910,8531],[4903,8528],[4898,8529],[4905,8531]]],[[[4895,8531],[4890,8534],[4891,8538],[4896,8533],[4895,8531]]],[[[4875,8542],[4876,8538],[4875,8533],[4874,8539],[4875,8542]]],[[[4875,8666],[4877,8662],[4874,8659],[4870,8663],[4875,8666]]],[[[4981,8749],[4973,8745],[4971,8748],[4974,8750],[4981,8749]]],[[[4960,8786],[4955,8797],[4947,8805],[4944,8816],[4951,8822],[4952,8832],[4955,8834],[4943,8852],[4948,8865],[4938,8868],[4942,8873],[4940,8887],[4944,8892],[4930,8900],[4927,8909],[4920,8914],[4898,8918],[4894,8923],[4880,8929],[4865,8944],[4855,8947],[4859,8951],[4869,8947],[4868,8955],[4876,8960],[4886,8959],[4897,8946],[4907,8936],[4908,8931],[4928,8929],[4931,8926],[4947,8931],[4953,8936],[4974,8928],[4981,8922],[4988,8927],[4990,8936],[5003,8939],[5008,8946],[5006,8955],[5010,8965],[5014,8981],[5020,8983],[5029,8993],[5046,8992],[5060,8999],[5070,9001],[5085,8987],[5106,8980],[5112,8969],[5098,8957],[5101,8947],[5086,8940],[5096,8937],[5086,8921],[5092,8904],[5112,8898],[5121,8885],[5132,8878],[5129,8869],[5117,8859],[5105,8843],[5105,8836],[5118,8819],[5121,8809],[5129,8800],[5134,8786],[5134,8778],[5123,8777],[5123,8762],[5119,8758],[5127,8756],[5126,8751],[5119,8746],[5125,8737],[5133,8736],[5137,8729],[5131,8726],[5133,8718],[5148,8709],[5148,8700],[5137,8689],[5131,8687],[5145,8674],[5156,8670],[5167,8662],[5169,8657],[5178,8648],[5168,8629],[5151,8615],[5131,8594],[5108,8572],[5096,8566],[5067,8541],[5057,8537],[5048,8542],[5043,8538],[5024,8533],[5011,8533],[5012,8528],[4990,8528],[4990,8525],[4973,8523],[4968,8516],[4966,8520],[4948,8515],[4938,8515],[4933,8510],[4922,8509],[4933,8513],[4933,8519],[4922,8517],[4922,8530],[4911,8526],[4914,8533],[4902,8532],[4901,8536],[4889,8540],[4885,8538],[4876,8555],[4875,8564],[4880,8564],[4883,8570],[4883,8591],[4878,8603],[4874,8606],[4877,8623],[4870,8625],[4872,8634],[4869,8637],[4873,8646],[4880,8650],[4881,8656],[4887,8653],[4881,8662],[4893,8664],[4896,8668],[4907,8667],[4902,8673],[4909,8674],[4911,8683],[4918,8689],[4936,8694],[4937,8701],[4950,8709],[4957,8719],[4965,8724],[4967,8731],[4978,8740],[4987,8742],[4992,8738],[4997,8745],[4991,8752],[4994,8759],[4994,8771],[4987,8776],[4975,8777],[4971,8783],[4960,8786]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ID&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.38,&#34;hc-middle-y&#34;:0.39,&#34;hc-key&#34;:&#34;id&#34;,&#34;hc-a2&#34;:&#34;ID&#34;,&#34;name&#34;:&#34;Indonesia&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Indo.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;IDN&#34;,&#34;iso-a2&#34;:&#34;ID&#34;,&#34;woe-id&#34;:&#34;23424846&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7782,6231],[7789,6222],[7796,6222],[7805,6212],[7803,6206],[7795,6203],[7786,6205],[7781,6212],[7771,6218],[7764,6218],[7753,6221],[7750,6225],[7760,6230],[7782,6231]]],[[[7686,6259],[7678,6247],[7680,6244],[7670,6244],[7659,6247],[7665,6249],[7665,6258],[7675,6265],[7686,6259]]],[[[7908,6261],[7901,6254],[7907,6265],[7931,6266],[7932,6260],[7912,6257],[7908,6261]]],[[[7651,6251],[7644,6252],[7641,6246],[7632,6257],[7623,6259],[7618,6268],[7630,6265],[7640,6269],[7649,6266],[7655,6258],[7651,6251]]],[[[7979,6280],[7972,6272],[7960,6274],[7951,6270],[7957,6281],[7968,6280],[7977,6284],[7979,6280]]],[[[8331,6265],[8338,6259],[8307,6260],[8301,6258],[8304,6268],[8312,6281],[8319,6287],[8335,6289],[8343,6283],[8338,6269],[8331,6265]]],[[[8105,6284],[8106,6288],[8119,6290],[8121,6295],[8126,6288],[8124,6282],[8110,6266],[8110,6276],[8105,6284]]],[[[7613,6298],[7602,6299],[7592,6293],[7567,6295],[7572,6303],[7605,6304],[7613,6298]]],[[[7842,6346],[7835,6351],[7836,6356],[7842,6353],[7852,6357],[7852,6366],[7862,6369],[7863,6360],[7859,6356],[7856,6346],[7848,6349],[7842,6346]]],[[[7876,6368],[7871,6366],[7868,6354],[7876,6351],[7869,6347],[7864,6339],[7857,6344],[7862,6351],[7867,6374],[7870,6377],[7876,6368]]],[[[7673,6402],[7673,6391],[7666,6386],[7664,6396],[7667,6408],[7672,6411],[7673,6402]]],[[[7992,6394],[7991,6398],[7980,6392],[7963,6400],[7958,6407],[7959,6412],[7971,6415],[7983,6415],[7995,6406],[7992,6394]]],[[[7412,6420],[7416,6421],[7418,6430],[7430,6429],[7437,6422],[7434,6413],[7428,6410],[7417,6410],[7417,6420],[7412,6420]]],[[[7200,6424],[7206,6417],[7203,6414],[7193,6422],[7192,6432],[7200,6424]]],[[[7958,6446],[7960,6433],[7954,6444],[7939,6452],[7968,6452],[7958,6446]]],[[[8086,6456],[8089,6451],[8080,6445],[8068,6450],[8086,6456]]],[[[7910,6447],[7911,6456],[7918,6457],[7938,6453],[7938,6450],[7924,6450],[7910,6447]]],[[[8232,6461],[8237,6459],[8273,6454],[8278,6452],[8260,6449],[8238,6456],[8232,6461]]],[[[7399,6421],[7391,6415],[7369,6423],[7368,6432],[7363,6442],[7356,6445],[7349,6443],[7344,6448],[7351,6452],[7351,6458],[7357,6460],[7370,6459],[7375,6450],[7377,6436],[7381,6433],[7394,6430],[7387,6420],[7399,6421]]],[[[8007,6468],[8021,6459],[8021,6456],[8003,6454],[7999,6457],[8007,6468]]],[[[7885,6462],[7886,6455],[7878,6453],[7873,6459],[7875,6467],[7866,6459],[7867,6471],[7876,6471],[7877,6464],[7880,6469],[7886,6468],[7885,6462]]],[[[7161,6478],[7171,6453],[7160,6456],[7151,6470],[7153,6476],[7161,6478]]],[[[8091,6478],[8089,6482],[8106,6478],[8105,6466],[8101,6466],[8096,6477],[8091,6478]]],[[[8236,6486],[8249,6485],[8258,6474],[8257,6469],[8248,6472],[8246,6481],[8243,6479],[8236,6486]]],[[[7997,6482],[7992,6483],[7991,6497],[8001,6493],[8003,6496],[8008,6491],[8007,6484],[8013,6484],[8010,6479],[8006,6483],[7997,6482]]],[[[8096,6492],[8082,6499],[8084,6502],[8100,6505],[8114,6500],[8112,6494],[8104,6495],[8096,6503],[8098,6497],[8104,6494],[8096,6492]]],[[[7328,6492],[7321,6486],[7318,6491],[7328,6505],[7333,6500],[7326,6497],[7328,6492]]],[[[7261,6547],[7253,6553],[7266,6549],[7266,6538],[7282,6536],[7286,6531],[7281,6525],[7277,6528],[7268,6528],[7259,6537],[7261,6547]]],[[[7318,6530],[7318,6524],[7313,6534],[7305,6531],[7311,6540],[7317,6537],[7322,6540],[7334,6535],[7325,6530],[7324,6536],[7318,6530]]],[[[7115,6550],[7132,6534],[7130,6524],[7125,6522],[7122,6529],[7116,6533],[7112,6542],[7106,6547],[7115,6550]]],[[[7243,6565],[7240,6555],[7236,6557],[7234,6565],[7243,6565]]],[[[8022,6572],[8034,6582],[8037,6578],[8031,6565],[8026,6565],[8022,6572]]],[[[7072,6590],[7089,6574],[7087,6574],[7066,6586],[7072,6590]]],[[[7437,6625],[7440,6618],[7437,6613],[7428,6623],[7435,6629],[7437,6625]]],[[[7709,6259],[7707,6265],[7726,6267],[7732,6260],[7736,6263],[7743,6260],[7753,6264],[7753,6252],[7769,6256],[7764,6249],[7749,6250],[7736,6245],[7734,6251],[7727,6245],[7714,6244],[7693,6238],[7686,6241],[7688,6256],[7699,6260],[7706,6256],[7709,6259]]],[[[7900,6231],[7907,6226],[7913,6236],[7917,6237],[7926,6242],[7933,6236],[7927,6235],[7930,6227],[7928,6222],[7913,6207],[7903,6207],[7893,6201],[7886,6202],[7876,6188],[7865,6184],[7864,6189],[7871,6191],[7884,6201],[7884,6206],[7892,6209],[7887,6211],[7890,6223],[7900,6231]]],[[[7720,6627],[7713,6622],[7714,6627],[7720,6627]]],[[[8399,6429],[8399,6320],[8395,6309],[8399,6303],[8399,6238],[8385,6252],[8371,6263],[8372,6268],[8353,6265],[8347,6268],[8338,6262],[8344,6284],[8331,6294],[8346,6293],[8334,6297],[8328,6302],[8333,6303],[8332,6311],[8325,6318],[8319,6332],[8314,6337],[8306,6351],[8288,6358],[8278,6361],[8251,6373],[8229,6375],[8203,6392],[8203,6387],[8193,6392],[8183,6403],[8178,6393],[8172,6386],[8162,6385],[8156,6397],[8162,6401],[8159,6409],[8155,6405],[8153,6412],[8144,6419],[8135,6420],[8134,6424],[8141,6427],[8156,6423],[8165,6433],[8179,6434],[8188,6428],[8186,6434],[8194,6435],[8192,6443],[8180,6439],[8173,6441],[8155,6438],[8151,6441],[8145,6439],[8136,6444],[8132,6455],[8116,6464],[8111,6461],[8105,6463],[8113,6474],[8112,6481],[8131,6485],[8138,6491],[8146,6495],[8156,6495],[8169,6490],[8176,6484],[8193,6484],[8199,6480],[8195,6477],[8202,6466],[8196,6456],[8201,6454],[8198,6442],[8207,6421],[8210,6433],[8213,6430],[8214,6419],[8219,6420],[8218,6413],[8223,6408],[8238,6407],[8250,6418],[8252,6424],[8260,6430],[8264,6440],[8275,6439],[8287,6444],[8286,6453],[8307,6462],[8314,6458],[8331,6453],[8336,6448],[8366,6436],[8375,6437],[8399,6429]]],[[[8207,6321],[8205,6321],[8197,6327],[8205,6335],[8208,6346],[8216,6339],[8214,6320],[8207,6321],[8214,6312],[8209,6312],[8199,6302],[8195,6307],[8198,6324],[8204,6319],[8207,6321]]],[[[7868,6264],[7881,6261],[7887,6260],[7893,6265],[7898,6263],[7882,6253],[7875,6258],[7854,6249],[7844,6249],[7834,6244],[7823,6247],[7821,6244],[7809,6243],[7798,6247],[7780,6246],[7774,6250],[7778,6256],[7788,6262],[7810,6261],[7826,6253],[7831,6261],[7834,6256],[7841,6258],[7849,6252],[7868,6264]]],[[[7559,6304],[7567,6293],[7570,6292],[7568,6284],[7585,6277],[7599,6279],[7606,6282],[7619,6276],[7615,6259],[7622,6248],[7614,6253],[7604,6252],[7582,6262],[7566,6257],[7556,6261],[7540,6263],[7537,6260],[7529,6263],[7508,6265],[7488,6274],[7468,6279],[7459,6277],[7444,6280],[7438,6276],[7419,6281],[7411,6285],[7385,6288],[7380,6293],[7385,6298],[7369,6305],[7347,6305],[7346,6310],[7354,6306],[7364,6317],[7366,6327],[7371,6333],[7393,6326],[7400,6332],[7409,6330],[7419,6322],[7423,6324],[7431,6320],[7438,6322],[7444,6315],[7446,6307],[7456,6304],[7473,6305],[7485,6302],[7501,6302],[7507,6315],[7514,6318],[7521,6309],[7531,6311],[7548,6303],[7559,6304]]],[[[8021,6415],[8014,6402],[8015,6408],[8008,6410],[8016,6420],[8048,6423],[8050,6419],[8062,6424],[8077,6418],[8086,6418],[8093,6414],[8096,6406],[8102,6401],[8100,6392],[8076,6404],[8073,6408],[8061,6408],[8061,6404],[8043,6411],[8037,6407],[8039,6397],[8034,6402],[8015,6395],[8018,6400],[8030,6402],[8021,6415]]],[[[7875,6382],[7867,6382],[7865,6375],[7858,6376],[7844,6373],[7844,6364],[7832,6364],[7825,6369],[7829,6386],[7821,6389],[7808,6402],[7813,6412],[7813,6424],[7804,6429],[7787,6419],[7794,6410],[7795,6396],[7792,6391],[7792,6377],[7795,6369],[7789,6354],[7793,6348],[7798,6326],[7796,6316],[7795,6334],[7791,6344],[7769,6340],[7762,6348],[7767,6362],[7770,6379],[7769,6389],[7765,6396],[7766,6403],[7761,6405],[7750,6401],[7745,6415],[7746,6428],[7756,6433],[7758,6446],[7762,6448],[7761,6469],[7774,6487],[7775,6502],[7778,6507],[7775,6512],[7782,6520],[7783,6527],[7792,6530],[7798,6528],[7805,6536],[7808,6545],[7823,6542],[7829,6536],[7838,6537],[7854,6535],[7865,6529],[7869,6533],[7897,6529],[7917,6540],[7918,6547],[7932,6557],[7937,6546],[7932,6546],[7926,6534],[7919,6529],[7913,6518],[7891,6514],[7877,6515],[7872,6520],[7850,6520],[7834,6518],[7832,6520],[7807,6518],[7801,6521],[7791,6517],[7785,6511],[7781,6499],[7784,6486],[7789,6479],[7794,6479],[7801,6464],[7814,6464],[7826,6480],[7830,6481],[7831,6491],[7843,6497],[7846,6483],[7869,6484],[7863,6485],[7872,6489],[7882,6486],[7879,6474],[7872,6479],[7864,6478],[7851,6461],[7834,6455],[7827,6449],[7820,6453],[7828,6442],[7835,6438],[7841,6426],[7854,6413],[7848,6406],[7860,6385],[7872,6388],[7875,6382]]],[[[8013,6515],[8014,6504],[8018,6493],[8030,6479],[8018,6485],[8014,6493],[8001,6504],[7999,6516],[8005,6517],[7999,6527],[8004,6527],[7999,6540],[8008,6561],[8018,6570],[8012,6559],[8017,6555],[8017,6543],[8006,6534],[8012,6528],[8023,6540],[8023,6546],[8030,6550],[8038,6551],[8038,6536],[8026,6531],[8026,6525],[8037,6521],[8042,6512],[8016,6519],[8013,6515]]],[[[7710,6627],[7705,6625],[7718,6617],[7717,6610],[7709,6612],[7699,6611],[7713,6605],[7713,6600],[7704,6602],[7704,6598],[7711,6595],[7709,6591],[7716,6586],[7726,6572],[7718,6561],[7726,6554],[7752,6535],[7746,6529],[7728,6531],[7720,6537],[7724,6529],[7715,6527],[7708,6514],[7709,6504],[7706,6490],[7711,6493],[7711,6482],[7701,6481],[7694,6470],[7680,6463],[7676,6453],[7676,6441],[7682,6441],[7680,6432],[7675,6430],[7674,6421],[7670,6417],[7663,6400],[7623,6383],[7623,6397],[7612,6407],[7594,6404],[7593,6412],[7586,6409],[7576,6418],[7576,6413],[7562,6404],[7552,6408],[7543,6401],[7540,6402],[7541,6416],[7537,6424],[7533,6417],[7525,6419],[7516,6415],[7507,6415],[7503,6421],[7495,6417],[7494,6431],[7489,6449],[7484,6453],[7489,6463],[7485,6473],[7471,6467],[7471,6476],[7479,6477],[7466,6480],[7468,6488],[7461,6491],[7459,6497],[7463,6499],[7462,6508],[7455,6514],[7453,6529],[7460,6550],[7466,6555],[7468,6562],[7477,6566],[7473,6561],[7477,6552],[7495,6534],[7503,6530],[7522,6537],[7531,6533],[7549,6539],[7551,6547],[7560,6551],[7575,6551],[7578,6547],[7594,6541],[7602,6547],[7620,6547],[7629,6561],[7628,6571],[7640,6578],[7636,6588],[7641,6594],[7648,6594],[7653,6627],[7659,6634],[7675,6631],[7698,6632],[7710,6627]]],[[[7141,6627],[7162,6613],[7185,6598],[7192,6591],[7191,6584],[7195,6580],[7199,6584],[7204,6574],[7221,6560],[7216,6570],[7219,6572],[7231,6564],[7235,6555],[7244,6554],[7255,6546],[7258,6535],[7268,6527],[7283,6524],[7288,6519],[7293,6534],[7296,6523],[7292,6521],[7303,6512],[7305,6505],[7298,6505],[7294,6495],[7299,6498],[7303,6495],[7293,6490],[7292,6484],[7304,6476],[7321,6475],[7326,6451],[7335,6446],[7331,6436],[7332,6429],[7336,6438],[7343,6435],[7358,6435],[7363,6421],[7371,6416],[7371,6410],[7364,6398],[7368,6392],[7364,6381],[7366,6375],[7364,6340],[7358,6335],[7348,6346],[7346,6336],[7337,6339],[7331,6332],[7319,6340],[7307,6352],[7308,6355],[7286,6370],[7279,6374],[7261,6388],[7258,6399],[7240,6411],[7231,6426],[7225,6429],[7217,6442],[7218,6450],[7212,6458],[7209,6466],[7203,6471],[7201,6481],[7187,6496],[7185,6504],[7173,6512],[7167,6513],[7166,6523],[7149,6562],[7132,6572],[7126,6572],[7114,6565],[7114,6569],[7124,6576],[7122,6589],[7116,6591],[7112,6599],[7097,6615],[7089,6616],[7081,6626],[7075,6629],[7058,6646],[7053,6664],[7047,6671],[7054,6675],[7060,6669],[7072,6666],[7077,6660],[7087,6658],[7103,6659],[7111,6656],[7119,6659],[7131,6648],[7134,6638],[7142,6635],[7141,6627]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.42,&#34;hc-middle-y&#34;:0.58,&#34;hc-key&#34;:&#34;mu&#34;,&#34;hc-a2&#34;:&#34;MU&#34;,&#34;name&#34;:&#34;Mauritius&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Mus.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;MUS&#34;,&#34;iso-a2&#34;:&#34;MU&#34;,&#34;woe-id&#34;:&#34;23424894&#34;,&#34;continent&#34;:&#34;Seven seas (open ocean)&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5948,5909],[5950,5906],[5947,5898],[5938,5897],[5938,5905],[5942,5911],[5948,5909]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.6,&#34;hc-middle-y&#34;:0.29,&#34;hc-key&#34;:&#34;se&#34;,&#34;hc-a2&#34;:&#34;SE&#34;,&#34;name&#34;:&#34;Sweden&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Swe.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;SWE&#34;,&#34;iso-a2&#34;:&#34;SE&#34;,&#34;woe-id&#34;:&#34;23424954&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4751,8402],[4734,8356],[4732,8370],[4738,8382],[4740,8383],[4748,8401],[4751,8402]]],[[[4809,8426],[4815,8428],[4806,8419],[4802,8419],[4801,8407],[4805,8405],[4799,8398],[4790,8394],[4787,8386],[4781,8399],[4783,8412],[4792,8422],[4800,8427],[4809,8426]]],[[[4594,8433],[4591,8428],[4588,8428],[4587,8432],[4594,8433]]],[[[4595,8441],[4596,8435],[4587,8434],[4585,8437],[4592,8443],[4595,8441]]],[[[4789,8472],[4789,8472],[4789,8477],[4793,8477],[4789,8472]]],[[[4903,8767],[4903,8773],[4907,8771],[4907,8767],[4903,8767]]],[[[4855,8947],[4865,8944],[4880,8929],[4894,8923],[4898,8918],[4920,8914],[4927,8909],[4930,8900],[4944,8892],[4940,8887],[4942,8873],[4938,8868],[4948,8865],[4943,8852],[4955,8834],[4952,8832],[4951,8822],[4944,8816],[4947,8805],[4955,8797],[4960,8786],[4949,8782],[4948,8786],[4936,8786],[4929,8781],[4918,8781],[4907,8788],[4904,8778],[4909,8773],[4900,8774],[4892,8772],[4896,8767],[4881,8765],[4887,8760],[4878,8744],[4874,8744],[4871,8731],[4884,8720],[4874,8713],[4865,8705],[4860,8693],[4865,8688],[4852,8690],[4846,8683],[4840,8683],[4830,8677],[4828,8672],[4822,8678],[4816,8674],[4815,8667],[4809,8660],[4805,8665],[4795,8660],[4793,8648],[4781,8641],[4774,8629],[4765,8627],[4759,8629],[4765,8616],[4759,8603],[4761,8594],[4757,8592],[4752,8579],[4755,8574],[4753,8562],[4758,8550],[4754,8548],[4766,8546],[4768,8540],[4776,8543],[4787,8533],[4793,8524],[4800,8522],[4800,8526],[4805,8510],[4809,8505],[4794,8490],[4800,8488],[4794,8483],[4786,8487],[4791,8479],[4782,8477],[4777,8470],[4772,8471],[4763,8468],[4762,8464],[4747,8457],[4726,8459],[4741,8456],[4747,8451],[4738,8439],[4742,8425],[4732,8426],[4740,8408],[4735,8404],[4730,8373],[4727,8373],[4720,8357],[4715,8349],[4707,8355],[4701,8352],[4681,8352],[4683,8347],[4675,8348],[4667,8338],[4671,8327],[4666,8321],[4657,8323],[4642,8319],[4630,8321],[4629,8327],[4633,8333],[4629,8336],[4616,8357],[4626,8356],[4620,8363],[4628,8365],[4627,8373],[4623,8373],[4619,8380],[4612,8384],[4603,8407],[4601,8402],[4599,8414],[4592,8423],[4597,8440],[4594,8444],[4587,8442],[4592,8448],[4585,8449],[4579,8445],[4581,8455],[4576,8473],[4583,8477],[4585,8473],[4592,8470],[4596,8484],[4592,8497],[4599,8504],[4597,8511],[4606,8512],[4617,8522],[4616,8530],[4619,8538],[4613,8550],[4609,8561],[4622,8563],[4627,8578],[4620,8586],[4606,8594],[4611,8619],[4604,8633],[4604,8648],[4608,8652],[4601,8666],[4608,8674],[4607,8680],[4622,8697],[4638,8703],[4659,8699],[4665,8709],[4663,8721],[4650,8726],[4670,8750],[4676,8762],[4677,8780],[4680,8785],[4676,8801],[4691,8802],[4704,8808],[4702,8819],[4710,8824],[4720,8838],[4732,8847],[4732,8854],[4723,8865],[4737,8875],[4742,8889],[4758,8899],[4775,8893],[4783,8902],[4783,8921],[4791,8923],[4797,8920],[4809,8920],[4836,8912],[4844,8918],[4836,8922],[4844,8928],[4847,8941],[4840,8946],[4855,8947]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;tt&#34;,&#34;hc-a2&#34;:&#34;TT&#34;,&#34;name&#34;:&#34;Trinidad and Tobago&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Tr.T.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;TTO&#34;,&#34;iso-a2&#34;:&#34;TT&#34;,&#34;woe-id&#34;:&#34;23424958&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2455,6823],[2451,6818],[2452,6803],[2447,6801],[2429,6801],[2439,6807],[2438,6817],[2433,6819],[2441,6822],[2455,6823]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MY&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.89,&#34;hc-middle-y&#34;:0.31,&#34;hc-key&#34;:&#34;my&#34;,&#34;hc-a2&#34;:&#34;MY&#34;,&#34;name&#34;:&#34;Malaysia&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Malay.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;MYS&#34;,&#34;iso-a2&#34;:&#34;MY&#34;,&#34;woe-id&#34;:&#34;23424901&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7202,6665],[7201,6659],[7198,6659],[7198,6665],[7202,6665]]],[[[7714,6627],[7716,6629],[7720,6627],[7714,6627]]],[[[7634,6648],[7635,6649],[7635,6646],[7637,6634],[7644,6631],[7639,6649],[7645,6649],[7652,6658],[7640,6660],[7652,6668],[7659,6668],[7665,6676],[7667,6685],[7683,6701],[7687,6711],[7688,6698],[7698,6710],[7693,6718],[7700,6721],[7700,6705],[7702,6699],[7709,6699],[7715,6692],[7711,6687],[7716,6678],[7722,6682],[7726,6677],[7720,6675],[7727,6672],[7728,6677],[7744,6668],[7758,6665],[7760,6657],[7743,6650],[7733,6653],[7727,6648],[7736,6638],[7744,6637],[7739,6633],[7722,6629],[7713,6635],[7710,6627],[7698,6632],[7675,6631],[7659,6634],[7653,6627],[7648,6594],[7641,6594],[7636,6588],[7640,6578],[7628,6571],[7629,6561],[7620,6547],[7602,6547],[7594,6541],[7578,6547],[7575,6551],[7560,6551],[7551,6547],[7549,6539],[7531,6533],[7522,6537],[7503,6530],[7495,6534],[7477,6552],[7473,6561],[7477,6566],[7477,6562],[7485,6555],[7502,6556],[7501,6553],[7510,6549],[7517,6551],[7523,6566],[7524,6576],[7527,6574],[7528,6575],[7526,6576],[7526,6587],[7528,6584],[7528,6578],[7529,6584],[7536,6588],[7546,6590],[7576,6598],[7588,6615],[7603,6630],[7605,6640],[7612,6636],[7623,6623],[7630,6635],[7627,6644],[7634,6648]]],[[[7196,6694],[7198,6701],[7211,6694],[7217,6688],[7224,6688],[7224,6678],[7221,6675],[7226,6670],[7238,6678],[7246,6673],[7253,6684],[7254,6688],[7263,6685],[7267,6677],[7284,6663],[7294,6646],[7296,6631],[7291,6615],[7295,6608],[7294,6591],[7303,6583],[7316,6558],[7319,6545],[7307,6547],[7306,6547],[7301,6548],[7296,6542],[7292,6550],[7267,6566],[7248,6575],[7245,6581],[7230,6588],[7231,6601],[7223,6611],[7213,6619],[7216,6622],[7209,6632],[7212,6639],[7210,6647],[7203,6654],[7205,6657],[7203,6669],[7203,6681],[7196,6694]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BS&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.27,&#34;hc-middle-y&#34;:0.17,&#34;hc-key&#34;:&#34;bs&#34;,&#34;hc-a2&#34;:&#34;BS&#34;,&#34;name&#34;:&#34;The Bahamas&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Bhs.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;BHS&#34;,&#34;iso-a2&#34;:&#34;BS&#34;,&#34;woe-id&#34;:&#34;23424758&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[2097,7142],[2095,7128],[2080,7126],[2078,7129],[2087,7136],[2094,7134],[2097,7142]]],[[[1956,7228],[1965,7225],[1964,7213],[1958,7216],[1956,7228]]],[[[1957,7231],[1950,7230],[1943,7241],[1947,7252],[1945,7258],[1952,7256],[1952,7252],[1959,7243],[1957,7231]]],[[[1956,7302],[1952,7304],[1929,7299],[1936,7306],[1952,7306],[1954,7312],[1965,7311],[1980,7299],[1981,7293],[1976,7291],[1975,7281],[1970,7283],[1975,7288],[1974,7297],[1965,7310],[1956,7302]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.38,&#34;hc-middle-y&#34;:0.44,&#34;hc-key&#34;:&#34;pw&#34;,&#34;hc-a2&#34;:&#34;PW&#34;,&#34;name&#34;:&#34;Palau&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Palau&#34;,&#34;subregion&#34;:&#34;Micronesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;PLW&#34;,&#34;iso-a2&#34;:&#34;PW&#34;,&#34;woe-id&#34;:&#34;23424927&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[8209,6720],[8208,6724],[8210,6728],[8213,6728],[8209,6720]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;IR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.58,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;ir&#34;,&#34;hc-a2&#34;:&#34;IR&#34;,&#34;name&#34;:&#34;Iran&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Iran&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;IRN&#34;,&#34;iso-a2&#34;:&#34;IR&#34;,&#34;woe-id&#34;:&#34;23424851&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5909,7311],[5906,7313],[5893,7303],[5893,7307],[5876,7300],[5878,7304],[5904,7315],[5909,7311]]],[[[5566,7645],[5567,7650],[5560,7655],[5561,7664],[5550,7673],[5557,7686],[5552,7687],[5552,7703],[5549,7713],[5544,7721],[5556,7723],[5557,7732],[5561,7735],[5568,7730],[5578,7716],[5586,7708],[5607,7704],[5614,7706],[5618,7704],[5628,7714],[5656,7732],[5660,7733],[5672,7721],[5666,7719],[5671,7710],[5662,7702],[5674,7695],[5679,7688],[5687,7689],[5691,7665],[5704,7657],[5726,7653],[5735,7641],[5752,7631],[5777,7626],[5822,7636],[5839,7634],[5836,7652],[5844,7651],[5861,7658],[5863,7666],[5881,7677],[5906,7677],[5910,7683],[5919,7683],[5928,7681],[5933,7683],[5937,7673],[5961,7666],[5967,7662],[5980,7664],[5996,7656],[5996,7651],[6015,7641],[6025,7628],[6047,7628],[6050,7626],[6052,7594],[6048,7583],[6049,7577],[6043,7561],[6035,7557],[6041,7551],[6034,7550],[6029,7543],[6030,7528],[6040,7526],[6031,7509],[6039,7483],[6039,7458],[6065,7454],[6069,7443],[6068,7437],[6040,7406],[6053,7391],[6061,7374],[6071,7364],[6084,7360],[6091,7354],[6096,7354],[6095,7346],[6098,7330],[6096,7323],[6108,7323],[6113,7318],[6106,7303],[6096,7303],[6082,7299],[6081,7294],[6069,7290],[6067,7278],[6064,7276],[6062,7258],[6056,7254],[6045,7259],[6034,7261],[6031,7266],[6012,7262],[5999,7266],[5989,7264],[5980,7270],[5968,7271],[5961,7269],[5955,7274],[5936,7276],[5931,7286],[5927,7310],[5921,7319],[5911,7316],[5907,7321],[5895,7316],[5887,7315],[5883,7308],[5876,7308],[5861,7299],[5839,7307],[5840,7299],[5834,7305],[5823,7310],[5822,7314],[5810,7318],[5797,7326],[5793,7335],[5780,7341],[5771,7341],[5762,7344],[5752,7363],[5752,7370],[5744,7376],[5748,7378],[5741,7382],[5740,7392],[5725,7408],[5723,7416],[5709,7411],[5698,7415],[5689,7423],[5697,7421],[5697,7426],[5690,7427],[5687,7421],[5687,7411],[5677,7409],[5674,7417],[5662,7425],[5662,7442],[5652,7442],[5652,7455],[5657,7467],[5647,7480],[5644,7488],[5635,7490],[5624,7499],[5611,7506],[5606,7506],[5608,7513],[5599,7528],[5595,7526],[5584,7539],[5590,7549],[5585,7555],[5588,7560],[5594,7558],[5592,7564],[5600,7576],[5608,7580],[5602,7590],[5604,7596],[5612,7600],[5594,7601],[5587,7607],[5583,7606],[5580,7621],[5573,7625],[5575,7629],[5568,7633],[5570,7641],[5566,7645]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TV&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.25,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;tv&#34;,&#34;hc-a2&#34;:&#34;TV&#34;,&#34;name&#34;:&#34;Tuvalu&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Tuv.&#34;,&#34;subregion&#34;:&#34;Polynesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;TUV&#34;,&#34;iso-a2&#34;:&#34;TV&#34;,&#34;woe-id&#34;:&#34;23424970&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[9525,6255],[9525,6255],[9525,6257],[9525,6255],[9525,6255]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.6,&#34;hc-key&#34;:&#34;mh&#34;,&#34;hc-a2&#34;:&#34;MH&#34;,&#34;name&#34;:&#34;Marshall Islands&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;M. Is.&#34;,&#34;subregion&#34;:&#34;Micronesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;MHL&#34;,&#34;iso-a2&#34;:&#34;MH&#34;,&#34;woe-id&#34;:&#34;23424932&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[9285,6714],[9290,6712],[9291,6712],[9289,6712],[9285,6714]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CL&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.42,&#34;hc-middle-y&#34;:0.93,&#34;hc-key&#34;:&#34;cl&#34;,&#34;hc-a2&#34;:&#34;CL&#34;,&#34;name&#34;:&#34;Chile&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Chile&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;CHL&#34;,&#34;iso-a2&#34;:&#34;CL&#34;,&#34;woe-id&#34;:&#34;23424782&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[2176,5963],[2188,5965],[2194,5973],[2191,5981],[2202,5988],[2208,5974],[2212,5969],[2218,5947],[2217,5944],[2233,5929],[2226,5920],[2229,5911],[2223,5909],[2224,5899],[2232,5893],[2229,5886],[2234,5883],[2240,5873],[2243,5852],[2247,5848],[2250,5834],[2249,5826],[2257,5823],[2270,5826],[2275,5820],[2266,5789],[2239,5777],[2229,5765],[2235,5755],[2228,5745],[2234,5722],[2229,5717],[2229,5710],[2237,5699],[2236,5694],[2229,5690],[2222,5692],[2216,5681],[2211,5665],[2197,5651],[2193,5629],[2186,5621],[2190,5606],[2188,5598],[2192,5595],[2190,5590],[2183,5589],[2178,5574],[2179,5567],[2173,5565],[2170,5550],[2175,5540],[2180,5537],[2176,5534],[2182,5520],[2183,5511],[2187,5507],[2184,5502],[2187,5493],[2193,5490],[2190,5472],[2192,5462],[2186,5460],[2180,5451],[2176,5431],[2171,5430],[2175,5420],[2176,5402],[2166,5395],[2166,5390],[2156,5387],[2152,5371],[2155,5367],[2152,5360],[2154,5354],[2152,5346],[2158,5334],[2161,5313],[2146,5305],[2146,5294],[2142,5281],[2137,5282],[2140,5271],[2133,5260],[2138,5256],[2130,5242],[2133,5235],[2130,5211],[2136,5195],[2125,5188],[2127,5181],[2124,5177],[2124,5162],[2136,5155],[2130,5146],[2137,5141],[2134,5134],[2138,5129],[2132,5123],[2134,5112],[2152,5111],[2154,5107],[2149,5098],[2143,5100],[2127,5099],[2126,5094],[2140,5091],[2149,5079],[2142,5071],[2137,5071],[2134,5064],[2140,5055],[2131,5048],[2135,5045],[2138,5028],[2130,5024],[2128,5015],[2131,5008],[2119,5001],[2118,4994],[2112,4983],[2118,4977],[2120,4967],[2111,4963],[2111,4950],[2099,4942],[2095,4930],[2085,4930],[2082,4921],[2085,4912],[2082,4906],[2083,4898],[2089,4894],[2094,4875],[2106,4880],[2119,4879],[2121,4855],[2115,4843],[2129,4832],[2131,4826],[2189,4826],[2202,4821],[2210,4820],[2233,4814],[2233,4812],[2220,4814],[2213,4818],[2203,4815],[2197,4805],[2192,4807],[2166,4797],[2159,4778],[2160,4763],[2157,4754],[2149,4751],[2125,4759],[2117,4767],[2120,4777],[2128,4771],[2133,4777],[2136,4768],[2136,4777],[2147,4782],[2153,4794],[2144,4793],[2131,4786],[2128,4781],[2117,4784],[2122,4778],[2115,4779],[2113,4772],[2118,4765],[2113,4765],[2106,4771],[2093,4777],[2100,4780],[2100,4785],[2095,4782],[2085,4787],[2088,4792],[2075,4790],[2087,4795],[2087,4801],[2081,4796],[2082,4813],[2073,4822],[2057,4832],[2055,4837],[2067,4831],[2077,4823],[2077,4825],[2062,4838],[2068,4842],[2072,4835],[2071,4849],[2073,4855],[2064,4858],[2060,4864],[2065,4870],[2075,4867],[2073,4871],[2076,4878],[2085,4878],[2077,4884],[2071,4872],[2066,4874],[2062,4887],[2049,4897],[2059,4900],[2060,4914],[2056,4923],[2058,4935],[2056,4941],[2058,4957],[2051,4979],[2062,4987],[2074,4985],[2060,4980],[2073,4976],[2076,4978],[2089,4971],[2080,4980],[2083,4987],[2078,4988],[2078,4997],[2075,4987],[2053,4988],[2050,4982],[2048,4990],[2051,4996],[2059,4997],[2054,5001],[2060,5009],[2067,5012],[2060,5013],[2066,5017],[2062,5025],[2051,5025],[2049,5021],[2034,5031],[2035,5025],[2028,5031],[2025,5019],[2019,5025],[2019,5030],[2033,5039],[2042,5050],[2037,5058],[2064,5061],[2070,5053],[2077,5061],[2079,5053],[2089,5068],[2081,5062],[2075,5067],[2078,5074],[2082,5073],[2092,5079],[2086,5080],[2090,5085],[2089,5092],[2095,5092],[2107,5099],[2108,5109],[2101,5115],[2091,5120],[2101,5141],[2096,5146],[2106,5162],[2104,5179],[2107,5180],[2104,5189],[2111,5191],[2115,5182],[2114,5195],[2102,5201],[2109,5207],[2106,5213],[2100,5216],[2096,5206],[2084,5205],[2076,5206],[2071,5234],[2077,5249],[2076,5253],[2078,5269],[2085,5273],[2092,5285],[2091,5299],[2083,5322],[2085,5334],[2079,5345],[2079,5358],[2082,5365],[2085,5362],[2093,5365],[2095,5376],[2099,5380],[2104,5394],[2105,5404],[2111,5410],[2109,5418],[2122,5433],[2127,5448],[2128,5465],[2139,5487],[2135,5500],[2141,5503],[2146,5524],[2142,5529],[2143,5539],[2138,5562],[2137,5580],[2139,5592],[2143,5591],[2149,5602],[2147,5623],[2143,5625],[2142,5634],[2152,5651],[2154,5666],[2160,5676],[2159,5690],[2164,5696],[2168,5728],[2165,5732],[2168,5742],[2174,5746],[2173,5758],[2170,5767],[2173,5796],[2175,5804],[2169,5804],[2170,5817],[2177,5819],[2180,5841],[2185,5868],[2181,5887],[2184,5910],[2177,5949],[2176,5963]],[[2100,4785],[2100,4785],[2100,4787],[2100,4787],[2100,4787],[2100,4787],[2100,4793],[2108,4798],[2111,4793],[2124,4800],[2133,4798],[2144,4800],[2141,4804],[2119,4805],[2116,4800],[2103,4806],[2108,4800],[2098,4793],[2100,4787],[2100,4787],[2100,4787],[2100,4787],[2100,4785]]],[[[2261,4672],[2258,4671],[2258,4681],[2271,4674],[2273,4668],[2261,4672]]],[[[2287,4697],[2274,4692],[2273,4698],[2268,4693],[2261,4698],[2257,4695],[2249,4699],[2243,4696],[2240,4709],[2267,4708],[2279,4705],[2287,4697]]],[[[2156,4708],[2148,4713],[2166,4707],[2169,4712],[2178,4709],[2172,4705],[2179,4701],[2171,4697],[2158,4704],[2156,4708]]],[[[2142,4747],[2157,4742],[2158,4735],[2153,4731],[2144,4739],[2138,4737],[2138,4747],[2142,4747]]],[[[2132,4751],[2139,4749],[2131,4737],[2123,4742],[2121,4749],[2126,4747],[2132,4751]]],[[[2172,4742],[2179,4743],[2174,4737],[2163,4742],[2161,4751],[2169,4751],[2166,4758],[2174,4763],[2177,4746],[2172,4742]]],[[[2066,4810],[2066,4817],[2059,4823],[2075,4816],[2079,4807],[2075,4799],[2064,4803],[2071,4807],[2066,4810]]],[[[2051,4818],[2055,4811],[2045,4812],[2049,4825],[2051,4818]]],[[[2037,4830],[2038,4837],[2044,4831],[2043,4841],[2047,4834],[2043,4821],[2037,4830]]],[[[2036,4847],[2034,4853],[2040,4851],[2049,4857],[2046,4849],[2036,4847]]],[[[2042,4871],[2038,4878],[2048,4876],[2049,4869],[2055,4873],[2057,4857],[2042,4871]]],[[[2046,4885],[2049,4890],[2058,4886],[2063,4876],[2059,4871],[2052,4879],[2056,4883],[2046,4885]]],[[[2031,4950],[2037,4945],[2025,4932],[2021,4933],[2029,4940],[2021,4947],[2032,4946],[2031,4950]]],[[[2029,4962],[2030,4955],[2022,4956],[2023,4976],[2030,4979],[2037,4962],[2036,4949],[2029,4962]]],[[[2052,5063],[2049,5067],[2056,5075],[2063,5067],[2057,5062],[2052,5063]]],[[[2070,5129],[2066,5133],[2073,5134],[2081,5123],[2074,5114],[2079,5111],[2071,5106],[2054,5107],[2055,5101],[2047,5102],[2037,5093],[2034,5097],[2045,5106],[2060,5112],[2059,5121],[2066,5119],[2072,5123],[2070,5129]]],[[[2091,5112],[2099,5113],[2107,5107],[2104,5101],[2090,5093],[2085,5103],[2092,5103],[2091,5112]]],[[[2228,4801],[2227,4714],[2225,4715],[2227,4714],[2227,4710],[2215,4708],[2188,4715],[2184,4712],[2170,4715],[2165,4712],[2156,4722],[2152,4718],[2148,4725],[2130,4720],[2128,4728],[2141,4724],[2147,4731],[2159,4727],[2159,4732],[2169,4732],[2180,4723],[2170,4735],[2162,4736],[2160,4742],[2178,4733],[2188,4734],[2191,4726],[2195,4727],[2191,4734],[2202,4732],[2209,4729],[2209,4725],[2217,4729],[2186,4743],[2183,4757],[2197,4761],[2206,4765],[2206,4772],[2197,4772],[2181,4768],[2173,4774],[2175,4786],[2183,4786],[2185,4790],[2176,4796],[2183,4797],[2187,4793],[2195,4795],[2199,4805],[2204,4808],[2213,4799],[2223,4804],[2228,4801]]],[[[2190,4704],[2189,4710],[2194,4711],[2222,4706],[2233,4708],[2236,4703],[2228,4699],[2240,4695],[2233,4692],[2242,4689],[2247,4681],[2243,4676],[2239,4684],[2228,4687],[2221,4685],[2218,4688],[2222,4698],[2216,4695],[2203,4696],[2211,4686],[2205,4685],[2202,4690],[2193,4689],[2189,4693],[2190,4704]]],[[[2084,4764],[2075,4765],[2076,4769],[2097,4765],[2094,4769],[2101,4769],[2102,4759],[2105,4767],[2124,4754],[2118,4753],[2116,4747],[2122,4740],[2116,4733],[2112,4742],[2103,4741],[2103,4748],[2109,4752],[2099,4751],[2096,4745],[2090,4741],[2091,4758],[2081,4756],[2084,4764]]],[[[2042,4931],[2033,4936],[2038,4940],[2044,4938],[2038,4947],[2040,4954],[2053,4953],[2056,4930],[2054,4922],[2057,4913],[2055,4906],[2050,4902],[2044,4903],[2043,4918],[2040,4922],[2039,4910],[2035,4907],[2022,4918],[2029,4931],[2042,4931]]],[[[2083,5184],[2085,5180],[2076,5180],[2075,5176],[2084,5169],[2081,5164],[2084,5159],[2078,5157],[2077,5148],[2063,5148],[2053,5140],[2047,5138],[2063,5161],[2066,5175],[2064,5188],[2068,5200],[2082,5205],[2082,5200],[2088,5189],[2083,5184]]],[[[2081,4779],[2081,4779],[2081,4779],[2081,4779],[2081,4779],[2081,4779],[2081,4779]]],[[[2081,4779],[2084,4776],[2085,4781],[2096,4772],[2082,4774],[2081,4779],[2081,4779],[2081,4779]]],[[[2033,4887],[2034,4892],[2026,4890],[2031,4903],[2036,4902],[2038,4896],[2045,4899],[2034,4888],[2041,4893],[2037,4884],[2032,4875],[2026,4874],[2029,4885],[2033,4887]]],[[[2043,4965],[2039,4963],[2032,4977],[2038,4986],[2029,4989],[2040,4992],[2044,4989],[2048,4976],[2045,4968],[2048,4971],[2054,4954],[2040,4957],[2039,4961],[2043,4965]]],[[[2074,5081],[2062,5085],[2060,5076],[2054,5080],[2064,5089],[2059,5090],[2064,5097],[2073,5101],[2078,5107],[2080,5096],[2074,5099],[2070,5094],[2078,5085],[2076,5080],[2075,5080],[2074,5077],[2069,5057],[2066,5071],[2069,5075],[2065,5081],[2074,5081]]],[[[2081,4779],[2068,4784],[2067,4777],[2062,4785],[2052,4789],[2050,4797],[2065,4787],[2073,4786],[2081,4779],[2081,4779]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.32,&#34;hc-middle-y&#34;:0.87,&#34;hc-key&#34;:&#34;th&#34;,&#34;hc-a2&#34;:&#34;TH&#34;,&#34;name&#34;:&#34;Thailand&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Thai.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;THA&#34;,&#34;iso-a2&#34;:&#34;TH&#34;,&#34;woe-id&#34;:&#34;23424960&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7259,6862],[7262,6861],[7265,6857],[7260,6857],[7259,6862]]],[[[7254,6688],[7253,6684],[7246,6673],[7238,6678],[7226,6670],[7221,6675],[7224,6678],[7224,6688],[7217,6688],[7211,6694],[7198,6701],[7196,6694],[7183,6707],[7185,6714],[7174,6716],[7172,6728],[7161,6741],[7152,6745],[7151,6751],[7146,6749],[7147,6736],[7143,6733],[7140,6756],[7141,6773],[7143,6774],[7149,6788],[7146,6792],[7151,6798],[7156,6809],[7156,6819],[7169,6831],[7182,6852],[7175,6872],[7166,6889],[7169,6894],[7168,6909],[7161,6920],[7151,6927],[7141,6941],[7139,6954],[7149,6957],[7150,6979],[7158,6981],[7158,6991],[7154,6985],[7147,6999],[7146,7008],[7136,7017],[7124,7032],[7126,7036],[7117,7052],[7126,7055],[7124,7065],[7128,7071],[7127,7080],[7134,7087],[7134,7092],[7149,7088],[7163,7093],[7164,7099],[7172,7100],[7179,7104],[7176,7109],[7182,7107],[7191,7112],[7196,7108],[7203,7110],[7209,7100],[7204,7090],[7207,7084],[7215,7082],[7218,7086],[7229,7083],[7227,7079],[7231,7069],[7229,7057],[7223,7050],[7227,7047],[7227,7039],[7219,7025],[7226,7021],[7245,7040],[7254,7044],[7268,7036],[7269,7033],[7282,7037],[7286,7045],[7293,7051],[7310,7047],[7324,7027],[7334,7018],[7332,7007],[7333,6993],[7342,6981],[7352,6977],[7353,6970],[7358,6969],[7356,6955],[7353,6950],[7357,6947],[7352,6930],[7345,6928],[7341,6924],[7333,6930],[7324,6928],[7307,6927],[7300,6931],[7285,6927],[7279,6923],[7269,6906],[7261,6904],[7261,6896],[7266,6887],[7266,6877],[7274,6870],[7272,6863],[7278,6847],[7270,6862],[7260,6863],[7246,6878],[7236,6877],[7225,6878],[7221,6876],[7218,6890],[7221,6902],[7209,6903],[7194,6900],[7192,6895],[7196,6889],[7191,6878],[7193,6863],[7188,6857],[7178,6832],[7178,6824],[7172,6817],[7168,6802],[7168,6792],[7173,6781],[7171,6776],[7183,6778],[7183,6787],[7191,6786],[7195,6792],[7194,6783],[7188,6778],[7192,6757],[7201,6749],[7206,6724],[7202,6732],[7197,6731],[7205,6715],[7210,6717],[7215,6710],[7222,6706],[7238,6706],[7245,6696],[7254,6688]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GD&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;gd&#34;,&#34;hc-a2&#34;:&#34;GD&#34;,&#34;name&#34;:&#34;Grenada&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Gren.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;GRD&#34;,&#34;iso-a2&#34;:&#34;GD&#34;,&#34;woe-id&#34;:&#34;23424826&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2434,6859],[2430,6859],[2431,6863],[2434,6864],[2434,6859]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;EE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.35,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;ee&#34;,&#34;hc-a2&#34;:&#34;EE&#34;,&#34;name&#34;:&#34;Estonia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Est.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;EST&#34;,&#34;iso-a2&#34;:&#34;EE&#34;,&#34;woe-id&#34;:&#34;23424805&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4915,8455],[4928,8455],[4926,8446],[4916,8440],[4906,8439],[4902,8430],[4896,8429],[4902,8436],[4892,8441],[4896,8445],[4891,8452],[4899,8451],[4913,8457],[4915,8455]]],[[[4936,8457],[4932,8453],[4927,8456],[4931,8459],[4936,8457]]],[[[4932,8475],[4936,8475],[4937,8472],[4930,8472],[4932,8475]]],[[[4917,8474],[4924,8472],[4927,8466],[4918,8465],[4911,8460],[4909,8466],[4897,8470],[4910,8472],[4914,8477],[4917,8474]]],[[[5064,8473],[5046,8471],[5042,8464],[5048,8459],[5051,8448],[5062,8430],[5067,8424],[5059,8422],[5054,8410],[5039,8414],[5028,8409],[5015,8420],[5014,8423],[5002,8426],[4993,8433],[4987,8433],[4964,8424],[4969,8433],[4971,8444],[4964,8446],[4958,8440],[4947,8445],[4945,8453],[4941,8454],[4941,8462],[4938,8469],[4939,8482],[4958,8487],[4970,8499],[4971,8493],[4989,8497],[4996,8495],[5013,8501],[5016,8499],[5033,8497],[5038,8494],[5069,8491],[5073,8494],[5076,8492],[5078,8489],[5076,8488],[5073,8488],[5073,8488],[5075,8487],[5075,8487],[5075,8487],[5074,8487],[5071,8486],[5068,8480],[5064,8473]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.48,&#34;hc-key&#34;:&#34;ag&#34;,&#34;hc-a2&#34;:&#34;AG&#34;,&#34;name&#34;:&#34;Antigua and Barbuda&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Ant.B.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;ATG&#34;,&#34;iso-a2&#34;:&#34;AG&#34;,&#34;woe-id&#34;:&#34;23424737&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2429,7011],[2432,7008],[2427,7007],[2426,7010],[2429,7011]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.47,&#34;hc-key&#34;:&#34;tw&#34;,&#34;hc-a2&#34;:&#34;TW&#34;,&#34;name&#34;:&#34;Taiwan&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Taiwan&#34;,&#34;subregion&#34;:&#34;Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;TWN&#34;,&#34;iso-a2&#34;:&#34;TW&#34;,&#34;woe-id&#34;:&#34;23424971&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[7784,7205],[7802,7240],[7813,7254],[7828,7261],[7837,7256],[7835,7247],[7836,7236],[7830,7227],[7823,7194],[7812,7179],[7807,7170],[7806,7157],[7797,7172],[7791,7175],[7783,7192],[7784,7205]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BB&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.31,&#34;hc-middle-y&#34;:0.5600000000000001,&#34;hc-key&#34;:&#34;bb&#34;,&#34;hc-a2&#34;:&#34;BB&#34;,&#34;name&#34;:&#34;Barbados&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Barb.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;BRB&#34;,&#34;iso-a2&#34;:&#34;BB&#34;,&#34;woe-id&#34;:&#34;23424754&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2496,6889],[2492,6891],[2494,6897],[2499,6892],[2496,6889]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;IT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.87,&#34;hc-middle-y&#34;:0.62,&#34;hc-key&#34;:&#34;it&#34;,&#34;hc-a2&#34;:&#34;IT&#34;,&#34;name&#34;:&#34;Italy&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Italy&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;ITA&#34;,&#34;iso-a2&#34;:&#34;IT&#34;,&#34;woe-id&#34;:&#34;23424853&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4612,7671],[4624,7680],[4628,7675],[4634,7681],[4654,7673],[4668,7675],[4687,7681],[4692,7678],[4705,7684],[4709,7684],[4696,7666],[4693,7651],[4699,7641],[4695,7638],[4693,7629],[4675,7633],[4664,7644],[4657,7644],[4629,7659],[4621,7659],[4612,7671]]],[[[4526,7784],[4528,7775],[4538,7761],[4532,7752],[4535,7746],[4530,7713],[4516,7716],[4509,7704],[4496,7707],[4491,7714],[4497,7719],[4495,7740],[4498,7753],[4492,7763],[4489,7762],[4490,7773],[4499,7772],[4508,7776],[4518,7786],[4526,7784]]],[[[4469,7876],[4475,7887],[4474,7890],[4464,7888],[4454,7892],[4450,7903],[4454,7914],[4446,7917],[4443,7924],[4456,7928],[4459,7935],[4449,7945],[4448,7950],[4455,7954],[4459,7952],[4470,7956],[4479,7954],[4487,7961],[4486,7966],[4496,7973],[4496,7967],[4508,7959],[4510,7950],[4520,7965],[4521,7974],[4526,7975],[4529,7967],[4542,7970],[4545,7979],[4556,7976],[4556,7988],[4572,7985],[4577,7992],[4594,7992],[4608,7996],[4605,7990],[4613,7982],[4638,7977],[4652,7976],[4642,7967],[4650,7963],[4645,7957],[4649,7955],[4648,7950],[4657,7943],[4652,7942],[4650,7948],[4644,7946],[4637,7948],[4629,7943],[4606,7931],[4617,7919],[4609,7910],[4613,7892],[4622,7884],[4629,7881],[4649,7867],[4663,7834],[4682,7816],[4695,7810],[4720,7811],[4725,7805],[4716,7799],[4717,7794],[4737,7785],[4750,7780],[4763,7772],[4778,7765],[4793,7748],[4788,7736],[4780,7740],[4774,7753],[4764,7753],[4750,7761],[4737,7746],[4735,7732],[4753,7722],[4752,7705],[4747,7706],[4737,7701],[4736,7689],[4724,7679],[4721,7672],[4709,7674],[4709,7682],[4714,7684],[4717,7693],[4715,7697],[4725,7701],[4719,7723],[4708,7745],[4702,7743],[4687,7751],[4690,7757],[4683,7766],[4671,7763],[4674,7767],[4669,7772],[4662,7772],[4652,7786],[4641,7788],[4632,7786],[4628,7792],[4620,7793],[4609,7803],[4607,7808],[4596,7814],[4592,7823],[4583,7827],[4575,7826],[4578,7831],[4565,7845],[4557,7848],[4559,7853],[4552,7866],[4550,7878],[4546,7884],[4537,7886],[4520,7897],[4506,7899],[4498,7895],[4489,7882],[4483,7879],[4469,7876]],[[4615,7809],[4615,7809],[4615,7809],[4615,7809],[4615,7809]],[[4615,7880],[4616,7883],[4614,7883],[4613,7881],[4615,7880]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.53,&#34;hc-key&#34;:&#34;mt&#34;,&#34;hc-a2&#34;:&#34;MT&#34;,&#34;name&#34;:&#34;Malta&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Malta&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;MLT&#34;,&#34;iso-a2&#34;:&#34;MT&#34;,&#34;woe-id&#34;:&#34;23424897&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4669,7607],[4675,7604],[4676,7600],[4672,7601],[4669,7607]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.11,&#34;hc-middle-y&#34;:0.44,&#34;hc-key&#34;:&#34;pg&#34;,&#34;hc-a2&#34;:&#34;PG&#34;,&#34;name&#34;:&#34;Papua New Guinea&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;P.N.G.&#34;,&#34;subregion&#34;:&#34;Melanesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;PNG&#34;,&#34;iso-a2&#34;:&#34;PG&#34;,&#34;woe-id&#34;:&#34;23424926&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[8776,6164],[8762,6167],[8761,6172],[8774,6167],[8785,6173],[8791,6171],[8776,6164]]],[[[8675,6226],[8668,6231],[8671,6235],[8676,6230],[8687,6229],[8693,6224],[8698,6210],[8703,6213],[8701,6206],[8693,6209],[8690,6222],[8678,6223],[8675,6226]]],[[[8801,6345],[8798,6356],[8803,6356],[8806,6345],[8814,6343],[8818,6333],[8825,6325],[8836,6319],[8840,6309],[8833,6304],[8823,6308],[8818,6313],[8818,6320],[8812,6323],[8805,6332],[8805,6342],[8801,6345]]],[[[8573,6448],[8589,6445],[8582,6441],[8568,6443],[8564,6447],[8573,6448]]],[[[8399,6238],[8399,6303],[8395,6309],[8399,6320],[8399,6429],[8430,6419],[8433,6416],[8460,6407],[8474,6405],[8489,6394],[8503,6393],[8520,6378],[8528,6377],[8538,6366],[8546,6373],[8548,6367],[8541,6363],[8540,6345],[8546,6345],[8561,6341],[8578,6331],[8590,6331],[8601,6320],[8602,6309],[8575,6307],[8582,6286],[8587,6285],[8598,6273],[8610,6269],[8613,6254],[8619,6251],[8624,6239],[8640,6242],[8645,6240],[8642,6227],[8654,6223],[8665,6222],[8657,6217],[8660,6211],[8683,6203],[8675,6201],[8685,6195],[8671,6191],[8662,6196],[8667,6198],[8657,6202],[8649,6201],[8618,6206],[8611,6209],[8605,6207],[8592,6215],[8586,6225],[8579,6227],[8574,6238],[8565,6241],[8563,6248],[8549,6268],[8540,6273],[8531,6272],[8514,6277],[8507,6284],[8503,6277],[8495,6281],[8494,6277],[8481,6283],[8487,6271],[8477,6264],[8469,6263],[8468,6260],[8479,6258],[8467,6257],[8471,6242],[8448,6231],[8435,6236],[8418,6234],[8412,6237],[8403,6235],[8399,6238]]],[[[8692,6424],[8678,6427],[8670,6427],[8664,6433],[8672,6435],[8691,6428],[8714,6415],[8721,6422],[8722,6428],[8725,6410],[8738,6399],[8741,6393],[8748,6392],[8757,6380],[8755,6370],[8750,6363],[8743,6374],[8744,6383],[8732,6401],[8718,6407],[8712,6412],[8692,6424]]],[[[8728,6348],[8719,6341],[8707,6342],[8710,6339],[8696,6329],[8678,6321],[8654,6320],[8645,6328],[8637,6325],[8628,6333],[8617,6336],[8615,6340],[8608,6337],[8606,6334],[8599,6341],[8609,6345],[8631,6343],[8635,6345],[8642,6341],[8661,6343],[8666,6358],[8671,6357],[8666,6350],[8670,6343],[8677,6345],[8683,6342],[8695,6347],[8702,6359],[8699,6362],[8712,6360],[8714,6370],[8710,6383],[8724,6382],[8736,6378],[8736,6368],[8732,6361],[8723,6359],[8728,6348]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;DE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.52,&#34;hc-middle-y&#34;:0.35,&#34;hc-key&#34;:&#34;de&#34;,&#34;hc-a2&#34;:&#34;DE&#34;,&#34;name&#34;:&#34;Germany&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Ger.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;DEU&#34;,&#34;iso-a2&#34;:&#34;DE&#34;,&#34;woe-id&#34;:&#34;23424829&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4634,8286],[4638,8291],[4650,8288],[4648,8283],[4654,8278],[4642,8275],[4634,8278],[4639,8283],[4634,8286]]],[[[4519,8018],[4519,8018],[4519,8018],[4519,8018]]],[[[4503,8300],[4508,8301],[4526,8297],[4541,8296],[4547,8284],[4566,8277],[4576,8286],[4581,8281],[4575,8281],[4574,8271],[4565,8266],[4569,8263],[4577,8265],[4586,8260],[4592,8270],[4605,8271],[4616,8283],[4627,8279],[4631,8282],[4634,8275],[4644,8269],[4652,8270],[4654,8267],[4655,8271],[4667,8262],[4666,8260],[4666,8259],[4659,8258],[4657,8261],[4655,8258],[4668,8252],[4672,8235],[4671,8226],[4664,8218],[4679,8207],[4676,8201],[4683,8187],[4678,8177],[4682,8165],[4688,8163],[4690,8156],[4684,8140],[4679,8139],[4674,8146],[4667,8145],[4671,8141],[4647,8134],[4644,8130],[4617,8122],[4610,8113],[4604,8119],[4609,8108],[4617,8103],[4613,8097],[4621,8085],[4628,8081],[4645,8066],[4655,8060],[4652,8050],[4646,8053],[4643,8045],[4623,8035],[4631,8025],[4628,8020],[4633,8018],[4632,8012],[4607,8020],[4607,8016],[4590,8015],[4583,8010],[4572,8008],[4568,8012],[4555,8015],[4556,8010],[4547,8003],[4541,8014],[4534,8014],[4515,8024],[4519,8018],[4510,8018],[4502,8023],[4495,8019],[4497,8015],[4472,8015],[4470,8023],[4472,8036],[4476,8044],[4478,8054],[4490,8067],[4473,8070],[4468,8074],[4462,8072],[4449,8076],[4446,8074],[4440,8085],[4435,8086],[4440,8099],[4431,8102],[4428,8111],[4436,8118],[4425,8136],[4425,8144],[4429,8151],[4431,8165],[4423,8177],[4429,8180],[4436,8178],[4449,8183],[4445,8186],[4455,8193],[4454,8202],[4446,8203],[4447,8209],[4455,8209],[4460,8224],[4460,8234],[4463,8237],[4455,8239],[4457,8247],[4465,8253],[4469,8251],[4489,8253],[4485,8251],[4491,8240],[4492,8248],[4500,8246],[4498,8252],[4501,8258],[4521,8259],[4513,8260],[4508,8266],[4509,8274],[4504,8279],[4500,8292],[4493,8299],[4503,8300]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;VU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.12,&#34;hc-middle-y&#34;:0.1,&#34;hc-key&#34;:&#34;vu&#34;,&#34;hc-a2&#34;:&#34;VU&#34;,&#34;name&#34;:&#34;Vanuatu&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Van.&#34;,&#34;subregion&#34;:&#34;Melanesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;VUT&#34;,&#34;iso-a2&#34;:&#34;VU&#34;,&#34;woe-id&#34;:&#34;23424907&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[9234,5933],[9237,5923],[9231,5928],[9232,5943],[9224,5946],[9228,5954],[9234,5945],[9234,5933]]],[[[9202,6012],[9201,6018],[9192,6026],[9200,6031],[9204,6024],[9202,6012]]],[[[9178,6030],[9190,6019],[9180,6015],[9175,6030],[9170,6031],[9171,6036],[9178,6030]]],[[[9191,6049],[9185,6050],[9195,6055],[9199,6051],[9197,6065],[9200,6057],[9199,6049],[9203,6037],[9191,6049]]],[[[9172,6044],[9158,6044],[9151,6068],[9153,6074],[9159,6059],[9168,6065],[9168,6059],[9172,6044]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GQ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.67,&#34;hc-middle-y&#34;:0.78,&#34;hc-key&#34;:&#34;gq&#34;,&#34;hc-a2&#34;:&#34;GQ&#34;,&#34;name&#34;:&#34;Equatorial Guinea&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Eq. G.&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;GNQ&#34;,&#34;iso-a2&#34;:&#34;GQ&#34;,&#34;woe-id&#34;:&#34;23424804&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4506,6615],[4512,6611],[4504,6599],[4497,6601],[4503,6614],[4506,6615]]],[[[4582,6568],[4582,6534],[4537,6534],[4523,6540],[4537,6562],[4537,6574],[4542,6568],[4582,6568]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CY&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.39,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;cy&#34;,&#34;hc-a2&#34;:&#34;CY&#34;,&#34;name&#34;:&#34;Cyprus&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Cyp.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;CYP&#34;,&#34;iso-a2&#34;:&#34;CY&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5242,7573],[5242,7574],[5242,7574],[5242,7573]]],[[[5250,7575],[5252,7572],[5246,7572],[5243,7575],[5246,7575],[5249,7575],[5250,7575]]],[[[5242,7573],[5243,7573],[5243,7573],[5243,7572],[5242,7573]]],[[[5241,7572],[5238,7567],[5220,7561],[5215,7563],[5213,7562],[5203,7565],[5199,7575],[5208,7579],[5209,7578],[5210,7579],[5211,7579],[5215,7575],[5232,7579],[5233,7573],[5241,7573],[5241,7572]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.41,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;km&#34;,&#34;hc-a2&#34;:&#34;KM&#34;,&#34;name&#34;:&#34;Comoros&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Com.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;COM&#34;,&#34;iso-a2&#34;:&#34;KM&#34;,&#34;woe-id&#34;:&#34;23424786&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5528,6155],[5521,6160],[5522,6171],[5526,6170],[5528,6155]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;FJ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.36,&#34;hc-middle-y&#34;:0.77,&#34;hc-key&#34;:&#34;fj&#34;,&#34;hc-a2&#34;:&#34;FJ&#34;,&#34;name&#34;:&#34;Fiji&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Fiji&#34;,&#34;subregion&#34;:&#34;Melanesia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;FJI&#34;,&#34;iso-a2&#34;:&#34;FJ&#34;,&#34;woe-id&#34;:&#34;23424813&#34;,&#34;continent&#34;:&#34;Oceania&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[9550,6012],[9553,6010],[9547,6003],[9545,6010],[9527,6009],[9526,6012],[9516,6008],[9512,6003],[9507,6010],[9516,6019],[9531,6021],[9541,6028],[9545,6026],[9533,6012],[9535,6010],[9546,6019],[9545,6013],[9550,6012]]],[[[9530,5979],[9529,5969],[9520,5983],[9514,5982],[9507,5976],[9510,5971],[9501,5970],[9493,5965],[9486,5965],[9470,5970],[9468,5977],[9479,5990],[9497,5992],[9496,5990],[9510,5982],[9519,5985],[9530,5979]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;RU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.58,&#34;hc-middle-y&#34;:0.57,&#34;hc-key&#34;:&#34;ru&#34;,&#34;hc-a2&#34;:&#34;RU&#34;,&#34;name&#34;:&#34;Russia&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Rus.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;RUS&#34;,&#34;iso-a2&#34;:&#34;RU&#34;,&#34;woe-id&#34;:&#34;23424936&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[8097,7823],[8095,7827],[8092,7831],[8088,7839],[8099,7843],[8105,7843],[8111,7852],[8113,7864],[8110,7867],[8113,7886],[8107,7908],[8103,7914],[8118,7919],[8129,7932],[8135,7928],[8138,7920],[8136,7913],[8145,7903],[8153,7909],[8159,7922],[8168,7924],[8168,7935],[8178,7943],[8179,7952],[8184,7954],[8184,7962],[8191,7966],[8189,7974],[8193,7980],[8198,8003],[8208,8009],[8216,8020],[8210,8031],[8215,8041],[8205,8045],[8186,8040],[8178,8034],[8167,8035],[8156,8029],[8149,8020],[8145,8021],[8123,8018],[8118,8021],[8107,8019],[8096,8033],[8100,8042],[8098,8049],[8091,8054],[8096,8064],[8083,8063],[8073,8070],[8067,8079],[8058,8085],[8050,8082],[8040,8086],[8041,8090],[8019,8089],[8013,8091],[8003,8099],[8002,8108],[8005,8115],[7998,8118],[7996,8136],[7986,8148],[7986,8158],[7978,8168],[7977,8174],[7971,8184],[7974,8190],[7964,8205],[7958,8210],[7950,8223],[7932,8232],[7920,8230],[7903,8238],[7898,8242],[7878,8247],[7866,8243],[7850,8244],[7817,8235],[7806,8235],[7790,8219],[7782,8214],[7787,8207],[7795,8210],[7803,8206],[7800,8198],[7804,8189],[7798,8181],[7784,8171],[7774,8148],[7767,8142],[7767,8135],[7756,8121],[7763,8120],[7758,8107],[7742,8105],[7737,8100],[7715,8088],[7695,8094],[7684,8100],[7670,8107],[7655,8102],[7646,8102],[7627,8116],[7613,8117],[7592,8107],[7581,8099],[7577,8091],[7567,8087],[7560,8089],[7547,8084],[7526,8082],[7509,8074],[7498,8078],[7492,8075],[7462,8082],[7444,8081],[7426,8094],[7427,8104],[7405,8106],[7389,8119],[7376,8118],[7369,8122],[7349,8125],[7322,8118],[7316,8113],[7301,8112],[7289,8114],[7269,8123],[7259,8131],[7257,8157],[7238,8164],[7232,8163],[7208,8174],[7193,8174],[7184,8180],[7173,8182],[7160,8189],[7154,8177],[7143,8173],[7140,8164],[7135,8163],[7128,8145],[7133,8139],[7135,8131],[7142,8127],[7137,8109],[7129,8104],[7121,8103],[7114,8096],[7103,8102],[7085,8102],[7071,8107],[7060,8102],[7048,8105],[7043,8108],[7034,8107],[7026,8115],[7023,8128],[6987,8131],[6985,8137],[6976,8133],[6968,8140],[6962,8133],[6950,8133],[6940,8124],[6927,8123],[6918,8115],[6899,8109],[6897,8105],[6887,8103],[6889,8096],[6865,8085],[6857,8087],[6845,8086],[6844,8079],[6834,8075],[6825,8073],[6819,8072],[6811,8078],[6805,8088],[6798,8091],[6803,8095],[6798,8099],[6786,8086],[6769,8092],[6759,8091],[6751,8109],[6729,8117],[6727,8126],[6716,8140],[6705,8145],[6685,8142],[6682,8137],[6665,8134],[6655,8137],[6647,8135],[6645,8144],[6635,8144],[6638,8152],[6624,8157],[6617,8153],[6617,8144],[6603,8138],[6588,8164],[6559,8210],[6541,8235],[6533,8242],[6501,8262],[6497,8270],[6506,8269],[6511,8276],[6506,8282],[6499,8277],[6475,8268],[6457,8256],[6450,8257],[6440,8251],[6439,8243],[6434,8248],[6417,8248],[6410,8241],[6404,8250],[6412,8259],[6418,8259],[6419,8266],[6412,8262],[6399,8263],[6397,8268],[6387,8270],[6388,8262],[6379,8261],[6382,8270],[6369,8279],[6371,8269],[6361,8274],[6360,8269],[6348,8272],[6343,8268],[6339,8278],[6344,8277],[6345,8293],[6339,8295],[6338,8308],[6333,8317],[6322,8316],[6316,8310],[6300,8318],[6285,8318],[6278,8323],[6279,8316],[6271,8319],[6268,8313],[6258,8313],[6255,8303],[6247,8303],[6239,8299],[6205,8293],[6191,8289],[6175,8289],[6168,8285],[6168,8278],[6159,8280],[6133,8277],[6130,8272],[6124,8274],[6106,8268],[6092,8267],[6089,8259],[6086,8265],[6062,8262],[6057,8266],[6044,8259],[6050,8257],[6045,8249],[6054,8246],[6050,8235],[6075,8229],[6075,8222],[6062,8222],[6057,8225],[6046,8221],[6035,8211],[6045,8198],[6035,8190],[6027,8189],[6019,8180],[6028,8177],[6030,8169],[6042,8169],[6045,8164],[6058,8162],[6064,8155],[6060,8153],[6055,8137],[6036,8132],[6024,8133],[6019,8139],[6014,8139],[6008,8127],[6001,8125],[5998,8131],[5983,8133],[5973,8140],[5973,8146],[5965,8151],[5962,8148],[5949,8150],[5948,8143],[5940,8140],[5931,8149],[5912,8148],[5907,8141],[5887,8127],[5877,8132],[5869,8141],[5858,8146],[5858,8130],[5849,8130],[5852,8140],[5846,8142],[5841,8149],[5829,8154],[5827,8160],[5819,8165],[5807,8163],[5793,8165],[5789,8175],[5775,8172],[5773,8164],[5759,8164],[5761,8170],[5748,8172],[5738,8170],[5731,8158],[5714,8149],[5704,8150],[5702,8139],[5681,8129],[5682,8119],[5688,8107],[5674,8099],[5669,8101],[5661,8114],[5648,8124],[5641,8117],[5641,8108],[5629,8100],[5625,8081],[5633,8076],[5625,8065],[5617,8046],[5635,8041],[5633,8030],[5636,8024],[5643,8019],[5644,8025],[5663,8022],[5677,8009],[5682,7997],[5691,7985],[5675,7981],[5698,7969],[5686,7959],[5685,7951],[5678,7955],[5669,7946],[5664,7947],[5656,7942],[5651,7946],[5638,7919],[5624,7907],[5625,7898],[5639,7891],[5645,7877],[5657,7884],[5650,7875],[5647,7865],[5646,7849],[5653,7843],[5658,7833],[5679,7807],[5672,7798],[5663,7794],[5654,7784],[5640,7788],[5624,7807],[5615,7809],[5601,7813],[5591,7821],[5595,7829],[5584,7831],[5579,7837],[5568,7839],[5552,7837],[5542,7832],[5538,7839],[5519,7846],[5509,7854],[5497,7856],[5486,7855],[5472,7856],[5445,7867],[5428,7868],[5426,7862],[5396,7889],[5385,7896],[5372,7898],[5361,7910],[5352,7908],[5343,7920],[5325,7927],[5336,7932],[5340,7929],[5353,7933],[5356,7944],[5362,7947],[5365,7957],[5374,7962],[5384,7960],[5371,7970],[5362,7974],[5359,7981],[5368,7980],[5375,7983],[5384,7981],[5379,7987],[5391,7989],[5399,7995],[5405,7994],[5404,8003],[5392,7999],[5373,7997],[5373,8005],[5377,8016],[5389,8019],[5392,8025],[5419,8024],[5421,8035],[5425,8040],[5421,8052],[5415,8053],[5417,8059],[5426,8064],[5419,8064],[5417,8069],[5424,8070],[5430,8078],[5426,8092],[5420,8089],[5413,8096],[5404,8097],[5402,8101],[5395,8099],[5387,8105],[5372,8109],[5367,8103],[5355,8114],[5350,8123],[5335,8120],[5327,8115],[5316,8117],[5311,8123],[5298,8120],[5292,8125],[5293,8132],[5281,8153],[5269,8152],[5267,8154],[5255,8155],[5258,8160],[5252,8171],[5262,8174],[5252,8182],[5251,8191],[5244,8198],[5236,8196],[5225,8199],[5217,8194],[5201,8197],[5197,8188],[5187,8186],[5183,8188],[5175,8211],[5176,8218],[5168,8225],[5172,8231],[5183,8232],[5194,8227],[5203,8232],[5212,8242],[5203,8246],[5205,8251],[5193,8256],[5183,8256],[5186,8264],[5171,8273],[5166,8289],[5154,8296],[5161,8306],[5155,8316],[5159,8321],[5158,8329],[5153,8329],[5145,8337],[5137,8340],[5128,8339],[5116,8333],[5113,8344],[5103,8347],[5096,8343],[5091,8350],[5082,8348],[5077,8352],[5079,8357],[5076,8369],[5066,8382],[5062,8381],[5068,8401],[5054,8410],[5059,8422],[5067,8424],[5062,8430],[5072,8424],[5077,8431],[5071,8438],[5061,8436],[5058,8440],[5068,8450],[5064,8473],[5068,8480],[5071,8485],[5074,8487],[5075,8487],[5073,8488],[5073,8488],[5073,8488],[5075,8487],[5078,8489],[5076,8492],[5073,8494],[5075,8508],[5084,8502],[5088,8511],[5094,8507],[5101,8509],[5107,8517],[5136,8511],[5139,8516],[5130,8518],[5127,8524],[5104,8525],[5096,8533],[5093,8528],[5086,8542],[5093,8537],[5090,8547],[5079,8541],[5067,8541],[5096,8566],[5108,8572],[5131,8594],[5151,8615],[5168,8629],[5178,8648],[5169,8657],[5167,8662],[5156,8670],[5145,8674],[5131,8687],[5137,8689],[5148,8700],[5148,8709],[5133,8718],[5131,8726],[5137,8729],[5133,8736],[5125,8737],[5119,8746],[5126,8751],[5127,8756],[5119,8758],[5123,8762],[5123,8777],[5134,8778],[5134,8786],[5129,8800],[5121,8809],[5118,8819],[5105,8836],[5105,8843],[5117,8859],[5129,8869],[5132,8878],[5121,8885],[5112,8898],[5092,8904],[5086,8921],[5096,8937],[5086,8940],[5101,8947],[5109,8950],[5112,8960],[5130,8964],[5135,8968],[5138,8978],[5147,8973],[5157,8973],[5159,8980],[5156,8987],[5175,8982],[5185,8981],[5182,8988],[5193,8988],[5192,8996],[5209,8986],[5224,8983],[5216,8976],[5195,8979],[5191,8975],[5202,8976],[5203,8971],[5222,8970],[5216,8964],[5229,8969],[5235,8968],[5229,8958],[5234,8955],[5237,8961],[5256,8966],[5269,8958],[5287,8956],[5288,8960],[5307,8954],[5317,8948],[5333,8942],[5351,8932],[5358,8931],[5379,8912],[5390,8909],[5386,8914],[5412,8898],[5422,8897],[5438,8888],[5441,8881],[5445,8885],[5457,8878],[5455,8867],[5460,8865],[5459,8857],[5466,8854],[5466,8845],[5461,8834],[5439,8815],[5428,8809],[5407,8801],[5383,8797],[5365,8799],[5334,8809],[5320,8809],[5290,8815],[5273,8825],[5262,8821],[5254,8828],[5244,8829],[5235,8836],[5235,8830],[5215,8843],[5209,8851],[5198,8850],[5207,8843],[5206,8838],[5214,8831],[5225,8829],[5221,8824],[5230,8818],[5241,8816],[5238,8811],[5252,8807],[5264,8800],[5278,8781],[5270,8785],[5272,8775],[5263,8764],[5270,8745],[5277,8740],[5273,8735],[5278,8728],[5272,8725],[5291,8712],[5309,8716],[5305,8711],[5315,8705],[5317,8699],[5329,8695],[5343,8694],[5351,8689],[5367,8696],[5368,8713],[5361,8719],[5348,8715],[5341,8717],[5330,8731],[5325,8733],[5321,8742],[5332,8744],[5332,8753],[5338,8755],[5358,8747],[5368,8739],[5394,8734],[5413,8725],[5418,8725],[5428,8735],[5441,8724],[5439,8737],[5434,8747],[5429,8750],[5418,8766],[5421,8776],[5434,8782],[5449,8794],[5466,8798],[5481,8809],[5489,8820],[5496,8820],[5502,8833],[5504,8816],[5501,8814],[5522,8816],[5534,8805],[5523,8799],[5539,8804],[5545,8799],[5549,8788],[5547,8807],[5558,8828],[5554,8833],[5558,8840],[5552,8848],[5538,8853],[5538,8861],[5548,8884],[5547,8889],[5551,8907],[5548,8911],[5524,8925],[5528,8928],[5543,8922],[5582,8922],[5601,8917],[5604,8911],[5618,8901],[5624,8886],[5603,8882],[5584,8880],[5582,8874],[5574,8870],[5572,8860],[5591,8852],[5597,8839],[5603,8836],[5620,8838],[5620,8835],[5644,8840],[5650,8839],[5653,8844],[5652,8854],[5660,8866],[5656,8872],[5662,8876],[5676,8877],[5684,8880],[5686,8887],[5695,8887],[5710,8893],[5733,8905],[5746,8916],[5755,8920],[5771,8919],[5785,8923],[5783,8913],[5787,8910],[5799,8916],[5793,8928],[5822,8941],[5841,8945],[5858,8944],[5827,8941],[5839,8937],[5830,8928],[5838,8912],[5834,8910],[5822,8913],[5815,8908],[5838,8905],[5844,8910],[5855,8909],[5859,8903],[5871,8919],[5897,8928],[5917,8926],[5922,8923],[5936,8923],[5944,8932],[5954,8932],[5955,8937],[5982,8945],[5987,8958],[5993,8953],[5992,8945],[5982,8942],[5998,8933],[5987,8926],[5989,8915],[6005,8911],[6014,8918],[6008,8926],[6012,8931],[6029,8931],[6042,8942],[6041,8952],[6032,8952],[6032,8959],[6019,8975],[6022,8980],[6034,8980],[6038,8990],[6056,8987],[6092,8984],[6115,8980],[6136,8974],[6174,8954],[6186,8953],[6182,8950],[6195,8947],[6211,8940],[6228,8936],[6225,8933],[6258,8911],[6259,8904],[6270,8910],[6267,8913],[6278,8927],[6283,8942],[6271,8941],[6265,8944],[6251,8962],[6252,8971],[6230,8978],[6231,8972],[6225,8964],[6222,8971],[6215,8976],[6214,8985],[6218,8998],[6228,8999],[6231,9003],[6224,9009],[6230,9023],[6231,9036],[6225,9042],[6212,9039],[6209,9046],[6205,9034],[6215,9019],[6204,9028],[6204,9042],[6218,9067],[6238,9073],[6251,9082],[6264,9096],[6269,9107],[6279,9144],[6294,9160],[6303,9160],[6297,9154],[6355,9156],[6383,9149],[6393,9145],[6394,9121],[6379,9098],[6374,9084],[6363,9080],[6363,9074],[6371,9067],[6388,9057],[6387,9052],[6393,9045],[6388,9031],[6391,9020],[6381,9013],[6386,9006],[6383,9000],[6389,8989],[6383,8979],[6387,8968],[6383,8967],[6387,8960],[6382,8954],[6385,8942],[6393,8935],[6413,8924],[6416,8920],[6400,8905],[6403,8894],[6402,8881],[6385,8875],[6380,8867],[6380,8860],[6370,8857],[6375,8852],[6361,8840],[6348,8842],[6354,8838],[6356,8827],[6341,8826],[6338,8821],[6330,8820],[6319,8824],[6306,8838],[6279,8834],[6283,8825],[6291,8820],[6301,8818],[6320,8811],[6343,8813],[6370,8806],[6379,8811],[6377,8819],[6383,8825],[6396,8827],[6398,8831],[6412,8835],[6425,8848],[6424,8859],[6430,8865],[6449,8878],[6451,8891],[6448,8903],[6437,8914],[6441,8921],[6440,8930],[6446,8934],[6462,8939],[6497,8945],[6504,8944],[6505,8933],[6525,8921],[6521,8908],[6526,8906],[6521,8893],[6524,8890],[6519,8882],[6535,8875],[6536,8871],[6552,8873],[6559,8872],[6574,8874],[6560,8875],[6557,8879],[6548,8877],[6529,8883],[6530,8898],[6536,8905],[6548,8907],[6542,8921],[6539,8920],[6535,8939],[6522,8945],[6513,8946],[6507,8952],[6487,8958],[6471,8959],[6450,8950],[6434,8953],[6426,8950],[6420,8956],[6424,8967],[6413,8984],[6417,8990],[6419,9007],[6436,9025],[6436,9033],[6426,9042],[6414,9065],[6398,9074],[6413,9089],[6413,9096],[6437,9103],[6454,9111],[6459,9117],[6460,9128],[6456,9143],[6449,9150],[6456,9154],[6466,9151],[6477,9136],[6473,9133],[6478,9119],[6472,9114],[6469,9105],[6464,9102],[6463,9093],[6471,9087],[6472,9080],[6463,9073],[6467,9069],[6486,9064],[6538,9059],[6545,9049],[6557,9045],[6576,9048],[6576,9052],[6567,9047],[6558,9048],[6559,9057],[6552,9057],[6553,9065],[6542,9068],[6536,9066],[6507,9076],[6496,9081],[6486,9100],[6496,9105],[6514,9108],[6533,9096],[6548,9099],[6551,9104],[6546,9111],[6527,9111],[6530,9118],[6537,9117],[6549,9127],[6559,9128],[6586,9127],[6604,9117],[6628,9110],[6623,9107],[6641,9098],[6643,9092],[6655,9089],[6668,9089],[6688,9094],[6699,9090],[6701,9087],[6694,9081],[6693,9073],[6671,9066],[6673,9056],[6669,9052],[6675,9039],[6665,9028],[6673,9008],[6667,9028],[6676,9030],[6677,9040],[6683,9049],[6688,9051],[6696,9045],[6692,9028],[6692,9020],[6682,9011],[6682,9006],[6696,9002],[6691,9015],[6706,9015],[6715,9023],[6706,9046],[6696,9064],[6709,9079],[6710,9085],[6703,9097],[6686,9100],[6668,9111],[6671,9113],[6668,9121],[6650,9125],[6639,9125],[6624,9136],[6628,9140],[6622,9146],[6629,9157],[6626,9163],[6613,9173],[6620,9174],[6612,9179],[6621,9186],[6620,9194],[6628,9194],[6649,9198],[6661,9199],[6706,9198],[6713,9201],[6732,9202],[6745,9205],[6751,9202],[6764,9202],[6769,9208],[6803,9213],[6812,9211],[6810,9205],[6792,9197],[6807,9201],[6803,9195],[6815,9196],[6822,9208],[6815,9212],[6810,9221],[6802,9226],[6804,9229],[6795,9233],[6781,9233],[6779,9240],[6789,9236],[6788,9242],[6794,9245],[6799,9241],[6818,9239],[6812,9244],[6804,9243],[6795,9251],[6786,9254],[6773,9255],[6762,9262],[6767,9265],[6771,9260],[6781,9260],[6786,9265],[6790,9259],[6799,9259],[6809,9254],[6813,9268],[6833,9278],[6821,9279],[6807,9283],[6811,9286],[6838,9282],[6848,9287],[6857,9297],[6873,9303],[6890,9303],[6887,9307],[6900,9307],[6897,9311],[6916,9313],[6924,9317],[6936,9314],[6946,9318],[7003,9327],[7008,9330],[7002,9333],[6999,9329],[6995,9335],[6983,9330],[6984,9340],[6999,9343],[7002,9339],[7016,9340],[7007,9344],[7026,9344],[7033,9340],[7043,9354],[7053,9344],[7057,9346],[7071,9345],[7075,9336],[7062,9330],[7067,9328],[7073,9333],[7089,9337],[7094,9335],[7088,9329],[7099,9330],[7106,9337],[7097,9338],[7109,9342],[7116,9339],[7110,9336],[7129,9336],[7140,9343],[7131,9344],[7158,9353],[7155,9349],[7171,9350],[7169,9344],[7185,9339],[7181,9324],[7188,9330],[7189,9342],[7180,9353],[7165,9358],[7159,9368],[7178,9365],[7199,9366],[7202,9365],[7218,9369],[7224,9366],[7257,9362],[7218,9370],[7225,9374],[7229,9383],[7218,9388],[7220,9396],[7228,9397],[7228,9404],[7268,9429],[7278,9432],[7288,9439],[7298,9437],[7311,9444],[7320,9444],[7320,9440],[7332,9442],[7334,9438],[7350,9432],[7366,9433],[7369,9424],[7378,9421],[7386,9426],[7397,9426],[7380,9417],[7363,9421],[7346,9410],[7321,9406],[7315,9403],[7333,9405],[7336,9403],[7363,9405],[7363,9400],[7353,9397],[7368,9398],[7375,9402],[7389,9398],[7394,9401],[7406,9398],[7413,9392],[7382,9367],[7424,9369],[7428,9374],[7427,9381],[7437,9379],[7467,9383],[7489,9379],[7498,9383],[7508,9381],[7521,9382],[7533,9378],[7531,9374],[7541,9373],[7553,9364],[7566,9358],[7564,9350],[7571,9345],[7564,9339],[7574,9340],[7575,9345],[7584,9347],[7573,9352],[7583,9353],[7581,9363],[7588,9358],[7586,9349],[7592,9329],[7598,9333],[7602,9328],[7596,9312],[7589,9309],[7594,9308],[7597,9301],[7593,9293],[7572,9276],[7550,9269],[7538,9257],[7530,9259],[7515,9250],[7502,9246],[7486,9238],[7484,9230],[7472,9223],[7457,9219],[7443,9205],[7430,9197],[7403,9196],[7403,9191],[7388,9178],[7376,9179],[7371,9177],[7365,9162],[7358,9156],[7343,9149],[7354,9148],[7369,9158],[7389,9152],[7402,9153],[7388,9155],[7376,9160],[7374,9166],[7380,9172],[7392,9169],[7400,9171],[7420,9171],[7431,9175],[7439,9174],[7440,9179],[7464,9183],[7463,9192],[7479,9187],[7499,9197],[7513,9200],[7514,9205],[7507,9206],[7495,9201],[7476,9201],[7474,9209],[7482,9211],[7488,9219],[7504,9218],[7517,9213],[7521,9220],[7532,9221],[7522,9217],[7529,9207],[7540,9203],[7557,9201],[7570,9204],[7574,9207],[7570,9218],[7579,9211],[7587,9200],[7587,9194],[7579,9187],[7590,9180],[7590,9159],[7579,9153],[7581,9146],[7587,9143],[7580,9152],[7591,9158],[7592,9175],[7600,9181],[7589,9190],[7602,9192],[7608,9195],[7625,9195],[7646,9202],[7681,9199],[7695,9196],[7715,9194],[7736,9195],[7752,9189],[7743,9186],[7736,9188],[7733,9177],[7736,9173],[7750,9168],[7775,9162],[7801,9160],[7813,9157],[7822,9160],[7839,9159],[7842,9155],[7850,9157],[7868,9155],[7853,9160],[7858,9163],[7874,9157],[7880,9160],[7882,9171],[7886,9174],[7877,9183],[7882,9186],[7878,9193],[7887,9202],[7890,9195],[7898,9197],[7909,9207],[7910,9215],[7916,9213],[7921,9201],[7935,9198],[7948,9191],[7944,9186],[7967,9193],[7970,9184],[7986,9186],[7989,9192],[8001,9189],[8003,9192],[8018,9189],[8016,9181],[8028,9181],[8024,9176],[8043,9173],[8040,9165],[8048,9168],[8060,9163],[8057,9158],[8044,9160],[8026,9156],[8021,9149],[8027,9150],[8056,9145],[8052,9142],[8031,9146],[8029,9143],[8016,9142],[8035,9132],[8050,9132],[8061,9125],[8062,9119],[8045,9109],[8032,9117],[8033,9120],[8021,9123],[8013,9129],[8010,9123],[8023,9118],[8044,9091],[8052,9096],[8047,9106],[8055,9099],[8055,9092],[8041,9088],[8043,9083],[8051,9084],[8058,9070],[8069,9059],[8078,9055],[8085,9048],[8094,9044],[8099,9049],[8102,9038],[8112,9037],[8121,9045],[8132,9063],[8143,9088],[8151,9099],[8158,9101],[8156,9093],[8164,9090],[8169,9082],[8183,9075],[8199,9071],[8208,9071],[8224,9080],[8241,9085],[8252,9085],[8275,9079],[8280,9076],[8296,9070],[8297,9063],[8314,9058],[8304,9063],[8317,9064],[8316,9069],[8306,9072],[8313,9081],[8334,9086],[8342,9082],[8347,9073],[8354,9078],[8371,9076],[8363,9087],[8363,9097],[8358,9102],[8367,9115],[8375,9118],[8357,9118],[8347,9114],[8345,9122],[8357,9133],[8387,9133],[8403,9138],[8400,9144],[8390,9150],[8388,9155],[8411,9152],[8416,9148],[8436,9144],[8445,9145],[8479,9142],[8530,9136],[8551,9131],[8570,9124],[8538,9126],[8528,9125],[8516,9130],[8509,9126],[8503,9118],[8491,9121],[8500,9115],[8520,9120],[8574,9123],[8562,9109],[8546,9098],[8547,9107],[8557,9112],[8544,9117],[8536,9111],[8541,9102],[8527,9098],[8517,9104],[8524,9097],[8514,9093],[8514,9088],[8527,9087],[8552,9096],[8582,9124],[8598,9124],[8618,9123],[8653,9114],[8667,9101],[8665,9097],[8655,9093],[8646,9100],[8635,9089],[8658,9086],[8663,9087],[8661,9076],[8668,9079],[8683,9079],[8683,9066],[8695,9072],[8709,9069],[8727,9054],[8725,9050],[8714,9050],[8730,9044],[8753,9042],[8763,9045],[8773,9043],[8790,9049],[8840,9056],[8888,9055],[8916,9049],[8937,9042],[8950,9033],[8960,9020],[8962,9010],[8950,8992],[8953,8987],[8969,8979],[8974,8981],[8986,8979],[8989,8961],[8988,8951],[9001,8944],[8995,8935],[8993,8923],[8999,8930],[8998,8934],[9006,8941],[9000,8957],[9002,8960],[9000,8976],[9015,8979],[9009,8971],[9030,8981],[9041,8979],[9052,8983],[9070,8981],[9078,8986],[9090,8978],[9102,8975],[9126,8976],[9138,8973],[9164,8971],[9189,8986],[9197,8982],[9193,8979],[9202,8974],[9200,8965],[9206,8957],[9220,8955],[9233,8950],[9238,8937],[9243,8934],[9264,8936],[9282,8948],[9281,8961],[9271,8977],[9262,8975],[9257,8981],[9271,8985],[9269,8994],[9272,9004],[9292,9001],[9312,8997],[9336,8996],[9347,8989],[9356,8989],[9349,8993],[9356,8995],[9369,8989],[9374,8992],[9403,8989],[9416,8990],[9430,8985],[9434,8992],[9437,8986],[9452,8980],[9470,8977],[9495,8968],[9500,8971],[9521,8962],[9509,8965],[9511,8960],[9526,8959],[9547,8945],[9535,8951],[9541,8945],[9560,8941],[9567,8936],[9582,8933],[9586,8922],[9606,8916],[9605,8907],[9616,8912],[9618,8904],[9623,8907],[9644,8896],[9643,8892],[9651,8888],[9664,8887],[9664,8880],[9656,8879],[9668,8873],[9675,8873],[9665,8880],[9671,8885],[9687,8877],[9690,8861],[9696,8865],[9702,8859],[9698,8846],[9704,8831],[9696,8828],[9712,8821],[9711,8808],[9724,8818],[9731,8810],[9734,8816],[9717,8822],[9727,8827],[9724,8842],[9708,8848],[9746,8847],[9745,8835],[9750,8842],[9764,8838],[9773,8841],[9760,8846],[9782,8841],[9792,8841],[9794,8835],[9803,8831],[9802,8828],[9817,8820],[9826,8812],[9851,8801],[9851,8795],[9838,8795],[9827,8788],[9827,8776],[9809,8780],[9799,8787],[9805,8778],[9813,8775],[9812,8769],[9806,8771],[9778,8772],[9772,8779],[9764,8776],[9772,8774],[9776,8766],[9781,8770],[9778,8757],[9781,8749],[9767,8743],[9770,8738],[9782,8734],[9765,8731],[9777,8718],[9766,8716],[9759,8723],[9759,8714],[9751,8710],[9743,8712],[9746,8720],[9735,8715],[9725,8718],[9722,8725],[9705,8733],[9703,8737],[9683,8735],[9670,8746],[9673,8752],[9668,8766],[9664,8768],[9637,8776],[9624,8768],[9598,8768],[9591,8771],[9595,8779],[9588,8782],[9578,8797],[9585,8794],[9592,8802],[9593,8813],[9584,8803],[9578,8802],[9565,8812],[9571,8804],[9560,8800],[9557,8804],[9553,8792],[9555,8785],[9569,8777],[9570,8772],[9563,8765],[9558,8753],[9545,8749],[9533,8738],[9511,8732],[9496,8730],[9477,8733],[9473,8743],[9455,8750],[9469,8738],[9461,8735],[9456,8739],[9442,8740],[9432,8745],[9443,8732],[9452,8726],[9459,8733],[9474,8735],[9470,8725],[9479,8713],[9489,8709],[9498,8716],[9507,8700],[9512,8681],[9507,8671],[9531,8658],[9526,8652],[9535,8645],[9537,8639],[9529,8629],[9523,8629],[9522,8620],[9517,8623],[9491,8631],[9469,8633],[9470,8643],[9458,8638],[9467,8632],[9451,8629],[9439,8621],[9420,8615],[9386,8598],[9374,8599],[9371,8593],[9358,8595],[9356,8586],[9346,8579],[9334,8581],[9341,8575],[9332,8570],[9324,8571],[9321,8566],[9327,8564],[9313,8555],[9295,8552],[9288,8542],[9271,8536],[9265,8515],[9261,8513],[9252,8519],[9245,8535],[9231,8542],[9203,8543],[9171,8533],[9166,8536],[9163,8530],[9147,8512],[9139,8509],[9141,8522],[9147,8538],[9136,8536],[9126,8528],[9110,8521],[9113,8516],[9101,8508],[9098,8516],[9091,8522],[9087,8516],[9066,8519],[9068,8512],[9058,8509],[9059,8501],[9053,8495],[9057,8486],[9050,8485],[9055,8477],[9046,8480],[9050,8472],[9030,8458],[9023,8447],[9018,8434],[9019,8427],[9033,8420],[9033,8425],[9039,8429],[9057,8418],[9050,8407],[9042,8402],[9043,8390],[9041,8378],[9054,8377],[9058,8353],[9049,8346],[9042,8348],[9037,8355],[9045,8364],[9038,8366],[9030,8361],[9036,8357],[9022,8351],[9012,8330],[9011,8320],[9014,8308],[9023,8299],[9011,8285],[8998,8284],[8993,8288],[8981,8286],[8961,8271],[8956,8263],[8954,8250],[8958,8247],[8956,8240],[8961,8228],[8948,8234],[8930,8227],[8921,8220],[8918,8226],[8913,8222],[8919,8220],[8913,8208],[8917,8197],[8912,8193],[8909,8183],[8893,8166],[8864,8145],[8863,8153],[8858,8156],[8854,8193],[8845,8221],[8840,8255],[8833,8281],[8828,8316],[8831,8343],[8840,8372],[8843,8378],[8862,8390],[8871,8406],[8865,8420],[8870,8424],[8878,8420],[8885,8422],[8892,8431],[8902,8430],[8930,8448],[8951,8468],[8955,8479],[8968,8488],[8974,8497],[8984,8500],[9004,8520],[9015,8526],[9016,8535],[9024,8541],[9040,8545],[9044,8550],[9058,8552],[9070,8558],[9062,8561],[9078,8577],[9070,8583],[9073,8590],[9078,8592],[9081,8618],[9093,8627],[9113,8624],[9100,8632],[9095,8637],[9079,8636],[9074,8633],[9055,8630],[9058,8621],[9050,8617],[9053,8609],[9047,8597],[9058,8593],[9049,8584],[9045,8592],[9030,8592],[9018,8578],[8986,8557],[8983,8549],[8979,8550],[8964,8542],[8964,8553],[8972,8563],[8965,8563],[8953,8558],[8959,8566],[8953,8572],[8960,8582],[8968,8586],[8971,8596],[8969,8604],[8960,8599],[8956,8593],[8947,8591],[8940,8601],[8927,8602],[8925,8598],[8908,8598],[8903,8594],[8885,8596],[8861,8584],[8861,8570],[8858,8571],[8844,8561],[8836,8549],[8811,8533],[8799,8521],[8795,8520],[8797,8512],[8789,8511],[8789,8502],[8785,8495],[8790,8492],[8795,8497],[8811,8495],[8817,8490],[8818,8481],[8797,8483],[8784,8475],[8777,8481],[8764,8484],[8763,8477],[8756,8477],[8751,8470],[8740,8471],[8734,8476],[8724,8468],[8705,8467],[8697,8478],[8685,8479],[8687,8494],[8678,8500],[8653,8506],[8639,8501],[8641,8496],[8628,8494],[8635,8489],[8629,8483],[8619,8485],[8617,8490],[8603,8490],[8601,8485],[8593,8483],[8584,8488],[8556,8491],[8557,8481],[8548,8479],[8542,8484],[8546,8491],[8518,8489],[8485,8492],[8473,8487],[8463,8489],[8446,8483],[8430,8473],[8417,8457],[8397,8446],[8390,8438],[8385,8423],[8368,8415],[8364,8408],[8353,8400],[8347,8399],[8339,8390],[8331,8387],[8315,8368],[8318,8364],[8309,8361],[8299,8351],[8262,8325],[8257,8318],[8239,8308],[8230,8300],[8231,8293],[8242,8291],[8245,8287],[8268,8288],[8272,8292],[8279,8288],[8275,8282],[8276,8267],[8272,8261],[8275,8255],[8285,8256],[8291,8265],[8284,8270],[8301,8280],[8309,8283],[8295,8268],[8291,8266],[8305,8262],[8292,8245],[8309,8247],[8320,8254],[8328,8264],[8329,8257],[8320,8245],[8324,8244],[8331,8253],[8334,8263],[8333,8277],[8352,8272],[8365,8276],[8377,8266],[8378,8260],[8398,8241],[8412,8236],[8413,8230],[8404,8223],[8396,8229],[8399,8222],[8407,8218],[8409,8210],[8404,8203],[8405,8198],[8416,8193],[8409,8185],[8412,8181],[8397,8170],[8397,8162],[8391,8158],[8391,8146],[8386,8140],[8383,8127],[8386,8112],[8391,8110],[8383,8102],[8387,8090],[8381,8077],[8382,8068],[8378,8063],[8376,8048],[8349,8023],[8340,8005],[8329,7996],[8314,7965],[8302,7949],[8286,7934],[8276,7927],[8263,7912],[8257,7902],[8249,7898],[8242,7890],[8236,7875],[8227,7866],[8192,7844],[8182,7843],[8169,7837],[8157,7845],[8149,7841],[8143,7844],[8144,7859],[8128,7848],[8136,7858],[8129,7860],[8117,7846],[8111,7834],[8095,7836],[8102,7831],[8097,7823]],[[5234,8955],[5234,8954],[5234,8954],[5234,8954],[5222,8948],[5232,8951],[5234,8954],[5234,8954],[5234,8954],[5235,8955],[5234,8955]],[[7589,9309],[7588,9309],[7588,9309],[7588,9309],[7594,9316],[7583,9318],[7562,9327],[7561,9323],[7570,9321],[7569,9312],[7584,9315],[7583,9311],[7588,9309],[7588,9309],[7588,9309],[7588,9309],[7589,9309]]],[[[8557,7899],[8562,7897],[8551,7893],[8534,7874],[8530,7878],[8539,7885],[8551,7902],[8557,7899]]],[[[8630,7932],[8612,7927],[8606,7920],[8597,7920],[8593,7914],[8575,7899],[8572,7900],[8582,7910],[8580,7914],[8590,7919],[8603,7928],[8615,7930],[8624,7938],[8631,7937],[8630,7932]]],[[[8682,7965],[8671,7954],[8654,7942],[8648,7941],[8655,7951],[8665,7959],[8682,7965]]],[[[8832,8138],[8831,8142],[8844,8137],[8855,8140],[8853,8132],[8847,8133],[8845,8126],[8835,8114],[8827,8112],[8824,8106],[8819,8109],[8818,8118],[8831,8121],[8838,8133],[8832,8138]]],[[[8283,8302],[8272,8301],[8281,8308],[8296,8306],[8300,8313],[8315,8305],[8311,8296],[8303,8289],[8296,8300],[8283,8302]]],[[[9135,8320],[9144,8317],[9143,8311],[9155,8298],[9155,8292],[9142,8302],[9136,8314],[9128,8317],[9135,8320]]],[[[9094,8481],[9099,8474],[9096,8467],[9082,8465],[9065,8454],[9071,8469],[9076,8474],[9093,8484],[9094,8481]]],[[[5307,8754],[5309,8748],[5301,8745],[5294,8751],[5307,8754]]],[[[6288,8834],[6312,8829],[6311,8819],[6305,8818],[6296,8824],[6292,8832],[6288,8834]]],[[[5724,8943],[5706,8934],[5679,8931],[5668,8940],[5670,8960],[5685,8971],[5699,8972],[5725,8959],[5730,8953],[5724,8943]]],[[[9000,8974],[8998,8958],[9004,8944],[8993,8950],[8994,8962],[8991,8968],[9000,8974]]],[[[9236,8985],[9230,8975],[9221,8975],[9200,8982],[9188,8989],[9203,8999],[9237,8991],[9236,8985]]],[[[5996,9016],[6001,9009],[6015,9003],[6029,8993],[6029,8983],[6021,8981],[6002,8983],[6004,8987],[5998,8992],[5984,8995],[5973,9002],[5970,9012],[5980,9009],[5975,9015],[5986,9023],[5996,9016]]],[[[6698,9018],[6696,9032],[6700,9040],[6706,9037],[6701,9032],[6701,9021],[6698,9018]]],[[[5801,9073],[5802,9068],[5816,9063],[5810,9053],[5803,9056],[5797,9064],[5787,9066],[5787,9070],[5801,9073]]],[[[8308,9082],[8310,9079],[8305,9074],[8283,9080],[8288,9082],[8308,9082]]],[[[6538,9122],[6513,9122],[6513,9126],[6523,9131],[6533,9141],[6552,9137],[6556,9133],[6538,9122]]],[[[8044,9141],[8036,9135],[8020,9141],[8036,9143],[8044,9141]]],[[[8056,9148],[8026,9151],[8029,9154],[8046,9157],[8058,9154],[8056,9148]]],[[[6590,9157],[6591,9147],[6586,9145],[6572,9147],[6564,9155],[6578,9167],[6590,9157]]],[[[6452,9166],[6441,9155],[6430,9162],[6433,9168],[6452,9166]]],[[[7776,9163],[7771,9167],[7782,9171],[7788,9163],[7776,9163]]],[[[6343,9181],[6346,9185],[6358,9174],[6361,9164],[6350,9171],[6312,9162],[6306,9163],[6311,9177],[6308,9184],[6323,9189],[6337,9190],[6343,9181]]],[[[6491,9193],[6507,9188],[6488,9191],[6480,9187],[6468,9187],[6475,9193],[6491,9193]]],[[[8245,9228],[8260,9218],[8257,9211],[8236,9227],[8234,9233],[8245,9228]]],[[[8386,9213],[8380,9215],[8375,9222],[8377,9231],[8397,9234],[8403,9228],[8401,9218],[8386,9213]]],[[[7586,9239],[7580,9231],[7569,9223],[7551,9226],[7534,9233],[7530,9238],[7544,9240],[7546,9249],[7585,9246],[7586,9239]]],[[[6775,9252],[6786,9249],[6775,9244],[6770,9248],[6760,9245],[6758,9252],[6775,9252]]],[[[6813,9274],[6808,9267],[6790,9268],[6796,9276],[6813,9274]]],[[[6665,9286],[6659,9295],[6653,9293],[6649,9299],[6661,9307],[6668,9307],[6666,9302],[6671,9296],[6664,9297],[6665,9286]]],[[[8248,9299],[8236,9299],[8241,9310],[8239,9317],[8243,9328],[8249,9319],[8257,9314],[8252,9308],[8254,9303],[8248,9299]]],[[[7101,9358],[7105,9351],[7097,9347],[7095,9354],[7092,9348],[7089,9353],[7083,9350],[7087,9346],[7072,9346],[7055,9349],[7056,9354],[7062,9351],[7069,9355],[7079,9351],[7087,9357],[7101,9358]]],[[[7561,9374],[7564,9363],[7549,9370],[7545,9375],[7561,9374]]],[[[7055,9377],[7041,9375],[7049,9380],[7077,9377],[7089,9380],[7082,9374],[7055,9377]]],[[[8643,9375],[8619,9374],[8631,9381],[8647,9383],[8643,9375]]],[[[7089,9403],[7066,9395],[7072,9400],[7053,9397],[7058,9401],[7084,9408],[7088,9411],[7089,9403]]],[[[6873,9406],[6863,9397],[6859,9403],[6870,9407],[6878,9417],[6887,9417],[6891,9408],[6873,9406]]],[[[7375,9473],[7369,9475],[7383,9483],[7391,9480],[7383,9477],[7383,9471],[7415,9473],[7419,9469],[7412,9464],[7381,9469],[7375,9473]]],[[[6494,9568],[6500,9568],[6533,9561],[6533,9558],[6506,9557],[6507,9560],[6491,9563],[6494,9568]]],[[[5756,9592],[5762,9586],[5722,9590],[5737,9591],[5750,9599],[5758,9596],[5756,9592]]],[[[6012,9604],[6018,9604],[6010,9597],[6013,9592],[5996,9586],[5979,9593],[5978,9586],[5963,9588],[5979,9595],[6001,9600],[6012,9604]]],[[[5722,9596],[5707,9603],[5717,9608],[5727,9607],[5722,9596]]],[[[5929,9615],[5931,9600],[5925,9596],[5896,9597],[5889,9599],[5898,9605],[5897,9615],[5916,9614],[5918,9617],[5929,9615]]],[[[5819,9619],[5824,9613],[5834,9611],[5823,9604],[5798,9604],[5785,9611],[5796,9612],[5806,9620],[5819,9619]]],[[[5876,9614],[5881,9610],[5870,9607],[5872,9611],[5867,9620],[5876,9621],[5876,9614]]],[[[5857,9626],[5861,9619],[5854,9617],[5850,9607],[5843,9605],[5841,9611],[5850,9611],[5850,9618],[5857,9626]]],[[[5993,9615],[5973,9615],[5958,9610],[5969,9608],[5968,9603],[5953,9604],[5955,9599],[5939,9601],[5933,9608],[5933,9621],[5925,9625],[5969,9624],[5982,9621],[5993,9615]]],[[[5846,9632],[5851,9624],[5845,9620],[5832,9624],[5837,9628],[5835,9633],[5846,9632]]],[[[5917,9643],[5924,9637],[5907,9634],[5892,9635],[5880,9641],[5891,9644],[5913,9646],[5917,9643]]],[[[5985,9647],[5968,9643],[5951,9648],[5961,9651],[5978,9654],[5985,9647]]],[[[5879,9651],[5897,9647],[5864,9641],[5854,9645],[5839,9646],[5848,9651],[5867,9653],[5879,9651]]],[[[6607,9657],[6617,9656],[6613,9651],[6578,9647],[6574,9651],[6581,9657],[6596,9659],[6607,9657]]],[[[5972,9657],[5963,9657],[5951,9664],[5958,9668],[5975,9663],[5972,9657]]],[[[6053,9659],[6044,9655],[6025,9657],[6017,9661],[6033,9667],[6064,9668],[6062,9663],[6053,9659]]],[[[5902,9669],[5918,9668],[5925,9665],[5946,9662],[5949,9658],[5964,9655],[5951,9650],[5942,9651],[5925,9658],[5921,9662],[5901,9667],[5902,9669]]],[[[5883,9661],[5898,9663],[5915,9659],[5916,9656],[5947,9648],[5943,9643],[5928,9639],[5917,9647],[5891,9650],[5877,9659],[5868,9657],[5864,9660],[5850,9661],[5857,9669],[5883,9661]]],[[[5744,9664],[5731,9662],[5731,9669],[5743,9672],[5749,9668],[5744,9664]]],[[[6153,9675],[6169,9670],[6175,9662],[6176,9655],[6162,9647],[6145,9642],[6123,9641],[6107,9638],[6089,9650],[6107,9658],[6134,9659],[6141,9672],[6153,9675]]],[[[6937,9666],[6933,9664],[6898,9668],[6895,9672],[6900,9675],[6941,9674],[6945,9670],[6937,9666]]],[[[5947,9670],[5938,9669],[5926,9672],[5953,9677],[5958,9675],[5947,9670]]],[[[5920,9687],[5947,9683],[5950,9680],[5928,9678],[5915,9673],[5904,9676],[5892,9673],[5884,9676],[5881,9683],[5893,9683],[5913,9678],[5907,9687],[5920,9687]]],[[[6007,9674],[6007,9672],[5986,9674],[5987,9680],[5970,9683],[5976,9687],[5986,9689],[6007,9674]]],[[[5950,9698],[5953,9694],[5968,9694],[5973,9689],[5965,9687],[5950,9687],[5939,9691],[5919,9692],[5927,9698],[5950,9698]]],[[[6079,9700],[6069,9700],[6080,9710],[6123,9709],[6127,9707],[6117,9702],[6094,9703],[6089,9707],[6079,9700]]],[[[5968,9704],[5965,9701],[5953,9710],[5960,9715],[5955,9718],[5992,9721],[5998,9718],[5996,9713],[5965,9711],[5968,9704]]],[[[9600,9077],[9623,9064],[9618,9057],[9609,9053],[9581,9050],[9567,9046],[9548,9050],[9538,9044],[9522,9044],[9513,9040],[9508,9054],[9516,9064],[9535,9075],[9556,9083],[9568,9081],[9575,9083],[9595,9080],[9600,9077]]],[[[8415,9178],[8394,9184],[8385,9184],[8369,9180],[8363,9185],[8368,9188],[8385,9189],[8397,9207],[8404,9211],[8431,9213],[8446,9208],[8471,9192],[8475,9174],[8464,9171],[8415,9178]]],[[[6960,9579],[6930,9582],[6935,9585],[6928,9590],[6931,9595],[6951,9596],[6970,9594],[6976,9591],[7008,9587],[7006,9581],[6988,9573],[6975,9570],[6955,9570],[6967,9574],[6960,9579]]],[[[6002,9647],[6020,9650],[6024,9647],[6076,9652],[6082,9645],[6075,9637],[6076,9634],[6065,9633],[6062,9628],[6053,9627],[6054,9623],[6046,9619],[6024,9626],[6006,9621],[5993,9628],[5992,9636],[6002,9647]]],[[[4830,8282],[4837,8287],[4849,8292],[4838,8293],[4826,8282],[4826,8283],[4834,8291],[4835,8300],[4848,8302],[4856,8307],[4864,8316],[4866,8316],[4853,8302],[4873,8302],[4874,8315],[4878,8317],[4899,8306],[4913,8307],[4920,8300],[4916,8282],[4919,8278],[4917,8278],[4830,8282]]],[[[6711,9223],[6710,9223],[6710,9223],[6710,9223],[6711,9223],[6711,9223]]],[[[6711,9223],[6721,9220],[6733,9221],[6733,9216],[6719,9218],[6711,9223],[6711,9223]]],[[[8488,8079],[8466,8083],[8458,8072],[8458,8065],[8445,8031],[8445,8022],[8451,8010],[8459,8003],[8464,7983],[8464,7988],[8474,7984],[8477,7970],[8473,7963],[8470,7976],[8453,7978],[8451,7983],[8443,7980],[8432,7953],[8427,7958],[8424,7979],[8431,7995],[8428,8016],[8435,8029],[8433,8043],[8425,8060],[8428,8063],[8434,8094],[8434,8121],[8430,8128],[8437,8151],[8432,8164],[8420,8174],[8419,8199],[8425,8208],[8427,8225],[8422,8239],[8436,8245],[8443,8239],[8449,8246],[8444,8250],[8453,8252],[8450,8262],[8439,8275],[8445,8276],[8451,8281],[8459,8269],[8455,8257],[8461,8248],[8467,8230],[8468,8208],[8464,8197],[8463,8179],[8468,8175],[8465,8166],[8472,8165],[8482,8119],[8488,8107],[8495,8088],[8496,8078],[8503,8066],[8488,8079]]],[[[5795,9085],[5792,9077],[5775,9076],[5766,9082],[5762,9092],[5763,9102],[5768,9110],[5775,9114],[5791,9110],[5791,9120],[5800,9126],[5802,9141],[5791,9145],[5797,9153],[5810,9157],[5818,9154],[5820,9162],[5812,9167],[5822,9175],[5831,9178],[5844,9177],[5854,9182],[5866,9185],[5877,9180],[5910,9174],[5913,9168],[5891,9165],[5908,9165],[5904,9162],[5887,9160],[5905,9159],[5901,9149],[5889,9149],[5895,9143],[5889,9141],[5879,9122],[5885,9116],[5874,9102],[5883,9100],[5887,9084],[5898,9072],[5900,9065],[5928,9044],[5940,9041],[5945,9036],[5940,9030],[5920,9035],[5922,9032],[5935,9028],[5931,9024],[5912,9035],[5916,9028],[5900,9033],[5901,9029],[5889,9030],[5881,9037],[5872,9027],[5853,9039],[5855,9033],[5825,9040],[5818,9044],[5830,9048],[5823,9055],[5845,9058],[5832,9062],[5826,9062],[5816,9076],[5806,9072],[5797,9076],[5795,9085]]],[[[8581,9297],[8587,9303],[8618,9302],[8623,9299],[8619,9294],[8624,9289],[8639,9292],[8669,9290],[8671,9287],[8690,9284],[8683,9270],[8659,9265],[8656,9263],[8641,9262],[8611,9265],[8592,9275],[8579,9277],[8566,9284],[8553,9287],[8549,9291],[8552,9300],[8559,9305],[8558,9311],[8570,9307],[8566,9303],[8570,9298],[8581,9297]]],[[[8445,9328],[8460,9325],[8470,9325],[8476,9329],[8487,9326],[8512,9315],[8523,9313],[8529,9307],[8511,9303],[8508,9296],[8514,9294],[8508,9286],[8499,9280],[8488,9278],[8481,9281],[8471,9281],[8455,9285],[8444,9299],[8445,9305],[8459,9312],[8459,9319],[8439,9320],[8432,9308],[8435,9297],[8448,9282],[8472,9277],[8479,9273],[8472,9271],[8453,9269],[8440,9266],[8428,9273],[8440,9272],[8435,9277],[8425,9276],[8411,9272],[8403,9272],[8372,9266],[8366,9274],[8355,9273],[8358,9268],[8351,9258],[8341,9256],[8335,9260],[8316,9263],[8308,9267],[8305,9275],[8286,9285],[8278,9298],[8293,9297],[8290,9312],[8282,9313],[8287,9316],[8288,9324],[8299,9323],[8295,9334],[8312,9338],[8321,9345],[8325,9340],[8327,9348],[8338,9350],[8344,9342],[8364,9335],[8364,9330],[8375,9324],[8386,9322],[8384,9315],[8399,9314],[8396,9321],[8397,9336],[8407,9340],[8417,9337],[8411,9347],[8434,9337],[8445,9328]]],[[[6165,9365],[6180,9372],[6191,9369],[6184,9378],[6204,9388],[6219,9395],[6238,9399],[6264,9396],[6274,9390],[6278,9380],[6274,9372],[6278,9371],[6261,9358],[6259,9353],[6248,9352],[6225,9343],[6212,9340],[6197,9334],[6168,9328],[6124,9314],[6104,9312],[6082,9303],[6075,9303],[6066,9299],[6058,9290],[6055,9296],[6047,9288],[6039,9285],[6036,9278],[6029,9283],[6029,9278],[6015,9275],[6033,9275],[6031,9269],[6021,9268],[6023,9262],[6008,9260],[6011,9255],[6003,9253],[5990,9261],[5994,9256],[5990,9244],[5961,9252],[5975,9243],[5977,9232],[5973,9229],[5963,9229],[5960,9217],[5948,9221],[5942,9229],[5943,9222],[5953,9213],[5954,9207],[5949,9202],[5938,9209],[5944,9196],[5937,9193],[5919,9198],[5934,9187],[5919,9175],[5901,9178],[5898,9185],[5895,9179],[5880,9180],[5868,9186],[5852,9183],[5846,9180],[5839,9182],[5850,9188],[5844,9190],[5854,9196],[5870,9201],[5853,9201],[5846,9195],[5837,9197],[5827,9204],[5834,9205],[5847,9214],[5862,9217],[5858,9222],[5873,9229],[5892,9224],[5886,9229],[5870,9234],[5889,9236],[5874,9240],[5879,9244],[5905,9246],[5893,9250],[5882,9251],[5883,9256],[5894,9257],[5908,9260],[5911,9265],[5895,9264],[5894,9267],[5917,9274],[5906,9274],[5909,9279],[5893,9276],[5891,9286],[5899,9290],[5908,9288],[5910,9281],[5923,9290],[5919,9294],[5928,9300],[5948,9296],[5943,9307],[5961,9312],[5957,9317],[5974,9320],[5977,9330],[5991,9336],[6007,9332],[6024,9338],[6016,9340],[6023,9343],[6040,9344],[6029,9338],[6036,9337],[6047,9342],[6041,9346],[6047,9353],[6063,9355],[6077,9352],[6085,9353],[6085,9348],[6097,9353],[6102,9349],[6124,9358],[6134,9356],[6147,9361],[6151,9359],[6157,9366],[6165,9365]]],[[[7260,9554],[7278,9551],[7285,9547],[7273,9536],[7272,9528],[7263,9514],[7275,9523],[7278,9528],[7305,9535],[7310,9534],[7313,9526],[7322,9525],[7325,9516],[7342,9515],[7345,9513],[7352,9498],[7350,9493],[7334,9482],[7316,9482],[7302,9477],[7281,9477],[7271,9471],[7269,9475],[7259,9475],[7228,9473],[7222,9469],[7194,9458],[7178,9457],[7171,9463],[7185,9478],[7194,9483],[7193,9488],[7201,9499],[7204,9509],[7218,9512],[7216,9519],[7224,9528],[7223,9534],[7231,9541],[7238,9542],[7238,9548],[7246,9550],[7250,9543],[7259,9541],[7256,9549],[7260,9554]]],[[[7046,9528],[7035,9534],[7034,9539],[7027,9541],[7025,9557],[7016,9554],[7008,9555],[7016,9558],[7009,9561],[7000,9559],[6995,9555],[6990,9556],[6980,9551],[6966,9555],[6980,9554],[6982,9562],[6995,9562],[7010,9569],[7021,9577],[7036,9580],[7023,9585],[7038,9592],[7045,9599],[7052,9593],[7060,9599],[7090,9599],[7122,9604],[7136,9596],[7129,9592],[7126,9584],[7120,9579],[7125,9576],[7132,9585],[7145,9584],[7151,9590],[7150,9596],[7169,9595],[7179,9588],[7193,9580],[7191,9571],[7202,9569],[7190,9565],[7186,9568],[7183,9557],[7185,9549],[7180,9543],[7167,9546],[7165,9544],[7187,9532],[7191,9523],[7175,9514],[7127,9513],[7112,9516],[7098,9525],[7086,9527],[7066,9525],[7065,9530],[7058,9532],[7046,9528]]],[[[5576,9636],[5630,9643],[5636,9649],[5648,9650],[5658,9647],[5670,9649],[5681,9643],[5675,9641],[5684,9637],[5683,9633],[5663,9637],[5655,9644],[5643,9639],[5644,9632],[5638,9634],[5632,9629],[5622,9630],[5617,9623],[5605,9622],[5602,9631],[5588,9627],[5581,9632],[5569,9634],[5576,9636]]],[[[5645,9622],[5662,9629],[5674,9631],[5678,9626],[5695,9627],[5703,9634],[5710,9635],[5709,9642],[5697,9639],[5691,9645],[5727,9656],[5746,9655],[5749,9649],[5734,9647],[5728,9642],[5759,9645],[5771,9641],[5771,9638],[5755,9634],[5748,9628],[5724,9628],[5712,9625],[5715,9619],[5705,9617],[5686,9618],[5681,9613],[5694,9605],[5690,9602],[5676,9605],[5672,9598],[5665,9601],[5662,9598],[5651,9597],[5655,9604],[5664,9606],[5659,9609],[5645,9608],[5635,9603],[5622,9613],[5635,9617],[5639,9613],[5662,9613],[5667,9615],[5650,9619],[5667,9620],[5664,9624],[5645,9622]]],[[[6983,9638],[6994,9646],[6984,9644],[6972,9645],[6977,9652],[6990,9655],[6988,9660],[7000,9663],[7018,9665],[7042,9670],[7051,9676],[7048,9679],[7068,9681],[7091,9666],[7094,9660],[7103,9654],[7126,9649],[7132,9640],[7110,9636],[7105,9628],[7111,9615],[7117,9614],[7110,9608],[7046,9601],[7032,9601],[7023,9595],[7020,9591],[7007,9592],[6972,9603],[6959,9604],[6963,9606],[6982,9603],[6982,9605],[6965,9607],[6960,9612],[6977,9612],[6995,9610],[6992,9613],[6943,9612],[6942,9616],[6960,9619],[6955,9624],[6965,9627],[6980,9627],[6983,9638]]],[[[6710,9223],[6704,9220],[6684,9224],[6673,9223],[6679,9228],[6697,9227],[6710,9223],[6710,9223]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;UG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.16,&#34;hc-middle-y&#34;:0.54,&#34;hc-key&#34;:&#34;ug&#34;,&#34;hc-a2&#34;:&#34;UG&#34;,&#34;name&#34;:&#34;Uganda&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Uga.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;UGA&#34;,&#34;iso-a2&#34;:&#34;UG&#34;,&#34;woe-id&#34;:&#34;23424974&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5249,6512],[5237,6510],[5229,6516],[5230,6508],[5223,6511],[5214,6506],[5208,6509],[5198,6507],[5196,6503],[5204,6493],[5190,6496],[5182,6482],[5184,6476],[5156,6476],[5145,6474],[5141,6474],[5136,6466],[5130,6462],[5126,6466],[5119,6465],[5118,6478],[5121,6491],[5129,6501],[5122,6502],[5130,6520],[5130,6529],[5136,6532],[5139,6539],[5146,6541],[5149,6536],[5159,6550],[5166,6552],[5173,6561],[5172,6573],[5169,6569],[5160,6575],[5152,6577],[5157,6589],[5153,6595],[5159,6605],[5156,6607],[5166,6616],[5176,6612],[5184,6617],[5188,6610],[5196,6608],[5201,6614],[5213,6615],[5220,6619],[5225,6615],[5234,6615],[5249,6629],[5252,6619],[5262,6612],[5262,6598],[5271,6589],[5277,6578],[5278,6554],[5272,6546],[5273,6541],[5264,6537],[5261,6529],[5254,6523],[5249,6512]]],[[[5185,6476],[5185,6476],[5186,6476],[5185,6476]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;VA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.61,&#34;hc-middle-y&#34;:0.44,&#34;hc-key&#34;:&#34;va&#34;,&#34;hc-a2&#34;:&#34;VA&#34;,&#34;name&#34;:&#34;Vatican&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Vat.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;VAT&#34;,&#34;iso-a2&#34;:&#34;VA&#34;,&#34;woe-id&#34;:&#34;23424986&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4615,7809],[4615,7809],[4615,7809],[4615,7809],[4615,7809]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.42,&#34;hc-key&#34;:&#34;sm&#34;,&#34;hc-a2&#34;:&#34;SM&#34;,&#34;name&#34;:&#34;San Marino&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;S.M.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;SMR&#34;,&#34;iso-a2&#34;:&#34;SM&#34;,&#34;woe-id&#34;:&#34;23424947&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4615,7880],[4613,7881],[4614,7883],[4616,7883],[4615,7880]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.58,&#34;hc-middle-y&#34;:0.47,&#34;hc-key&#34;:&#34;kz&#34;,&#34;hc-a2&#34;:&#34;KZ&#34;,&#34;name&#34;:&#34;Kazakhstan&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Kaz.&#34;,&#34;subregion&#34;:&#34;Central Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;KAZ&#34;,&#34;iso-a2&#34;:&#34;KZ&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[6025,7957],[6028,7957],[6028,7954],[6017,7957],[6025,7957]]],[[[5726,7915],[5720,7918],[5722,7922],[5731,7923],[5726,7915]]],[[[5978,7937],[5987,7945],[5988,7950],[5997,7940],[5998,7925],[5978,7937]]],[[[5973,7940],[5957,7937],[5896,7920],[5896,7789],[5883,7787],[5874,7794],[5865,7810],[5844,7824],[5840,7825],[5821,7822],[5808,7817],[5792,7804],[5791,7816],[5797,7824],[5800,7839],[5784,7844],[5777,7842],[5769,7855],[5758,7854],[5759,7865],[5746,7885],[5745,7891],[5727,7898],[5730,7908],[5746,7907],[5754,7901],[5759,7905],[5749,7914],[5749,7919],[5756,7922],[5762,7932],[5795,7935],[5811,7957],[5813,7967],[5811,7975],[5815,7980],[5811,7989],[5792,7993],[5783,7986],[5765,7995],[5756,7998],[5733,7990],[5727,7983],[5715,7976],[5700,7977],[5702,7971],[5698,7969],[5675,7981],[5691,7985],[5682,7997],[5677,8009],[5663,8022],[5644,8025],[5643,8019],[5636,8024],[5633,8030],[5635,8041],[5617,8046],[5625,8065],[5633,8076],[5625,8081],[5629,8100],[5641,8108],[5641,8117],[5648,8124],[5661,8114],[5669,8101],[5674,8099],[5688,8107],[5682,8119],[5681,8129],[5702,8139],[5704,8150],[5714,8149],[5731,8158],[5738,8170],[5748,8172],[5761,8170],[5759,8164],[5773,8164],[5775,8172],[5789,8175],[5793,8165],[5807,8163],[5819,8165],[5827,8160],[5829,8154],[5841,8149],[5846,8142],[5852,8140],[5849,8130],[5858,8130],[5858,8146],[5869,8141],[5877,8132],[5887,8127],[5907,8141],[5912,8148],[5931,8149],[5940,8140],[5948,8143],[5949,8150],[5962,8148],[5965,8151],[5973,8146],[5973,8140],[5983,8133],[5998,8131],[6001,8125],[6008,8127],[6014,8139],[6019,8139],[6024,8133],[6036,8132],[6055,8137],[6060,8153],[6064,8155],[6058,8162],[6045,8164],[6042,8169],[6030,8169],[6028,8177],[6019,8180],[6027,8189],[6035,8190],[6045,8198],[6035,8211],[6046,8221],[6057,8225],[6062,8222],[6075,8222],[6075,8229],[6050,8235],[6054,8246],[6045,8249],[6050,8257],[6044,8259],[6057,8266],[6062,8262],[6086,8265],[6089,8259],[6092,8267],[6106,8268],[6124,8274],[6130,8272],[6133,8277],[6159,8280],[6168,8278],[6168,8285],[6175,8289],[6191,8289],[6205,8293],[6239,8299],[6247,8303],[6255,8303],[6258,8313],[6268,8313],[6271,8319],[6279,8316],[6278,8323],[6285,8318],[6300,8318],[6316,8310],[6322,8316],[6333,8317],[6338,8308],[6339,8295],[6345,8293],[6344,8277],[6339,8278],[6343,8268],[6348,8272],[6360,8269],[6361,8274],[6371,8269],[6369,8279],[6382,8270],[6379,8261],[6388,8262],[6387,8270],[6397,8268],[6399,8263],[6412,8262],[6419,8266],[6418,8259],[6412,8259],[6404,8250],[6410,8241],[6417,8248],[6434,8248],[6439,8243],[6440,8251],[6450,8257],[6457,8256],[6475,8268],[6499,8277],[6506,8282],[6511,8276],[6506,8269],[6497,8270],[6501,8262],[6533,8242],[6541,8235],[6559,8210],[6588,8164],[6603,8138],[6617,8144],[6617,8153],[6624,8157],[6638,8152],[6635,8144],[6645,8144],[6647,8135],[6655,8137],[6665,8134],[6682,8137],[6685,8142],[6705,8145],[6716,8140],[6727,8126],[6729,8117],[6751,8109],[6759,8091],[6769,8092],[6786,8086],[6798,8099],[6803,8095],[6798,8091],[6805,8088],[6811,8078],[6819,8072],[6806,8072],[6802,8065],[6803,8058],[6797,8051],[6786,8046],[6774,8046],[6766,8028],[6771,8008],[6766,7995],[6758,7995],[6743,7987],[6741,7993],[6719,7992],[6696,8001],[6693,8001],[6692,7991],[6687,7983],[6677,7953],[6671,7939],[6681,7936],[6677,7924],[6670,7928],[6661,7925],[6653,7933],[6629,7925],[6607,7921],[6600,7916],[6603,7913],[6618,7910],[6614,7907],[6616,7886],[6625,7864],[6623,7860],[6627,7853],[6615,7849],[6620,7844],[6611,7842],[6608,7835],[6612,7821],[6610,7819],[6601,7828],[6587,7829],[6575,7839],[6557,7844],[6521,7845],[6514,7848],[6507,7845],[6479,7845],[6477,7842],[6462,7843],[6448,7848],[6432,7857],[6414,7849],[6410,7835],[6413,7828],[6390,7836],[6364,7842],[6351,7841],[6339,7833],[6334,7823],[6337,7821],[6331,7820],[6327,7814],[6320,7815],[6307,7803],[6298,7801],[6281,7791],[6281,7785],[6267,7775],[6268,7764],[6264,7763],[6250,7771],[6254,7780],[6249,7785],[6216,7783],[6212,7785],[6206,7812],[6192,7813],[6194,7848],[6185,7844],[6177,7859],[6170,7863],[6160,7874],[6145,7868],[6109,7870],[6075,7865],[6049,7890],[6045,7898],[6017,7914],[6017,7933],[6014,7941],[6007,7945],[6014,7954],[6027,7951],[6039,7961],[6051,7965],[6052,7973],[6040,7975],[6038,7981],[6025,7982],[6015,7978],[6018,7970],[6026,7972],[6032,7968],[6037,7971],[6039,7962],[6034,7959],[6010,7962],[6007,7969],[6001,7968],[6007,7959],[6004,7948],[5995,7945],[5992,7948],[5996,7955],[5984,7956],[5978,7952],[5973,7940]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.7,&#34;hc-middle-y&#34;:0.15,&#34;hc-key&#34;:&#34;az&#34;,&#34;hc-a2&#34;:&#34;AZ&#34;,&#34;name&#34;:&#34;Azerbaijan&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Aze.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;AZE&#34;,&#34;iso-a2&#34;:&#34;AZ&#34;,&#34;woe-id&#34;:&#34;23424741&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5574,7779],[5573,7779],[5572,7780],[5574,7780],[5574,7779]]],[[[5580,7777],[5579,7777],[5578,7777],[5579,7777],[5580,7777]]],[[[5568,7730],[5567,7732],[5574,7735],[5586,7725],[5596,7727],[5596,7721],[5602,7717],[5607,7704],[5586,7708],[5578,7716],[5568,7730]]],[[[5679,7807],[5692,7792],[5697,7780],[5707,7770],[5708,7764],[5722,7763],[5731,7756],[5730,7753],[5717,7756],[5704,7745],[5703,7733],[5700,7725],[5697,7709],[5690,7715],[5687,7704],[5687,7689],[5679,7688],[5674,7695],[5662,7702],[5671,7710],[5666,7719],[5672,7721],[5660,7733],[5656,7732],[5628,7714],[5618,7704],[5615,7716],[5620,7716],[5614,7721],[5618,7727],[5609,7729],[5599,7736],[5592,7744],[5599,7743],[5602,7751],[5589,7758],[5584,7766],[5591,7773],[5586,7778],[5575,7781],[5573,7788],[5581,7793],[5595,7789],[5597,7785],[5609,7785],[5617,7779],[5623,7787],[5612,7795],[5608,7801],[5615,7809],[5624,7807],[5640,7788],[5654,7784],[5663,7794],[5672,7798],[5679,7807]],[[5587,7764],[5588,7764],[5590,7765],[5588,7766],[5587,7764]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.1,&#34;hc-middle-y&#34;:0.12,&#34;hc-key&#34;:&#34;am&#34;,&#34;hc-a2&#34;:&#34;AM&#34;,&#34;name&#34;:&#34;Armenia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Arm.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;ARM&#34;,&#34;iso-a2&#34;:&#34;AM&#34;,&#34;woe-id&#34;:&#34;23424743&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5587,7764],[5588,7766],[5590,7765],[5588,7764],[5587,7764]]],[[[5618,7704],[5614,7706],[5607,7704],[5602,7717],[5596,7721],[5596,7727],[5586,7725],[5574,7735],[5567,7732],[5553,7744],[5545,7743],[5534,7747],[5531,7759],[5536,7766],[5533,7775],[5527,7781],[5537,7781],[5549,7786],[5560,7784],[5573,7788],[5575,7781],[5586,7778],[5591,7773],[5584,7766],[5589,7758],[5602,7751],[5599,7743],[5592,7744],[5599,7736],[5609,7729],[5618,7727],[5614,7721],[5620,7716],[5615,7716],[5618,7704]],[[5574,7779],[5574,7780],[5572,7780],[5573,7779],[5574,7779]],[[5580,7777],[5579,7777],[5578,7777],[5579,7777],[5580,7777]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TJ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;tj&#34;,&#34;hc-a2&#34;:&#34;TJ&#34;,&#34;name&#34;:&#34;Tajikistan&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Tjk.&#34;,&#34;subregion&#34;:&#34;Central Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;TJK&#34;,&#34;iso-a2&#34;:&#34;TJ&#34;,&#34;woe-id&#34;:&#34;23424961&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[6328,7776],[6328,7775],[6325,7778],[6327,7778],[6328,7776]]],[[[6328,7738],[6330,7737],[6326,7735],[6324,7739],[6328,7738]]],[[[6416,7724],[6415,7716],[6422,7708],[6418,7704],[6422,7694],[6428,7692],[6431,7697],[6437,7697],[6449,7692],[6450,7677],[6455,7666],[6453,7661],[6461,7654],[6453,7648],[6447,7654],[6437,7654],[6419,7648],[6420,7655],[6406,7656],[6391,7648],[6388,7641],[6376,7639],[6363,7630],[6357,7630],[6351,7643],[6356,7671],[6346,7672],[6349,7684],[6339,7690],[6327,7686],[6323,7678],[6314,7672],[6318,7664],[6313,7658],[6307,7661],[6295,7660],[6291,7655],[6293,7648],[6287,7644],[6279,7651],[6270,7650],[6251,7638],[6244,7647],[6247,7660],[6254,7671],[6258,7672],[6260,7682],[6252,7692],[6253,7708],[6241,7708],[6241,7712],[6231,7716],[6234,7725],[6242,7730],[6263,7726],[6268,7730],[6269,7738],[6276,7739],[6278,7748],[6268,7748],[6280,7751],[6288,7750],[6286,7762],[6292,7771],[6299,7765],[6318,7773],[6322,7778],[6332,7767],[6320,7759],[6326,7750],[6338,7751],[6325,7744],[6308,7750],[6297,7746],[6292,7739],[6289,7742],[6287,7734],[6289,7726],[6300,7728],[6315,7726],[6323,7729],[6332,7721],[6352,7729],[6355,7724],[6361,7724],[6362,7718],[6370,7721],[6375,7715],[6377,7720],[6387,7722],[6403,7721],[6416,7724]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LS&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.48,&#34;hc-key&#34;:&#34;ls&#34;,&#34;hc-a2&#34;:&#34;LS&#34;,&#34;name&#34;:&#34;Lesotho&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Les.&#34;,&#34;subregion&#34;:&#34;Southern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;LSO&#34;,&#34;iso-a2&#34;:&#34;LS&#34;,&#34;woe-id&#34;:&#34;23424880&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5077,5642],[5091,5646],[5108,5630],[5115,5621],[5107,5611],[5106,5603],[5096,5597],[5084,5596],[5079,5590],[5075,5579],[5065,5581],[5054,5590],[5044,5612],[5051,5615],[5065,5635],[5073,5637],[5077,5642]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;UZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.46,&#34;hc-middle-y&#34;:0.53,&#34;hc-key&#34;:&#34;uz&#34;,&#34;hc-a2&#34;:&#34;UZ&#34;,&#34;name&#34;:&#34;Uzbekistan&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Uzb.&#34;,&#34;subregion&#34;:&#34;Central Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;UZB&#34;,&#34;iso-a2&#34;:&#34;UZ&#34;,&#34;woe-id&#34;:&#34;23424980&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[6361,7739],[6359,7740],[6358,7741],[6362,7742],[6361,7739]]],[[[6344,7744],[6345,7739],[6339,7739],[6337,7746],[6344,7744]]],[[[5998,7925],[5991,7911],[5993,7906],[6005,7896],[6001,7890],[6012,7892],[6016,7899],[6014,7907],[6017,7914],[6045,7898],[6049,7890],[6075,7865],[6109,7870],[6145,7868],[6160,7874],[6170,7863],[6177,7859],[6185,7844],[6194,7848],[6192,7813],[6206,7812],[6212,7785],[6216,7783],[6249,7785],[6254,7780],[6250,7771],[6264,7763],[6268,7764],[6267,7775],[6281,7785],[6281,7791],[6298,7801],[6307,7803],[6320,7815],[6327,7814],[6331,7820],[6337,7821],[6346,7820],[6323,7803],[6314,7798],[6323,7792],[6328,7794],[6332,7786],[6344,7781],[6351,7782],[6361,7793],[6364,7784],[6373,7784],[6373,7778],[6378,7780],[6388,7773],[6398,7773],[6401,7770],[6391,7766],[6385,7760],[6379,7764],[6376,7759],[6359,7748],[6346,7754],[6338,7751],[6326,7750],[6320,7759],[6332,7767],[6322,7778],[6318,7773],[6299,7765],[6292,7771],[6286,7762],[6288,7750],[6280,7751],[6268,7748],[6278,7748],[6276,7739],[6269,7738],[6268,7730],[6263,7726],[6242,7730],[6234,7725],[6231,7716],[6241,7712],[6241,7708],[6253,7708],[6252,7692],[6260,7682],[6258,7672],[6254,7671],[6247,7660],[6244,7647],[6236,7650],[6229,7646],[6221,7653],[6207,7653],[6208,7675],[6188,7683],[6180,7682],[6161,7695],[6151,7700],[6143,7707],[6136,7707],[6124,7715],[6117,7722],[6091,7739],[6087,7743],[6084,7758],[6079,7760],[6073,7778],[6064,7786],[6057,7788],[6053,7783],[6040,7786],[6027,7786],[6018,7791],[6020,7798],[6017,7803],[6022,7805],[6013,7811],[6016,7819],[6011,7823],[5998,7823],[5989,7832],[5982,7832],[5973,7841],[5972,7836],[5964,7837],[5970,7823],[5956,7830],[5952,7819],[5945,7818],[5939,7825],[5932,7821],[5929,7810],[5925,7808],[5927,7786],[5896,7789],[5896,7920],[5957,7937],[5973,7940],[5963,7917],[5965,7899],[5972,7902],[5979,7910],[5976,7924],[5978,7937],[5998,7925]],[[6328,7776],[6327,7778],[6325,7778],[6328,7775],[6328,7776]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.6,&#34;hc-middle-y&#34;:0.21,&#34;hc-key&#34;:&#34;ma&#34;,&#34;hc-a2&#34;:&#34;MA&#34;,&#34;name&#34;:&#34;Morocco&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Mor.&#34;,&#34;subregion&#34;:&#34;Northern Africa&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;MAR&#34;,&#34;iso-a2&#34;:&#34;MA&#34;,&#34;woe-id&#34;:&#34;23424893&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4162,7582],[4162,7582],[4164,7578],[4183,7576],[4196,7565],[4193,7560],[4198,7556],[4195,7552],[4199,7543],[4197,7530],[4201,7524],[4199,7515],[4204,7509],[4206,7499],[4217,7492],[4212,7486],[4211,7477],[4174,7479],[4162,7476],[4165,7468],[4140,7463],[4140,7455],[4136,7453],[4144,7441],[4141,7433],[4120,7426],[4093,7406],[4085,7395],[4079,7398],[4051,7395],[4049,7392],[4038,7394],[4032,7390],[4023,7390],[4002,7375],[3993,7367],[3993,7336],[3989,7336],[3989,7318],[3971,7317],[3962,7310],[3946,7310],[3938,7314],[3927,7315],[3913,7311],[3914,7303],[3903,7287],[3894,7284],[3886,7255],[3882,7247],[3864,7233],[3856,7220],[3843,7214],[3835,7203],[3831,7183],[3830,7169],[3817,7155],[3816,7147],[3811,7142],[3785,7144],[3756,7143],[3747,7141],[3749,7152],[3756,7168],[3762,7169],[3767,7177],[3771,7192],[3784,7214],[3782,7218],[3788,7222],[3801,7235],[3810,7243],[3813,7266],[3821,7281],[3822,7287],[3831,7297],[3847,7305],[3851,7312],[3860,7336],[3867,7344],[3893,7349],[3910,7357],[3923,7370],[3937,7378],[3946,7388],[3959,7405],[3964,7414],[3965,7423],[3957,7432],[3959,7436],[3958,7455],[3964,7466],[3975,7481],[3976,7493],[3987,7503],[3997,7516],[4039,7535],[4047,7541],[4063,7569],[4074,7599],[4089,7604],[4090,7603],[4091,7602],[4094,7593],[4108,7581],[4119,7578],[4140,7583],[4148,7580],[4161,7584],[4161,7584],[4162,7582]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.51,&#34;hc-middle-y&#34;:0.54,&#34;hc-key&#34;:&#34;co&#34;,&#34;hc-a2&#34;:&#34;CO&#34;,&#34;name&#34;:&#34;Colombia&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Col.&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;COL&#34;,&#34;iso-a2&#34;:&#34;CO&#34;,&#34;woe-id&#34;:&#34;23424787&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2032,6502],[2012,6511],[2002,6519],[1999,6513],[1985,6512],[1969,6516],[1967,6524],[1960,6530],[1956,6529],[1935,6540],[1927,6547],[1922,6552],[1927,6558],[1935,6557],[1931,6569],[1942,6583],[1956,6585],[1960,6592],[1974,6610],[1978,6618],[1971,6620],[1965,6628],[1971,6636],[1970,6663],[1967,6669],[1974,6675],[1967,6686],[1971,6697],[1961,6707],[1955,6717],[1959,6731],[1964,6726],[1976,6738],[1969,6753],[1970,6759],[1988,6737],[1988,6752],[1983,6756],[1991,6760],[2003,6769],[2006,6776],[2013,6782],[2022,6782],[2021,6791],[2024,6806],[2025,6815],[2045,6831],[2055,6828],[2053,6821],[2059,6821],[2066,6839],[2075,6836],[2090,6837],[2106,6849],[2121,6854],[2125,6865],[2143,6871],[2151,6867],[2155,6860],[2148,6853],[2129,6848],[2120,6833],[2114,6832],[2101,6811],[2099,6793],[2087,6774],[2099,6778],[2104,6773],[2108,6759],[2117,6750],[2118,6743],[2114,6738],[2114,6724],[2122,6721],[2125,6713],[2149,6711],[2152,6709],[2170,6713],[2178,6708],[2183,6709],[2204,6684],[2209,6683],[2215,6687],[2227,6685],[2247,6687],[2251,6690],[2261,6687],[2263,6680],[2257,6674],[2257,6667],[2251,6660],[2252,6653],[2250,6638],[2257,6615],[2267,6605],[2251,6590],[2257,6587],[2270,6575],[2279,6541],[2273,6540],[2272,6555],[2265,6566],[2258,6565],[2251,6557],[2245,6557],[2240,6564],[2241,6555],[2191,6555],[2192,6536],[2206,6536],[2212,6530],[2213,6524],[2203,6527],[2186,6522],[2185,6500],[2198,6490],[2198,6484],[2204,6476],[2204,6464],[2188,6381],[2178,6393],[2166,6394],[2186,6426],[2166,6437],[2157,6441],[2145,6436],[2136,6443],[2130,6437],[2117,6433],[2109,6437],[2101,6434],[2093,6440],[2096,6444],[2093,6453],[2083,6456],[2084,6462],[2080,6468],[2062,6477],[2057,6489],[2045,6500],[2033,6504],[2032,6502]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TL&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.63,&#34;hc-middle-y&#34;:0.31,&#34;hc-key&#34;:&#34;tl&#34;,&#34;hc-a2&#34;:&#34;TL&#34;,&#34;name&#34;:&#34;East Timor&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;T.L.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;TLS&#34;,&#34;iso-a2&#34;:&#34;TL&#34;,&#34;woe-id&#34;:&#34;23424968&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7900,6231],[7906,6234],[7913,6236],[7907,6226],[7900,6231]]],[[[7926,6242],[7933,6252],[7970,6258],[7974,6256],[7987,6262],[7997,6258],[7988,6251],[7975,6247],[7972,6243],[7946,6236],[7930,6227],[7927,6235],[7933,6236],[7926,6242]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.82,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;kh&#34;,&#34;hc-a2&#34;:&#34;KH&#34;,&#34;name&#34;:&#34;Cambodia&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Camb.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;KHM&#34;,&#34;iso-a2&#34;:&#34;KH&#34;,&#34;woe-id&#34;:&#34;23424776&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[7324,6811],[7318,6815],[7299,6813],[7296,6817],[7301,6820],[7301,6830],[7296,6833],[7293,6825],[7284,6826],[7285,6837],[7278,6847],[7272,6863],[7274,6870],[7266,6877],[7266,6887],[7261,6896],[7261,6904],[7269,6906],[7279,6923],[7285,6927],[7300,6931],[7307,6927],[7324,6928],[7333,6930],[7341,6924],[7345,6928],[7350,6921],[7356,6922],[7366,6915],[7374,6919],[7368,6928],[7384,6935],[7393,6927],[7401,6929],[7414,6938],[7408,6921],[7416,6902],[7412,6888],[7415,6876],[7414,6868],[7403,6866],[7390,6857],[7381,6857],[7382,6848],[7370,6851],[7364,6847],[7365,6837],[7375,6827],[7374,6821],[7362,6829],[7349,6823],[7341,6826],[7342,6820],[7336,6814],[7324,6811]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.43,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;sa&#34;,&#34;hc-a2&#34;:&#34;SA&#34;,&#34;name&#34;:&#34;Saudi Arabia&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Saud.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;SAU&#34;,&#34;iso-a2&#34;:&#34;SA&#34;,&#34;woe-id&#34;:&#34;23424938&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5674,7363],[5681,7348],[5688,7341],[5688,7333],[5698,7332],[5695,7329],[5700,7321],[5707,7326],[5708,7318],[5725,7304],[5720,7305],[5726,7296],[5723,7283],[5725,7275],[5734,7266],[5737,7254],[5744,7244],[5749,7239],[5756,7240],[5765,7239],[5758,7230],[5767,7229],[5767,7223],[5796,7188],[5871,7178],[5873,7181],[5886,7159],[5867,7098],[5779,7067],[5695,7056],[5666,7042],[5649,7021],[5645,7010],[5631,7006],[5624,7015],[5612,7014],[5586,7017],[5578,7020],[5563,7020],[5536,7018],[5526,7023],[5519,7017],[5518,7004],[5521,7001],[5515,6993],[5508,6988],[5507,6997],[5501,7004],[5490,6998],[5490,6995],[5478,7002],[5495,7013],[5494,7021],[5478,7033],[5470,7044],[5468,7052],[5462,7058],[5454,7083],[5448,7091],[5428,7107],[5424,7106],[5416,7112],[5411,7121],[5405,7126],[5399,7138],[5402,7141],[5395,7160],[5397,7159],[5399,7176],[5380,7214],[5369,7223],[5358,7230],[5353,7229],[5342,7247],[5345,7248],[5345,7257],[5332,7276],[5326,7276],[5329,7284],[5324,7286],[5315,7303],[5295,7329],[5285,7347],[5266,7350],[5273,7363],[5272,7367],[5277,7389],[5309,7384],[5322,7394],[5330,7405],[5351,7410],[5357,7421],[5367,7426],[5336,7458],[5395,7475],[5401,7479],[5438,7472],[5487,7445],[5510,7426],[5564,7385],[5613,7380],[5618,7381],[5645,7378],[5652,7363],[5674,7363]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PK&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.29,&#34;hc-middle-y&#34;:0.74,&#34;hc-key&#34;:&#34;pk&#34;,&#34;hc-a2&#34;:&#34;PK&#34;,&#34;name&#34;:&#34;Pakistan&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Pak.&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;PAK&#34;,&#34;iso-a2&#34;:&#34;PK&#34;,&#34;woe-id&#34;:&#34;23424922&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6443,7641],[6453,7637],[6460,7640],[6469,7632],[6480,7630],[6485,7622],[6486,7614],[6483,7610],[6491,7600],[6502,7603],[6509,7595],[6517,7577],[6505,7565],[6487,7563],[6479,7557],[6467,7559],[6437,7566],[6425,7561],[6420,7552],[6425,7550],[6425,7540],[6434,7541],[6426,7529],[6431,7525],[6427,7513],[6436,7507],[6437,7500],[6447,7502],[6446,7494],[6448,7490],[6457,7490],[6467,7484],[6465,7480],[6451,7476],[6441,7465],[6445,7457],[6443,7446],[6446,7445],[6436,7439],[6422,7421],[6425,7416],[6409,7408],[6404,7395],[6396,7380],[6379,7371],[6373,7358],[6365,7349],[6364,7345],[6345,7341],[6336,7337],[6330,7338],[6323,7348],[6312,7340],[6310,7334],[6297,7321],[6294,7309],[6304,7301],[6314,7300],[6311,7283],[6317,7274],[6329,7273],[6329,7264],[6334,7257],[6341,7242],[6341,7234],[6332,7228],[6326,7234],[6312,7230],[6308,7226],[6296,7230],[6275,7228],[6272,7230],[6272,7220],[6263,7220],[6256,7216],[6255,7211],[6246,7218],[6242,7214],[6231,7223],[6226,7242],[6220,7247],[6212,7247],[6212,7259],[6204,7271],[6202,7267],[6181,7263],[6174,7264],[6167,7261],[6148,7261],[6125,7264],[6118,7258],[6088,7260],[6084,7257],[6065,7253],[6062,7258],[6064,7276],[6067,7278],[6069,7290],[6081,7294],[6082,7299],[6096,7303],[6106,7303],[6113,7318],[6108,7323],[6096,7323],[6098,7330],[6095,7346],[6096,7354],[6091,7354],[6084,7360],[6071,7364],[6061,7374],[6053,7391],[6040,7406],[6088,7391],[6120,7394],[6135,7390],[6147,7396],[6163,7395],[6197,7405],[6201,7418],[6199,7429],[6202,7440],[6208,7442],[6212,7449],[6219,7452],[6231,7449],[6243,7453],[6241,7459],[6252,7465],[6254,7469],[6265,7466],[6270,7467],[6274,7462],[6281,7464],[6289,7473],[6287,7488],[6292,7496],[6296,7510],[6306,7510],[6318,7518],[6312,7531],[6305,7538],[6309,7542],[6325,7538],[6341,7542],[6342,7552],[6338,7556],[6347,7569],[6353,7572],[6358,7580],[6354,7583],[6356,7592],[6349,7605],[6344,7608],[6357,7622],[6360,7620],[6385,7634],[6403,7636],[6422,7636],[6430,7635],[6443,7641]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.59,&#34;hc-middle-y&#34;:0.64,&#34;hc-key&#34;:&#34;ae&#34;,&#34;hc-a2&#34;:&#34;AE&#34;,&#34;name&#34;:&#34;United Arab Emirates&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;U.A.E.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;ARE&#34;,&#34;iso-a2&#34;:&#34;AE&#34;,&#34;woe-id&#34;:&#34;23424738&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5905,7272],[5908,7268],[5908,7251],[5899,7244],[5897,7251],[5891,7248],[5890,7228],[5897,7223],[5881,7220],[5883,7214],[5873,7190],[5873,7181],[5871,7178],[5796,7188],[5767,7223],[5767,7229],[5772,7230],[5774,7221],[5784,7220],[5796,7226],[5826,7222],[5842,7225],[5852,7233],[5857,7244],[5870,7253],[5884,7269],[5898,7280],[5899,7285],[5902,7284],[5901,7273],[5905,7272]],[[5905,7259],[5907,7261],[5904,7262],[5904,7259],[5905,7259]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.87,&#34;hc-middle-y&#34;:0.7,&#34;hc-key&#34;:&#34;ke&#34;,&#34;hc-a2&#34;:&#34;KE&#34;,&#34;name&#34;:&#34;Kenya&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Ken.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;KEN&#34;,&#34;iso-a2&#34;:&#34;KE&#34;,&#34;woe-id&#34;:&#34;23424863&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5402,6368],[5360,6398],[5355,6405],[5358,6408],[5357,6416],[5252,6474],[5254,6480],[5250,6484],[5251,6492],[5254,6494],[5262,6490],[5263,6495],[5274,6496],[5271,6503],[5257,6498],[5249,6504],[5249,6512],[5254,6523],[5261,6529],[5264,6537],[5273,6541],[5272,6546],[5278,6554],[5277,6578],[5271,6589],[5262,6598],[5262,6612],[5252,6619],[5249,6629],[5261,6640],[5291,6652],[5296,6649],[5297,6640],[5306,6640],[5309,6635],[5333,6635],[5366,6614],[5370,6611],[5383,6611],[5412,6605],[5422,6618],[5448,6631],[5460,6620],[5481,6621],[5466,6599],[5454,6587],[5455,6480],[5471,6459],[5471,6456],[5464,6448],[5449,6438],[5444,6430],[5437,6430],[5431,6424],[5430,6410],[5425,6406],[5420,6390],[5408,6370],[5402,6368]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.68,&#34;hc-middle-y&#34;:0.7,&#34;hc-key&#34;:&#34;pe&#34;,&#34;hc-a2&#34;:&#34;PE&#34;,&#34;name&#34;:&#34;Peru&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Peru&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;PER&#34;,&#34;iso-a2&#34;:&#34;PE&#34;,&#34;woe-id&#34;:&#34;23424919&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2206,6048],[2195,6054],[2189,6051],[2194,6041],[2189,6044],[2186,6038],[2192,6040],[2196,6034],[2204,6033],[2202,6028],[2213,6026],[2215,6027],[2218,6026],[2214,6018],[2216,6017],[2204,6000],[2197,5994],[2202,5988],[2191,5981],[2194,5973],[2188,5965],[2176,5963],[2152,5980],[2146,5982],[2143,5994],[2125,6002],[2117,6011],[2108,6013],[2089,6023],[2078,6026],[2056,6041],[2034,6052],[2025,6066],[2013,6074],[2002,6091],[2005,6107],[2004,6112],[1996,6122],[1995,6127],[1987,6138],[1987,6141],[1977,6152],[1975,6163],[1962,6173],[1961,6184],[1950,6201],[1941,6223],[1937,6236],[1933,6240],[1929,6253],[1923,6264],[1908,6279],[1901,6297],[1894,6306],[1884,6313],[1869,6321],[1860,6327],[1859,6333],[1865,6334],[1868,6340],[1857,6353],[1861,6358],[1853,6368],[1856,6381],[1869,6396],[1883,6406],[1888,6391],[1878,6386],[1883,6382],[1881,6374],[1889,6380],[1898,6374],[1907,6372],[1909,6364],[1920,6358],[1924,6366],[1932,6372],[1932,6378],[1939,6394],[1941,6406],[1946,6407],[1956,6418],[1990,6430],[2008,6443],[2023,6460],[2028,6478],[2033,6477],[2032,6489],[2022,6502],[2032,6502],[2033,6504],[2045,6500],[2057,6489],[2062,6477],[2080,6468],[2084,6462],[2083,6456],[2093,6453],[2096,6444],[2093,6440],[2101,6434],[2109,6437],[2117,6433],[2130,6437],[2136,6443],[2145,6436],[2157,6441],[2166,6437],[2186,6426],[2166,6394],[2178,6393],[2188,6381],[2181,6378],[2178,6383],[2164,6383],[2159,6377],[2131,6373],[2110,6358],[2101,6355],[2099,6338],[2092,6327],[2095,6318],[2077,6303],[2078,6291],[2069,6284],[2078,6277],[2083,6260],[2088,6257],[2100,6239],[2093,6229],[2104,6229],[2119,6225],[2123,6212],[2146,6211],[2152,6213],[2172,6228],[2168,6216],[2168,6182],[2179,6180],[2188,6184],[2200,6184],[2226,6138],[2217,6126],[2218,6108],[2214,6103],[2221,6087],[2209,6075],[2205,6064],[2212,6056],[2206,6048]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;DO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;do&#34;,&#34;hc-a2&#34;:&#34;DO&#34;,&#34;name&#34;:&#34;Dominican Republic&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Dom. Rep.&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;DOM&#34;,&#34;iso-a2&#34;:&#34;DO&#34;,&#34;woe-id&#34;:&#34;23424800&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2131,7052],[2131,7052],[2130,7053],[2130,7053],[2128,7056],[2137,7061],[2134,7066],[2139,7074],[2135,7089],[2138,7095],[2152,7093],[2158,7096],[2169,7091],[2184,7087],[2189,7088],[2194,7077],[2201,7078],[2210,7074],[2198,7074],[2199,7070],[2224,7067],[2236,7057],[2233,7048],[2229,7049],[2229,7041],[2224,7041],[2219,7050],[2201,7050],[2190,7051],[2182,7044],[2171,7044],[2166,7050],[2156,7042],[2145,7025],[2138,7030],[2135,7039],[2137,7047],[2131,7052]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;HT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.21,&#34;hc-middle-y&#34;:0.92,&#34;hc-key&#34;:&#34;ht&#34;,&#34;hc-a2&#34;:&#34;HT&#34;,&#34;name&#34;:&#34;Haiti&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Haiti&#34;,&#34;subregion&#34;:&#34;Caribbean&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;HTI&#34;,&#34;iso-a2&#34;:&#34;HT&#34;,&#34;woe-id&#34;:&#34;23424839&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[2131,7052],[2130,7053],[2130,7053],[2130,7053],[2131,7052]]],[[[2135,7089],[2139,7074],[2134,7066],[2137,7061],[2128,7056],[2129,7052],[2131,7052],[2137,7047],[2135,7039],[2126,7045],[2112,7044],[2102,7042],[2090,7045],[2079,7044],[2072,7039],[2070,7042],[2055,7050],[2062,7058],[2081,7052],[2107,7051],[2110,7054],[2093,7063],[2093,7067],[2103,7062],[2107,7081],[2099,7086],[2087,7087],[2086,7092],[2095,7096],[2105,7096],[2128,7089],[2135,7089]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.67,&#34;hc-key&#34;:&#34;ao&#34;,&#34;hc-a2&#34;:&#34;AO&#34;,&#34;name&#34;:&#34;Angola&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Ang.&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;AGO&#34;,&#34;iso-a2&#34;:&#34;AO&#34;,&#34;woe-id&#34;:&#34;23424745&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4608,6336],[4608,6345],[4602,6358],[4613,6370],[4620,6372],[4624,6377],[4633,6369],[4625,6366],[4615,6357],[4617,6354],[4617,6337],[4608,6336]]],[[[4595,5995],[4596,6019],[4594,6039],[4601,6045],[4603,6056],[4610,6071],[4611,6090],[4616,6097],[4617,6110],[4629,6123],[4629,6127],[4636,6135],[4642,6135],[4650,6145],[4654,6159],[4656,6179],[4654,6192],[4637,6221],[4636,6230],[4631,6238],[4637,6246],[4642,6248],[4642,6260],[4627,6292],[4626,6303],[4620,6308],[4610,6326],[4623,6328],[4636,6334],[4659,6334],[4668,6333],[4729,6334],[4737,6332],[4741,6324],[4742,6309],[4746,6304],[4749,6291],[4766,6268],[4781,6267],[4784,6271],[4818,6271],[4818,6283],[4823,6286],[4823,6300],[4846,6300],[4855,6303],[4852,6292],[4890,6292],[4892,6286],[4889,6271],[4894,6257],[4890,6229],[4892,6223],[4901,6214],[4905,6201],[4905,6189],[4901,6186],[4903,6175],[4912,6181],[4926,6179],[4939,6183],[4951,6182],[4954,6186],[4957,6170],[4954,6163],[4954,6147],[4956,6141],[4951,6129],[4955,6123],[4895,6123],[4896,6028],[4899,6017],[4906,6013],[4919,5998],[4925,5994],[4937,5984],[4878,5972],[4873,5975],[4861,5972],[4847,5977],[4838,5976],[4808,5978],[4801,5981],[4792,5991],[4667,5991],[4659,5991],[4646,5999],[4645,6003],[4636,6005],[4618,5996],[4607,5999],[4595,5995]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.55,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;mz&#34;,&#34;hc-a2&#34;:&#34;MZ&#34;,&#34;name&#34;:&#34;Mozambique&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Moz.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;MOZ&#34;,&#34;iso-a2&#34;:&#34;MZ&#34;,&#34;woe-id&#34;:&#34;23424902&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5275,6107],[5272,6125],[5274,6131],[5270,6140],[5270,6147],[5275,6151],[5278,6165],[5296,6164],[5303,6170],[5313,6165],[5314,6161],[5330,6162],[5339,6165],[5351,6161],[5362,6166],[5363,6172],[5370,6175],[5382,6170],[5393,6177],[5404,6177],[5411,6182],[5426,6188],[5439,6198],[5444,6187],[5438,6173],[5442,6153],[5440,6138],[5445,6130],[5438,6124],[5443,6124],[5442,6104],[5446,6088],[5445,6080],[5450,6080],[5451,6069],[5443,6049],[5431,6036],[5423,6021],[5400,6007],[5399,6004],[5385,6000],[5364,5992],[5340,5977],[5334,5967],[5322,5955],[5315,5946],[5312,5949],[5298,5939],[5292,5930],[5275,5916],[5272,5918],[5272,5908],[5269,5899],[5282,5883],[5279,5879],[5288,5854],[5288,5839],[5294,5848],[5294,5823],[5290,5794],[5295,5794],[5293,5786],[5282,5771],[5268,5764],[5241,5755],[5224,5747],[5215,5740],[5211,5731],[5206,5729],[5215,5718],[5219,5728],[5217,5700],[5201,5700],[5194,5701],[5192,5718],[5193,5727],[5189,5728],[5190,5738],[5190,5776],[5183,5794],[5177,5806],[5177,5815],[5169,5839],[5174,5842],[5202,5873],[5200,5878],[5205,5884],[5206,5895],[5209,5895],[5220,5911],[5221,5919],[5215,5922],[5213,5929],[5216,5939],[5211,5948],[5216,5949],[5216,5957],[5221,5962],[5218,5974],[5220,5992],[5215,6005],[5219,6013],[5199,6020],[5188,6020],[5182,6027],[5173,6028],[5169,6032],[5143,6033],[5143,6044],[5138,6064],[5156,6070],[5173,6074],[5180,6077],[5226,6093],[5239,6075],[5241,6078],[5259,6081],[5264,6076],[5267,6064],[5266,6054],[5256,6036],[5261,6028],[5279,6009],[5282,6008],[5281,6000],[5287,5999],[5287,6012],[5283,6017],[5290,6029],[5302,6032],[5304,6051],[5302,6058],[5305,6066],[5304,6074],[5281,6102],[5275,6107]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.22,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;pa&#34;,&#34;hc-a2&#34;:&#34;PA&#34;,&#34;name&#34;:&#34;Panama&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Pan.&#34;,&#34;subregion&#34;:&#34;Central America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;PAN&#34;,&#34;iso-a2&#34;:&#34;PA&#34;,&#34;woe-id&#34;:&#34;23424924&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1817,6786],[1831,6777],[1826,6774],[1831,6767],[1841,6769],[1847,6764],[1861,6763],[1881,6773],[1896,6779],[1904,6787],[1920,6783],[1939,6781],[1951,6776],[1960,6766],[1970,6759],[1969,6753],[1976,6738],[1964,6726],[1959,6731],[1955,6717],[1943,6731],[1939,6741],[1942,6741],[1947,6751],[1940,6749],[1936,6757],[1926,6748],[1918,6747],[1918,6752],[1925,6754],[1930,6762],[1920,6769],[1906,6768],[1902,6759],[1890,6751],[1882,6749],[1878,6742],[1889,6732],[1892,6724],[1882,6721],[1880,6717],[1867,6716],[1864,6727],[1840,6717],[1837,6725],[1848,6731],[1841,6745],[1826,6746],[1814,6749],[1808,6746],[1807,6741],[1803,6749],[1809,6755],[1807,6762],[1813,6767],[1806,6771],[1806,6783],[1809,6787],[1817,6786]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.16,&#34;hc-middle-y&#34;:0.09,&#34;hc-key&#34;:&#34;cr&#34;,&#34;hc-a2&#34;:&#34;CR&#34;,&#34;name&#34;:&#34;Costa Rica&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;C.R.&#34;,&#34;subregion&#34;:&#34;Central America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;CRI&#34;,&#34;iso-a2&#34;:&#34;CR&#34;,&#34;woe-id&#34;:&#34;23424791&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1785,6826],[1791,6813],[1811,6789],[1817,6786],[1809,6787],[1806,6783],[1806,6771],[1813,6767],[1807,6762],[1809,6755],[1803,6749],[1807,6741],[1800,6750],[1799,6758],[1790,6761],[1796,6751],[1787,6753],[1779,6761],[1785,6760],[1786,6770],[1769,6783],[1759,6784],[1755,6788],[1753,6798],[1743,6804],[1741,6799],[1750,6794],[1742,6785],[1737,6793],[1726,6796],[1720,6809],[1725,6815],[1726,6822],[1718,6825],[1725,6826],[1725,6831],[1728,6834],[1748,6826],[1754,6830],[1765,6828],[1769,6822],[1777,6820],[1785,6826]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SV&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;sv&#34;,&#34;hc-a2&#34;:&#34;SV&#34;,&#34;name&#34;:&#34;El Salvador&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;El. S.&#34;,&#34;subregion&#34;:&#34;Central America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;SLV&#34;,&#34;iso-a2&#34;:&#34;SV&#34;,&#34;woe-id&#34;:&#34;23424807&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1663,6900],[1659,6892],[1634,6895],[1620,6902],[1604,6903],[1596,6909],[1595,6912],[1612,6924],[1611,6929],[1617,6930],[1627,6927],[1629,6923],[1642,6917],[1643,6913],[1654,6917],[1657,6913],[1666,6912],[1663,6900]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.59,&#34;hc-key&#34;:&#34;bo&#34;,&#34;hc-a2&#34;:&#34;BO&#34;,&#34;name&#34;:&#34;Bolivia&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Bolivia&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;BOL&#34;,&#34;iso-a2&#34;:&#34;BO&#34;,&#34;woe-id&#34;:&#34;23424762&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[2270,5826],[2257,5823],[2249,5826],[2250,5834],[2247,5848],[2243,5852],[2240,5873],[2234,5883],[2229,5886],[2232,5893],[2224,5899],[2223,5909],[2229,5911],[2226,5920],[2233,5929],[2217,5944],[2218,5947],[2212,5969],[2208,5974],[2202,5988],[2197,5994],[2204,6000],[2216,6017],[2219,6020],[2229,6023],[2221,6027],[2223,6035],[2206,6048],[2212,6056],[2205,6064],[2209,6075],[2221,6087],[2214,6103],[2218,6108],[2217,6126],[2226,6138],[2200,6184],[2224,6182],[2223,6178],[2237,6183],[2243,6191],[2254,6191],[2258,6197],[2270,6202],[2286,6214],[2321,6221],[2326,6216],[2326,6206],[2321,6198],[2326,6183],[2323,6178],[2329,6160],[2334,6153],[2349,6145],[2352,6139],[2366,6136],[2374,6138],[2384,6132],[2391,6133],[2399,6123],[2413,6118],[2418,6119],[2428,6107],[2451,6109],[2468,6099],[2468,6089],[2473,6074],[2474,6060],[2464,6060],[2474,6049],[2477,6025],[2527,6023],[2531,6024],[2526,6013],[2529,5995],[2540,5988],[2546,5987],[2554,5967],[2547,5941],[2537,5920],[2545,5913],[2536,5907],[2535,5918],[2508,5934],[2481,5934],[2430,5923],[2424,5909],[2415,5895],[2415,5880],[2404,5844],[2399,5851],[2366,5851],[2356,5834],[2354,5824],[2346,5845],[2334,5848],[2312,5848],[2298,5857],[2296,5849],[2283,5844],[2282,5838],[2275,5835],[2270,5826]]],[[[2213,6026],[2213,6032],[2218,6026],[2215,6027],[2213,6026]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;HR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.34,&#34;hc-middle-y&#34;:0.59,&#34;hc-key&#34;:&#34;hr&#34;,&#34;hc-a2&#34;:&#34;HR&#34;,&#34;name&#34;:&#34;Croatia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Cro.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;HRV&#34;,&#34;iso-a2&#34;:&#34;HR&#34;,&#34;woe-id&#34;:&#34;23424843&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4793,7827],[4773,7841],[4755,7847],[4748,7845],[4747,7840],[4741,7848],[4756,7849],[4768,7844],[4774,7842],[4791,7832],[4791,7830],[4793,7827]]],[[[4805,7954],[4803,7950],[4808,7941],[4807,7934],[4819,7926],[4809,7925],[4812,7918],[4808,7915],[4804,7915],[4798,7923],[4785,7926],[4773,7922],[4747,7930],[4743,7927],[4735,7928],[4729,7920],[4720,7928],[4713,7926],[4714,7909],[4723,7903],[4726,7891],[4766,7851],[4766,7846],[4758,7853],[4739,7853],[4725,7862],[4729,7865],[4718,7866],[4717,7872],[4703,7881],[4702,7876],[4693,7881],[4685,7890],[4697,7896],[4687,7902],[4685,7909],[4688,7918],[4686,7923],[4678,7928],[4684,7919],[4679,7921],[4674,7917],[4676,7907],[4668,7908],[4672,7911],[4669,7924],[4676,7925],[4677,7929],[4670,7933],[4660,7914],[4649,7924],[4646,7936],[4648,7938],[4657,7935],[4660,7939],[4671,7937],[4678,7944],[4680,7939],[4694,7936],[4699,7936],[4697,7946],[4708,7950],[4709,7964],[4727,7970],[4726,7975],[4735,7975],[4744,7971],[4759,7955],[4768,7951],[4790,7947],[4798,7953],[4805,7954]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.35,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;bz&#34;,&#34;hc-a2&#34;:&#34;BZ&#34;,&#34;name&#34;:&#34;Belize&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Belize&#34;,&#34;subregion&#34;:&#34;Central America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;BLZ&#34;,&#34;iso-a2&#34;:&#34;BZ&#34;,&#34;woe-id&#34;:&#34;23424760&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1623,7032],[1626,7037],[1632,7034],[1643,7052],[1648,7052],[1646,7049],[1654,7049],[1654,7040],[1662,7042],[1659,7036],[1653,7036],[1650,7028],[1655,7029],[1655,7022],[1650,7022],[1648,7013],[1651,7006],[1648,6997],[1641,6985],[1635,6984],[1630,6974],[1621,6974],[1623,7008],[1623,7032]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ZA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.36,&#34;hc-middle-y&#34;:0.7,&#34;hc-key&#34;:&#34;za&#34;,&#34;hc-a2&#34;:&#34;ZA&#34;,&#34;name&#34;:&#34;South Africa&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;S.Af.&#34;,&#34;subregion&#34;:&#34;Southern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;ZAF&#34;,&#34;iso-a2&#34;:&#34;ZA&#34;,&#34;woe-id&#34;:&#34;23424942&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5194,5701],[5201,5700],[5217,5700],[5210,5679],[5207,5658],[5202,5646],[5191,5636],[5183,5633],[5166,5614],[5162,5603],[5158,5599],[5143,5573],[5132,5559],[5114,5546],[5098,5526],[5083,5512],[5046,5486],[5029,5478],[5012,5480],[5004,5477],[5005,5469],[4985,5471],[4980,5464],[4969,5465],[4960,5468],[4944,5471],[4937,5466],[4924,5467],[4913,5470],[4901,5467],[4893,5459],[4876,5456],[4864,5458],[4862,5455],[4853,5455],[4837,5443],[4827,5445],[4816,5457],[4802,5458],[4803,5465],[4787,5469],[4792,5475],[4787,5487],[4775,5502],[4774,5509],[4786,5514],[4789,5527],[4784,5545],[4775,5557],[4757,5589],[4744,5629],[4737,5637],[4734,5646],[4743,5652],[4746,5661],[4751,5663],[4759,5657],[4761,5642],[4776,5639],[4783,5635],[4800,5637],[4811,5633],[4816,5636],[4824,5647],[4837,5651],[4837,5766],[4848,5757],[4860,5730],[4862,5723],[4855,5714],[4857,5699],[4862,5702],[4870,5700],[4886,5700],[4890,5706],[4896,5707],[4903,5716],[4912,5720],[4917,5727],[4921,5743],[4926,5749],[4939,5749],[4953,5739],[4960,5739],[4965,5735],[4979,5732],[4996,5735],[5002,5739],[5010,5762],[5010,5766],[5026,5770],[5038,5781],[5044,5801],[5054,5808],[5065,5813],[5078,5830],[5100,5837],[5103,5844],[5112,5845],[5124,5847],[5141,5840],[5156,5842],[5169,5839],[5177,5815],[5177,5806],[5183,5794],[5190,5776],[5190,5738],[5189,5728],[5186,5728],[5174,5735],[5165,5730],[5155,5714],[5155,5702],[5165,5689],[5176,5686],[5190,5686],[5190,5702],[5194,5701]],[[5077,5642],[5073,5637],[5065,5635],[5051,5615],[5044,5612],[5054,5590],[5065,5581],[5075,5579],[5079,5590],[5084,5596],[5096,5597],[5106,5603],[5107,5611],[5115,5621],[5108,5630],[5091,5646],[5077,5642]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LY&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.39,&#34;hc-key&#34;:&#34;ly&#34;,&#34;hc-a2&#34;:&#34;LY&#34;,&#34;name&#34;:&#34;Libya&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Libya&#34;,&#34;subregion&#34;:&#34;Northern Africa&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;LBY&#34;,&#34;iso-a2&#34;:&#34;LY&#34;,&#34;woe-id&#34;:&#34;23424882&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4984,7159],[4984,7098],[4954,7098],[4954,7083],[4719,7204],[4689,7190],[4667,7178],[4645,7196],[4601,7206],[4588,7230],[4563,7238],[4555,7236],[4544,7248],[4543,7262],[4525,7287],[4527,7294],[4538,7299],[4540,7310],[4534,7324],[4541,7342],[4536,7355],[4538,7371],[4538,7382],[4533,7398],[4522,7414],[4529,7417],[4539,7421],[4551,7440],[4546,7456],[4552,7465],[4557,7466],[4561,7473],[4568,7479],[4589,7490],[4585,7495],[4587,7513],[4597,7510],[4612,7502],[4623,7501],[4641,7504],[4648,7501],[4666,7498],[4674,7492],[4695,7488],[4701,7480],[4704,7464],[4712,7455],[4721,7451],[4741,7450],[4760,7445],[4784,7435],[4797,7424],[4809,7419],[4818,7420],[4830,7427],[4838,7436],[4841,7449],[4835,7467],[4839,7480],[4854,7493],[4869,7500],[4879,7501],[4885,7505],[4900,7506],[4911,7500],[4929,7496],[4928,7486],[4933,7482],[4945,7481],[4958,7475],[4975,7476],[4984,7474],[4989,7464],[4980,7455],[4981,7444],[4984,7435],[4982,7426],[4975,7416],[4979,7407],[4984,7384],[4984,7159]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SD&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;sd&#34;,&#34;hc-a2&#34;:&#34;SD&#34;,&#34;name&#34;:&#34;Sudan&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Sudan&#34;,&#34;subregion&#34;:&#34;Northern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;SDN&#34;,&#34;iso-a2&#34;:&#34;SD&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4954,7083],[4954,7098],[4984,7098],[4984,7159],[5168,7159],[5172,7165],[5174,7159],[5334,7159],[5334,7148],[5341,7137],[5340,7130],[5346,7123],[5343,7098],[5347,7072],[5354,7059],[5358,7060],[5371,7050],[5369,7048],[5385,7037],[5373,7023],[5352,7017],[5351,7010],[5338,7009],[5334,6993],[5336,6985],[5328,6969],[5327,6960],[5321,6951],[5324,6925],[5320,6905],[5315,6898],[5312,6879],[5299,6877],[5285,6855],[5281,6852],[5281,6844],[5274,6820],[5266,6825],[5258,6815],[5259,6805],[5252,6789],[5251,6782],[5246,6782],[5249,6794],[5247,6804],[5225,6823],[5222,6846],[5226,6864],[5212,6864],[5212,6858],[5193,6858],[5201,6849],[5203,6830],[5189,6818],[5181,6805],[5168,6792],[5154,6790],[5132,6807],[5120,6800],[5116,6792],[5102,6787],[5098,6779],[5074,6779],[5070,6787],[5046,6787],[5034,6783],[5030,6784],[5019,6797],[5011,6804],[5009,6811],[4987,6807],[4982,6795],[4978,6793],[4971,6766],[4960,6760],[4940,6763],[4939,6774],[4944,6777],[4944,6795],[4934,6812],[4921,6826],[4924,6834],[4923,6840],[4914,6843],[4912,6848],[4914,6860],[4907,6872],[4909,6876],[4902,6880],[4897,6877],[4890,6881],[4895,6890],[4904,6897],[4898,6911],[4902,6916],[4912,6921],[4907,6933],[4916,6938],[4918,6947],[4923,6951],[4923,6963],[4928,6968],[4954,6969],[4954,7083]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CD&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.58,&#34;hc-middle-y&#34;:0.42,&#34;hc-key&#34;:&#34;cd&#34;,&#34;hc-a2&#34;:&#34;CD&#34;,&#34;name&#34;:&#34;Democratic Republic of the Congo&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;D.R.C.&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;COD&#34;,&#34;iso-a2&#34;:&#34;CD&#34;,&#34;woe-id&#34;:&#34;23424780&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5108,6408],[5105,6395],[5106,6378],[5105,6357],[5113,6341],[5107,6332],[5117,6309],[5125,6299],[5135,6293],[5139,6275],[5147,6269],[5148,6264],[5099,6256],[5082,6238],[5082,6226],[5088,6230],[5093,6218],[5091,6214],[5091,6196],[5086,6172],[5083,6169],[5088,6156],[5095,6153],[5103,6141],[5117,6139],[5116,6145],[5126,6148],[5126,6110],[5118,6116],[5108,6110],[5102,6111],[5099,6118],[5082,6139],[5062,6144],[5056,6155],[5050,6158],[5049,6165],[5044,6164],[5042,6156],[5034,6152],[5026,6155],[5013,6155],[4994,6163],[4993,6176],[4976,6172],[4968,6168],[4963,6171],[4966,6179],[4959,6181],[4954,6186],[4951,6182],[4939,6183],[4926,6179],[4912,6181],[4903,6175],[4901,6186],[4905,6189],[4905,6201],[4901,6214],[4892,6223],[4890,6229],[4894,6257],[4889,6271],[4892,6286],[4890,6292],[4852,6292],[4855,6303],[4846,6300],[4823,6300],[4823,6286],[4818,6283],[4818,6271],[4784,6271],[4781,6267],[4766,6268],[4749,6291],[4746,6304],[4742,6309],[4741,6324],[4737,6332],[4729,6334],[4668,6333],[4659,6334],[4636,6334],[4614,6328],[4608,6336],[4617,6337],[4617,6354],[4615,6357],[4625,6366],[4633,6369],[4643,6362],[4652,6368],[4652,6375],[4659,6373],[4672,6380],[4672,6362],[4685,6364],[4696,6378],[4706,6386],[4717,6390],[4726,6408],[4725,6421],[4726,6443],[4734,6450],[4744,6468],[4749,6473],[4758,6475],[4771,6490],[4770,6499],[4777,6516],[4774,6535],[4780,6550],[4780,6568],[4796,6597],[4797,6607],[4797,6624],[4794,6632],[4800,6634],[4810,6649],[4820,6655],[4829,6655],[4847,6645],[4854,6634],[4863,6635],[4873,6631],[4888,6631],[4902,6627],[4911,6628],[4922,6646],[4935,6640],[4970,6654],[4974,6649],[4993,6652],[4995,6661],[5001,6662],[5011,6656],[5018,6659],[5029,6653],[5039,6653],[5047,6657],[5056,6654],[5066,6644],[5066,6640],[5083,6630],[5095,6638],[5108,6632],[5116,6642],[5126,6638],[5137,6621],[5147,6618],[5148,6611],[5154,6613],[5156,6607],[5159,6605],[5153,6595],[5157,6589],[5152,6577],[5160,6575],[5169,6569],[5146,6549],[5146,6541],[5139,6539],[5136,6532],[5130,6529],[5130,6520],[5122,6502],[5116,6499],[5111,6491],[5113,6485],[5121,6491],[5118,6478],[5119,6465],[5112,6461],[5109,6456],[5105,6457],[5101,6448],[5105,6440],[5098,6433],[5099,6428],[5103,6426],[5109,6416],[5108,6408]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.65,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;kw&#34;,&#34;hc-a2&#34;:&#34;KW&#34;,&#34;name&#34;:&#34;Kuwait&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Kwt.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;KWT&#34;,&#34;iso-a2&#34;:&#34;KW&#34;,&#34;woe-id&#34;:&#34;23424870&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5660,7410],[5663,7404],[5667,7408],[5672,7403],[5667,7396],[5661,7397],[5653,7390],[5664,7389],[5666,7379],[5674,7363],[5652,7363],[5645,7378],[5618,7381],[5628,7392],[5635,7409],[5643,7413],[5652,7413],[5660,7410]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ER&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.1,&#34;hc-middle-y&#34;:0.24,&#34;hc-key&#34;:&#34;er&#34;,&#34;hc-a2&#34;:&#34;ER&#34;,&#34;name&#34;:&#34;Eritrea&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Erit.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;ERI&#34;,&#34;iso-a2&#34;:&#34;ER&#34;,&#34;woe-id&#34;:&#34;23424806&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5324,6925],[5321,6951],[5327,6960],[5328,6969],[5336,6985],[5334,6993],[5338,7009],[5351,7010],[5352,7017],[5373,7023],[5385,7037],[5394,7019],[5401,6999],[5406,6974],[5409,6971],[5410,6963],[5415,6962],[5417,6951],[5422,6952],[5419,6959],[5427,6972],[5431,6966],[5422,6962],[5428,6957],[5431,6947],[5444,6946],[5449,6939],[5460,6936],[5475,6915],[5484,6913],[5493,6905],[5496,6894],[5501,6894],[5508,6883],[5518,6879],[5511,6876],[5505,6868],[5496,6872],[5489,6881],[5483,6884],[5479,6892],[5461,6906],[5451,6920],[5429,6931],[5423,6930],[5412,6934],[5403,6930],[5397,6937],[5393,6932],[5380,6930],[5374,6938],[5364,6944],[5354,6920],[5346,6931],[5340,6927],[5324,6925]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;IE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.44,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;ie&#34;,&#34;hc-a2&#34;:&#34;IE&#34;,&#34;name&#34;:&#34;Ireland&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Ire.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;IRL&#34;,&#34;iso-a2&#34;:&#34;IE&#34;,&#34;woe-id&#34;:&#34;23424803&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4035,8308],[4030,8305],[4026,8294],[4015,8292],[4021,8289],[4008,8283],[4017,8273],[4033,8269],[4042,8281],[4053,8271],[4053,8266],[4064,8268],[4061,8265],[4065,8250],[4069,8247],[4068,8240],[4072,8222],[4065,8211],[4061,8198],[4061,8192],[4051,8193],[4025,8188],[4012,8177],[4005,8177],[3992,8168],[3988,8168],[3972,8164],[3971,8167],[3959,8163],[3970,8172],[3968,8174],[3953,8169],[3954,8174],[3942,8181],[3956,8187],[3955,8190],[3941,8188],[3940,8191],[3949,8196],[3958,8194],[3965,8207],[3979,8209],[3967,8210],[3956,8206],[3965,8213],[3973,8221],[3969,8222],[3975,8230],[3985,8231],[3985,8235],[3963,8233],[3964,8240],[3953,8239],[3949,8246],[3958,8249],[3957,8254],[3967,8256],[3966,8260],[3956,8258],[3948,8265],[3959,8262],[3953,8273],[3958,8277],[3994,8274],[3993,8279],[4009,8290],[3993,8289],[3989,8292],[4001,8299],[4000,8305],[4004,8311],[4023,8316],[4028,8306],[4027,8317],[4036,8319],[4044,8314],[4035,8308]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KP&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.34,&#34;hc-middle-y&#34;:0.68,&#34;hc-key&#34;:&#34;kp&#34;,&#34;hc-a2&#34;:&#34;KP&#34;,&#34;name&#34;:&#34;North Korea&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;N.K.&#34;,&#34;subregion&#34;:&#34;Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;PRK&#34;,&#34;iso-a2&#34;:&#34;KP&#34;,&#34;woe-id&#34;:&#34;23424865&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[8097,7823],[8091,7825],[8078,7815],[8066,7797],[8070,7791],[8067,7782],[8068,7772],[8053,7766],[8049,7759],[8035,7753],[8037,7750],[8027,7744],[8017,7744],[8013,7739],[8003,7734],[8004,7729],[7999,7721],[8001,7714],[8010,7712],[8014,7707],[8028,7695],[8022,7686],[7992,7685],[7987,7682],[7978,7668],[7970,7670],[7962,7668],[7946,7675],[7947,7666],[7939,7663],[7938,7668],[7929,7672],[7934,7673],[7925,7679],[7927,7689],[7923,7692],[7942,7698],[7933,7702],[7942,7719],[7937,7726],[7925,7733],[7918,7731],[7910,7738],[7910,7746],[7926,7760],[7941,7765],[7951,7774],[7958,7774],[7973,7793],[7976,7801],[7986,7806],[7995,7795],[8021,7791],[8026,7798],[8018,7808],[8018,7812],[8044,7814],[8053,7820],[8056,7828],[8067,7828],[8072,7847],[8079,7847],[8083,7839],[8092,7831],[8095,7827],[8097,7823]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;VE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.44,&#34;hc-middle-y&#34;:0.25,&#34;hc-key&#34;:&#34;ve&#34;,&#34;hc-a2&#34;:&#34;VE&#34;,&#34;name&#34;:&#34;Venezuela&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Ven.&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;VEN&#34;,&#34;iso-a2&#34;:&#34;VE&#34;,&#34;woe-id&#34;:&#34;23424982&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2481,6756],[2487,6748],[2481,6741],[2466,6734],[2460,6726],[2463,6716],[2473,6714],[2471,6708],[2460,6703],[2455,6705],[2446,6697],[2449,6686],[2441,6678],[2460,6657],[2464,6650],[2453,6638],[2439,6634],[2436,6630],[2418,6625],[2410,6628],[2401,6623],[2400,6611],[2393,6610],[2381,6621],[2362,6620],[2360,6625],[2346,6626],[2340,6630],[2345,6621],[2358,6610],[2357,6597],[2364,6585],[2362,6577],[2383,6576],[2381,6568],[2362,6561],[2360,6551],[2352,6549],[2342,6542],[2330,6538],[2318,6524],[2319,6530],[2312,6534],[2301,6526],[2293,6529],[2279,6541],[2270,6575],[2257,6587],[2251,6590],[2267,6605],[2257,6615],[2250,6638],[2252,6653],[2251,6660],[2257,6667],[2257,6674],[2263,6680],[2261,6687],[2251,6690],[2247,6687],[2227,6685],[2215,6687],[2209,6683],[2204,6684],[2183,6709],[2178,6708],[2170,6713],[2152,6709],[2149,6711],[2125,6713],[2122,6721],[2114,6724],[2114,6738],[2118,6743],[2117,6750],[2108,6759],[2104,6773],[2099,6778],[2087,6774],[2099,6793],[2101,6811],[2114,6832],[2120,6833],[2129,6848],[2148,6853],[2143,6849],[2131,6847],[2130,6839],[2141,6820],[2139,6812],[2129,6802],[2125,6793],[2135,6780],[2135,6773],[2143,6770],[2150,6773],[2156,6780],[2157,6791],[2144,6810],[2141,6822],[2162,6834],[2172,6836],[2183,6842],[2195,6843],[2193,6849],[2182,6846],[2178,6854],[2181,6861],[2187,6864],[2192,6858],[2198,6842],[2209,6844],[2221,6842],[2234,6833],[2238,6826],[2238,6818],[2248,6812],[2275,6817],[2297,6818],[2308,6807],[2332,6800],[2341,6801],[2358,6813],[2374,6813],[2365,6816],[2357,6814],[2361,6825],[2352,6827],[2357,6831],[2363,6828],[2367,6833],[2370,6827],[2365,6825],[2366,6817],[2377,6817],[2389,6820],[2402,6821],[2424,6818],[2413,6814],[2400,6813],[2408,6803],[2413,6790],[2416,6800],[2428,6792],[2433,6796],[2458,6780],[2455,6767],[2460,6765],[2468,6755],[2471,6758],[2481,6756]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GY&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.39,&#34;hc-middle-y&#34;:0.28,&#34;hc-key&#34;:&#34;gy&#34;,&#34;hc-a2&#34;:&#34;GY&#34;,&#34;name&#34;:&#34;Guyana&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Guy.&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;GUY&#34;,&#34;iso-a2&#34;:&#34;GY&#34;,&#34;woe-id&#34;:&#34;23424836&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2460,6657],[2441,6678],[2449,6686],[2446,6697],[2455,6705],[2460,6703],[2471,6708],[2473,6714],[2463,6716],[2460,6726],[2466,6734],[2481,6741],[2487,6748],[2481,6756],[2508,6740],[2520,6728],[2527,6719],[2523,6696],[2528,6709],[2540,6704],[2565,6683],[2565,6672],[2565,6670],[2563,6666],[2560,6661],[2562,6652],[2549,6651],[2543,6646],[2545,6641],[2539,6627],[2540,6622],[2551,6604],[2561,6604],[2565,6588],[2579,6564],[2585,6562],[2576,6560],[2567,6564],[2557,6561],[2553,6555],[2541,6554],[2540,6549],[2531,6552],[2525,6542],[2516,6540],[2503,6546],[2489,6560],[2489,6571],[2484,6574],[2482,6584],[2486,6611],[2496,6620],[2490,6627],[2491,6633],[2478,6637],[2482,6654],[2475,6659],[2460,6657]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;HN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.71,&#34;hc-middle-y&#34;:0.1,&#34;hc-key&#34;:&#34;hn&#34;,&#34;hc-a2&#34;:&#34;HN&#34;,&#34;name&#34;:&#34;Honduras&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Hond.&#34;,&#34;subregion&#34;:&#34;Central America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;HND&#34;,&#34;iso-a2&#34;:&#34;HN&#34;,&#34;woe-id&#34;:&#34;23424841&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1651,6969],[1653,6968],[1665,6975],[1673,6971],[1676,6973],[1689,6970],[1705,6970],[1718,6977],[1731,6973],[1746,6977],[1766,6971],[1775,6963],[1772,6958],[1782,6953],[1794,6954],[1801,6947],[1793,6948],[1786,6943],[1761,6936],[1752,6942],[1741,6934],[1741,6927],[1724,6916],[1724,6912],[1713,6918],[1704,6910],[1694,6910],[1695,6896],[1692,6896],[1686,6887],[1677,6887],[1672,6896],[1675,6899],[1663,6900],[1666,6912],[1657,6913],[1654,6917],[1643,6913],[1642,6917],[1629,6923],[1627,6927],[1617,6930],[1624,6938],[1623,6949],[1629,6951],[1651,6969]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.19,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;mm&#34;,&#34;hc-a2&#34;:&#34;MM&#34;,&#34;name&#34;:&#34;Myanmar&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Myan.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;MMR&#34;,&#34;iso-a2&#34;:&#34;MM&#34;,&#34;woe-id&#34;:&#34;23424763&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6965,7130],[6962,7134],[6967,7142],[6976,7138],[6974,7159],[6977,7164],[6983,7158],[6991,7171],[6989,7183],[6991,7190],[6998,7194],[6999,7210],[6995,7221],[7005,7221],[7019,7216],[7025,7231],[7037,7253],[7032,7260],[7034,7264],[7046,7275],[7048,7287],[7047,7298],[7049,7302],[7057,7305],[7079,7323],[7096,7326],[7105,7317],[7107,7320],[7101,7329],[7101,7335],[7114,7343],[7114,7353],[7120,7363],[7124,7363],[7137,7350],[7137,7345],[7142,7332],[7146,7336],[7154,7333],[7154,7320],[7156,7303],[7150,7287],[7154,7280],[7148,7278],[7144,7270],[7138,7271],[7137,7264],[7125,7254],[7127,7247],[7120,7244],[7119,7235],[7123,7234],[7125,7225],[7119,7219],[7123,7216],[7139,7225],[7151,7223],[7159,7225],[7153,7220],[7160,7203],[7159,7196],[7170,7192],[7178,7192],[7172,7182],[7174,7174],[7167,7164],[7191,7161],[7191,7151],[7197,7149],[7198,7142],[7213,7144],[7226,7152],[7227,7145],[7214,7138],[7208,7123],[7199,7120],[7196,7108],[7191,7112],[7182,7107],[7176,7109],[7179,7104],[7172,7100],[7164,7099],[7163,7093],[7149,7088],[7134,7092],[7134,7087],[7127,7080],[7128,7071],[7124,7065],[7126,7055],[7117,7052],[7126,7036],[7124,7032],[7136,7017],[7146,7008],[7147,6999],[7154,6985],[7158,6991],[7158,6981],[7150,6979],[7149,6957],[7139,6954],[7141,6941],[7151,6927],[7161,6920],[7168,6909],[7169,6894],[7166,6889],[7175,6872],[7182,6852],[7169,6831],[7156,6819],[7156,6809],[7150,6798],[7138,6794],[7139,6801],[7148,6804],[7147,6820],[7142,6820],[7139,6814],[7140,6827],[7148,6822],[7155,6826],[7153,6832],[7156,6851],[7150,6852],[7149,6844],[7141,6842],[7134,6849],[7141,6848],[7149,6858],[7155,6857],[7149,6872],[7144,6867],[7132,6869],[7142,6873],[7143,6878],[7152,6874],[7154,6879],[7151,6893],[7141,6909],[7132,6911],[7136,6915],[7137,6922],[7128,6944],[7128,6952],[7124,6963],[7125,6974],[7121,6978],[7123,6985],[7118,6986],[7110,7008],[7101,7019],[7102,7009],[7098,6999],[7093,6993],[7083,6995],[7083,6988],[7072,6984],[7058,6969],[7054,6974],[7049,6972],[7049,6982],[7045,6970],[7035,6973],[7033,6977],[7028,6972],[7022,6978],[7024,6993],[7030,7006],[7030,7013],[7034,7024],[7029,7037],[7028,7047],[7020,7062],[7017,7063],[7018,7074],[7014,7063],[7009,7064],[7005,7058],[7001,7064],[7007,7064],[7005,7072],[7001,7078],[7011,7075],[7005,7083],[7015,7080],[6998,7101],[6988,7098],[6980,7104],[6983,7108],[6979,7113],[6979,7106],[6968,7119],[6965,7130]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.34,&#34;hc-middle-y&#34;:0.62,&#34;hc-key&#34;:&#34;ga&#34;,&#34;hc-a2&#34;:&#34;GA&#34;,&#34;name&#34;:&#34;Gabon&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Gabon&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;GAB&#34;,&#34;iso-a2&#34;:&#34;GA&#34;,&#34;woe-id&#34;:&#34;23424822&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4537,6534],[4582,6534],[4582,6568],[4582,6572],[4611,6573],[4624,6571],[4638,6572],[4640,6568],[4635,6552],[4638,6541],[4654,6547],[4668,6544],[4674,6532],[4667,6521],[4663,6521],[4657,6511],[4655,6499],[4663,6497],[4675,6488],[4672,6476],[4674,6469],[4672,6450],[4668,6447],[4663,6432],[4657,6432],[4653,6444],[4645,6434],[4632,6437],[4625,6449],[4614,6450],[4615,6437],[4594,6434],[4589,6437],[4591,6422],[4595,6417],[4592,6412],[4600,6408],[4597,6397],[4586,6402],[4578,6397],[4575,6390],[4571,6397],[4562,6404],[4561,6408],[4540,6426],[4534,6434],[4542,6428],[4547,6430],[4535,6433],[4521,6451],[4520,6459],[4524,6466],[4514,6467],[4504,6488],[4514,6483],[4521,6493],[4524,6506],[4522,6513],[4537,6509],[4528,6514],[4522,6521],[4525,6524],[4531,6520],[4530,6533],[4537,6534]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NI&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.84,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;ni&#34;,&#34;hc-a2&#34;:&#34;NI&#34;,&#34;name&#34;:&#34;Nicaragua&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Nic.&#34;,&#34;subregion&#34;:&#34;Central America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;NIC&#34;,&#34;iso-a2&#34;:&#34;NI&#34;,&#34;woe-id&#34;:&#34;23424915&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1725,6831],[1701,6851],[1693,6864],[1668,6884],[1671,6889],[1677,6887],[1686,6887],[1692,6896],[1695,6896],[1694,6910],[1704,6910],[1713,6918],[1724,6912],[1724,6916],[1741,6927],[1741,6934],[1752,6942],[1761,6936],[1786,6943],[1793,6948],[1801,6947],[1796,6940],[1799,6928],[1792,6916],[1788,6900],[1789,6869],[1787,6877],[1782,6874],[1786,6868],[1783,6856],[1785,6846],[1779,6840],[1780,6832],[1785,6826],[1777,6820],[1769,6822],[1765,6828],[1754,6830],[1748,6826],[1728,6834],[1725,6831]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.21,&#34;hc-middle-y&#34;:0.31,&#34;hc-key&#34;:&#34;mw&#34;,&#34;hc-a2&#34;:&#34;MW&#34;,&#34;name&#34;:&#34;Malawi&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Mal.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;MWI&#34;,&#34;iso-a2&#34;:&#34;MW&#34;,&#34;woe-id&#34;:&#34;23424889&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5276,6170],[5276,6170],[5276,6170],[5276,6170]]],[[[5271,6174],[5271,6175],[5271,6175],[5271,6174],[5271,6174]]],[[[5258,6220],[5255,6223],[5255,6223],[5258,6220]]],[[[5252,6226],[5252,6226],[5252,6226],[5252,6226]]],[[[5218,6229],[5229,6227],[5232,6223],[5242,6224],[5247,6220],[5248,6212],[5257,6199],[5255,6195],[5259,6162],[5251,6152],[5251,6142],[5258,6127],[5259,6112],[5268,6102],[5265,6094],[5270,6085],[5275,6093],[5286,6081],[5287,6083],[5280,6101],[5275,6102],[5275,6107],[5281,6102],[5304,6074],[5305,6066],[5302,6058],[5304,6051],[5302,6032],[5290,6029],[5283,6017],[5287,6012],[5287,5999],[5281,6000],[5282,6008],[5279,6009],[5261,6028],[5256,6036],[5266,6054],[5267,6064],[5264,6076],[5259,6081],[5241,6078],[5239,6075],[5226,6093],[5220,6092],[5214,6102],[5214,6107],[5220,6125],[5221,6134],[5230,6137],[5235,6143],[5230,6143],[5227,6170],[5231,6177],[5227,6186],[5240,6195],[5236,6205],[5229,6210],[5231,6215],[5225,6223],[5219,6223],[5218,6229]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SX&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.76,&#34;hc-middle-y&#34;:0.52,&#34;hc-key&#34;:&#34;sx&#34;,&#34;hc-a2&#34;:&#34;SX&#34;,&#34;name&#34;:&#34;Somaliland&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Solnd.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;-99&#34;,&#34;iso-a2&#34;:&#34;SX&#34;,&#34;woe-id&#34;:&#34;-99&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5521,6843],[5528,6839],[5534,6828],[5552,6812],[5561,6810],[5572,6811],[5596,6825],[5616,6819],[5622,6821],[5644,6834],[5653,6831],[5665,6832],[5681,6838],[5689,6836],[5689,6782],[5661,6739],[5631,6739],[5544,6769],[5533,6779],[5527,6781],[5520,6795],[5509,6805],[5504,6817],[5512,6828],[5521,6843]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.38,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;tm&#34;,&#34;hc-a2&#34;:&#34;TM&#34;,&#34;name&#34;:&#34;Turkmenistan&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Turkm.&#34;,&#34;subregion&#34;:&#34;Central Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;TKM&#34;,&#34;iso-a2&#34;:&#34;TM&#34;,&#34;woe-id&#34;:&#34;23424972&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5929,7810],[5937,7796],[5952,7801],[5953,7806],[5947,7809],[5945,7818],[5952,7819],[5956,7830],[5970,7823],[5964,7837],[5972,7836],[5973,7841],[5982,7832],[5989,7832],[5998,7823],[6011,7823],[6016,7819],[6013,7811],[6022,7805],[6017,7803],[6020,7798],[6018,7791],[6027,7786],[6040,7786],[6053,7783],[6057,7788],[6064,7786],[6073,7778],[6079,7760],[6084,7758],[6087,7743],[6091,7739],[6117,7722],[6124,7715],[6136,7707],[6143,7707],[6151,7700],[6161,7695],[6180,7682],[6188,7683],[6208,7675],[6207,7653],[6200,7651],[6184,7660],[6177,7648],[6164,7648],[6155,7643],[6156,7638],[6151,7630],[6147,7616],[6129,7608],[6113,7602],[6106,7602],[6109,7597],[6106,7588],[6092,7581],[6086,7583],[6082,7578],[6074,7588],[6060,7588],[6052,7594],[6050,7626],[6047,7628],[6025,7628],[6015,7641],[5996,7651],[5996,7656],[5980,7664],[5967,7662],[5961,7666],[5937,7673],[5933,7683],[5928,7681],[5919,7683],[5910,7683],[5906,7677],[5881,7677],[5863,7666],[5861,7658],[5844,7651],[5836,7652],[5833,7665],[5833,7692],[5838,7705],[5829,7711],[5826,7720],[5812,7723],[5815,7727],[5830,7727],[5821,7735],[5825,7741],[5817,7741],[5801,7745],[5801,7760],[5807,7777],[5812,7770],[5825,7769],[5826,7774],[5830,7764],[5848,7768],[5847,7775],[5852,7771],[5861,7776],[5859,7782],[5841,7794],[5835,7809],[5835,7815],[5829,7818],[5814,7816],[5808,7812],[5803,7804],[5806,7802],[5803,7791],[5796,7796],[5792,7804],[5808,7817],[5821,7822],[5840,7825],[5844,7824],[5865,7810],[5874,7794],[5883,7787],[5896,7789],[5927,7786],[5925,7808],[5929,7810]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ZM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.25,&#34;hc-middle-y&#34;:0.67,&#34;hc-key&#34;:&#34;zm&#34;,&#34;hc-a2&#34;:&#34;ZM&#34;,&#34;name&#34;:&#34;Zambia&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Zambia&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;ZMB&#34;,&#34;iso-a2&#34;:&#34;ZM&#34;,&#34;woe-id&#34;:&#34;23425003&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5088,6230],[5094,6232],[5102,6242],[5106,6251],[5099,6256],[5148,6264],[5145,6258],[5155,6254],[5162,6247],[5166,6253],[5177,6250],[5181,6244],[5189,6243],[5190,6239],[5203,6237],[5218,6229],[5219,6223],[5225,6223],[5231,6215],[5229,6210],[5236,6205],[5240,6195],[5227,6186],[5231,6177],[5227,6170],[5230,6143],[5235,6143],[5230,6137],[5221,6134],[5220,6125],[5214,6107],[5214,6102],[5220,6092],[5226,6093],[5180,6077],[5173,6074],[5156,6070],[5138,6064],[5143,6044],[5127,6045],[5108,6039],[5098,6032],[5095,6017],[5086,6017],[5059,5999],[5046,5980],[5044,5974],[5034,5971],[5020,5976],[5013,5973],[5004,5979],[4992,5979],[4983,5986],[4961,5989],[4937,5984],[4925,5994],[4919,5998],[4906,6013],[4899,6017],[4896,6028],[4895,6123],[4955,6123],[4951,6129],[4956,6141],[4954,6147],[4954,6163],[4957,6170],[4954,6186],[4959,6181],[4966,6179],[4963,6171],[4968,6168],[4976,6172],[4993,6176],[4994,6163],[5013,6155],[5026,6155],[5034,6152],[5042,6156],[5044,6164],[5049,6165],[5050,6158],[5056,6155],[5062,6144],[5082,6139],[5099,6118],[5102,6111],[5108,6110],[5118,6116],[5126,6110],[5126,6148],[5116,6145],[5117,6139],[5103,6141],[5095,6153],[5088,6156],[5083,6169],[5086,6172],[5091,6196],[5091,6214],[5093,6218],[5088,6230]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NC&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.55,&#34;hc-middle-y&#34;:0.64,&#34;hc-key&#34;:&#34;nc&#34;,&#34;hc-a2&#34;:&#34;NC&#34;,&#34;name&#34;:&#34;Northern Cyprus&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;N. Cy.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;-99&#34;,&#34;iso-a2&#34;:&#34;NC&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5247,7576],[5242,7574],[5240,7574],[5232,7580],[5215,7576],[5211,7579],[5215,7578],[5218,7587],[5232,7584],[5250,7589],[5267,7596],[5248,7584],[5250,7575],[5247,7576]]],[[[5208,7579],[5209,7579],[5209,7579],[5208,7579]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.62,&#34;hc-middle-y&#34;:0.63,&#34;hc-key&#34;:&#34;mr&#34;,&#34;hc-a2&#34;:&#34;MR&#34;,&#34;name&#34;:&#34;Mauritania&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Mrt.&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;MRT&#34;,&#34;iso-a2&#34;:&#34;MR&#34;,&#34;woe-id&#34;:&#34;23424896&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3993,7324],[4086,7265],[4106,7252],[4054,7252],[4073,7083],[4083,6993],[4091,6986],[4086,6962],[3973,6962],[3951,6958],[3932,6960],[3927,6950],[3912,6965],[3903,6963],[3899,6953],[3900,6944],[3893,6939],[3887,6940],[3881,6948],[3870,6954],[3867,6962],[3858,6966],[3856,6975],[3851,6982],[3841,6981],[3837,6987],[3826,6996],[3809,6996],[3787,6992],[3767,6991],[3761,6971],[3761,6985],[3764,6996],[3772,7015],[3776,7036],[3775,7052],[3771,7067],[3762,7080],[3767,7080],[3763,7090],[3771,7098],[3771,7105],[3762,7121],[3757,7119],[3750,7133],[3746,7121],[3749,7139],[3865,7139],[3863,7174],[3861,7182],[3865,7191],[3877,7198],[3894,7204],[3894,7283],[3992,7283],[3993,7324]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;DZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.63,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;dz&#34;,&#34;hc-a2&#34;:&#34;DZ&#34;,&#34;name&#34;:&#34;Algeria&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Alg.&#34;,&#34;subregion&#34;:&#34;Northern Africa&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;DZA&#34;,&#34;iso-a2&#34;:&#34;DZ&#34;,&#34;woe-id&#34;:&#34;23424740&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4106,7252],[4086,7265],[3993,7324],[3993,7336],[3993,7367],[4002,7375],[4023,7390],[4032,7390],[4038,7394],[4049,7392],[4051,7395],[4079,7398],[4085,7395],[4093,7406],[4120,7426],[4141,7433],[4144,7441],[4136,7453],[4140,7455],[4140,7463],[4165,7468],[4162,7476],[4174,7479],[4211,7477],[4212,7486],[4217,7492],[4206,7499],[4204,7509],[4199,7515],[4201,7524],[4197,7530],[4199,7543],[4195,7552],[4198,7556],[4193,7560],[4196,7565],[4183,7576],[4196,7578],[4211,7586],[4213,7592],[4224,7599],[4230,7597],[4234,7603],[4246,7600],[4252,7608],[4267,7618],[4279,7623],[4309,7626],[4317,7628],[4325,7627],[4335,7634],[4351,7633],[4362,7637],[4389,7637],[4402,7628],[4409,7629],[4417,7635],[4431,7637],[4439,7643],[4443,7639],[4459,7637],[4466,7643],[4478,7640],[4481,7635],[4491,7639],[4502,7638],[4503,7635],[4489,7623],[4494,7622],[4491,7601],[4493,7595],[4493,7577],[4491,7562],[4479,7554],[4477,7548],[4470,7543],[4468,7537],[4476,7514],[4486,7510],[4492,7502],[4494,7492],[4515,7477],[4529,7417],[4522,7414],[4533,7398],[4538,7382],[4538,7371],[4536,7355],[4541,7342],[4534,7324],[4540,7310],[4538,7299],[4527,7294],[4525,7287],[4543,7262],[4544,7248],[4555,7236],[4563,7238],[4588,7230],[4601,7206],[4469,7125],[4419,7081],[4373,7072],[4347,7067],[4340,7072],[4344,7079],[4343,7092],[4335,7096],[4319,7100],[4313,7106],[4304,7105],[4294,7116],[4282,7121],[4282,7132],[4106,7252]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.25,&#34;hc-middle-y&#34;:0.12,&#34;hc-key&#34;:&#34;lt&#34;,&#34;hc-a2&#34;:&#34;LT&#34;,&#34;name&#34;:&#34;Lithuania&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Lith.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;LTU&#34;,&#34;iso-a2&#34;:&#34;LT&#34;,&#34;woe-id&#34;:&#34;23424875&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4874,8315],[4871,8333],[4868,8349],[4876,8355],[4899,8363],[4916,8360],[4923,8363],[4929,8359],[4934,8361],[4946,8361],[4959,8357],[4968,8357],[4981,8364],[4988,8354],[5004,8352],[5019,8340],[5022,8335],[5031,8332],[5027,8319],[5036,8317],[5031,8310],[5023,8311],[5018,8303],[5010,8302],[5006,8295],[5006,8287],[5000,8278],[5008,8274],[5004,8269],[4998,8276],[4990,8274],[4986,8269],[4978,8268],[4966,8259],[4960,8262],[4944,8260],[4940,8262],[4939,8270],[4924,8280],[4919,8278],[4916,8282],[4920,8300],[4913,8307],[4899,8306],[4878,8317],[4874,8315]]],[[[4864,8316],[4869,8325],[4866,8316],[4864,8316]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ET&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.45,&#34;hc-middle-y&#34;:0.58,&#34;hc-key&#34;:&#34;et&#34;,&#34;hc-a2&#34;:&#34;ET&#34;,&#34;name&#34;:&#34;Ethiopia&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Eth.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;ETH&#34;,&#34;iso-a2&#34;:&#34;ET&#34;,&#34;woe-id&#34;:&#34;23424808&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5479,6837],[5475,6834],[5479,6831],[5483,6826],[5503,6831],[5512,6828],[5504,6817],[5509,6805],[5520,6795],[5527,6781],[5533,6779],[5544,6769],[5631,6739],[5661,6739],[5615,6695],[5571,6649],[5543,6650],[5530,6647],[5518,6641],[5509,6631],[5488,6628],[5481,6621],[5460,6620],[5448,6631],[5422,6618],[5412,6605],[5383,6611],[5370,6611],[5366,6614],[5333,6635],[5309,6635],[5306,6640],[5302,6645],[5302,6661],[5291,6664],[5289,6662],[5278,6677],[5271,6700],[5264,6707],[5258,6710],[5250,6722],[5241,6730],[5222,6734],[5220,6737],[5226,6747],[5227,6753],[5248,6752],[5253,6758],[5251,6782],[5252,6789],[5259,6805],[5258,6815],[5266,6825],[5274,6820],[5281,6844],[5281,6852],[5285,6855],[5299,6877],[5312,6879],[5315,6898],[5320,6905],[5324,6925],[5340,6927],[5346,6931],[5354,6920],[5364,6944],[5374,6938],[5380,6930],[5393,6932],[5397,6937],[5403,6930],[5412,6934],[5423,6930],[5429,6931],[5451,6920],[5461,6906],[5479,6892],[5483,6884],[5489,6881],[5496,6872],[5477,6844],[5479,6837]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.39,&#34;hc-middle-y&#34;:0.74,&#34;hc-key&#34;:&#34;so&#34;,&#34;hc-a2&#34;:&#34;SO&#34;,&#34;name&#34;:&#34;Somalia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Som.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;SOM&#34;,&#34;iso-a2&#34;:&#34;SO&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5481,6621],[5488,6628],[5509,6631],[5518,6641],[5530,6647],[5543,6650],[5571,6649],[5615,6695],[5661,6739],[5689,6782],[5689,6836],[5703,6838],[5728,6846],[5737,6855],[5744,6857],[5758,6853],[5753,6843],[5752,6834],[5754,6819],[5748,6808],[5744,6787],[5745,6783],[5739,6771],[5733,6766],[5730,6756],[5723,6744],[5715,6738],[5715,6732],[5702,6711],[5693,6693],[5692,6685],[5675,6658],[5667,6649],[5660,6636],[5621,6594],[5603,6576],[5573,6560],[5554,6546],[5528,6523],[5502,6496],[5481,6471],[5471,6456],[5471,6459],[5455,6480],[5454,6587],[5466,6599],[5481,6621]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.13,&#34;hc-middle-y&#34;:0.77,&#34;hc-key&#34;:&#34;gh&#34;,&#34;hc-a2&#34;:&#34;GH&#34;,&#34;name&#34;:&#34;Ghana&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Ghana&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;GHA&#34;,&#34;iso-a2&#34;:&#34;GH&#34;,&#34;woe-id&#34;:&#34;23424824&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4283,6684],[4276,6675],[4255,6674],[4237,6666],[4225,6658],[4219,6658],[4202,6652],[4187,6644],[4182,6648],[4156,6654],[4157,6655],[4161,6654],[4165,6656],[4168,6662],[4166,6669],[4162,6669],[4155,6689],[4153,6706],[4159,6712],[4162,6727],[4167,6738],[4174,6746],[4171,6767],[4167,6771],[4169,6783],[4165,6808],[4167,6811],[4162,6817],[4167,6828],[4224,6828],[4231,6828],[4243,6832],[4249,6830],[4246,6817],[4259,6805],[4258,6791],[4255,6786],[4264,6781],[4259,6762],[4269,6748],[4265,6746],[4266,6731],[4263,6722],[4267,6720],[4263,6706],[4270,6694],[4283,6684]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SI&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.52,&#34;hc-middle-y&#34;:0.5600000000000001,&#34;hc-key&#34;:&#34;si&#34;,&#34;hc-a2&#34;:&#34;SI&#34;,&#34;name&#34;:&#34;Slovenia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Slo.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;SVN&#34;,&#34;iso-a2&#34;:&#34;SI&#34;,&#34;woe-id&#34;:&#34;23424945&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4648,7938],[4648,7940],[4652,7942],[4657,7943],[4648,7950],[4649,7955],[4645,7957],[4650,7963],[4642,7967],[4652,7976],[4672,7973],[4676,7970],[4685,7979],[4692,7980],[4704,7979],[4709,7983],[4720,7982],[4722,7988],[4727,7988],[4735,7975],[4726,7975],[4727,7970],[4709,7964],[4708,7950],[4697,7946],[4699,7936],[4694,7936],[4680,7939],[4678,7944],[4671,7937],[4660,7939],[4657,7935],[4648,7938]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.23,&#34;hc-middle-y&#34;:0.79,&#34;hc-key&#34;:&#34;gt&#34;,&#34;hc-a2&#34;:&#34;GT&#34;,&#34;name&#34;:&#34;Guatemala&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Guat.&#34;,&#34;subregion&#34;:&#34;Central America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;GTM&#34;,&#34;iso-a2&#34;:&#34;GT&#34;,&#34;woe-id&#34;:&#34;23424834&#34;,&#34;continent&#34;:&#34;North America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[1630,6974],[1639,6970],[1643,6973],[1651,6969],[1629,6951],[1623,6949],[1624,6938],[1617,6930],[1611,6929],[1612,6924],[1595,6912],[1596,6909],[1578,6915],[1560,6916],[1546,6923],[1532,6934],[1537,6949],[1533,6955],[1547,6979],[1584,6979],[1587,6988],[1575,7001],[1567,7004],[1556,7015],[1569,7015],[1569,7032],[1623,7032],[1623,7008],[1621,6974],[1630,6974]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.55,&#34;hc-middle-y&#34;:0.31,&#34;hc-key&#34;:&#34;ba&#34;,&#34;hc-a2&#34;:&#34;BA&#34;,&#34;name&#34;:&#34;Bosnia and Herzegovina&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;B.H.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;BIH&#34;,&#34;iso-a2&#34;:&#34;BA&#34;,&#34;woe-id&#34;:&#34;23424761&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4768,7844],[4765,7846],[4766,7846],[4766,7851],[4726,7891],[4723,7903],[4714,7909],[4713,7926],[4720,7928],[4729,7920],[4735,7928],[4743,7927],[4747,7930],[4773,7922],[4785,7926],[4798,7923],[4804,7915],[4808,7915],[4819,7916],[4811,7903],[4812,7894],[4826,7885],[4814,7882],[4821,7875],[4822,7868],[4813,7867],[4805,7866],[4805,7860],[4798,7856],[4797,7849],[4792,7848],[4794,7835],[4791,7832],[4774,7842],[4768,7844]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;JO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.07000000000000001,&#34;hc-middle-y&#34;:0.78,&#34;hc-key&#34;:&#34;jo&#34;,&#34;hc-a2&#34;:&#34;JO&#34;,&#34;name&#34;:&#34;Jordan&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Jord.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;JOR&#34;,&#34;iso-a2&#34;:&#34;JO&#34;,&#34;woe-id&#34;:&#34;23424860&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5291,7445],[5294,7448],[5291,7450],[5290,7451],[5291,7453],[5295,7453],[5295,7467],[5295,7496],[5301,7499],[5310,7492],[5320,7487],[5332,7485],[5390,7519],[5398,7491],[5398,7485],[5403,7486],[5401,7479],[5395,7475],[5336,7458],[5367,7426],[5357,7421],[5351,7410],[5330,7405],[5322,7394],[5309,7384],[5277,7389],[5279,7395],[5277,7396],[5283,7414],[5283,7424],[5291,7445]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MC&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.67,&#34;hc-key&#34;:&#34;mc&#34;,&#34;hc-a2&#34;:&#34;MC&#34;,&#34;name&#34;:&#34;Monaco&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Mco.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;MCO&#34;,&#34;iso-a2&#34;:&#34;MC&#34;,&#34;woe-id&#34;:&#34;23424892&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4467,7875],[4466,7874],[4465,7874],[4466,7875],[4467,7875]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AL&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.4,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;al&#34;,&#34;hc-a2&#34;:&#34;AL&#34;,&#34;name&#34;:&#34;Albania&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Alb.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;ALB&#34;,&#34;iso-a2&#34;:&#34;AL&#34;,&#34;woe-id&#34;:&#34;23424742&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4865,7774],[4865,7774],[4865,7774],[4865,7774]]],[[[4819,7816],[4818,7821],[4819,7824],[4828,7836],[4830,7830],[4839,7832],[4844,7824],[4852,7820],[4854,7808],[4850,7797],[4856,7780],[4856,7775],[4858,7774],[4862,7775],[4865,7774],[4864,7774],[4866,7773],[4866,7773],[4864,7770],[4866,7770],[4865,7769],[4867,7767],[4866,7766],[4867,7767],[4856,7746],[4846,7742],[4849,7737],[4842,7730],[4837,7732],[4833,7744],[4822,7750],[4822,7759],[4817,7765],[4823,7787],[4820,7792],[4824,7798],[4825,7806],[4818,7807],[4818,7811],[4819,7816]]],[[[4819,7823],[4818,7823],[4818,7823],[4819,7823]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;UY&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.74,&#34;hc-middle-y&#34;:0.9,&#34;hc-key&#34;:&#34;uy&#34;,&#34;hc-a2&#34;:&#34;UY&#34;,&#34;name&#34;:&#34;Uruguay&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Ury.&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;URY&#34;,&#34;iso-a2&#34;:&#34;UY&#34;,&#34;woe-id&#34;:&#34;23424979&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2683,5514],[2678,5505],[2669,5499],[2672,5485],[2672,5482],[2677,5479],[2665,5457],[2654,5448],[2630,5439],[2618,5444],[2603,5443],[2595,5439],[2589,5444],[2574,5448],[2565,5455],[2545,5455],[2538,5464],[2529,5472],[2528,5485],[2530,5498],[2538,5501],[2535,5521],[2538,5526],[2535,5539],[2541,5549],[2538,5553],[2543,5560],[2546,5571],[2545,5585],[2552,5594],[2554,5591],[2565,5592],[2568,5597],[2575,5597],[2593,5581],[2600,5573],[2599,5565],[2604,5566],[2611,5573],[2622,5560],[2640,5553],[2645,5546],[2654,5538],[2665,5534],[2669,5524],[2683,5514]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CNM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.65,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;cnm&#34;,&#34;hc-a2&#34;:&#34;CN&#34;,&#34;name&#34;:&#34;Cyprus No Mans Area&#34;,&#34;labelrank&#34;:&#34;9&#34;,&#34;country-abbrev&#34;:null,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;-99&#34;,&#34;iso-a2&#34;:null,&#34;woe-id&#34;:&#34;-99&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[5250,7575],[5250,7575],[5249,7575],[5246,7575],[5247,7576],[5250,7575]]],[[[5208,7579],[5208,7579],[5209,7579],[5209,7579],[5210,7579],[5209,7578],[5208,7579]]],[[[5211,7579],[5211,7579],[5215,7576],[5232,7580],[5240,7574],[5241,7573],[5241,7573],[5233,7573],[5232,7579],[5215,7575],[5211,7579]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.52,&#34;hc-key&#34;:&#34;mn&#34;,&#34;hc-a2&#34;:&#34;MN&#34;,&#34;name&#34;:&#34;Mongolia&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Mong.&#34;,&#34;subregion&#34;:&#34;Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;MNG&#34;,&#34;iso-a2&#34;:&#34;MN&#34;,&#34;woe-id&#34;:&#34;23424887&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[7708,8022],[7712,8018],[7719,8026],[7715,8030],[7728,8032],[7739,8029],[7745,8022],[7754,8018],[7756,8013],[7771,8001],[7778,7990],[7779,7983],[7772,7978],[7761,7979],[7747,7984],[7744,7981],[7730,7983],[7713,7975],[7705,7978],[7702,7969],[7688,7971],[7681,7968],[7670,7953],[7669,7946],[7654,7937],[7632,7934],[7621,7934],[7617,7927],[7605,7917],[7593,7911],[7578,7913],[7563,7917],[7558,7922],[7546,7923],[7538,7919],[7529,7900],[7535,7886],[7541,7882],[7544,7873],[7533,7866],[7516,7859],[7499,7840],[7477,7832],[7472,7829],[7452,7827],[7433,7829],[7392,7823],[7346,7804],[7340,7798],[7325,7801],[7325,7808],[7302,7804],[7283,7813],[7252,7819],[7241,7831],[7228,7831],[7193,7837],[7177,7833],[7110,7841],[7085,7838],[7084,7845],[7071,7857],[7060,7883],[7055,7884],[7057,7894],[7046,7893],[7026,7902],[7021,7908],[7014,7908],[7002,7918],[6979,7921],[6963,7920],[6958,7923],[6943,7923],[6941,7925],[6924,7927],[6917,7938],[6919,7947],[6928,7957],[6925,7968],[6929,7977],[6924,7991],[6919,7994],[6912,8005],[6908,8018],[6901,8022],[6899,8026],[6891,8024],[6886,8031],[6870,8030],[6857,8038],[6856,8044],[6838,8053],[6841,8056],[6832,8063],[6836,8067],[6834,8075],[6844,8079],[6845,8086],[6857,8087],[6865,8085],[6889,8096],[6887,8103],[6897,8105],[6899,8109],[6918,8115],[6927,8123],[6940,8124],[6950,8133],[6962,8133],[6968,8140],[6976,8133],[6985,8137],[6987,8131],[7023,8128],[7026,8115],[7034,8107],[7043,8108],[7048,8105],[7060,8102],[7071,8107],[7085,8102],[7103,8102],[7114,8096],[7121,8103],[7129,8104],[7137,8109],[7142,8127],[7135,8131],[7133,8139],[7128,8145],[7135,8163],[7140,8164],[7143,8173],[7154,8177],[7160,8189],[7173,8182],[7184,8180],[7193,8174],[7208,8174],[7232,8163],[7238,8164],[7257,8157],[7259,8131],[7269,8123],[7289,8114],[7301,8112],[7316,8113],[7322,8118],[7349,8125],[7369,8122],[7376,8118],[7389,8119],[7405,8106],[7427,8104],[7426,8094],[7444,8081],[7462,8082],[7492,8075],[7498,8078],[7509,8074],[7526,8082],[7547,8084],[7560,8089],[7567,8087],[7577,8091],[7581,8099],[7592,8107],[7613,8117],[7627,8116],[7646,8102],[7655,8102],[7670,8107],[7684,8100],[7658,8050],[7658,8041],[7649,8036],[7651,8028],[7659,8020],[7671,8026],[7689,8026],[7702,8018],[7708,8022]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;RW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.55,&#34;hc-key&#34;:&#34;rw&#34;,&#34;hc-a2&#34;:&#34;RW&#34;,&#34;name&#34;:&#34;Rwanda&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Rwa.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;RWA&#34;,&#34;iso-a2&#34;:&#34;RW&#34;,&#34;woe-id&#34;:&#34;23424937&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5103,6426],[5099,6428],[5098,6433],[5113,6446],[5109,6456],[5112,6461],[5119,6465],[5126,6466],[5130,6462],[5136,6466],[5141,6474],[5145,6474],[5148,6467],[5156,6458],[5156,6437],[5148,6435],[5143,6438],[5135,6434],[5130,6437],[5129,6427],[5123,6423],[5112,6422],[5105,6429],[5103,6426]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.27,&#34;hc-middle-y&#34;:0.67,&#34;hc-key&#34;:&#34;cm&#34;,&#34;hc-a2&#34;:&#34;CM&#34;,&#34;name&#34;:&#34;Cameroon&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Cam.&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;CMR&#34;,&#34;iso-a2&#34;:&#34;CM&#34;,&#34;woe-id&#34;:&#34;23424785&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4640,6568],[4638,6572],[4624,6571],[4611,6573],[4582,6572],[4582,6568],[4542,6568],[4537,6574],[4540,6600],[4532,6609],[4532,6618],[4536,6621],[4526,6623],[4522,6620],[4513,6625],[4510,6639],[4499,6638],[4501,6646],[4507,6656],[4510,6669],[4509,6676],[4523,6690],[4534,6696],[4536,6704],[4547,6710],[4549,6707],[4557,6706],[4560,6714],[4574,6701],[4575,6694],[4582,6694],[4587,6699],[4589,6707],[4598,6714],[4594,6718],[4602,6727],[4607,6738],[4608,6750],[4625,6763],[4627,6780],[4637,6785],[4638,6801],[4644,6803],[4647,6817],[4653,6829],[4660,6836],[4665,6835],[4678,6843],[4676,6849],[4680,6863],[4675,6868],[4666,6869],[4662,6890],[4670,6890],[4668,6884],[4675,6887],[4677,6880],[4685,6877],[4687,6862],[4691,6860],[4694,6844],[4691,6834],[4692,6822],[4699,6808],[4710,6798],[4683,6796],[4666,6798],[4659,6788],[4671,6774],[4695,6754],[4703,6735],[4706,6733],[4704,6726],[4696,6717],[4691,6704],[4682,6688],[4672,6682],[4679,6673],[4676,6659],[4680,6656],[4682,6640],[4690,6634],[4691,6623],[4695,6615],[4713,6596],[4722,6588],[4722,6579],[4725,6571],[4721,6563],[4724,6556],[4712,6561],[4697,6565],[4687,6564],[4677,6570],[4668,6568],[4640,6568]]],[[[4671,6890],[4672,6889],[4671,6890],[4671,6890]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.15,&#34;hc-middle-y&#34;:0.78,&#34;hc-key&#34;:&#34;cg&#34;,&#34;hc-a2&#34;:&#34;CG&#34;,&#34;name&#34;:&#34;Republic of Congo&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Rep. Congo&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;COG&#34;,&#34;iso-a2&#34;:&#34;CG&#34;,&#34;woe-id&#34;:&#34;23424779&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4640,6568],[4668,6568],[4677,6570],[4687,6564],[4697,6565],[4712,6561],[4724,6556],[4721,6563],[4725,6571],[4733,6588],[4736,6606],[4759,6611],[4762,6614],[4774,6609],[4792,6611],[4797,6607],[4796,6597],[4780,6568],[4780,6550],[4774,6535],[4777,6516],[4770,6499],[4771,6490],[4758,6475],[4749,6473],[4744,6468],[4734,6450],[4726,6443],[4725,6421],[4726,6408],[4717,6390],[4706,6386],[4696,6378],[4685,6364],[4672,6362],[4672,6380],[4659,6373],[4652,6375],[4652,6368],[4643,6362],[4633,6369],[4624,6377],[4620,6372],[4613,6370],[4602,6358],[4596,6365],[4596,6371],[4575,6390],[4578,6397],[4586,6402],[4597,6397],[4600,6408],[4592,6412],[4595,6417],[4591,6422],[4589,6437],[4594,6434],[4615,6437],[4614,6450],[4625,6449],[4632,6437],[4645,6434],[4653,6444],[4657,6432],[4663,6432],[4668,6447],[4672,6450],[4674,6469],[4672,6476],[4675,6488],[4663,6497],[4655,6499],[4657,6511],[4663,6521],[4667,6521],[4674,6532],[4668,6544],[4654,6547],[4638,6541],[4635,6552],[4640,6568]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;EH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.41,&#34;hc-middle-y&#34;:0.71,&#34;hc-key&#34;:&#34;eh&#34;,&#34;hc-a2&#34;:&#34;EH&#34;,&#34;name&#34;:&#34;Western Sahara&#34;,&#34;labelrank&#34;:&#34;7&#34;,&#34;country-abbrev&#34;:&#34;W. Sah.&#34;,&#34;subregion&#34;:&#34;Northern Africa&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;ESH&#34;,&#34;iso-a2&#34;:&#34;EH&#34;,&#34;woe-id&#34;:&#34;23424990&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3746,7121],[3745,7124],[3747,7141],[3756,7143],[3785,7144],[3811,7142],[3816,7147],[3817,7155],[3830,7169],[3831,7183],[3835,7203],[3843,7214],[3856,7220],[3864,7233],[3882,7247],[3886,7255],[3894,7284],[3903,7287],[3914,7303],[3913,7311],[3927,7315],[3938,7314],[3946,7310],[3962,7310],[3971,7317],[3989,7318],[3989,7336],[3993,7336],[3993,7324],[3992,7283],[3894,7283],[3894,7204],[3877,7198],[3865,7191],[3861,7182],[3863,7174],[3865,7139],[3749,7139],[3746,7121]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;RS&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.45,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;rs&#34;,&#34;hc-a2&#34;:&#34;RS&#34;,&#34;name&#34;:&#34;Republic of Serbia&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Serb.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;SRB&#34;,&#34;iso-a2&#34;:&#34;RS&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4808,7915],[4812,7918],[4809,7925],[4819,7926],[4807,7934],[4808,7941],[4803,7950],[4805,7954],[4815,7956],[4824,7963],[4844,7960],[4848,7956],[4860,7947],[4860,7938],[4866,7932],[4881,7925],[4877,7920],[4882,7916],[4878,7912],[4886,7909],[4896,7908],[4900,7902],[4909,7910],[4919,7905],[4910,7900],[4916,7892],[4908,7884],[4906,7877],[4911,7865],[4918,7862],[4924,7852],[4917,7844],[4909,7841],[4911,7827],[4906,7824],[4894,7824],[4883,7821],[4889,7836],[4878,7839],[4869,7851],[4860,7857],[4847,7842],[4835,7852],[4825,7854],[4813,7867],[4822,7868],[4821,7875],[4814,7882],[4826,7885],[4812,7894],[4811,7903],[4819,7916],[4808,7915]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ME&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.42,&#34;hc-middle-y&#34;:0.47,&#34;hc-key&#34;:&#34;me&#34;,&#34;hc-a2&#34;:&#34;ME&#34;,&#34;name&#34;:&#34;Montenegro&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Mont.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;MNE&#34;,&#34;iso-a2&#34;:&#34;ME&#34;,&#34;woe-id&#34;:&#34;20069817&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4839,7832],[4830,7830],[4828,7836],[4819,7824],[4819,7823],[4818,7823],[4812,7822],[4819,7816],[4818,7811],[4818,7807],[4801,7822],[4797,7829],[4793,7827],[4791,7830],[4791,7832],[4794,7835],[4792,7848],[4797,7849],[4798,7856],[4805,7860],[4805,7866],[4813,7867],[4825,7854],[4835,7852],[4847,7842],[4838,7838],[4839,7832]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BJ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.57,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;bj&#34;,&#34;hc-a2&#34;:&#34;BJ&#34;,&#34;name&#34;:&#34;Benin&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Benin&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;BEN&#34;,&#34;iso-a2&#34;:&#34;BJ&#34;,&#34;woe-id&#34;:&#34;23424764&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4328,6692],[4304,6689],[4296,6687],[4301,6689],[4294,6701],[4296,6710],[4295,6771],[4287,6784],[4287,6798],[4271,6810],[4275,6828],[4291,6842],[4295,6840],[4307,6841],[4316,6848],[4319,6855],[4318,6865],[4332,6870],[4354,6849],[4350,6841],[4356,6832],[4361,6816],[4353,6807],[4356,6803],[4352,6794],[4340,6783],[4339,6772],[4330,6771],[4329,6745],[4327,6737],[4330,6711],[4328,6710],[4328,6692]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.33,&#34;hc-key&#34;:&#34;ng&#34;,&#34;hc-a2&#34;:&#34;NG&#34;,&#34;name&#34;:&#34;Nigeria&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Nigeria&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;NGA&#34;,&#34;iso-a2&#34;:&#34;NG&#34;,&#34;woe-id&#34;:&#34;23424908&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4328,6692],[4328,6710],[4330,6711],[4327,6737],[4329,6745],[4330,6771],[4339,6772],[4340,6783],[4352,6794],[4356,6803],[4353,6807],[4361,6816],[4356,6832],[4350,6841],[4354,6849],[4355,6873],[4364,6880],[4369,6887],[4370,6902],[4379,6908],[4390,6910],[4402,6910],[4411,6914],[4429,6907],[4436,6906],[4452,6887],[4466,6891],[4479,6898],[4487,6896],[4504,6885],[4521,6882],[4532,6882],[4546,6895],[4563,6899],[4585,6898],[4603,6891],[4615,6889],[4618,6895],[4628,6902],[4638,6904],[4641,6909],[4649,6908],[4662,6890],[4666,6869],[4675,6868],[4680,6863],[4676,6849],[4678,6843],[4665,6835],[4660,6836],[4653,6829],[4647,6817],[4644,6803],[4638,6801],[4637,6785],[4627,6780],[4625,6763],[4608,6750],[4607,6738],[4602,6727],[4594,6718],[4598,6714],[4589,6707],[4587,6699],[4582,6694],[4575,6694],[4574,6701],[4560,6714],[4557,6706],[4549,6707],[4547,6710],[4536,6704],[4534,6696],[4523,6690],[4509,6676],[4510,6669],[4507,6656],[4501,6646],[4496,6644],[4491,6650],[4493,6638],[4471,6638],[4463,6640],[4450,6634],[4430,6630],[4422,6633],[4413,6641],[4403,6664],[4392,6681],[4378,6691],[4362,6693],[4350,6693],[4359,6699],[4348,6697],[4348,6692],[4328,6692]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.7,&#34;hc-middle-y&#34;:0.8100000000000001,&#34;hc-key&#34;:&#34;tg&#34;,&#34;hc-a2&#34;:&#34;TG&#34;,&#34;name&#34;:&#34;Togo&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Togo&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;TGO&#34;,&#34;iso-a2&#34;:&#34;TG&#34;,&#34;woe-id&#34;:&#34;23424965&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4275,6828],[4271,6810],[4287,6798],[4287,6784],[4295,6771],[4296,6710],[4294,6701],[4301,6689],[4296,6687],[4290,6686],[4283,6684],[4270,6694],[4263,6706],[4267,6720],[4263,6722],[4266,6731],[4265,6746],[4269,6748],[4259,6762],[4264,6781],[4255,6786],[4258,6791],[4259,6805],[4246,6817],[4249,6830],[4243,6832],[4263,6828],[4275,6828]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AF&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.38,&#34;hc-middle-y&#34;:0.53,&#34;hc-key&#34;:&#34;af&#34;,&#34;hc-a2&#34;:&#34;AF&#34;,&#34;name&#34;:&#34;Afghanistan&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Afg.&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;AFG&#34;,&#34;iso-a2&#34;:&#34;AF&#34;,&#34;woe-id&#34;:&#34;23424739&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6453,7648],[6448,7650],[6438,7645],[6443,7641],[6430,7635],[6422,7636],[6403,7636],[6385,7634],[6360,7620],[6357,7622],[6344,7608],[6349,7605],[6356,7592],[6354,7583],[6358,7580],[6353,7572],[6347,7569],[6338,7556],[6342,7552],[6341,7542],[6325,7538],[6309,7542],[6305,7538],[6312,7531],[6318,7518],[6306,7510],[6296,7510],[6292,7496],[6287,7488],[6289,7473],[6281,7464],[6274,7462],[6270,7467],[6265,7466],[6254,7469],[6252,7465],[6241,7459],[6243,7453],[6231,7449],[6219,7452],[6212,7449],[6208,7442],[6202,7440],[6199,7429],[6201,7418],[6197,7405],[6163,7395],[6147,7396],[6135,7390],[6120,7394],[6088,7391],[6040,7406],[6068,7437],[6069,7443],[6065,7454],[6039,7458],[6039,7483],[6031,7509],[6040,7526],[6030,7528],[6029,7543],[6034,7550],[6041,7551],[6035,7557],[6043,7561],[6049,7577],[6048,7583],[6052,7594],[6060,7588],[6074,7588],[6082,7578],[6086,7583],[6092,7581],[6106,7588],[6109,7597],[6106,7602],[6113,7602],[6129,7608],[6147,7616],[6151,7630],[6156,7638],[6155,7643],[6164,7648],[6177,7648],[6184,7660],[6200,7651],[6207,7653],[6221,7653],[6229,7646],[6236,7650],[6244,7647],[6251,7638],[6270,7650],[6279,7651],[6287,7644],[6293,7648],[6291,7655],[6295,7660],[6307,7661],[6313,7658],[6318,7664],[6314,7672],[6323,7678],[6327,7686],[6339,7690],[6349,7684],[6346,7672],[6356,7671],[6351,7643],[6357,7630],[6363,7630],[6376,7639],[6388,7641],[6391,7648],[6406,7656],[6420,7655],[6419,7648],[6437,7654],[6447,7654],[6453,7648]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;UA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.7,&#34;hc-middle-y&#34;:0.47,&#34;hc-key&#34;:&#34;ua&#34;,&#34;hc-a2&#34;:&#34;UA&#34;,&#34;name&#34;:&#34;Ukraine&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Ukr.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;UKR&#34;,&#34;iso-a2&#34;:&#34;UA&#34;,&#34;woe-id&#34;:&#34;23424976&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4900,8046],[4900,8052],[4905,8056],[4912,8071],[4921,8068],[4917,8075],[4915,8089],[4928,8105],[4947,8122],[4954,8122],[4958,8127],[4954,8138],[4959,8140],[4952,8146],[4944,8158],[4943,8165],[4948,8170],[4954,8168],[4966,8180],[4988,8182],[5007,8182],[5026,8178],[5039,8174],[5048,8174],[5051,8168],[5069,8169],[5075,8167],[5080,8170],[5082,8166],[5095,8164],[5104,8170],[5112,8159],[5121,8164],[5127,8162],[5136,8164],[5148,8155],[5151,8160],[5147,8167],[5151,8177],[5159,8187],[5175,8189],[5183,8188],[5187,8186],[5197,8188],[5201,8197],[5217,8194],[5225,8199],[5236,8196],[5244,8198],[5251,8191],[5252,8182],[5262,8174],[5252,8171],[5258,8160],[5255,8155],[5267,8154],[5269,8152],[5281,8153],[5293,8132],[5292,8125],[5298,8120],[5311,8123],[5316,8117],[5327,8115],[5335,8120],[5350,8123],[5355,8114],[5367,8103],[5372,8109],[5387,8105],[5395,8099],[5402,8101],[5404,8097],[5413,8096],[5420,8089],[5426,8092],[5430,8078],[5424,8070],[5417,8069],[5419,8064],[5426,8064],[5417,8059],[5415,8053],[5421,8052],[5425,8040],[5421,8035],[5419,8024],[5392,8025],[5389,8019],[5377,8016],[5373,8005],[5373,7997],[5355,7997],[5348,7989],[5344,7991],[5314,7981],[5305,7981],[5290,7970],[5285,7971],[5273,7963],[5275,7954],[5289,7934],[5293,7931],[5312,7937],[5325,7936],[5321,7928],[5322,7923],[5315,7920],[5304,7920],[5296,7924],[5291,7922],[5281,7913],[5272,7913],[5263,7910],[5259,7904],[5248,7898],[5241,7898],[5231,7905],[5235,7907],[5238,7918],[5236,7923],[5228,7926],[5217,7933],[5206,7932],[5206,7937],[5216,7943],[5243,7954],[5229,7961],[5217,7961],[5221,7957],[5205,7959],[5183,7965],[5194,7964],[5185,7969],[5191,7973],[5178,7977],[5200,7974],[5202,7977],[5195,7977],[5189,7986],[5187,7980],[5166,7980],[5154,7975],[5155,7973],[5146,7959],[5126,7942],[5121,7949],[5120,7937],[5124,7936],[5122,7928],[5121,7933],[5112,7936],[5096,7929],[5082,7932],[5079,7937],[5087,7939],[5087,7944],[5101,7957],[5103,7963],[5101,7973],[5108,7976],[5108,7970],[5116,7974],[5120,7970],[5123,7974],[5126,7969],[5134,7970],[5129,7976],[5129,7986],[5119,7991],[5118,8005],[5114,8004],[5106,8013],[5109,8026],[5101,8028],[5096,8035],[5083,8040],[5075,8040],[5065,8048],[5058,8048],[5049,8044],[5038,8045],[5032,8040],[5023,8039],[5019,8030],[4992,8027],[4981,8020],[4974,8027],[4962,8027],[4948,8030],[4936,8030],[4930,8034],[4922,8029],[4918,8035],[4914,8034],[4900,8046]],[[5135,7970],[5144,7960],[5146,7962],[5138,7971],[5135,7970]],[[5249,7960],[5278,7944],[5282,7932],[5291,7929],[5279,7945],[5273,7958],[5255,7967],[5240,7965],[5249,7957],[5249,7960]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SK&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.78,&#34;hc-middle-y&#34;:0.28,&#34;hc-key&#34;:&#34;sk&#34;,&#34;hc-a2&#34;:&#34;SK&#34;,&#34;name&#34;:&#34;Slovakia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Svk.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;SVK&#34;,&#34;iso-a2&#34;:&#34;SK&#34;,&#34;woe-id&#34;:&#34;23424877&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4912,8071],[4905,8056],[4900,8052],[4900,8046],[4889,8043],[4879,8052],[4870,8049],[4861,8052],[4851,8051],[4845,8040],[4835,8036],[4823,8038],[4822,8035],[4803,8032],[4802,8024],[4785,8021],[4773,8021],[4759,8031],[4753,8031],[4744,8044],[4747,8053],[4752,8062],[4765,8061],[4775,8066],[4781,8072],[4784,8079],[4794,8087],[4803,8088],[4807,8083],[4813,8084],[4821,8091],[4826,8084],[4830,8083],[4832,8076],[4839,8075],[4846,8083],[4857,8084],[4864,8079],[4874,8086],[4891,8083],[4896,8076],[4912,8071]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;JK&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.4,&#34;hc-middle-y&#34;:0.63,&#34;hc-key&#34;:&#34;jk&#34;,&#34;hc-a2&#34;:&#34;JK&#34;,&#34;name&#34;:&#34;Siachen Glacier&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Siachen&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;-99&#34;,&#34;iso-a2&#34;:&#34;JK&#34;,&#34;woe-id&#34;:&#34;23424928&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6539,7590],[6517,7577],[6509,7595],[6527,7589],[6539,7590]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.76,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;bg&#34;,&#34;hc-a2&#34;:&#34;BG&#34;,&#34;name&#34;:&#34;Bulgaria&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Bulg.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;BGR&#34;,&#34;iso-a2&#34;:&#34;BG&#34;,&#34;woe-id&#34;:&#34;23424771&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5090,7875],[5090,7867],[5087,7861],[5076,7862],[5069,7849],[5069,7838],[5065,7838],[5057,7830],[5064,7828],[5073,7812],[5059,7809],[5053,7815],[5045,7816],[5032,7811],[5024,7803],[5015,7802],[5017,7790],[5001,7789],[4991,7786],[4981,7792],[4978,7790],[4970,7797],[4956,7796],[4943,7791],[4923,7789],[4926,7803],[4921,7813],[4912,7817],[4906,7824],[4911,7827],[4909,7841],[4917,7844],[4924,7852],[4918,7862],[4911,7865],[4906,7877],[4908,7884],[4916,7892],[4926,7887],[4923,7878],[4935,7880],[4960,7875],[4969,7877],[4995,7871],[5007,7874],[5018,7884],[5044,7890],[5055,7884],[5070,7884],[5072,7878],[5090,7875]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;QA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;qa&#34;,&#34;hc-a2&#34;:&#34;QA&#34;,&#34;name&#34;:&#34;Qatar&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Qatar&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;QAT&#34;,&#34;iso-a2&#34;:&#34;QA&#34;,&#34;woe-id&#34;:&#34;23424930&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5744,7244],[5743,7267],[5745,7267],[5747,7277],[5751,7285],[5757,7288],[5767,7280],[5764,7268],[5768,7261],[5767,7251],[5763,7242],[5756,7240],[5749,7239],[5744,7244]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LI&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.61,&#34;hc-middle-y&#34;:0.53,&#34;hc-key&#34;:&#34;li&#34;,&#34;hc-a2&#34;:&#34;LI&#34;,&#34;name&#34;:&#34;Liechtenstein&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Liech.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;LIE&#34;,&#34;iso-a2&#34;:&#34;LI&#34;,&#34;woe-id&#34;:&#34;23424879&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4529,8003],[4531,7997],[4530,7996],[4527,7996],[4529,8003]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.51,&#34;hc-middle-y&#34;:0.61,&#34;hc-key&#34;:&#34;at&#34;,&#34;hc-a2&#34;:&#34;AT&#34;,&#34;name&#34;:&#34;Austria&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Aust.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;AUT&#34;,&#34;iso-a2&#34;:&#34;AT&#34;,&#34;woe-id&#34;:&#34;23424750&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4530,7996],[4531,7997],[4529,8003],[4532,8009],[4530,8012],[4533,8012],[4534,8014],[4541,8014],[4547,8003],[4556,8010],[4555,8015],[4568,8012],[4572,8008],[4583,8010],[4590,8015],[4607,8016],[4607,8020],[4632,8012],[4633,8018],[4628,8020],[4631,8025],[4623,8035],[4643,8045],[4646,8053],[4652,8050],[4655,8060],[4663,8053],[4674,8055],[4681,8053],[4684,8060],[4688,8059],[4689,8067],[4698,8068],[4722,8059],[4732,8061],[4745,8058],[4747,8053],[4744,8044],[4753,8031],[4751,8020],[4743,8019],[4736,8022],[4731,8018],[4738,8017],[4738,8010],[4732,8006],[4732,7994],[4722,7988],[4720,7982],[4709,7983],[4704,7979],[4692,7980],[4685,7979],[4676,7970],[4672,7973],[4652,7976],[4638,7977],[4613,7982],[4605,7990],[4608,7996],[4594,7992],[4577,7992],[4572,7985],[4556,7988],[4554,7993],[4546,7988],[4538,7994],[4530,7996]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.52,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;sz&#34;,&#34;hc-a2&#34;:&#34;SZ&#34;,&#34;name&#34;:&#34;Eswatini&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Swz.&#34;,&#34;subregion&#34;:&#34;Southern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;SWZ&#34;,&#34;iso-a2&#34;:&#34;SZ&#34;,&#34;woe-id&#34;:&#34;23424993&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5189,5728],[5193,5727],[5192,5718],[5194,5701],[5190,5702],[5190,5686],[5176,5686],[5165,5689],[5155,5702],[5155,5714],[5165,5730],[5174,5735],[5186,5728],[5189,5728]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;HU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.27,&#34;hc-middle-y&#34;:0.59,&#34;hc-key&#34;:&#34;hu&#34;,&#34;hc-a2&#34;:&#34;HU&#34;,&#34;name&#34;:&#34;Hungary&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Hun.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;HUN&#34;,&#34;iso-a2&#34;:&#34;HU&#34;,&#34;woe-id&#34;:&#34;23424844&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4900,8046],[4914,8034],[4918,8035],[4922,8029],[4913,8022],[4904,8020],[4896,8012],[4881,7983],[4876,7979],[4871,7967],[4861,7966],[4855,7961],[4844,7960],[4824,7963],[4815,7956],[4805,7954],[4798,7953],[4790,7947],[4768,7951],[4759,7955],[4744,7971],[4735,7975],[4727,7988],[4722,7988],[4732,7994],[4732,8006],[4738,8010],[4738,8017],[4731,8018],[4736,8022],[4743,8019],[4751,8020],[4753,8031],[4759,8031],[4773,8021],[4785,8021],[4802,8024],[4803,8032],[4822,8035],[4823,8038],[4835,8036],[4845,8040],[4851,8051],[4861,8052],[4870,8049],[4879,8052],[4889,8043],[4900,8046]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;RO&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.67,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;ro&#34;,&#34;hc-a2&#34;:&#34;RO&#34;,&#34;name&#34;:&#34;Romania&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Rom.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;ROU&#34;,&#34;iso-a2&#34;:&#34;RO&#34;,&#34;woe-id&#34;:&#34;23424933&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4844,7960],[4855,7961],[4861,7966],[4871,7967],[4876,7979],[4881,7983],[4896,8012],[4904,8020],[4913,8022],[4922,8029],[4930,8034],[4936,8030],[4948,8030],[4962,8027],[4974,8027],[4981,8020],[4992,8027],[5019,8030],[5023,8039],[5032,8040],[5043,8037],[5048,8030],[5052,8018],[5067,7999],[5073,7995],[5080,7979],[5080,7972],[5075,7957],[5079,7937],[5082,7932],[5096,7929],[5112,7936],[5121,7933],[5122,7928],[5118,7914],[5105,7912],[5102,7920],[5098,7918],[5099,7905],[5091,7895],[5092,7884],[5090,7875],[5072,7878],[5070,7884],[5055,7884],[5044,7890],[5018,7884],[5007,7874],[4995,7871],[4969,7877],[4960,7875],[4935,7880],[4923,7878],[4926,7887],[4916,7892],[4910,7900],[4919,7905],[4909,7910],[4900,7902],[4896,7908],[4886,7909],[4878,7912],[4882,7916],[4877,7920],[4881,7925],[4866,7932],[4860,7938],[4860,7947],[4848,7956],[4844,7960]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LU&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.59,&#34;hc-key&#34;:&#34;lu&#34;,&#34;hc-a2&#34;:&#34;LU&#34;,&#34;name&#34;:&#34;Luxembourg&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Lux.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;LUX&#34;,&#34;iso-a2&#34;:&#34;LU&#34;,&#34;woe-id&#34;:&#34;23424881&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4435,8086],[4424,8085],[4419,8089],[4422,8093],[4417,8102],[4425,8113],[4428,8111],[4431,8102],[4440,8099],[4435,8086]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;AD&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.58,&#34;hc-middle-y&#34;:0.28,&#34;hc-key&#34;:&#34;ad&#34;,&#34;hc-a2&#34;:&#34;AD&#34;,&#34;name&#34;:&#34;Andorra&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;And.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;AND&#34;,&#34;iso-a2&#34;:&#34;AD&#34;,&#34;woe-id&#34;:&#34;23424744&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4290,7834],[4299,7834],[4299,7830],[4293,7828],[4290,7834]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CI&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.78,&#34;hc-key&#34;:&#34;ci&#34;,&#34;hc-a2&#34;:&#34;CI&#34;,&#34;name&#34;:&#34;Ivory Coast&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;I.C.&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;CIV&#34;,&#34;iso-a2&#34;:&#34;CI&#34;,&#34;woe-id&#34;:&#34;23424854&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4026,6633],[4025,6654],[4030,6662],[4028,6675],[4021,6678],[4017,6687],[4008,6689],[3994,6695],[4002,6703],[4004,6714],[3998,6727],[4006,6726],[4010,6733],[4010,6744],[4005,6747],[4007,6754],[4018,6754],[4023,6751],[4022,6758],[4014,6763],[4015,6769],[4020,6771],[4015,6774],[4017,6781],[4008,6785],[4008,6797],[4013,6803],[4023,6811],[4027,6812],[4031,6806],[4043,6804],[4043,6809],[4051,6809],[4053,6818],[4056,6815],[4064,6820],[4065,6806],[4071,6804],[4075,6809],[4086,6811],[4089,6807],[4098,6807],[4102,6796],[4110,6789],[4121,6787],[4122,6791],[4140,6797],[4154,6796],[4167,6781],[4169,6783],[4167,6771],[4171,6767],[4174,6746],[4167,6738],[4162,6727],[4159,6712],[4153,6706],[4155,6689],[4162,6669],[4166,6669],[4168,6662],[4165,6656],[4151,6655],[4130,6659],[4131,6658],[4086,6654],[4076,6652],[4045,6642],[4026,6633]],[[4130,6659],[4129,6660],[4127,6660],[4127,6660],[4127,6660],[4127,6660],[4121,6661],[4107,6657],[4127,6660],[4127,6660],[4127,6660],[4127,6660],[4130,6659]]],[[[4156,6654],[4152,6655],[4157,6655],[4156,6654]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.9399999999999999,&#34;hc-middle-y&#34;:0.74,&#34;hc-key&#34;:&#34;lr&#34;,&#34;hc-a2&#34;:&#34;LR&#34;,&#34;name&#34;:&#34;Liberia&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Liberia&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;LBR&#34;,&#34;iso-a2&#34;:&#34;LR&#34;,&#34;woe-id&#34;:&#34;23424876&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3998,6727],[4004,6714],[4002,6703],[3994,6695],[4008,6689],[4017,6687],[4021,6678],[4028,6675],[4030,6662],[4025,6654],[4026,6633],[4005,6639],[3975,6656],[3968,6663],[3944,6685],[3931,6689],[3930,6694],[3914,6701],[3910,6708],[3913,6714],[3936,6733],[3936,6741],[3944,6745],[3945,6754],[3952,6752],[3959,6754],[3969,6750],[3968,6745],[3973,6728],[3970,6723],[3976,6721],[3980,6716],[3987,6720],[3992,6731],[3998,6727]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.51,&#34;hc-middle-y&#34;:0.57,&#34;hc-key&#34;:&#34;bn&#34;,&#34;hc-a2&#34;:&#34;BN&#34;,&#34;name&#34;:&#34;Brunei&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Brunei&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;BRN&#34;,&#34;iso-a2&#34;:&#34;BN&#34;,&#34;woe-id&#34;:&#34;23424773&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[7635,6646],[7638,6647],[7639,6649],[7644,6631],[7637,6634],[7635,6646]]],[[[7605,6640],[7620,6642],[7636,6653],[7634,6648],[7627,6644],[7630,6635],[7623,6623],[7612,6636],[7605,6640]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.51,&#34;hc-middle-y&#34;:0.37,&#34;hc-key&#34;:&#34;be&#34;,&#34;hc-a2&#34;:&#34;BE&#34;,&#34;name&#34;:&#34;Belgium&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Belg.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;BEL&#34;,&#34;iso-a2&#34;:&#34;BE&#34;,&#34;woe-id&#34;:&#34;23424757&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4428,8111],[4425,8113],[4417,8102],[4422,8093],[4419,8089],[4409,8087],[4389,8105],[4391,8112],[4379,8104],[4370,8106],[4372,8116],[4366,8120],[4356,8119],[4356,8124],[4345,8127],[4340,8137],[4333,8133],[4324,8139],[4322,8149],[4340,8158],[4347,8160],[4348,8155],[4355,8157],[4360,8153],[4373,8160],[4375,8157],[4374,8160],[4388,8164],[4396,8164],[4402,8155],[4409,8156],[4420,8151],[4416,8136],[4425,8136],[4436,8118],[4428,8111]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;IQ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.46,&#34;hc-middle-y&#34;:0.44,&#34;hc-key&#34;:&#34;iq&#34;,&#34;hc-a2&#34;:&#34;IQ&#34;,&#34;name&#34;:&#34;Iraq&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Iraq&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;IRQ&#34;,&#34;iso-a2&#34;:&#34;IQ&#34;,&#34;woe-id&#34;:&#34;23424855&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5677,7409],[5665,7412],[5660,7410],[5652,7413],[5643,7413],[5635,7409],[5628,7392],[5618,7381],[5613,7380],[5564,7385],[5510,7426],[5487,7445],[5438,7472],[5401,7479],[5403,7486],[5398,7485],[5398,7491],[5390,7519],[5446,7551],[5454,7553],[5461,7566],[5461,7579],[5466,7595],[5462,7609],[5467,7624],[5480,7627],[5495,7644],[5501,7645],[5506,7652],[5518,7653],[5528,7648],[5551,7648],[5551,7640],[5562,7646],[5566,7645],[5570,7641],[5568,7633],[5575,7629],[5573,7625],[5580,7621],[5583,7606],[5587,7607],[5594,7601],[5612,7600],[5604,7596],[5602,7590],[5608,7580],[5600,7576],[5592,7564],[5594,7558],[5588,7560],[5585,7555],[5590,7549],[5584,7539],[5595,7526],[5599,7528],[5608,7513],[5606,7506],[5611,7506],[5624,7499],[5635,7490],[5644,7488],[5647,7480],[5657,7467],[5652,7455],[5652,7442],[5662,7442],[5662,7425],[5674,7417],[5677,7409]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.25,&#34;hc-middle-y&#34;:0.45,&#34;hc-key&#34;:&#34;ge&#34;,&#34;hc-a2&#34;:&#34;GE&#34;,&#34;name&#34;:&#34;Georgia&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Geo.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;GEO&#34;,&#34;iso-a2&#34;:&#34;GE&#34;,&#34;woe-id&#34;:&#34;23424823&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5573,7788],[5560,7784],[5549,7786],[5537,7781],[5527,7781],[5508,7798],[5502,7798],[5499,7793],[5483,7795],[5479,7792],[5471,7796],[5478,7806],[5470,7835],[5460,7841],[5456,7848],[5437,7854],[5426,7862],[5428,7868],[5445,7867],[5472,7856],[5486,7855],[5497,7856],[5509,7854],[5519,7846],[5538,7839],[5542,7832],[5552,7837],[5568,7839],[5579,7837],[5584,7831],[5595,7829],[5591,7821],[5601,7813],[5615,7809],[5608,7801],[5612,7795],[5623,7787],[5617,7779],[5609,7785],[5597,7785],[5595,7789],[5581,7793],[5573,7788]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GM&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.44,&#34;hc-key&#34;:&#34;gm&#34;,&#34;hc-a2&#34;:&#34;GM&#34;,&#34;name&#34;:&#34;Gambia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Gambia&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;GMB&#34;,&#34;iso-a2&#34;:&#34;GM&#34;,&#34;woe-id&#34;:&#34;23424821&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3755,6889],[3753,6898],[3757,6902],[3761,6896],[3761,6905],[3791,6905],[3795,6910],[3810,6911],[3814,6906],[3820,6907],[3825,6901],[3836,6905],[3840,6897],[3825,6894],[3814,6898],[3803,6905],[3800,6900],[3782,6897],[3782,6892],[3757,6892],[3755,6889]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CH&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.87,&#34;hc-middle-y&#34;:0.52,&#34;hc-key&#34;:&#34;ch&#34;,&#34;hc-a2&#34;:&#34;CH&#34;,&#34;name&#34;:&#34;Switzerland&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Switz.&#34;,&#34;subregion&#34;:&#34;Western Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;CHE&#34;,&#34;iso-a2&#34;:&#34;CH&#34;,&#34;woe-id&#34;:&#34;23424957&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4519,8018],[4519,8018],[4519,8018],[4519,8018],[4528,8012],[4530,8012],[4532,8009],[4529,8003],[4527,7996],[4530,7996],[4538,7994],[4546,7988],[4554,7993],[4556,7988],[4556,7976],[4545,7979],[4542,7970],[4529,7967],[4526,7975],[4521,7974],[4520,7965],[4510,7950],[4508,7959],[4496,7967],[4496,7973],[4486,7966],[4487,7961],[4479,7954],[4470,7956],[4459,7952],[4455,7954],[4448,7961],[4448,7972],[4443,7976],[4434,7973],[4432,7967],[4424,7961],[4429,7970],[4428,7978],[4438,7985],[4438,7991],[4443,7993],[4456,8006],[4450,8007],[4455,8012],[4465,8009],[4472,8015],[4497,8015],[4495,8019],[4502,8023],[4510,8018],[4519,8018]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TD&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.47,&#34;hc-middle-y&#34;:0.63,&#34;hc-key&#34;:&#34;td&#34;,&#34;hc-a2&#34;:&#34;TD&#34;,&#34;name&#34;:&#34;Chad&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Chad&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;TCD&#34;,&#34;iso-a2&#34;:&#34;TD&#34;,&#34;woe-id&#34;:&#34;23424777&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4675,6887],[4683,6890],[4676,6895],[4671,6890],[4671,6890],[4669,6892],[4670,6890],[4662,6890],[4649,6908],[4644,6929],[4654,6939],[4656,6948],[4671,6970],[4704,7005],[4712,7095],[4718,7108],[4707,7121],[4708,7127],[4695,7144],[4695,7159],[4689,7190],[4719,7204],[4954,7083],[4954,6969],[4928,6968],[4923,6963],[4923,6951],[4918,6947],[4916,6938],[4907,6933],[4912,6921],[4902,6916],[4898,6911],[4904,6897],[4895,6890],[4890,6881],[4897,6877],[4902,6880],[4909,6876],[4907,6872],[4914,6860],[4912,6848],[4914,6843],[4923,6840],[4924,6834],[4921,6826],[4909,6828],[4901,6823],[4888,6817],[4889,6811],[4867,6791],[4861,6781],[4853,6779],[4850,6773],[4840,6774],[4834,6770],[4811,6769],[4804,6765],[4811,6759],[4796,6741],[4768,6739],[4742,6726],[4735,6736],[4730,6730],[4712,6724],[4704,6726],[4706,6733],[4703,6735],[4695,6754],[4671,6774],[4659,6788],[4666,6798],[4683,6796],[4710,6798],[4699,6808],[4692,6822],[4691,6834],[4694,6844],[4691,6860],[4687,6862],[4685,6877],[4677,6880],[4675,6887]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KV&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.52,&#34;hc-key&#34;:&#34;kv&#34;,&#34;hc-a2&#34;:&#34;KV&#34;,&#34;name&#34;:&#34;Kosovo&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Kos.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;-99&#34;,&#34;iso-a2&#34;:&#34;KV&#34;,&#34;woe-id&#34;:&#34;-90&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4854,7808],[4852,7820],[4844,7824],[4839,7832],[4838,7838],[4847,7842],[4860,7857],[4869,7851],[4878,7839],[4889,7836],[4883,7821],[4874,7816],[4869,7820],[4860,7815],[4859,7809],[4854,7808]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LB&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.43,&#34;hc-middle-y&#34;:0.52,&#34;hc-key&#34;:&#34;lb&#34;,&#34;hc-a2&#34;:&#34;LB&#34;,&#34;name&#34;:&#34;Lebanon&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Leb.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;LBN&#34;,&#34;iso-a2&#34;:&#34;LB&#34;,&#34;woe-id&#34;:&#34;23424873&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5282,7510],[5287,7522],[5296,7537],[5298,7550],[5308,7558],[5307,7562],[5320,7560],[5326,7547],[5316,7537],[5310,7534],[5309,7527],[5303,7521],[5293,7510],[5282,7510]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;DJ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.54,&#34;hc-middle-y&#34;:0.55,&#34;hc-key&#34;:&#34;dj&#34;,&#34;hc-a2&#34;:&#34;DJ&#34;,&#34;name&#34;:&#34;Djibouti&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Dji.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;DJI&#34;,&#34;iso-a2&#34;:&#34;DJ&#34;,&#34;woe-id&#34;:&#34;23424797&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5512,6828],[5503,6831],[5483,6826],[5479,6831],[5481,6834],[5479,6837],[5477,6844],[5496,6872],[5505,6868],[5511,6876],[5518,6879],[5524,6872],[5527,6864],[5525,6857],[5508,6850],[5505,6844],[5519,6846],[5521,6843],[5512,6828]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BI&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5600000000000001,&#34;hc-middle-y&#34;:0.47,&#34;hc-key&#34;:&#34;bi&#34;,&#34;hc-a2&#34;:&#34;BI&#34;,&#34;name&#34;:&#34;Burundi&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Bur.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;BDI&#34;,&#34;iso-a2&#34;:&#34;BI&#34;,&#34;woe-id&#34;:&#34;23424774&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5121,6375],[5113,6391],[5112,6406],[5108,6408],[5109,6416],[5103,6426],[5105,6429],[5112,6422],[5123,6423],[5129,6427],[5130,6437],[5135,6434],[5143,6438],[5148,6435],[5144,6422],[5153,6418],[5156,6410],[5144,6401],[5132,6380],[5121,6375]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SR&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.91,&#34;hc-middle-y&#34;:0.1,&#34;hc-key&#34;:&#34;sr&#34;,&#34;hc-a2&#34;:&#34;SR&#34;,&#34;name&#34;:&#34;Suriname&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Sur.&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;SUR&#34;,&#34;iso-a2&#34;:&#34;SR&#34;,&#34;woe-id&#34;:&#34;23424913&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2585,6562],[2579,6564],[2565,6588],[2561,6604],[2551,6604],[2540,6622],[2539,6627],[2545,6641],[2543,6646],[2549,6651],[2562,6652],[2560,6661],[2563,6666],[2565,6672],[2568,6679],[2571,6681],[2601,6675],[2603,6680],[2624,6679],[2628,6681],[2644,6679],[2658,6676],[2653,6662],[2644,6649],[2648,6623],[2657,6611],[2658,6606],[2652,6597],[2653,6589],[2647,6578],[2640,6573],[2629,6580],[2608,6575],[2600,6579],[2597,6571],[2602,6565],[2599,6559],[2585,6562]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;IL&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.68,&#34;hc-middle-y&#34;:0.1,&#34;hc-key&#34;:&#34;il&#34;,&#34;hc-a2&#34;:&#34;IL&#34;,&#34;name&#34;:&#34;Israel&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Isr.&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;ISR&#34;,&#34;iso-a2&#34;:&#34;IL&#34;,&#34;woe-id&#34;:&#34;23424852&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5255,7452],[5263,7461],[5270,7473],[5274,7484],[5277,7501],[5282,7510],[5293,7510],[5303,7521],[5301,7518],[5305,7506],[5301,7499],[5295,7496],[5295,7467],[5290,7459],[5291,7453],[5290,7451],[5291,7450],[5289,7448],[5291,7445],[5283,7424],[5283,7414],[5277,7396],[5276,7394],[5275,7394],[5274,7402],[5255,7452]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ML&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.59,&#34;hc-middle-y&#34;:0.38,&#34;hc-key&#34;:&#34;ml&#34;,&#34;hc-a2&#34;:&#34;ML&#34;,&#34;name&#34;:&#34;Mali&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Mali&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;MLI&#34;,&#34;iso-a2&#34;:&#34;ML&#34;,&#34;woe-id&#34;:&#34;23424891&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4086,6811],[4075,6809],[4071,6804],[4065,6806],[4064,6820],[4056,6815],[4053,6818],[4051,6809],[4043,6809],[4043,6804],[4031,6806],[4027,6812],[4023,6811],[4013,6803],[4013,6808],[4006,6811],[4003,6821],[4004,6827],[3992,6828],[4002,6839],[3988,6848],[3989,6856],[3986,6859],[3983,6869],[3978,6872],[3963,6862],[3962,6859],[3946,6864],[3939,6861],[3933,6855],[3930,6861],[3923,6864],[3916,6858],[3910,6862],[3913,6870],[3911,6874],[3913,6885],[3908,6895],[3900,6897],[3892,6908],[3896,6915],[3895,6922],[3888,6929],[3887,6940],[3893,6939],[3900,6944],[3899,6953],[3903,6963],[3912,6965],[3927,6950],[3932,6960],[3951,6958],[3973,6962],[4086,6962],[4091,6986],[4083,6993],[4073,7083],[4054,7252],[4106,7252],[4282,7132],[4282,7121],[4294,7116],[4304,7105],[4313,7106],[4319,7100],[4335,7096],[4343,7092],[4344,7079],[4340,7072],[4347,7067],[4373,7072],[4373,7007],[4371,6990],[4368,6986],[4361,6968],[4352,6962],[4352,6958],[4338,6960],[4337,6957],[4287,6956],[4276,6947],[4268,6945],[4255,6947],[4255,6944],[4241,6949],[4227,6949],[4216,6941],[4198,6932],[4189,6931],[4186,6922],[4176,6926],[4165,6919],[4163,6907],[4152,6909],[4153,6896],[4144,6893],[4136,6898],[4128,6899],[4120,6891],[4124,6880],[4116,6879],[4119,6874],[4114,6862],[4108,6858],[4096,6856],[4092,6846],[4095,6841],[4091,6832],[4086,6830],[4088,6824],[4086,6811]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.23,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;sn&#34;,&#34;hc-a2&#34;:&#34;SN&#34;,&#34;name&#34;:&#34;Senegal&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Sen.&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;SEN&#34;,&#34;iso-a2&#34;:&#34;SN&#34;,&#34;woe-id&#34;:&#34;23424943&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3756,6868],[3754,6882],[3755,6889],[3757,6892],[3782,6892],[3782,6897],[3800,6900],[3803,6905],[3814,6898],[3825,6894],[3840,6897],[3836,6905],[3825,6901],[3820,6907],[3814,6906],[3810,6911],[3795,6910],[3791,6905],[3761,6905],[3757,6910],[3749,6929],[3741,6938],[3732,6940],[3744,6945],[3751,6954],[3761,6971],[3767,6991],[3787,6992],[3809,6996],[3826,6996],[3837,6987],[3841,6981],[3851,6982],[3856,6975],[3858,6966],[3867,6962],[3870,6954],[3881,6948],[3887,6940],[3888,6929],[3895,6922],[3896,6915],[3892,6908],[3900,6897],[3908,6895],[3913,6885],[3911,6874],[3913,6870],[3892,6870],[3884,6867],[3863,6873],[3863,6877],[3844,6878],[3801,6878],[3787,6871],[3771,6871],[3756,6868]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.54,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;gw&#34;,&#34;hc-a2&#34;:&#34;GW&#34;,&#34;name&#34;:&#34;Guinea Bissau&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;GnB.&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;GNB&#34;,&#34;iso-a2&#34;:&#34;GW&#34;,&#34;woe-id&#34;:&#34;23424929&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3756,6868],[3771,6871],[3787,6871],[3801,6878],[3844,6878],[3845,6866],[3837,6862],[3844,6858],[3844,6849],[3828,6848],[3815,6843],[3806,6827],[3800,6828],[3794,6838],[3782,6834],[3781,6830],[3772,6829],[3772,6835],[3780,6835],[3779,6846],[3781,6859],[3776,6851],[3768,6858],[3768,6863],[3756,6868]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;GN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.26,&#34;hc-middle-y&#34;:0.53,&#34;hc-key&#34;:&#34;gn&#34;,&#34;hc-a2&#34;:&#34;GN&#34;,&#34;name&#34;:&#34;Guinea&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Gin.&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;GIN&#34;,&#34;iso-a2&#34;:&#34;GN&#34;,&#34;woe-id&#34;:&#34;23424835&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3844,6878],[3863,6877],[3863,6873],[3884,6867],[3892,6870],[3913,6870],[3910,6862],[3916,6858],[3923,6864],[3930,6861],[3933,6855],[3939,6861],[3946,6864],[3962,6859],[3963,6862],[3978,6872],[3983,6869],[3986,6859],[3989,6856],[3988,6848],[4002,6839],[3992,6828],[4004,6827],[4003,6821],[4006,6811],[4013,6808],[4013,6803],[4008,6797],[4008,6785],[4017,6781],[4015,6774],[4020,6771],[4015,6769],[4014,6763],[4022,6758],[4023,6751],[4018,6754],[4007,6754],[4005,6747],[4010,6744],[4010,6733],[4006,6726],[3998,6727],[3992,6731],[3987,6720],[3980,6716],[3976,6721],[3970,6723],[3973,6728],[3968,6745],[3969,6750],[3959,6754],[3952,6752],[3945,6754],[3932,6748],[3940,6759],[3936,6771],[3932,6772],[3934,6778],[3917,6798],[3898,6798],[3891,6795],[3880,6794],[3874,6781],[3867,6777],[3865,6772],[3857,6770],[3848,6786],[3848,6792],[3841,6794],[3825,6805],[3820,6814],[3817,6813],[3810,6827],[3806,6827],[3815,6843],[3828,6848],[3844,6849],[3844,6858],[3837,6862],[3845,6866],[3844,6878]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;ZW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.44,&#34;hc-middle-y&#34;:0.63,&#34;hc-key&#34;:&#34;zw&#34;,&#34;hc-a2&#34;:&#34;ZW&#34;,&#34;name&#34;:&#34;Zimbabwe&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Zimb.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;ZWE&#34;,&#34;iso-a2&#34;:&#34;ZW&#34;,&#34;woe-id&#34;:&#34;23425004&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4992,5979],[5004,5979],[5013,5973],[5020,5976],[5034,5971],[5044,5974],[5054,5985],[5060,5989],[5064,5997],[5074,6001],[5076,6008],[5088,6011],[5097,6010],[5102,6015],[5095,6017],[5098,6032],[5108,6039],[5127,6045],[5143,6044],[5143,6033],[5169,6032],[5173,6028],[5182,6027],[5188,6020],[5199,6020],[5219,6013],[5215,6005],[5220,5992],[5218,5974],[5221,5962],[5216,5957],[5216,5949],[5211,5948],[5216,5939],[5213,5929],[5215,5922],[5221,5919],[5220,5911],[5209,5895],[5206,5895],[5205,5884],[5200,5878],[5202,5873],[5174,5842],[5169,5839],[5156,5842],[5141,5840],[5124,5847],[5112,5845],[5105,5849],[5104,5856],[5091,5862],[5074,5864],[5063,5880],[5064,5897],[5051,5897],[5049,5909],[5035,5914],[5018,5927],[5012,5945],[5007,5954],[4999,5961],[4991,5977],[4992,5979]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PL&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.51,&#34;hc-middle-y&#34;:0.27,&#34;hc-key&#34;:&#34;pl&#34;,&#34;hc-a2&#34;:&#34;PL&#34;,&#34;name&#34;:&#34;Poland&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Pol.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;POL&#34;,&#34;iso-a2&#34;:&#34;PL&#34;,&#34;woe-id&#34;:&#34;23424923&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4826,8282],[4814,8278],[4819,8275],[4830,8282],[4917,8278],[4919,8278],[4924,8280],[4939,8270],[4940,8262],[4943,8248],[4952,8230],[4951,8211],[4937,8204],[4930,8196],[4944,8188],[4942,8175],[4943,8165],[4944,8158],[4952,8146],[4959,8140],[4954,8138],[4958,8127],[4954,8122],[4947,8122],[4928,8105],[4915,8089],[4917,8075],[4921,8068],[4912,8071],[4896,8076],[4891,8083],[4874,8086],[4864,8079],[4857,8084],[4846,8083],[4839,8075],[4832,8076],[4830,8083],[4826,8084],[4821,8091],[4813,8084],[4807,8083],[4803,8088],[4796,8096],[4795,8103],[4779,8107],[4773,8106],[4766,8113],[4771,8115],[4759,8117],[4754,8121],[4745,8122],[4749,8115],[4740,8110],[4725,8123],[4732,8129],[4720,8130],[4713,8135],[4700,8137],[4698,8143],[4690,8146],[4689,8140],[4684,8140],[4690,8156],[4688,8163],[4682,8165],[4678,8177],[4683,8187],[4676,8201],[4679,8207],[4664,8218],[4671,8226],[4672,8235],[4668,8252],[4676,8250],[4679,8258],[4666,8259],[4666,8260],[4667,8262],[4672,8261],[4683,8265],[4723,8276],[4736,8287],[4747,8289],[4759,8294],[4775,8298],[4788,8298],[4795,8286],[4796,8282],[4808,8278],[4826,8283],[4826,8282]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MK&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;mk&#34;,&#34;hc-a2&#34;:&#34;MK&#34;,&#34;name&#34;:&#34;North Macedonia&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Mkd.&#34;,&#34;subregion&#34;:&#34;Southern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;MKD&#34;,&#34;iso-a2&#34;:&#34;MK&#34;,&#34;woe-id&#34;:&#34;23424890&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;MultiPolygon&#34;,&#34;coordinates&#34;:[[[[4866,7773],[4866,7773],[4866,7773],[4866,7773]]],[[[4906,7824],[4912,7817],[4921,7813],[4926,7803],[4923,7789],[4917,7783],[4902,7783],[4893,7781],[4889,7775],[4870,7772],[4866,7778],[4865,7774],[4865,7774],[4865,7774],[4862,7775],[4858,7774],[4861,7781],[4856,7780],[4850,7797],[4854,7808],[4859,7809],[4860,7815],[4869,7820],[4874,7816],[4883,7821],[4894,7824],[4906,7824]]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;PY&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;py&#34;,&#34;hc-a2&#34;:&#34;PY&#34;,&#34;name&#34;:&#34;Paraguay&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Para.&#34;,&#34;subregion&#34;:&#34;South America&#34;,&#34;region-wb&#34;:&#34;Latin America &amp; Caribbean&#34;,&#34;iso-a3&#34;:&#34;PRY&#34;,&#34;iso-a2&#34;:&#34;PY&#34;,&#34;woe-id&#34;:&#34;23424917&#34;,&#34;continent&#34;:&#34;South America&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[2650,5787],[2647,5775],[2640,5745],[2641,5742],[2641,5740],[2639,5721],[2635,5707],[2625,5697],[2617,5696],[2607,5682],[2596,5686],[2589,5677],[2583,5681],[2573,5682],[2565,5680],[2540,5687],[2523,5686],[2521,5691],[2531,5699],[2538,5723],[2554,5744],[2548,5753],[2534,5760],[2517,5765],[2501,5774],[2497,5778],[2481,5789],[2472,5789],[2452,5795],[2449,5801],[2431,5813],[2424,5819],[2414,5836],[2404,5844],[2415,5880],[2415,5895],[2424,5909],[2430,5923],[2481,5934],[2508,5934],[2535,5918],[2536,5907],[2541,5899],[2541,5891],[2546,5883],[2544,5861],[2541,5849],[2552,5846],[2580,5844],[2587,5849],[2593,5843],[2603,5841],[2610,5831],[2610,5820],[2613,5813],[2613,5802],[2616,5791],[2624,5789],[2639,5795],[2650,5787]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BY&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.51,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;by&#34;,&#34;hc-a2&#34;:&#34;BY&#34;,&#34;name&#34;:&#34;Belarus&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Bela.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;BLR&#34;,&#34;iso-a2&#34;:&#34;BY&#34;,&#34;woe-id&#34;:&#34;23424765&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4943,8165],[4942,8175],[4944,8188],[4930,8196],[4937,8204],[4951,8211],[4952,8230],[4943,8248],[4940,8262],[4944,8260],[4960,8262],[4966,8259],[4978,8268],[4986,8269],[4990,8274],[4998,8276],[5004,8269],[5008,8274],[5000,8278],[5006,8287],[5006,8295],[5010,8302],[5018,8303],[5023,8311],[5031,8310],[5036,8317],[5027,8319],[5031,8332],[5043,8339],[5061,8337],[5062,8343],[5070,8350],[5077,8352],[5082,8348],[5091,8350],[5096,8343],[5103,8347],[5113,8344],[5116,8333],[5128,8339],[5137,8340],[5145,8337],[5153,8329],[5158,8329],[5159,8321],[5155,8316],[5161,8306],[5154,8296],[5166,8289],[5171,8273],[5186,8264],[5183,8256],[5193,8256],[5205,8251],[5203,8246],[5212,8242],[5203,8232],[5194,8227],[5183,8232],[5172,8231],[5168,8225],[5176,8218],[5175,8211],[5183,8188],[5175,8189],[5159,8187],[5151,8177],[5147,8167],[5151,8160],[5148,8155],[5136,8164],[5127,8162],[5121,8164],[5112,8159],[5104,8170],[5095,8164],[5082,8166],[5080,8170],[5075,8167],[5069,8169],[5051,8168],[5048,8174],[5039,8174],[5026,8178],[5007,8182],[4988,8182],[4966,8180],[4954,8168],[4948,8170],[4943,8165]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LV&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.29,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;lv&#34;,&#34;hc-a2&#34;:&#34;LV&#34;,&#34;name&#34;:&#34;Latvia&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Lat.&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;LVA&#34;,&#34;iso-a2&#34;:&#34;LV&#34;,&#34;woe-id&#34;:&#34;23424874&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5077,8352],[5070,8350],[5062,8343],[5061,8337],[5043,8339],[5031,8332],[5022,8335],[5019,8340],[5004,8352],[4988,8354],[4981,8364],[4968,8357],[4959,8357],[4946,8361],[4934,8361],[4929,8359],[4923,8363],[4916,8360],[4899,8363],[4876,8355],[4868,8349],[4866,8356],[4868,8381],[4878,8388],[4879,8400],[4888,8412],[4896,8413],[4914,8420],[4915,8412],[4929,8403],[4933,8392],[4946,8386],[4954,8388],[4966,8397],[4967,8402],[4964,8424],[4987,8433],[4993,8433],[5002,8426],[5014,8423],[5015,8420],[5028,8409],[5039,8414],[5054,8410],[5068,8401],[5062,8381],[5066,8382],[5076,8369],[5079,8357],[5077,8352]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SY&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.26,&#34;hc-middle-y&#34;:0.54,&#34;hc-key&#34;:&#34;sy&#34;,&#34;hc-a2&#34;:&#34;SY&#34;,&#34;name&#34;:&#34;Syria&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Syria&#34;,&#34;subregion&#34;:&#34;Western Asia&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;SYR&#34;,&#34;iso-a2&#34;:&#34;SY&#34;,&#34;woe-id&#34;:&#34;23424956&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5301,7499],[5305,7506],[5301,7518],[5303,7521],[5309,7527],[5310,7534],[5316,7537],[5326,7547],[5320,7560],[5307,7562],[5304,7571],[5307,7580],[5306,7587],[5300,7592],[5306,7604],[5313,7601],[5319,7606],[5319,7614],[5328,7614],[5324,7623],[5327,7634],[5337,7632],[5338,7628],[5351,7628],[5374,7637],[5387,7631],[5404,7629],[5419,7632],[5438,7640],[5452,7644],[5470,7643],[5485,7646],[5491,7651],[5495,7644],[5480,7627],[5467,7624],[5462,7609],[5466,7595],[5461,7579],[5461,7566],[5454,7553],[5446,7551],[5390,7519],[5332,7485],[5320,7487],[5310,7492],[5301,7499]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BF&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.64,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;bf&#34;,&#34;hc-a2&#34;:&#34;BF&#34;,&#34;name&#34;:&#34;Burkina Faso&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;B.F.&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;BFA&#34;,&#34;iso-a2&#34;:&#34;BF&#34;,&#34;woe-id&#34;:&#34;23424978&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4275,6828],[4263,6828],[4243,6832],[4231,6828],[4224,6828],[4167,6828],[4162,6817],[4167,6811],[4165,6808],[4169,6783],[4167,6781],[4154,6796],[4140,6797],[4122,6791],[4121,6787],[4110,6789],[4102,6796],[4098,6807],[4089,6807],[4086,6811],[4088,6824],[4086,6830],[4091,6832],[4095,6841],[4092,6846],[4096,6856],[4108,6858],[4114,6862],[4119,6874],[4116,6879],[4124,6880],[4120,6891],[4128,6899],[4136,6898],[4144,6893],[4153,6896],[4152,6909],[4163,6907],[4165,6919],[4176,6926],[4186,6922],[4189,6931],[4198,6932],[4216,6941],[4227,6949],[4241,6949],[4255,6944],[4253,6934],[4260,6925],[4258,6921],[4266,6908],[4275,6906],[4283,6898],[4277,6898],[4277,6888],[4294,6877],[4303,6876],[4306,6879],[4313,6875],[4314,6870],[4309,6868],[4319,6855],[4316,6848],[4307,6841],[4295,6840],[4291,6842],[4275,6828]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NE&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.64,&#34;hc-middle-y&#34;:0.53,&#34;hc-key&#34;:&#34;ne&#34;,&#34;hc-a2&#34;:&#34;NE&#34;,&#34;name&#34;:&#34;Niger&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Niger&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;NER&#34;,&#34;iso-a2&#34;:&#34;NE&#34;,&#34;woe-id&#34;:&#34;23424906&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4319,6855],[4309,6868],[4314,6870],[4313,6875],[4306,6879],[4303,6876],[4294,6877],[4277,6888],[4277,6898],[4283,6898],[4275,6906],[4266,6908],[4258,6921],[4260,6925],[4253,6934],[4255,6944],[4255,6947],[4268,6945],[4276,6947],[4287,6956],[4337,6957],[4338,6960],[4352,6958],[4352,6962],[4361,6968],[4368,6986],[4371,6990],[4373,7007],[4373,7072],[4419,7081],[4469,7125],[4601,7206],[4645,7196],[4667,7178],[4689,7190],[4695,7159],[4695,7144],[4708,7127],[4707,7121],[4718,7108],[4712,7095],[4704,7005],[4671,6970],[4656,6948],[4654,6939],[4644,6929],[4649,6908],[4641,6909],[4638,6904],[4628,6902],[4618,6895],[4615,6889],[4603,6891],[4585,6898],[4563,6899],[4546,6895],[4532,6882],[4521,6882],[4504,6885],[4487,6896],[4479,6898],[4466,6891],[4452,6887],[4436,6906],[4429,6907],[4411,6914],[4402,6910],[4390,6910],[4379,6908],[4370,6902],[4369,6887],[4364,6880],[4355,6873],[4354,6849],[4332,6870],[4318,6865],[4319,6855]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.33,&#34;hc-middle-y&#34;:0.37,&#34;hc-key&#34;:&#34;na&#34;,&#34;hc-a2&#34;:&#34;NA&#34;,&#34;name&#34;:&#34;Namibia&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Nam.&#34;,&#34;subregion&#34;:&#34;Southern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;NAM&#34;,&#34;iso-a2&#34;:&#34;NA&#34;,&#34;woe-id&#34;:&#34;23424987&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4937,5984],[4961,5989],[4983,5986],[4992,5979],[4982,5979],[4972,5971],[4961,5973],[4942,5959],[4934,5973],[4925,5972],[4881,5964],[4866,5963],[4866,5852],[4866,5851],[4836,5851],[4837,5766],[4837,5651],[4824,5647],[4816,5636],[4811,5633],[4800,5637],[4783,5635],[4776,5639],[4761,5642],[4759,5657],[4751,5663],[4746,5661],[4743,5652],[4734,5646],[4730,5646],[4710,5666],[4699,5685],[4697,5697],[4692,5706],[4693,5714],[4689,5716],[4689,5725],[4685,5735],[4683,5764],[4678,5772],[4674,5790],[4676,5793],[4675,5811],[4673,5818],[4676,5823],[4675,5834],[4672,5843],[4659,5858],[4655,5868],[4643,5886],[4636,5908],[4633,5909],[4618,5940],[4610,5952],[4603,5958],[4597,5969],[4593,5987],[4595,5995],[4607,5999],[4618,5996],[4636,6005],[4645,6003],[4646,5999],[4659,5991],[4667,5991],[4792,5991],[4801,5981],[4808,5978],[4838,5976],[4847,5977],[4861,5972],[4873,5975],[4878,5972],[4937,5984]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;TN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.42,&#34;hc-middle-y&#34;:0.09,&#34;hc-key&#34;:&#34;tn&#34;,&#34;hc-a2&#34;:&#34;TN&#34;,&#34;name&#34;:&#34;Tunisia&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Tun.&#34;,&#34;subregion&#34;:&#34;Northern Africa&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;TUN&#34;,&#34;iso-a2&#34;:&#34;TN&#34;,&#34;woe-id&#34;:&#34;23424967&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4587,7513],[4585,7495],[4589,7490],[4568,7479],[4561,7473],[4557,7466],[4552,7465],[4546,7456],[4551,7440],[4539,7421],[4529,7417],[4515,7477],[4494,7492],[4492,7502],[4486,7510],[4476,7514],[4468,7537],[4470,7543],[4477,7548],[4479,7554],[4491,7562],[4493,7577],[4493,7595],[4491,7601],[4494,7622],[4489,7623],[4503,7635],[4502,7638],[4508,7640],[4514,7645],[4535,7652],[4551,7646],[4548,7643],[4552,7632],[4559,7633],[4569,7642],[4574,7643],[4576,7635],[4566,7622],[4558,7618],[4557,7610],[4561,7601],[4573,7593],[4573,7584],[4577,7581],[4570,7572],[4580,7567],[4575,7562],[4570,7569],[4560,7558],[4546,7551],[4543,7546],[4545,7538],[4552,7530],[4564,7531],[4564,7536],[4574,7534],[4569,7528],[4575,7525],[4577,7514],[4587,7513]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;KG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.44,&#34;hc-key&#34;:&#34;kg&#34;,&#34;hc-a2&#34;:&#34;KG&#34;,&#34;name&#34;:&#34;Kyrgyzstan&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Kgz.&#34;,&#34;subregion&#34;:&#34;Central Asia&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;KGZ&#34;,&#34;iso-a2&#34;:&#34;KG&#34;,&#34;woe-id&#34;:&#34;23424864&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6338,7751],[6346,7754],[6359,7748],[6376,7759],[6379,7764],[6385,7760],[6391,7766],[6401,7770],[6398,7773],[6388,7773],[6378,7780],[6373,7778],[6373,7784],[6364,7784],[6361,7793],[6351,7782],[6344,7781],[6332,7786],[6328,7794],[6323,7792],[6314,7798],[6323,7803],[6346,7820],[6337,7821],[6334,7823],[6339,7833],[6351,7841],[6364,7842],[6390,7836],[6413,7828],[6410,7835],[6414,7849],[6432,7857],[6448,7848],[6462,7843],[6477,7842],[6479,7845],[6507,7845],[6514,7848],[6521,7845],[6557,7844],[6575,7839],[6587,7829],[6601,7828],[6610,7819],[6609,7813],[6599,7813],[6596,7808],[6583,7805],[6555,7791],[6547,7779],[6530,7777],[6516,7779],[6509,7776],[6504,7764],[6496,7755],[6493,7758],[6477,7753],[6473,7765],[6462,7758],[6452,7761],[6448,7754],[6437,7746],[6426,7744],[6422,7737],[6425,7728],[6416,7724],[6403,7721],[6387,7722],[6377,7720],[6375,7715],[6370,7721],[6362,7718],[6361,7724],[6355,7724],[6352,7729],[6332,7721],[6323,7729],[6315,7726],[6300,7728],[6289,7726],[6287,7734],[6289,7742],[6292,7739],[6297,7746],[6308,7750],[6325,7744],[6338,7751]],[[6328,7738],[6324,7739],[6326,7735],[6330,7737],[6328,7738]],[[6361,7739],[6362,7742],[6358,7741],[6359,7740],[6361,7739]],[[6344,7744],[6337,7746],[6339,7739],[6345,7739],[6344,7744]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MD&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.53,&#34;hc-middle-y&#34;:0.41,&#34;hc-key&#34;:&#34;md&#34;,&#34;hc-a2&#34;:&#34;MD&#34;,&#34;name&#34;:&#34;Moldova&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Mda.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;MDA&#34;,&#34;iso-a2&#34;:&#34;MD&#34;,&#34;woe-id&#34;:&#34;23424885&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5079,7937],[5075,7957],[5080,7972],[5080,7979],[5073,7995],[5067,7999],[5052,8018],[5048,8030],[5043,8037],[5032,8040],[5038,8045],[5049,8044],[5058,8048],[5065,8048],[5075,8040],[5083,8040],[5096,8035],[5101,8028],[5109,8026],[5106,8013],[5114,8004],[5118,8005],[5119,7991],[5129,7986],[5129,7976],[5134,7970],[5126,7969],[5123,7974],[5120,7970],[5116,7974],[5108,7970],[5108,7976],[5101,7973],[5103,7963],[5101,7957],[5087,7944],[5087,7939],[5079,7937]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SS&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.58,&#34;hc-key&#34;:&#34;ss&#34;,&#34;hc-a2&#34;:&#34;SS&#34;,&#34;name&#34;:&#34;South Sudan&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;S. Sud.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;SSD&#34;,&#34;iso-a2&#34;:&#34;SS&#34;,&#34;woe-id&#34;:&#34;-99&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5249,6629],[5234,6615],[5225,6615],[5220,6619],[5213,6615],[5201,6614],[5196,6608],[5188,6610],[5184,6617],[5176,6612],[5166,6616],[5156,6607],[5154,6613],[5148,6611],[5147,6618],[5137,6621],[5126,6638],[5116,6642],[5108,6632],[5095,6638],[5083,6630],[5066,6640],[5066,6644],[5056,6654],[5051,6659],[5051,6668],[5047,6674],[5035,6681],[5026,6683],[5029,6687],[5022,6692],[5025,6700],[5016,6705],[5015,6710],[4995,6720],[4989,6727],[4993,6730],[4979,6744],[4961,6748],[4960,6760],[4971,6766],[4978,6793],[4982,6795],[4987,6807],[5009,6811],[5011,6804],[5019,6797],[5030,6784],[5034,6783],[5046,6787],[5070,6787],[5074,6779],[5098,6779],[5102,6787],[5116,6792],[5120,6800],[5132,6807],[5154,6790],[5168,6792],[5181,6805],[5189,6818],[5203,6830],[5201,6849],[5193,6858],[5212,6858],[5212,6864],[5226,6864],[5222,6846],[5225,6823],[5247,6804],[5249,6794],[5246,6782],[5251,6782],[5253,6758],[5248,6752],[5227,6753],[5226,6747],[5220,6737],[5222,6734],[5241,6730],[5250,6722],[5258,6710],[5264,6707],[5271,6700],[5278,6677],[5289,6662],[5291,6664],[5302,6661],[5302,6645],[5306,6640],[5297,6640],[5296,6649],[5291,6652],[5261,6640],[5249,6629]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CF&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.47,&#34;hc-middle-y&#34;:0.46,&#34;hc-key&#34;:&#34;cf&#34;,&#34;hc-a2&#34;:&#34;CF&#34;,&#34;name&#34;:&#34;Central African Republic&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;C.A.R.&#34;,&#34;subregion&#34;:&#34;Middle Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;CAF&#34;,&#34;iso-a2&#34;:&#34;CF&#34;,&#34;woe-id&#34;:&#34;23424792&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4921,6826],[4934,6812],[4944,6795],[4944,6777],[4939,6774],[4940,6763],[4960,6760],[4961,6748],[4979,6744],[4993,6730],[4989,6727],[4995,6720],[5015,6710],[5016,6705],[5025,6700],[5022,6692],[5029,6687],[5026,6683],[5035,6681],[5047,6674],[5051,6668],[5051,6659],[5056,6654],[5047,6657],[5039,6653],[5029,6653],[5018,6659],[5011,6656],[5001,6662],[4995,6661],[4993,6652],[4974,6649],[4970,6654],[4935,6640],[4922,6646],[4911,6628],[4902,6627],[4888,6631],[4873,6631],[4863,6635],[4854,6634],[4847,6645],[4829,6655],[4820,6655],[4810,6649],[4800,6634],[4794,6632],[4797,6624],[4797,6607],[4792,6611],[4774,6609],[4762,6614],[4759,6611],[4736,6606],[4733,6588],[4725,6571],[4722,6579],[4722,6588],[4713,6596],[4695,6615],[4691,6623],[4690,6634],[4682,6640],[4680,6656],[4676,6659],[4679,6673],[4672,6682],[4682,6688],[4691,6704],[4696,6717],[4704,6726],[4712,6724],[4730,6730],[4735,6736],[4742,6726],[4768,6739],[4796,6741],[4811,6759],[4804,6765],[4811,6769],[4834,6770],[4840,6774],[4850,6773],[4853,6779],[4861,6781],[4867,6791],[4889,6811],[4888,6817],[4901,6823],[4909,6828],[4921,6826]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BW&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.6,&#34;hc-key&#34;:&#34;bw&#34;,&#34;hc-a2&#34;:&#34;BW&#34;,&#34;name&#34;:&#34;Botswana&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Bwa.&#34;,&#34;subregion&#34;:&#34;Southern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;BWA&#34;,&#34;iso-a2&#34;:&#34;BW&#34;,&#34;woe-id&#34;:&#34;23424755&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4992,5979],[4991,5977],[4999,5961],[5007,5954],[5012,5945],[5018,5927],[5035,5914],[5049,5909],[5051,5897],[5064,5897],[5063,5880],[5074,5864],[5091,5862],[5104,5856],[5105,5849],[5112,5845],[5103,5844],[5100,5837],[5078,5830],[5065,5813],[5054,5808],[5044,5801],[5038,5781],[5026,5770],[5010,5766],[5010,5762],[5002,5739],[4996,5735],[4979,5732],[4965,5735],[4960,5739],[4953,5739],[4939,5749],[4926,5749],[4921,5743],[4917,5727],[4912,5720],[4903,5716],[4896,5707],[4890,5706],[4886,5700],[4870,5700],[4862,5702],[4857,5699],[4855,5714],[4862,5723],[4860,5730],[4848,5757],[4837,5766],[4836,5851],[4866,5851],[4866,5852],[4866,5963],[4881,5964],[4925,5972],[4934,5973],[4942,5959],[4961,5973],[4972,5971],[4982,5979],[4992,5979]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.57,&#34;hc-key&#34;:&#34;sg&#34;,&#34;hc-a2&#34;:&#34;SG&#34;,&#34;name&#34;:&#34;Singapore&#34;,&#34;labelrank&#34;:&#34;6&#34;,&#34;country-abbrev&#34;:&#34;Sing.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;SGP&#34;,&#34;iso-a2&#34;:&#34;SG&#34;,&#34;woe-id&#34;:&#34;23424948&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[7307,6547],[7310,6545],[7306,6542],[7300,6543],[7306,6547],[7306,6547],[7307,6547]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;VN&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.59,&#34;hc-middle-y&#34;:0.88,&#34;hc-key&#34;:&#34;vn&#34;,&#34;hc-a2&#34;:&#34;VN&#34;,&#34;name&#34;:&#34;Vietnam&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Viet.&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;VNM&#34;,&#34;iso-a2&#34;:&#34;VN&#34;,&#34;woe-id&#34;:&#34;23424984&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[7428,7143],[7422,7145],[7417,7135],[7422,7128],[7416,7129],[7409,7124],[7410,7129],[7396,7127],[7401,7120],[7390,7125],[7392,7120],[7385,7115],[7386,7105],[7381,7104],[7374,7098],[7370,7098],[7364,7087],[7362,7071],[7358,7068],[7364,7055],[7372,7046],[7382,7041],[7382,7033],[7388,7021],[7402,7010],[7405,7005],[7418,6994],[7425,6985],[7434,6984],[7442,6970],[7451,6959],[7460,6939],[7460,6935],[7467,6914],[7464,6899],[7471,6885],[7471,6875],[7464,6877],[7468,6870],[7462,6871],[7466,6857],[7458,6839],[7451,6837],[7442,6830],[7431,6826],[7425,6820],[7407,6810],[7399,6814],[7395,6810],[7391,6814],[7393,6803],[7385,6794],[7384,6785],[7377,6788],[7375,6780],[7356,6773],[7343,6758],[7333,6764],[7337,6794],[7342,6798],[7334,6805],[7328,6803],[7324,6811],[7336,6814],[7342,6820],[7341,6826],[7349,6823],[7362,6829],[7374,6821],[7375,6827],[7365,6837],[7364,6847],[7370,6851],[7382,6848],[7381,6857],[7390,6857],[7403,6866],[7414,6868],[7415,6876],[7412,6888],[7416,6902],[7408,6921],[7414,6938],[7418,6955],[7403,6970],[7410,6975],[7393,6993],[7391,6990],[7385,6997],[7385,7007],[7378,7016],[7375,7015],[7361,7027],[7358,7036],[7342,7051],[7343,7058],[7331,7061],[7325,7067],[7306,7077],[7313,7082],[7310,7088],[7328,7086],[7339,7100],[7330,7108],[7321,7111],[7328,7118],[7319,7125],[7312,7127],[7304,7124],[7301,7118],[7293,7123],[7285,7124],[7277,7138],[7280,7146],[7276,7154],[7271,7149],[7269,7156],[7255,7171],[7265,7183],[7281,7172],[7290,7184],[7296,7177],[7300,7184],[7309,7175],[7313,7184],[7320,7180],[7335,7188],[7334,7193],[7349,7201],[7365,7187],[7369,7189],[7379,7185],[7384,7188],[7391,7182],[7386,7178],[7385,7170],[7391,7159],[7409,7147],[7423,7148],[7428,7143]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;SL&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.48,&#34;hc-middle-y&#34;:0.48,&#34;hc-key&#34;:&#34;sl&#34;,&#34;hc-a2&#34;:&#34;SL&#34;,&#34;name&#34;:&#34;Sierra Leone&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;S.L.&#34;,&#34;subregion&#34;:&#34;Western Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;SLE&#34;,&#34;iso-a2&#34;:&#34;SL&#34;,&#34;woe-id&#34;:&#34;23424946&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3910,6708],[3900,6715],[3867,6727],[3879,6728],[3867,6737],[3866,6747],[3861,6745],[3857,6754],[3862,6753],[3857,6770],[3865,6772],[3867,6777],[3874,6781],[3880,6794],[3891,6795],[3898,6798],[3917,6798],[3934,6778],[3932,6772],[3936,6771],[3940,6759],[3932,6748],[3945,6754],[3944,6745],[3936,6741],[3936,6733],[3913,6714],[3910,6708]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;MG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.45,&#34;hc-middle-y&#34;:0.48,&#34;hc-key&#34;:&#34;mg&#34;,&#34;hc-a2&#34;:&#34;MG&#34;,&#34;name&#34;:&#34;Madagascar&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Mad.&#34;,&#34;subregion&#34;:&#34;Eastern Africa&#34;,&#34;region-wb&#34;:&#34;Sub-Saharan Africa&#34;,&#34;iso-a3&#34;:&#34;MDG&#34;,&#34;iso-a2&#34;:&#34;MG&#34;,&#34;woe-id&#34;:&#34;23424883&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5721,6012],[5716,6001],[5716,6008],[5709,6006],[5704,5995],[5706,5981],[5702,5960],[5693,5941],[5680,5902],[5667,5857],[5659,5836],[5657,5823],[5649,5794],[5635,5759],[5625,5753],[5610,5752],[5590,5741],[5577,5740],[5568,5747],[5555,5750],[5545,5758],[5541,5770],[5535,5777],[5533,5800],[5537,5806],[5531,5818],[5525,5825],[5521,5843],[5524,5858],[5528,5861],[5529,5872],[5538,5875],[5541,5885],[5558,5913],[5555,5919],[5558,5927],[5551,5940],[5551,5949],[5545,5960],[5545,5980],[5542,5989],[5556,6012],[5557,6027],[5569,6026],[5581,6035],[5591,6034],[5594,6040],[5605,6041],[5612,6034],[5612,6044],[5631,6057],[5631,6048],[5639,6050],[5634,6057],[5645,6073],[5646,6061],[5654,6075],[5655,6086],[5659,6086],[5662,6094],[5658,6099],[5661,6107],[5668,6111],[5682,6110],[5685,6112],[5690,6128],[5684,6141],[5689,6138],[5697,6148],[5698,6154],[5708,6134],[5719,6122],[5719,6116],[5725,6099],[5726,6080],[5735,6050],[5727,6034],[5722,6037],[5718,6050],[5710,6047],[5711,6033],[5716,6026],[5716,6017],[5721,6012]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;IS&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.51,&#34;hc-key&#34;:&#34;is&#34;,&#34;hc-a2&#34;:&#34;IS&#34;,&#34;name&#34;:&#34;Iceland&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Iceland&#34;,&#34;subregion&#34;:&#34;Northern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;ISL&#34;,&#34;iso-a2&#34;:&#34;IS&#34;,&#34;woe-id&#34;:&#34;23424845&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[3595,8721],[3590,8725],[3591,8735],[3587,8737],[3554,8737],[3546,8733],[3540,8741],[3581,8747],[3589,8749],[3606,8748],[3607,8756],[3599,8752],[3584,8754],[3586,8758],[3601,8765],[3601,8771],[3595,8767],[3584,8773],[3579,8771],[3566,8774],[3545,8766],[3543,8769],[3526,8771],[3533,8777],[3545,8772],[3539,8778],[3540,8785],[3560,8777],[3550,8784],[3547,8791],[3556,8789],[3547,8798],[3556,8796],[3551,8800],[3557,8805],[3570,8800],[3576,8795],[3585,8793],[3587,8798],[3575,8802],[3572,8806],[3581,8812],[3568,8810],[3567,8816],[3584,8817],[3593,8813],[3594,8808],[3601,8808],[3621,8794],[3622,8788],[3616,8773],[3633,8763],[3630,8771],[3639,8780],[3644,8770],[3651,8778],[3651,8783],[3647,8799],[3656,8801],[3670,8783],[3677,8783],[3674,8793],[3678,8799],[3694,8805],[3702,8799],[3702,8793],[3708,8792],[3710,8803],[3721,8802],[3731,8793],[3735,8794],[3740,8803],[3750,8801],[3763,8804],[3765,8809],[3761,8820],[3772,8821],[3786,8814],[3784,8809],[3795,8802],[3797,8807],[3803,8808],[3811,8814],[3818,8812],[3807,8809],[3808,8806],[3801,8800],[3804,8797],[3816,8797],[3818,8792],[3811,8782],[3825,8785],[3824,8782],[3842,8771],[3847,8771],[3844,8762],[3849,8759],[3850,8750],[3846,8746],[3835,8750],[3844,8742],[3836,8734],[3823,8731],[3820,8718],[3808,8714],[3795,8712],[3778,8705],[3759,8693],[3742,8690],[3726,8685],[3719,8676],[3709,8678],[3710,8674],[3697,8671],[3680,8673],[3666,8677],[3654,8677],[3642,8685],[3624,8693],[3610,8691],[3591,8692],[3579,8691],[3579,8702],[3589,8698],[3601,8702],[3600,8707],[3609,8717],[3598,8714],[3601,8723],[3612,8730],[3595,8721]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;EG&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.66,&#34;hc-key&#34;:&#34;eg&#34;,&#34;hc-a2&#34;:&#34;EG&#34;,&#34;name&#34;:&#34;Egypt&#34;,&#34;labelrank&#34;:&#34;2&#34;,&#34;country-abbrev&#34;:&#34;Egypt&#34;,&#34;subregion&#34;:&#34;Northern Africa&#34;,&#34;region-wb&#34;:&#34;Middle East &amp; North Africa&#34;,&#34;iso-a3&#34;:&#34;EGY&#34;,&#34;iso-a2&#34;:&#34;EG&#34;,&#34;woe-id&#34;:&#34;23424802&#34;,&#34;continent&#34;:&#34;Africa&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[5275,7394],[5271,7388],[5268,7370],[5261,7356],[5264,7346],[5257,7338],[5241,7349],[5237,7356],[5227,7364],[5224,7379],[5211,7393],[5211,7402],[5206,7409],[5200,7397],[5208,7389],[5209,7377],[5237,7340],[5234,7335],[5249,7311],[5250,7302],[5259,7283],[5283,7239],[5291,7227],[5301,7220],[5294,7220],[5293,7205],[5299,7188],[5305,7182],[5315,7179],[5321,7170],[5335,7161],[5334,7159],[5174,7159],[5172,7165],[5168,7159],[4984,7159],[4984,7384],[4979,7407],[4975,7416],[4982,7426],[4984,7435],[4981,7444],[4980,7455],[4989,7464],[4996,7459],[5009,7462],[5053,7454],[5056,7449],[5068,7450],[5071,7445],[5085,7445],[5103,7437],[5117,7441],[5134,7453],[5136,7450],[5142,7459],[5160,7456],[5162,7461],[5177,7457],[5187,7460],[5184,7452],[5192,7449],[5194,7444],[5200,7451],[5208,7444],[5223,7450],[5239,7446],[5255,7452],[5274,7402],[5275,7394]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LK&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.58,&#34;hc-middle-y&#34;:0.91,&#34;hc-key&#34;:&#34;lk&#34;,&#34;hc-a2&#34;:&#34;LK&#34;,&#34;name&#34;:&#34;Sri Lanka&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Sri L.&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;LKA&#34;,&#34;iso-a2&#34;:&#34;LK&#34;,&#34;woe-id&#34;:&#34;23424778&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6605,6770],[6610,6783],[6602,6789],[6607,6793],[6626,6780],[6644,6754],[6652,6733],[6657,6728],[6659,6711],[6656,6699],[6644,6687],[6621,6679],[6606,6685],[6600,6705],[6595,6742],[6598,6742],[6602,6761],[6601,6768],[6605,6770]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;NP&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.52,&#34;hc-middle-y&#34;:0.5600000000000001,&#34;hc-key&#34;:&#34;np&#34;,&#34;hc-a2&#34;:&#34;NP&#34;,&#34;name&#34;:&#34;Nepal&#34;,&#34;labelrank&#34;:&#34;3&#34;,&#34;country-abbrev&#34;:&#34;Nepal&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;NPL&#34;,&#34;iso-a2&#34;:&#34;NP&#34;,&#34;woe-id&#34;:&#34;23424911&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6633,7416],[6639,7410],[6645,7422],[6651,7423],[6665,7421],[6667,7412],[6679,7408],[6687,7399],[6697,7398],[6707,7384],[6724,7386],[6728,7375],[6741,7366],[6756,7365],[6754,7356],[6769,7354],[6771,7357],[6780,7343],[6786,7346],[6793,7343],[6797,7350],[6802,7349],[6814,7341],[6831,7340],[6834,7343],[6843,7342],[6838,7318],[6844,7306],[6839,7295],[6835,7298],[6819,7294],[6813,7296],[6811,7301],[6801,7296],[6789,7302],[6781,7304],[6775,7301],[6769,7310],[6759,7306],[6746,7315],[6740,7316],[6738,7325],[6724,7331],[6717,7326],[6703,7330],[6700,7325],[6696,7329],[6685,7330],[6682,7337],[6676,7336],[6662,7344],[6659,7342],[6642,7352],[6620,7368],[6618,7364],[6605,7373],[6612,7388],[6610,7391],[6615,7402],[6633,7416]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;LA&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.26,&#34;hc-key&#34;:&#34;la&#34;,&#34;hc-a2&#34;:&#34;LA&#34;,&#34;name&#34;:&#34;Laos&#34;,&#34;labelrank&#34;:&#34;4&#34;,&#34;country-abbrev&#34;:&#34;Laos&#34;,&#34;subregion&#34;:&#34;South-Eastern Asia&#34;,&#34;region-wb&#34;:&#34;East Asia &amp; Pacific&#34;,&#34;iso-a3&#34;:&#34;LAO&#34;,&#34;iso-a2&#34;:&#34;LA&#34;,&#34;woe-id&#34;:&#34;23424872&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[7227,7145],[7230,7134],[7237,7136],[7243,7133],[7244,7154],[7237,7167],[7241,7173],[7255,7171],[7269,7156],[7271,7149],[7276,7154],[7280,7146],[7277,7138],[7285,7124],[7293,7123],[7301,7118],[7304,7124],[7312,7127],[7319,7125],[7328,7118],[7321,7111],[7330,7108],[7339,7100],[7328,7086],[7310,7088],[7313,7082],[7306,7077],[7325,7067],[7331,7061],[7343,7058],[7342,7051],[7358,7036],[7361,7027],[7375,7015],[7378,7016],[7385,7007],[7385,6997],[7391,6990],[7393,6993],[7410,6975],[7403,6970],[7418,6955],[7414,6938],[7401,6929],[7393,6927],[7384,6935],[7368,6928],[7374,6919],[7366,6915],[7356,6922],[7350,6921],[7345,6928],[7352,6930],[7357,6947],[7353,6950],[7356,6955],[7358,6969],[7353,6970],[7352,6977],[7342,6981],[7333,6993],[7332,7007],[7334,7018],[7324,7027],[7310,7047],[7293,7051],[7286,7045],[7282,7037],[7269,7033],[7268,7036],[7254,7044],[7245,7040],[7226,7021],[7219,7025],[7227,7039],[7227,7047],[7223,7050],[7229,7057],[7231,7069],[7227,7079],[7229,7083],[7218,7086],[7215,7082],[7207,7084],[7204,7090],[7209,7100],[7203,7110],[7196,7108],[7199,7120],[7208,7123],[7214,7138],[7227,7145]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;CZ&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.5,&#34;hc-middle-y&#34;:0.5,&#34;hc-key&#34;:&#34;cz&#34;,&#34;hc-a2&#34;:&#34;CZ&#34;,&#34;name&#34;:&#34;Czech Republic&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Cz. Rep.&#34;,&#34;subregion&#34;:&#34;Eastern Europe&#34;,&#34;region-wb&#34;:&#34;Europe &amp; Central Asia&#34;,&#34;iso-a3&#34;:&#34;CZE&#34;,&#34;iso-a2&#34;:&#34;CZ&#34;,&#34;woe-id&#34;:&#34;23424810&#34;,&#34;continent&#34;:&#34;Europe&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[4684,8140],[4689,8140],[4690,8146],[4698,8143],[4700,8137],[4713,8135],[4720,8130],[4732,8129],[4725,8123],[4740,8110],[4749,8115],[4745,8122],[4754,8121],[4759,8117],[4771,8115],[4766,8113],[4773,8106],[4779,8107],[4795,8103],[4796,8096],[4803,8088],[4794,8087],[4784,8079],[4781,8072],[4775,8066],[4765,8061],[4752,8062],[4747,8053],[4745,8058],[4732,8061],[4722,8059],[4698,8068],[4689,8067],[4688,8059],[4684,8060],[4681,8053],[4674,8055],[4663,8053],[4655,8060],[4645,8066],[4628,8081],[4621,8085],[4613,8097],[4617,8103],[4609,8108],[4604,8119],[4610,8113],[4617,8122],[4644,8130],[4647,8134],[4671,8141],[4667,8145],[4674,8146],[4679,8139],[4684,8140]]]}},{&#34;type&#34;:&#34;Feature&#34;,&#34;id&#34;:&#34;BT&#34;,&#34;properties&#34;:{&#34;hc-group&#34;:&#34;admin0&#34;,&#34;hc-middle-x&#34;:0.49,&#34;hc-middle-y&#34;:0.49,&#34;hc-key&#34;:&#34;bt&#34;,&#34;hc-a2&#34;:&#34;BT&#34;,&#34;name&#34;:&#34;Bhutan&#34;,&#34;labelrank&#34;:&#34;5&#34;,&#34;country-abbrev&#34;:&#34;Bhutan&#34;,&#34;subregion&#34;:&#34;Southern Asia&#34;,&#34;region-wb&#34;:&#34;South Asia&#34;,&#34;iso-a3&#34;:&#34;BTN&#34;,&#34;iso-a2&#34;:&#34;BT&#34;,&#34;woe-id&#34;:&#34;23424770&#34;,&#34;continent&#34;:&#34;Asia&#34;},&#34;geometry&#34;:{&#34;type&#34;:&#34;Polygon&#34;,&#34;coordinates&#34;:[[[6946,7339],[6944,7334],[6950,7328],[6956,7330],[6960,7324],[6957,7319],[6960,7313],[6948,7309],[6915,7308],[6909,7311],[6893,7305],[6879,7310],[6872,7309],[6864,7313],[6861,7319],[6866,7325],[6886,7351],[6894,7356],[6905,7358],[6915,7354],[6918,7349],[6930,7345],[6936,7349],[6947,7344],[6946,7339]]]}}]},&#34;data&#34;:[{&#34;a2&#34;:&#34;AW&#34;,&#34;iso-a3&#34;:&#34;ABW&#34;,&#34;ISOname&#34;:&#34;Aruba&#34;,&#34;mapname&#34;:&#34;Aruba&#34;,&#34;sovereignty&#34;:&#34;Netherlands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AF&#34;,&#34;iso-a3&#34;:&#34;AFG&#34;,&#34;ISOname&#34;:&#34;Afghanistan&#34;,&#34;mapname&#34;:&#34;Afghanistan&#34;,&#34;sovereignty&#34;:&#34;Afghanistan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AO&#34;,&#34;iso-a3&#34;:&#34;AGO&#34;,&#34;ISOname&#34;:&#34;Angola&#34;,&#34;mapname&#34;:&#34;Angola&#34;,&#34;sovereignty&#34;:&#34;Angola&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AI&#34;,&#34;iso-a3&#34;:&#34;AIA&#34;,&#34;ISOname&#34;:&#34;Anguilla&#34;,&#34;mapname&#34;:&#34;Anguilla&#34;,&#34;sovereignty&#34;:&#34;Anguilla&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AX&#34;,&#34;iso-a3&#34;:&#34;ALA&#34;,&#34;ISOname&#34;:&#34;Aland Islands&#34;,&#34;mapname&#34;:&#34;Finland:Aland Islands&#34;,&#34;sovereignty&#34;:&#34;Finland&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AL&#34;,&#34;iso-a3&#34;:&#34;ALB&#34;,&#34;ISOname&#34;:&#34;Albania&#34;,&#34;mapname&#34;:&#34;Albania&#34;,&#34;sovereignty&#34;:&#34;Albania&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AD&#34;,&#34;iso-a3&#34;:&#34;AND&#34;,&#34;ISOname&#34;:&#34;Andorra&#34;,&#34;mapname&#34;:&#34;Andorra&#34;,&#34;sovereignty&#34;:&#34;Andorra&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AE&#34;,&#34;iso-a3&#34;:&#34;ARE&#34;,&#34;ISOname&#34;:&#34;United Arab Emirates&#34;,&#34;mapname&#34;:&#34;United Arab Emirates&#34;,&#34;sovereignty&#34;:&#34;United Arab Emirates&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AR&#34;,&#34;iso-a3&#34;:&#34;ARG&#34;,&#34;ISOname&#34;:&#34;Argentina&#34;,&#34;mapname&#34;:&#34;Argentina&#34;,&#34;sovereignty&#34;:&#34;Argentina&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AM&#34;,&#34;iso-a3&#34;:&#34;ARM&#34;,&#34;ISOname&#34;:&#34;Armenia&#34;,&#34;mapname&#34;:&#34;Armenia&#34;,&#34;sovereignty&#34;:&#34;Armenia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AS&#34;,&#34;iso-a3&#34;:&#34;ASM&#34;,&#34;ISOname&#34;:&#34;American Samoa&#34;,&#34;mapname&#34;:&#34;American Samoa&#34;,&#34;sovereignty&#34;:&#34;USA&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AQ&#34;,&#34;iso-a3&#34;:&#34;ATA&#34;,&#34;ISOname&#34;:&#34;Antarctica&#34;,&#34;mapname&#34;:&#34;Antarctica&#34;,&#34;sovereignty&#34;:&#34;Antarctica&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TF&#34;,&#34;iso-a3&#34;:&#34;ATF&#34;,&#34;ISOname&#34;:&#34;French Southern and Antarctic Lands&#34;,&#34;mapname&#34;:&#34;French Southern and Antarctic Lands&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AG&#34;,&#34;iso-a3&#34;:&#34;ATG&#34;,&#34;ISOname&#34;:&#34;Antigua and Barbuda&#34;,&#34;mapname&#34;:&#34;Barbuda&#34;,&#34;sovereignty&#34;:&#34;Antigua and Barbuda&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AG&#34;,&#34;iso-a3&#34;:&#34;ATG&#34;,&#34;ISOname&#34;:&#34;Antigua and Barbuda&#34;,&#34;mapname&#34;:&#34;Antigua&#34;,&#34;sovereignty&#34;:&#34;Antigua and Barbuda&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;AU&#34;,&#34;iso-a3&#34;:&#34;AUS&#34;,&#34;ISOname&#34;:&#34;Australia&#34;,&#34;mapname&#34;:&#34;Australia&#34;,&#34;sovereignty&#34;:&#34;Australia&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;AT&#34;,&#34;iso-a3&#34;:&#34;AUT&#34;,&#34;ISOname&#34;:&#34;Austria&#34;,&#34;mapname&#34;:&#34;Austria&#34;,&#34;sovereignty&#34;:&#34;Austria&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;AZ&#34;,&#34;iso-a3&#34;:&#34;AZE&#34;,&#34;ISOname&#34;:&#34;Azerbaijan&#34;,&#34;mapname&#34;:&#34;Azerbaijan&#34;,&#34;sovereignty&#34;:&#34;Azerbaijan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BI&#34;,&#34;iso-a3&#34;:&#34;BDI&#34;,&#34;ISOname&#34;:&#34;Burundi&#34;,&#34;mapname&#34;:&#34;Burundi&#34;,&#34;sovereignty&#34;:&#34;Burundi&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BE&#34;,&#34;iso-a3&#34;:&#34;BEL&#34;,&#34;ISOname&#34;:&#34;Belgium&#34;,&#34;mapname&#34;:&#34;Belgium&#34;,&#34;sovereignty&#34;:&#34;Belgium&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;BJ&#34;,&#34;iso-a3&#34;:&#34;BEN&#34;,&#34;ISOname&#34;:&#34;Benin&#34;,&#34;mapname&#34;:&#34;Benin&#34;,&#34;sovereignty&#34;:&#34;Benin&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BQ&#34;,&#34;iso-a3&#34;:&#34;BES&#34;,&#34;ISOname&#34;:&#34;Bonaire, Sint Eustatius and Saba&#34;,&#34;mapname&#34;:&#34;Bonaire&#34;,&#34;sovereignty&#34;:&#34;Netherlands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BQ&#34;,&#34;iso-a3&#34;:&#34;BES&#34;,&#34;ISOname&#34;:&#34;Bonaire, Sint Eustatius and Saba&#34;,&#34;mapname&#34;:&#34;Sint Eustatius&#34;,&#34;sovereignty&#34;:&#34;Netherlands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BQ&#34;,&#34;iso-a3&#34;:&#34;BES&#34;,&#34;ISOname&#34;:&#34;Bonaire, Sint Eustatius and Saba&#34;,&#34;mapname&#34;:&#34;Saba&#34;,&#34;sovereignty&#34;:&#34;Netherlands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BF&#34;,&#34;iso-a3&#34;:&#34;BFA&#34;,&#34;ISOname&#34;:&#34;Burkina Faso&#34;,&#34;mapname&#34;:&#34;Burkina Faso&#34;,&#34;sovereignty&#34;:&#34;Burkina Faso&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BD&#34;,&#34;iso-a3&#34;:&#34;BGD&#34;,&#34;ISOname&#34;:&#34;Bangladesh&#34;,&#34;mapname&#34;:&#34;Bangladesh&#34;,&#34;sovereignty&#34;:&#34;Bangladesh&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BG&#34;,&#34;iso-a3&#34;:&#34;BGR&#34;,&#34;ISOname&#34;:&#34;Bulgaria&#34;,&#34;mapname&#34;:&#34;Bulgaria&#34;,&#34;sovereignty&#34;:&#34;Bulgaria&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BH&#34;,&#34;iso-a3&#34;:&#34;BHR&#34;,&#34;ISOname&#34;:&#34;Bahrain&#34;,&#34;mapname&#34;:&#34;Bahrain&#34;,&#34;sovereignty&#34;:&#34;Bahrain&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BS&#34;,&#34;iso-a3&#34;:&#34;BHS&#34;,&#34;ISOname&#34;:&#34;Bahamas&#34;,&#34;mapname&#34;:&#34;Bahamas&#34;,&#34;sovereignty&#34;:&#34;Bahamas&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BA&#34;,&#34;iso-a3&#34;:&#34;BIH&#34;,&#34;ISOname&#34;:&#34;Bosnia and Herzegovina&#34;,&#34;mapname&#34;:&#34;Bosnia and Herzegovina&#34;,&#34;sovereignty&#34;:&#34;Bosnia and Herzegovina&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BL&#34;,&#34;iso-a3&#34;:&#34;BLM&#34;,&#34;ISOname&#34;:&#34;Saint Barthelemy&#34;,&#34;mapname&#34;:&#34;Saint Barthelemy&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BY&#34;,&#34;iso-a3&#34;:&#34;BLR&#34;,&#34;ISOname&#34;:&#34;Belarus&#34;,&#34;mapname&#34;:&#34;Belarus&#34;,&#34;sovereignty&#34;:&#34;Belarus&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BZ&#34;,&#34;iso-a3&#34;:&#34;BLZ&#34;,&#34;ISOname&#34;:&#34;Belize&#34;,&#34;mapname&#34;:&#34;Belize&#34;,&#34;sovereignty&#34;:&#34;Belize&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BM&#34;,&#34;iso-a3&#34;:&#34;BMU&#34;,&#34;ISOname&#34;:&#34;Bermuda&#34;,&#34;mapname&#34;:&#34;Bermuda&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BO&#34;,&#34;iso-a3&#34;:&#34;BOL&#34;,&#34;ISOname&#34;:&#34;Bolivia, Plurinational State of&#34;,&#34;mapname&#34;:&#34;Bolivia&#34;,&#34;sovereignty&#34;:&#34;Bolivia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BR&#34;,&#34;iso-a3&#34;:&#34;BRA&#34;,&#34;ISOname&#34;:&#34;Brazil&#34;,&#34;mapname&#34;:&#34;Brazil&#34;,&#34;sovereignty&#34;:&#34;Brazil&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BB&#34;,&#34;iso-a3&#34;:&#34;BRB&#34;,&#34;ISOname&#34;:&#34;Barbados&#34;,&#34;mapname&#34;:&#34;Barbados&#34;,&#34;sovereignty&#34;:&#34;Barbados&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BN&#34;,&#34;iso-a3&#34;:&#34;BRN&#34;,&#34;ISOname&#34;:&#34;Brunei Darussalam&#34;,&#34;mapname&#34;:&#34;Brunei&#34;,&#34;sovereignty&#34;:&#34;Brunei&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BT&#34;,&#34;iso-a3&#34;:&#34;BTN&#34;,&#34;ISOname&#34;:&#34;Bhutan&#34;,&#34;mapname&#34;:&#34;Bhutan&#34;,&#34;sovereignty&#34;:&#34;Bhutan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BV&#34;,&#34;iso-a3&#34;:&#34;BVT&#34;,&#34;ISOname&#34;:&#34;Bouvet Island&#34;,&#34;mapname&#34;:&#34;Bouvet Island&#34;,&#34;sovereignty&#34;:&#34;Norway&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;BW&#34;,&#34;iso-a3&#34;:&#34;BWA&#34;,&#34;ISOname&#34;:&#34;Botswana&#34;,&#34;mapname&#34;:&#34;Botswana&#34;,&#34;sovereignty&#34;:&#34;Botswana&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CF&#34;,&#34;iso-a3&#34;:&#34;CAF&#34;,&#34;ISOname&#34;:&#34;Central African Republic&#34;,&#34;mapname&#34;:&#34;Central African Republic&#34;,&#34;sovereignty&#34;:&#34;Central African Republic&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CA&#34;,&#34;iso-a3&#34;:&#34;CAN&#34;,&#34;ISOname&#34;:&#34;Canada&#34;,&#34;mapname&#34;:&#34;Canada&#34;,&#34;sovereignty&#34;:&#34;Canada&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;CC&#34;,&#34;iso-a3&#34;:&#34;CCK&#34;,&#34;ISOname&#34;:&#34;Cocos (Keeling) Islands&#34;,&#34;mapname&#34;:&#34;Cocos Islands&#34;,&#34;sovereignty&#34;:&#34;Australia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CH&#34;,&#34;iso-a3&#34;:&#34;CHE&#34;,&#34;ISOname&#34;:&#34;Switzerland&#34;,&#34;mapname&#34;:&#34;Switzerland&#34;,&#34;sovereignty&#34;:&#34;Switzerland&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;CL&#34;,&#34;iso-a3&#34;:&#34;CHL&#34;,&#34;ISOname&#34;:&#34;Chile&#34;,&#34;mapname&#34;:&#34;Chile&#34;,&#34;sovereignty&#34;:&#34;Chile&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CN&#34;,&#34;iso-a3&#34;:&#34;CHN&#34;,&#34;ISOname&#34;:&#34;China&#34;,&#34;mapname&#34;:&#34;China&#34;,&#34;sovereignty&#34;:&#34;China&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CN&#34;,&#34;iso-a3&#34;:&#34;CHN&#34;,&#34;ISOname&#34;:&#34;Paracel Islands&#34;,&#34;mapname&#34;:&#34;Paracel Islands&#34;,&#34;sovereignty&#34;:&#34;China&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CI&#34;,&#34;iso-a3&#34;:&#34;CIV&#34;,&#34;ISOname&#34;:&#34;Cote d&#39;Ivoire&#34;,&#34;mapname&#34;:&#34;Ivory Coast&#34;,&#34;sovereignty&#34;:&#34;Ivory Coast&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CM&#34;,&#34;iso-a3&#34;:&#34;CMR&#34;,&#34;ISOname&#34;:&#34;Cameroon&#34;,&#34;mapname&#34;:&#34;Cameroon&#34;,&#34;sovereignty&#34;:&#34;Cameroon&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CD&#34;,&#34;iso-a3&#34;:&#34;COD&#34;,&#34;ISOname&#34;:&#34;Democratic Republic of the Congo&#34;,&#34;mapname&#34;:&#34;Democratic Republic of the Congo&#34;,&#34;sovereignty&#34;:&#34;Democratic Republic of the Congo&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CG&#34;,&#34;iso-a3&#34;:&#34;COG&#34;,&#34;ISOname&#34;:&#34;Republic of Congo&#34;,&#34;mapname&#34;:&#34;Republic of Congo&#34;,&#34;sovereignty&#34;:&#34;Republic of Congo&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CK&#34;,&#34;iso-a3&#34;:&#34;COK&#34;,&#34;ISOname&#34;:&#34;Cook Islands&#34;,&#34;mapname&#34;:&#34;Cook Islands&#34;,&#34;sovereignty&#34;:&#34;Cook Islands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CO&#34;,&#34;iso-a3&#34;:&#34;COL&#34;,&#34;ISOname&#34;:&#34;Colombia&#34;,&#34;mapname&#34;:&#34;Colombia&#34;,&#34;sovereignty&#34;:&#34;Colombia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KM&#34;,&#34;iso-a3&#34;:&#34;COM&#34;,&#34;ISOname&#34;:&#34;Comoros&#34;,&#34;mapname&#34;:&#34;Comoros&#34;,&#34;sovereignty&#34;:&#34;Comoros&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CV&#34;,&#34;iso-a3&#34;:&#34;CPV&#34;,&#34;ISOname&#34;:&#34;Cape Verde&#34;,&#34;mapname&#34;:&#34;Cape Verde&#34;,&#34;sovereignty&#34;:&#34;Cape Verde&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CR&#34;,&#34;iso-a3&#34;:&#34;CRI&#34;,&#34;ISOname&#34;:&#34;Costa Rica&#34;,&#34;mapname&#34;:&#34;Costa Rica&#34;,&#34;sovereignty&#34;:&#34;Costa Rica&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CU&#34;,&#34;iso-a3&#34;:&#34;CUB&#34;,&#34;ISOname&#34;:&#34;Cuba&#34;,&#34;mapname&#34;:&#34;Cuba&#34;,&#34;sovereignty&#34;:&#34;Cuba&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CW&#34;,&#34;iso-a3&#34;:&#34;CUW&#34;,&#34;ISOname&#34;:&#34;Curacao&#34;,&#34;mapname&#34;:&#34;Curacao&#34;,&#34;sovereignty&#34;:&#34;Netherlands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CX&#34;,&#34;iso-a3&#34;:&#34;CXR&#34;,&#34;ISOname&#34;:&#34;Christmas Island&#34;,&#34;mapname&#34;:&#34;Christmas Island&#34;,&#34;sovereignty&#34;:&#34;Australia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KY&#34;,&#34;iso-a3&#34;:&#34;CYM&#34;,&#34;ISOname&#34;:&#34;Cayman Islands&#34;,&#34;mapname&#34;:&#34;Cayman Islands&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CY&#34;,&#34;iso-a3&#34;:&#34;CYP&#34;,&#34;ISOname&#34;:&#34;Cyprus&#34;,&#34;mapname&#34;:&#34;Cyprus&#34;,&#34;sovereignty&#34;:&#34;Cyprus&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;CZ&#34;,&#34;iso-a3&#34;:&#34;CZE&#34;,&#34;ISOname&#34;:&#34;Czech Republic&#34;,&#34;mapname&#34;:&#34;Czech Republic&#34;,&#34;sovereignty&#34;:&#34;Czech Republic&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;DE&#34;,&#34;iso-a3&#34;:&#34;DEU&#34;,&#34;ISOname&#34;:&#34;Germany&#34;,&#34;mapname&#34;:&#34;Germany&#34;,&#34;sovereignty&#34;:&#34;Germany&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;DJ&#34;,&#34;iso-a3&#34;:&#34;DJI&#34;,&#34;ISOname&#34;:&#34;Djibouti&#34;,&#34;mapname&#34;:&#34;Djibouti&#34;,&#34;sovereignty&#34;:&#34;Djibouti&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;DM&#34;,&#34;iso-a3&#34;:&#34;DMA&#34;,&#34;ISOname&#34;:&#34;Dominica&#34;,&#34;mapname&#34;:&#34;Dominica&#34;,&#34;sovereignty&#34;:&#34;Dominica&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;DK&#34;,&#34;iso-a3&#34;:&#34;DNK&#34;,&#34;ISOname&#34;:&#34;Denmark&#34;,&#34;mapname&#34;:&#34;Denmark&#34;,&#34;sovereignty&#34;:&#34;Denmark&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;DO&#34;,&#34;iso-a3&#34;:&#34;DOM&#34;,&#34;ISOname&#34;:&#34;Dominican Republic&#34;,&#34;mapname&#34;:&#34;Dominican Republic&#34;,&#34;sovereignty&#34;:&#34;Dominican Republic&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;DZ&#34;,&#34;iso-a3&#34;:&#34;DZA&#34;,&#34;ISOname&#34;:&#34;Algeria&#34;,&#34;mapname&#34;:&#34;Algeria&#34;,&#34;sovereignty&#34;:&#34;Algeria&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;EC&#34;,&#34;iso-a3&#34;:&#34;ECU&#34;,&#34;ISOname&#34;:&#34;Ecuador&#34;,&#34;mapname&#34;:&#34;Ecuador&#34;,&#34;sovereignty&#34;:&#34;Ecuador&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;EG&#34;,&#34;iso-a3&#34;:&#34;EGY&#34;,&#34;ISOname&#34;:&#34;Egypt&#34;,&#34;mapname&#34;:&#34;Egypt&#34;,&#34;sovereignty&#34;:&#34;Egypt&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;ER&#34;,&#34;iso-a3&#34;:&#34;ERI&#34;,&#34;ISOname&#34;:&#34;Eritrea&#34;,&#34;mapname&#34;:&#34;Eritrea&#34;,&#34;sovereignty&#34;:&#34;Eritrea&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;EH&#34;,&#34;iso-a3&#34;:&#34;ESH&#34;,&#34;ISOname&#34;:&#34;Western Sahara&#34;,&#34;mapname&#34;:&#34;Western Sahara&#34;,&#34;sovereignty&#34;:&#34;Western Sahara&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;ES&#34;,&#34;iso-a3&#34;:&#34;ESP&#34;,&#34;ISOname&#34;:&#34;Spain&#34;,&#34;mapname&#34;:&#34;Spain&#34;,&#34;sovereignty&#34;:&#34;Spain&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;ES&#34;,&#34;iso-a3&#34;:&#34;ESP&#34;,&#34;ISOname&#34;:&#34;Spain&#34;,&#34;mapname&#34;:&#34;Canary Islands&#34;,&#34;sovereignty&#34;:&#34;Spain&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;EE&#34;,&#34;iso-a3&#34;:&#34;EST&#34;,&#34;ISOname&#34;:&#34;Estonia&#34;,&#34;mapname&#34;:&#34;Estonia&#34;,&#34;sovereignty&#34;:&#34;Estonia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;ET&#34;,&#34;iso-a3&#34;:&#34;ETH&#34;,&#34;ISOname&#34;:&#34;Ethiopia&#34;,&#34;mapname&#34;:&#34;Ethiopia&#34;,&#34;sovereignty&#34;:&#34;Ethiopia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;FI&#34;,&#34;iso-a3&#34;:&#34;FIN&#34;,&#34;ISOname&#34;:&#34;Finland&#34;,&#34;mapname&#34;:&#34;Finland(?!:Aland)&#34;,&#34;sovereignty&#34;:&#34;Finland&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;FJ&#34;,&#34;iso-a3&#34;:&#34;FJI&#34;,&#34;ISOname&#34;:&#34;Fiji&#34;,&#34;mapname&#34;:&#34;Fiji&#34;,&#34;sovereignty&#34;:&#34;Fiji&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;FK&#34;,&#34;iso-a3&#34;:&#34;FLK&#34;,&#34;ISOname&#34;:&#34;Falkland Islands (Malvinas)&#34;,&#34;mapname&#34;:&#34;Falkland Islands&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;FR&#34;,&#34;iso-a3&#34;:&#34;FRA&#34;,&#34;ISOname&#34;:&#34;France&#34;,&#34;mapname&#34;:&#34;France&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;FR&#34;,&#34;iso-a3&#34;:&#34;FRA&#34;,&#34;ISOname&#34;:&#34;Clipperton Island&#34;,&#34;mapname&#34;:&#34;Clipperton Island&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;FO&#34;,&#34;iso-a3&#34;:&#34;FRO&#34;,&#34;ISOname&#34;:&#34;Faroe Islands&#34;,&#34;mapname&#34;:&#34;Faroe Islands&#34;,&#34;sovereignty&#34;:&#34;Denmark&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;FM&#34;,&#34;iso-a3&#34;:&#34;FSM&#34;,&#34;ISOname&#34;:&#34;Federated States of Micronesia&#34;,&#34;mapname&#34;:&#34;Micronesia&#34;,&#34;sovereignty&#34;:&#34;Micronesia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GA&#34;,&#34;iso-a3&#34;:&#34;GAB&#34;,&#34;ISOname&#34;:&#34;Gabon&#34;,&#34;mapname&#34;:&#34;Gabon&#34;,&#34;sovereignty&#34;:&#34;Gabon&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GB&#34;,&#34;iso-a3&#34;:&#34;GBR&#34;,&#34;ISOname&#34;:&#34;United Kingdom of Great Britain and Northern Ireland&#34;,&#34;mapname&#34;:&#34;UK(?!r)&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;GE&#34;,&#34;iso-a3&#34;:&#34;GEO&#34;,&#34;ISOname&#34;:&#34;Georgia&#34;,&#34;mapname&#34;:&#34;Georgia&#34;,&#34;sovereignty&#34;:&#34;Georgia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GG&#34;,&#34;iso-a3&#34;:&#34;GGY&#34;,&#34;ISOname&#34;:&#34;Guernsey&#34;,&#34;mapname&#34;:&#34;Guernsey&#34;,&#34;sovereignty&#34;:&#34;Guernsey&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GH&#34;,&#34;iso-a3&#34;:&#34;GHA&#34;,&#34;ISOname&#34;:&#34;Ghana&#34;,&#34;mapname&#34;:&#34;Ghana&#34;,&#34;sovereignty&#34;:&#34;Ghana&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GI&#34;,&#34;iso-a3&#34;:&#34;GIB&#34;,&#34;ISOname&#34;:&#34;Gibraltar&#34;,&#34;mapname&#34;:&#34;Gibraltar&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GN&#34;,&#34;iso-a3&#34;:&#34;GIN&#34;,&#34;ISOname&#34;:&#34;Guinea&#34;,&#34;mapname&#34;:&#34;Guinea&#34;,&#34;sovereignty&#34;:&#34;Guinea&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GP&#34;,&#34;iso-a3&#34;:&#34;GLP&#34;,&#34;ISOname&#34;:&#34;Guadeloupe&#34;,&#34;mapname&#34;:&#34;Guadeloupe&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GM&#34;,&#34;iso-a3&#34;:&#34;GMB&#34;,&#34;ISOname&#34;:&#34;Gambia&#34;,&#34;mapname&#34;:&#34;Gambia&#34;,&#34;sovereignty&#34;:&#34;Gambia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GW&#34;,&#34;iso-a3&#34;:&#34;GNB&#34;,&#34;ISOname&#34;:&#34;Guinea-Bissau&#34;,&#34;mapname&#34;:&#34;Guinea-Bissau&#34;,&#34;sovereignty&#34;:&#34;Guinea-Bissau&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GQ&#34;,&#34;iso-a3&#34;:&#34;GNQ&#34;,&#34;ISOname&#34;:&#34;Equatorial Guinea&#34;,&#34;mapname&#34;:&#34;Equatorial Guinea&#34;,&#34;sovereignty&#34;:&#34;Equatorial Guinea&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GR&#34;,&#34;iso-a3&#34;:&#34;GRC&#34;,&#34;ISOname&#34;:&#34;Greece&#34;,&#34;mapname&#34;:&#34;Greece&#34;,&#34;sovereignty&#34;:&#34;Greece&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;GD&#34;,&#34;iso-a3&#34;:&#34;GRD&#34;,&#34;ISOname&#34;:&#34;Grenada&#34;,&#34;mapname&#34;:&#34;Grenada&#34;,&#34;sovereignty&#34;:&#34;Grenada&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GL&#34;,&#34;iso-a3&#34;:&#34;GRL&#34;,&#34;ISOname&#34;:&#34;Greenland&#34;,&#34;mapname&#34;:&#34;Greenland&#34;,&#34;sovereignty&#34;:&#34;Denmark&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GT&#34;,&#34;iso-a3&#34;:&#34;GTM&#34;,&#34;ISOname&#34;:&#34;Guatemala&#34;,&#34;mapname&#34;:&#34;Guatemala&#34;,&#34;sovereignty&#34;:&#34;Guatemala&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GF&#34;,&#34;iso-a3&#34;:&#34;GUF&#34;,&#34;ISOname&#34;:&#34;French Guiana&#34;,&#34;mapname&#34;:&#34;French Guiana&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GU&#34;,&#34;iso-a3&#34;:&#34;GUM&#34;,&#34;ISOname&#34;:&#34;Guam&#34;,&#34;mapname&#34;:&#34;Guam&#34;,&#34;sovereignty&#34;:&#34;USA&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GY&#34;,&#34;iso-a3&#34;:&#34;GUY&#34;,&#34;ISOname&#34;:&#34;Guyana&#34;,&#34;mapname&#34;:&#34;Guyana&#34;,&#34;sovereignty&#34;:&#34;Guyana&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;HK&#34;,&#34;iso-a3&#34;:&#34;HKG&#34;,&#34;ISOname&#34;:&#34;Hong Kong&#34;,&#34;mapname&#34;:&#34;China:Hong Kong&#34;,&#34;sovereignty&#34;:&#34;China&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;HM&#34;,&#34;iso-a3&#34;:&#34;HMD&#34;,&#34;ISOname&#34;:&#34;Heard Island and McDonald Islands&#34;,&#34;mapname&#34;:&#34;Heard Island&#34;,&#34;sovereignty&#34;:&#34;Australia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;HM&#34;,&#34;iso-a3&#34;:&#34;HMD&#34;,&#34;ISOname&#34;:&#34;Heard Island and McDonald Islands&#34;,&#34;mapname&#34;:&#34;McDonald Islands&#34;,&#34;sovereignty&#34;:&#34;Australia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;HN&#34;,&#34;iso-a3&#34;:&#34;HND&#34;,&#34;ISOname&#34;:&#34;Honduras&#34;,&#34;mapname&#34;:&#34;Honduras&#34;,&#34;sovereignty&#34;:&#34;Honduras&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;HR&#34;,&#34;iso-a3&#34;:&#34;HRV&#34;,&#34;ISOname&#34;:&#34;Croatia&#34;,&#34;mapname&#34;:&#34;Croatia&#34;,&#34;sovereignty&#34;:&#34;Croatia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;HT&#34;,&#34;iso-a3&#34;:&#34;HTI&#34;,&#34;ISOname&#34;:&#34;Haiti&#34;,&#34;mapname&#34;:&#34;Haiti&#34;,&#34;sovereignty&#34;:&#34;Haiti&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;HU&#34;,&#34;iso-a3&#34;:&#34;HUN&#34;,&#34;ISOname&#34;:&#34;Hungary&#34;,&#34;mapname&#34;:&#34;Hungary&#34;,&#34;sovereignty&#34;:&#34;Hungary&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;ID&#34;,&#34;iso-a3&#34;:&#34;IDN&#34;,&#34;ISOname&#34;:&#34;Indonesia&#34;,&#34;mapname&#34;:&#34;Indonesia&#34;,&#34;sovereignty&#34;:&#34;Indonesia&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;IM&#34;,&#34;iso-a3&#34;:&#34;IMN&#34;,&#34;ISOname&#34;:&#34;Isle of Man&#34;,&#34;mapname&#34;:&#34;Isle of Man&#34;,&#34;sovereignty&#34;:&#34;Isle of Man&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;IN&#34;,&#34;iso-a3&#34;:&#34;IND&#34;,&#34;ISOname&#34;:&#34;India&#34;,&#34;mapname&#34;:&#34;India&#34;,&#34;sovereignty&#34;:&#34;India&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;IO&#34;,&#34;iso-a3&#34;:&#34;IOT&#34;,&#34;ISOname&#34;:&#34;British Indian Ocean Territory&#34;,&#34;mapname&#34;:&#34;British Indian Ocean Territory&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;IO&#34;,&#34;iso-a3&#34;:&#34;IOT&#34;,&#34;ISOname&#34;:&#34;British Indian Ocean Territory&#34;,&#34;mapname&#34;:&#34;Chagos Archipelago&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;IE&#34;,&#34;iso-a3&#34;:&#34;IRL&#34;,&#34;ISOname&#34;:&#34;Ireland&#34;,&#34;mapname&#34;:&#34;Ireland&#34;,&#34;sovereignty&#34;:&#34;Ireland&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;IR&#34;,&#34;iso-a3&#34;:&#34;IRN&#34;,&#34;ISOname&#34;:&#34;Iran, Islamic Republic of&#34;,&#34;mapname&#34;:&#34;Iran&#34;,&#34;sovereignty&#34;:&#34;Iran&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;IQ&#34;,&#34;iso-a3&#34;:&#34;IRQ&#34;,&#34;ISOname&#34;:&#34;Iraq&#34;,&#34;mapname&#34;:&#34;Iraq&#34;,&#34;sovereignty&#34;:&#34;Iraq&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;IS&#34;,&#34;iso-a3&#34;:&#34;ISL&#34;,&#34;ISOname&#34;:&#34;Iceland&#34;,&#34;mapname&#34;:&#34;Iceland&#34;,&#34;sovereignty&#34;:&#34;Iceland&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;IL&#34;,&#34;iso-a3&#34;:&#34;ISR&#34;,&#34;ISOname&#34;:&#34;Israel&#34;,&#34;mapname&#34;:&#34;Israel&#34;,&#34;sovereignty&#34;:&#34;Israel&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;IT&#34;,&#34;iso-a3&#34;:&#34;ITA&#34;,&#34;ISOname&#34;:&#34;Italy&#34;,&#34;mapname&#34;:&#34;Italy&#34;,&#34;sovereignty&#34;:&#34;Italy&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;JM&#34;,&#34;iso-a3&#34;:&#34;JAM&#34;,&#34;ISOname&#34;:&#34;Jamaica&#34;,&#34;mapname&#34;:&#34;Jamaica&#34;,&#34;sovereignty&#34;:&#34;Jamaica&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;JE&#34;,&#34;iso-a3&#34;:&#34;JEY&#34;,&#34;ISOname&#34;:&#34;Jersey&#34;,&#34;mapname&#34;:&#34;Jersey&#34;,&#34;sovereignty&#34;:&#34;Jersey&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;JO&#34;,&#34;iso-a3&#34;:&#34;JOR&#34;,&#34;ISOname&#34;:&#34;Jordan&#34;,&#34;mapname&#34;:&#34;Jordan&#34;,&#34;sovereignty&#34;:&#34;Jordan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;JP&#34;,&#34;iso-a3&#34;:&#34;JPN&#34;,&#34;ISOname&#34;:&#34;Japan&#34;,&#34;mapname&#34;:&#34;Japan&#34;,&#34;sovereignty&#34;:&#34;Japan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KZ&#34;,&#34;iso-a3&#34;:&#34;KAZ&#34;,&#34;ISOname&#34;:&#34;Kazakhstan&#34;,&#34;mapname&#34;:&#34;Kazakhstan&#34;,&#34;sovereignty&#34;:&#34;Kazakhstan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KE&#34;,&#34;iso-a3&#34;:&#34;KEN&#34;,&#34;ISOname&#34;:&#34;Kenya&#34;,&#34;mapname&#34;:&#34;Kenya&#34;,&#34;sovereignty&#34;:&#34;Kenya&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KG&#34;,&#34;iso-a3&#34;:&#34;KGZ&#34;,&#34;ISOname&#34;:&#34;Kyrgyzstan&#34;,&#34;mapname&#34;:&#34;Kyrgyzstan&#34;,&#34;sovereignty&#34;:&#34;Kyrgyzstan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KH&#34;,&#34;iso-a3&#34;:&#34;KHM&#34;,&#34;ISOname&#34;:&#34;Cambodia&#34;,&#34;mapname&#34;:&#34;Cambodia&#34;,&#34;sovereignty&#34;:&#34;Cambodia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KI&#34;,&#34;iso-a3&#34;:&#34;KIR&#34;,&#34;ISOname&#34;:&#34;Kiribati&#34;,&#34;mapname&#34;:&#34;Kiribati&#34;,&#34;sovereignty&#34;:&#34;Kiribati&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KN&#34;,&#34;iso-a3&#34;:&#34;KNA&#34;,&#34;ISOname&#34;:&#34;Saint Kitts and Nevis&#34;,&#34;mapname&#34;:&#34;Saint Kitts&#34;,&#34;sovereignty&#34;:&#34;Saint Kitts and Nevis&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KN&#34;,&#34;iso-a3&#34;:&#34;KNA&#34;,&#34;ISOname&#34;:&#34;Saint Kitts and Nevis&#34;,&#34;mapname&#34;:&#34;Nevis&#34;,&#34;sovereignty&#34;:&#34;Saint Kitts and Nevis&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KR&#34;,&#34;iso-a3&#34;:&#34;KOR&#34;,&#34;ISOname&#34;:&#34;Republic of Korea&#34;,&#34;mapname&#34;:&#34;South Korea&#34;,&#34;sovereignty&#34;:&#34;South Korea&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KW&#34;,&#34;iso-a3&#34;:&#34;KWT&#34;,&#34;ISOname&#34;:&#34;Kuwait&#34;,&#34;mapname&#34;:&#34;Kuwait&#34;,&#34;sovereignty&#34;:&#34;Kuwait&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LA&#34;,&#34;iso-a3&#34;:&#34;LAO&#34;,&#34;ISOname&#34;:&#34;Lao People&#39;s Democratic Republic&#34;,&#34;mapname&#34;:&#34;Laos&#34;,&#34;sovereignty&#34;:&#34;Laos&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LB&#34;,&#34;iso-a3&#34;:&#34;LBN&#34;,&#34;ISOname&#34;:&#34;Lebanon&#34;,&#34;mapname&#34;:&#34;Lebanon&#34;,&#34;sovereignty&#34;:&#34;Lebanon&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LR&#34;,&#34;iso-a3&#34;:&#34;LBR&#34;,&#34;ISOname&#34;:&#34;Liberia&#34;,&#34;mapname&#34;:&#34;Liberia&#34;,&#34;sovereignty&#34;:&#34;Liberia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LY&#34;,&#34;iso-a3&#34;:&#34;LBY&#34;,&#34;ISOname&#34;:&#34;Libya&#34;,&#34;mapname&#34;:&#34;Libya&#34;,&#34;sovereignty&#34;:&#34;Libya&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LC&#34;,&#34;iso-a3&#34;:&#34;LCA&#34;,&#34;ISOname&#34;:&#34;Saint Lucia&#34;,&#34;mapname&#34;:&#34;Saint Lucia&#34;,&#34;sovereignty&#34;:&#34;Saint Lucia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LI&#34;,&#34;iso-a3&#34;:&#34;LIE&#34;,&#34;ISOname&#34;:&#34;Liechtenstein&#34;,&#34;mapname&#34;:&#34;Liechtenstein&#34;,&#34;sovereignty&#34;:&#34;Liechtenstein&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LK&#34;,&#34;iso-a3&#34;:&#34;LKA&#34;,&#34;ISOname&#34;:&#34;Sri Lanka&#34;,&#34;mapname&#34;:&#34;Sri Lanka&#34;,&#34;sovereignty&#34;:&#34;Sri Lanka&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LS&#34;,&#34;iso-a3&#34;:&#34;LSO&#34;,&#34;ISOname&#34;:&#34;Lesotho&#34;,&#34;mapname&#34;:&#34;Lesotho&#34;,&#34;sovereignty&#34;:&#34;Lesotho&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LT&#34;,&#34;iso-a3&#34;:&#34;LTU&#34;,&#34;ISOname&#34;:&#34;Lithuania&#34;,&#34;mapname&#34;:&#34;Lithuania&#34;,&#34;sovereignty&#34;:&#34;Lithuania&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;LU&#34;,&#34;iso-a3&#34;:&#34;LUX&#34;,&#34;ISOname&#34;:&#34;Luxembourg&#34;,&#34;mapname&#34;:&#34;Luxembourg&#34;,&#34;sovereignty&#34;:&#34;Luxembourg&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;LV&#34;,&#34;iso-a3&#34;:&#34;LVA&#34;,&#34;ISOname&#34;:&#34;Latvia&#34;,&#34;mapname&#34;:&#34;Latvia&#34;,&#34;sovereignty&#34;:&#34;Latvia&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;MO&#34;,&#34;iso-a3&#34;:&#34;MAC&#34;,&#34;ISOname&#34;:&#34;Macao&#34;,&#34;mapname&#34;:&#34;China:Macao&#34;,&#34;sovereignty&#34;:&#34;China&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MF&#34;,&#34;iso-a3&#34;:&#34;MAF&#34;,&#34;ISOname&#34;:&#34;Saint Martin (French part)&#34;,&#34;mapname&#34;:&#34;Saint Martin&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MA&#34;,&#34;iso-a3&#34;:&#34;MAR&#34;,&#34;ISOname&#34;:&#34;Morocco&#34;,&#34;mapname&#34;:&#34;Morocco&#34;,&#34;sovereignty&#34;:&#34;Morocco&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MC&#34;,&#34;iso-a3&#34;:&#34;MCO&#34;,&#34;ISOname&#34;:&#34;Monaco&#34;,&#34;mapname&#34;:&#34;Monaco&#34;,&#34;sovereignty&#34;:&#34;Monaco&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;MD&#34;,&#34;iso-a3&#34;:&#34;MDA&#34;,&#34;ISOname&#34;:&#34;Moldova, Republic of&#34;,&#34;mapname&#34;:&#34;Moldova&#34;,&#34;sovereignty&#34;:&#34;Moldova&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MG&#34;,&#34;iso-a3&#34;:&#34;MDG&#34;,&#34;ISOname&#34;:&#34;Madagascar&#34;,&#34;mapname&#34;:&#34;Madagascar&#34;,&#34;sovereignty&#34;:&#34;Madagascar&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MV&#34;,&#34;iso-a3&#34;:&#34;MDV&#34;,&#34;ISOname&#34;:&#34;Maldives&#34;,&#34;mapname&#34;:&#34;Maldives&#34;,&#34;sovereignty&#34;:&#34;Maldives&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MX&#34;,&#34;iso-a3&#34;:&#34;MEX&#34;,&#34;ISOname&#34;:&#34;Mexico&#34;,&#34;mapname&#34;:&#34;Mexico&#34;,&#34;sovereignty&#34;:&#34;Mexico&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MH&#34;,&#34;iso-a3&#34;:&#34;MHL&#34;,&#34;ISOname&#34;:&#34;Marshall Islands&#34;,&#34;mapname&#34;:&#34;Marshall Islands&#34;,&#34;sovereignty&#34;:&#34;Marshall Islands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MK&#34;,&#34;iso-a3&#34;:&#34;MKD&#34;,&#34;ISOname&#34;:&#34;Republic of North Macedonia&#34;,&#34;mapname&#34;:&#34;North Macedonia&#34;,&#34;sovereignty&#34;:&#34;North Macedonia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;ML&#34;,&#34;iso-a3&#34;:&#34;MLI&#34;,&#34;ISOname&#34;:&#34;Mali&#34;,&#34;mapname&#34;:&#34;Mali&#34;,&#34;sovereignty&#34;:&#34;Mali&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MT&#34;,&#34;iso-a3&#34;:&#34;MLT&#34;,&#34;ISOname&#34;:&#34;Malta&#34;,&#34;mapname&#34;:&#34;Malta&#34;,&#34;sovereignty&#34;:&#34;Malta&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MM&#34;,&#34;iso-a3&#34;:&#34;MMR&#34;,&#34;ISOname&#34;:&#34;Myanmar&#34;,&#34;mapname&#34;:&#34;Myanmar&#34;,&#34;sovereignty&#34;:&#34;Myanmar&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;ME&#34;,&#34;iso-a3&#34;:&#34;MNE&#34;,&#34;ISOname&#34;:&#34;Montenegro&#34;,&#34;mapname&#34;:&#34;Montenegro&#34;,&#34;sovereignty&#34;:&#34;Montenegro&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MN&#34;,&#34;iso-a3&#34;:&#34;MNG&#34;,&#34;ISOname&#34;:&#34;Mongolia&#34;,&#34;mapname&#34;:&#34;Mongolia&#34;,&#34;sovereignty&#34;:&#34;Mongolia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MP&#34;,&#34;iso-a3&#34;:&#34;MNP&#34;,&#34;ISOname&#34;:&#34;Northern Mariana Islands&#34;,&#34;mapname&#34;:&#34;Northern Mariana Islands&#34;,&#34;sovereignty&#34;:&#34;USA&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MZ&#34;,&#34;iso-a3&#34;:&#34;MOZ&#34;,&#34;ISOname&#34;:&#34;Mozambique&#34;,&#34;mapname&#34;:&#34;Mozambique&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MR&#34;,&#34;iso-a3&#34;:&#34;MRT&#34;,&#34;ISOname&#34;:&#34;Mauritania&#34;,&#34;mapname&#34;:&#34;Mauritania&#34;,&#34;sovereignty&#34;:&#34;Mauritania&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MS&#34;,&#34;iso-a3&#34;:&#34;MSR&#34;,&#34;ISOname&#34;:&#34;Montserrat&#34;,&#34;mapname&#34;:&#34;Montserrat&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MQ&#34;,&#34;iso-a3&#34;:&#34;MTQ&#34;,&#34;ISOname&#34;:&#34;Martinique&#34;,&#34;mapname&#34;:&#34;Martinique&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MU&#34;,&#34;iso-a3&#34;:&#34;MUS&#34;,&#34;ISOname&#34;:&#34;Mauritius&#34;,&#34;mapname&#34;:&#34;Mauritius&#34;,&#34;sovereignty&#34;:&#34;Mauritius&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MW&#34;,&#34;iso-a3&#34;:&#34;MWI&#34;,&#34;ISOname&#34;:&#34;Malawi&#34;,&#34;mapname&#34;:&#34;Malawi&#34;,&#34;sovereignty&#34;:&#34;Malawi&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;MY&#34;,&#34;iso-a3&#34;:&#34;MYS&#34;,&#34;ISOname&#34;:&#34;Malaysia&#34;,&#34;mapname&#34;:&#34;Malaysia&#34;,&#34;sovereignty&#34;:&#34;Malaysia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;YT&#34;,&#34;iso-a3&#34;:&#34;MYT&#34;,&#34;ISOname&#34;:&#34;Mayotte&#34;,&#34;mapname&#34;:&#34;Mayotte&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:null,&#34;iso-a3&#34;:&#34;NAM&#34;,&#34;ISOname&#34;:&#34;Namibia&#34;,&#34;mapname&#34;:&#34;Namibia&#34;,&#34;sovereignty&#34;:&#34;Namibia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NC&#34;,&#34;iso-a3&#34;:&#34;NCL&#34;,&#34;ISOname&#34;:&#34;New Caledonia&#34;,&#34;mapname&#34;:&#34;New Caledonia&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NE&#34;,&#34;iso-a3&#34;:&#34;NER&#34;,&#34;ISOname&#34;:&#34;Niger&#34;,&#34;mapname&#34;:&#34;Niger&#34;,&#34;sovereignty&#34;:&#34;Niger&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NF&#34;,&#34;iso-a3&#34;:&#34;NFK&#34;,&#34;ISOname&#34;:&#34;Norfolk Island&#34;,&#34;mapname&#34;:&#34;Norfolk Island&#34;,&#34;sovereignty&#34;:&#34;Australia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NG&#34;,&#34;iso-a3&#34;:&#34;NGA&#34;,&#34;ISOname&#34;:&#34;Nigeria&#34;,&#34;mapname&#34;:&#34;Nigeria&#34;,&#34;sovereignty&#34;:&#34;Nigeria&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NI&#34;,&#34;iso-a3&#34;:&#34;NIC&#34;,&#34;ISOname&#34;:&#34;Nicaragua&#34;,&#34;mapname&#34;:&#34;Nicaragua&#34;,&#34;sovereignty&#34;:&#34;Nicaragua&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NU&#34;,&#34;iso-a3&#34;:&#34;NIU&#34;,&#34;ISOname&#34;:&#34;Niue&#34;,&#34;mapname&#34;:&#34;Niue&#34;,&#34;sovereignty&#34;:&#34;Niue&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NL&#34;,&#34;iso-a3&#34;:&#34;NLD&#34;,&#34;ISOname&#34;:&#34;Netherlands&#34;,&#34;mapname&#34;:&#34;Netherlands&#34;,&#34;sovereignty&#34;:&#34;Netherlands&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;NO&#34;,&#34;iso-a3&#34;:&#34;NOR&#34;,&#34;ISOname&#34;:&#34;Norway&#34;,&#34;mapname&#34;:&#34;Norway(?!:Bouvet|:Svalbard|:Jan Mayen)&#34;,&#34;sovereignty&#34;:&#34;Norway&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;NP&#34;,&#34;iso-a3&#34;:&#34;NPL&#34;,&#34;ISOname&#34;:&#34;Nepal&#34;,&#34;mapname&#34;:&#34;Nepal&#34;,&#34;sovereignty&#34;:&#34;Nepal&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NR&#34;,&#34;iso-a3&#34;:&#34;NRU&#34;,&#34;ISOname&#34;:&#34;Nauru&#34;,&#34;mapname&#34;:&#34;Nauru&#34;,&#34;sovereignty&#34;:&#34;Nauru&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;NZ&#34;,&#34;iso-a3&#34;:&#34;NZL&#34;,&#34;ISOname&#34;:&#34;New Zealand&#34;,&#34;mapname&#34;:&#34;New Zealand&#34;,&#34;sovereignty&#34;:&#34;New Zealand&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;OM&#34;,&#34;iso-a3&#34;:&#34;OMN&#34;,&#34;ISOname&#34;:&#34;Oman&#34;,&#34;mapname&#34;:&#34;Oman&#34;,&#34;sovereignty&#34;:&#34;Oman&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PK&#34;,&#34;iso-a3&#34;:&#34;PAK&#34;,&#34;ISOname&#34;:&#34;Pakistan&#34;,&#34;mapname&#34;:&#34;Pakistan&#34;,&#34;sovereignty&#34;:&#34;Pakistan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PA&#34;,&#34;iso-a3&#34;:&#34;PAN&#34;,&#34;ISOname&#34;:&#34;Panama&#34;,&#34;mapname&#34;:&#34;Panama&#34;,&#34;sovereignty&#34;:&#34;Panama&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PN&#34;,&#34;iso-a3&#34;:&#34;PCN&#34;,&#34;ISOname&#34;:&#34;Pitcairn Islands&#34;,&#34;mapname&#34;:&#34;Pitcairn Islands&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PE&#34;,&#34;iso-a3&#34;:&#34;PER&#34;,&#34;ISOname&#34;:&#34;Peru&#34;,&#34;mapname&#34;:&#34;Peru&#34;,&#34;sovereignty&#34;:&#34;Peru&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PH&#34;,&#34;iso-a3&#34;:&#34;PHL&#34;,&#34;ISOname&#34;:&#34;Philippines&#34;,&#34;mapname&#34;:&#34;Philippines&#34;,&#34;sovereignty&#34;:&#34;Philippines&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PW&#34;,&#34;iso-a3&#34;:&#34;PLW&#34;,&#34;ISOname&#34;:&#34;Palau&#34;,&#34;mapname&#34;:&#34;Palau&#34;,&#34;sovereignty&#34;:&#34;USA&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PG&#34;,&#34;iso-a3&#34;:&#34;PNG&#34;,&#34;ISOname&#34;:&#34;Papua New Guinea&#34;,&#34;mapname&#34;:&#34;Papua New Guinea&#34;,&#34;sovereignty&#34;:&#34;Papua New Guinea&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PL&#34;,&#34;iso-a3&#34;:&#34;POL&#34;,&#34;ISOname&#34;:&#34;Poland&#34;,&#34;mapname&#34;:&#34;Poland&#34;,&#34;sovereignty&#34;:&#34;Poland&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PR&#34;,&#34;iso-a3&#34;:&#34;PRI&#34;,&#34;ISOname&#34;:&#34;Puerto Rico&#34;,&#34;mapname&#34;:&#34;Puerto Rico&#34;,&#34;sovereignty&#34;:&#34;Puerto Rico&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;KP&#34;,&#34;iso-a3&#34;:&#34;PRK&#34;,&#34;ISOname&#34;:&#34;Democratic People&#39;s Republic of Korea&#34;,&#34;mapname&#34;:&#34;North Korea&#34;,&#34;sovereignty&#34;:&#34;North Korea&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PT&#34;,&#34;iso-a3&#34;:&#34;PRT&#34;,&#34;ISOname&#34;:&#34;Portugal&#34;,&#34;mapname&#34;:&#34;Portugal&#34;,&#34;sovereignty&#34;:&#34;Portugal&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;PT&#34;,&#34;iso-a3&#34;:&#34;PRT&#34;,&#34;ISOname&#34;:&#34;Portugal&#34;,&#34;mapname&#34;:&#34;Azores&#34;,&#34;sovereignty&#34;:&#34;Portugal&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;PT&#34;,&#34;iso-a3&#34;:&#34;PRT&#34;,&#34;ISOname&#34;:&#34;Portugal&#34;,&#34;mapname&#34;:&#34;Madeira Islands&#34;,&#34;sovereignty&#34;:&#34;Portugal&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;PY&#34;,&#34;iso-a3&#34;:&#34;PRY&#34;,&#34;ISOname&#34;:&#34;Paraguay&#34;,&#34;mapname&#34;:&#34;Paraguay&#34;,&#34;sovereignty&#34;:&#34;Paraguay&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PS&#34;,&#34;iso-a3&#34;:&#34;PSE&#34;,&#34;ISOname&#34;:&#34;Palestine, State of&#34;,&#34;mapname&#34;:&#34;Palestine&#34;,&#34;sovereignty&#34;:&#34;Palestine&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PF&#34;,&#34;iso-a3&#34;:&#34;PYF&#34;,&#34;ISOname&#34;:&#34;French Polynesia&#34;,&#34;mapname&#34;:&#34;French Polynesia&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;QA&#34;,&#34;iso-a3&#34;:&#34;QAT&#34;,&#34;ISOname&#34;:&#34;Qatar&#34;,&#34;mapname&#34;:&#34;Qatar&#34;,&#34;sovereignty&#34;:&#34;Qatar&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;RE&#34;,&#34;iso-a3&#34;:&#34;REU&#34;,&#34;ISOname&#34;:&#34;Reunion&#34;,&#34;mapname&#34;:&#34;Reunion&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;RO&#34;,&#34;iso-a3&#34;:&#34;ROU&#34;,&#34;ISOname&#34;:&#34;Romania&#34;,&#34;mapname&#34;:&#34;Romania&#34;,&#34;sovereignty&#34;:&#34;Romania&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;RU&#34;,&#34;iso-a3&#34;:&#34;RUS&#34;,&#34;ISOname&#34;:&#34;Russian Federation&#34;,&#34;mapname&#34;:&#34;Russia&#34;,&#34;sovereignty&#34;:&#34;Russia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;RW&#34;,&#34;iso-a3&#34;:&#34;RWA&#34;,&#34;ISOname&#34;:&#34;Rwanda&#34;,&#34;mapname&#34;:&#34;Rwanda&#34;,&#34;sovereignty&#34;:&#34;Rwanda&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SA&#34;,&#34;iso-a3&#34;:&#34;SAU&#34;,&#34;ISOname&#34;:&#34;Saudi Arabia&#34;,&#34;mapname&#34;:&#34;Saudi Arabia&#34;,&#34;sovereignty&#34;:&#34;Saudi Arabia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SD&#34;,&#34;iso-a3&#34;:&#34;SDN&#34;,&#34;ISOname&#34;:&#34;Sudan&#34;,&#34;mapname&#34;:&#34;Sudan&#34;,&#34;sovereignty&#34;:&#34;Sudan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SN&#34;,&#34;iso-a3&#34;:&#34;SEN&#34;,&#34;ISOname&#34;:&#34;Senegal&#34;,&#34;mapname&#34;:&#34;Senegal&#34;,&#34;sovereignty&#34;:&#34;Senegal&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SG&#34;,&#34;iso-a3&#34;:&#34;SGP&#34;,&#34;ISOname&#34;:&#34;Singapore&#34;,&#34;mapname&#34;:&#34;Singapore&#34;,&#34;sovereignty&#34;:&#34;Singapore&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;GS&#34;,&#34;iso-a3&#34;:&#34;SGS&#34;,&#34;ISOname&#34;:&#34;South Georgia and the South Sandwich Islands&#34;,&#34;mapname&#34;:&#34;South Georgia&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;GS&#34;,&#34;iso-a3&#34;:&#34;SGS&#34;,&#34;ISOname&#34;:&#34;South Georgia and the South Sandwich Islands&#34;,&#34;mapname&#34;:&#34;South Sandwich Islands&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SH&#34;,&#34;iso-a3&#34;:&#34;SHN&#34;,&#34;ISOname&#34;:&#34;Saint Helena, Ascension and Tristan da Cunha&#34;,&#34;mapname&#34;:&#34;Saint Helena&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SH&#34;,&#34;iso-a3&#34;:&#34;SHN&#34;,&#34;ISOname&#34;:&#34;Saint Helena, Ascension and Tristan da Cunha&#34;,&#34;mapname&#34;:&#34;Ascension Island&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SH&#34;,&#34;iso-a3&#34;:&#34;SHN&#34;,&#34;ISOname&#34;:&#34;Saint Helena, Ascension and Tristan da Cunha&#34;,&#34;mapname&#34;:&#34;Tristan da Cunha&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SJ&#34;,&#34;iso-a3&#34;:&#34;SJM&#34;,&#34;ISOname&#34;:&#34;Svalbard and Jan Mayen&#34;,&#34;mapname&#34;:&#34;Norway:Svalbard&#34;,&#34;sovereignty&#34;:&#34;Norway&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SJ&#34;,&#34;iso-a3&#34;:&#34;SJM&#34;,&#34;ISOname&#34;:&#34;Svalbard and Jan Mayen&#34;,&#34;mapname&#34;:&#34;Norway:Jan Mayen&#34;,&#34;sovereignty&#34;:&#34;Norway&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SB&#34;,&#34;iso-a3&#34;:&#34;SLB&#34;,&#34;ISOname&#34;:&#34;Solomon Islands&#34;,&#34;mapname&#34;:&#34;Solomon Islands&#34;,&#34;sovereignty&#34;:&#34;Solomon Islands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SL&#34;,&#34;iso-a3&#34;:&#34;SLE&#34;,&#34;ISOname&#34;:&#34;Sierra Leone&#34;,&#34;mapname&#34;:&#34;Sierra Leone&#34;,&#34;sovereignty&#34;:&#34;Sierra Leone&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SV&#34;,&#34;iso-a3&#34;:&#34;SLV&#34;,&#34;ISOname&#34;:&#34;El Salvador&#34;,&#34;mapname&#34;:&#34;El Salvador&#34;,&#34;sovereignty&#34;:&#34;El Salvador&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SM&#34;,&#34;iso-a3&#34;:&#34;SMR&#34;,&#34;ISOname&#34;:&#34;San Marino&#34;,&#34;mapname&#34;:&#34;San Marino&#34;,&#34;sovereignty&#34;:&#34;San Marino&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SO&#34;,&#34;iso-a3&#34;:&#34;SOM&#34;,&#34;ISOname&#34;:&#34;Somalia&#34;,&#34;mapname&#34;:&#34;Somalia&#34;,&#34;sovereignty&#34;:&#34;Somalia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;PM&#34;,&#34;iso-a3&#34;:&#34;SPM&#34;,&#34;ISOname&#34;:&#34;Saint Pierre and Miquelon&#34;,&#34;mapname&#34;:&#34;Saint Pierre and Miquelon&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;RS&#34;,&#34;iso-a3&#34;:&#34;SRB&#34;,&#34;ISOname&#34;:&#34;Serbia&#34;,&#34;mapname&#34;:&#34;Serbia&#34;,&#34;sovereignty&#34;:&#34;Serbia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SS&#34;,&#34;iso-a3&#34;:&#34;SSD&#34;,&#34;ISOname&#34;:&#34;South Sudan&#34;,&#34;mapname&#34;:&#34;South Sudan&#34;,&#34;sovereignty&#34;:&#34;South Sudan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;ST&#34;,&#34;iso-a3&#34;:&#34;STP&#34;,&#34;ISOname&#34;:&#34;Sao Tome and Principe&#34;,&#34;mapname&#34;:&#34;Sao Tome and Principe&#34;,&#34;sovereignty&#34;:&#34;Sao Tome and Principe&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SR&#34;,&#34;iso-a3&#34;:&#34;SUR&#34;,&#34;ISOname&#34;:&#34;Suriname&#34;,&#34;mapname&#34;:&#34;Suriname&#34;,&#34;sovereignty&#34;:&#34;Suriname&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SK&#34;,&#34;iso-a3&#34;:&#34;SVK&#34;,&#34;ISOname&#34;:&#34;Slovakia&#34;,&#34;mapname&#34;:&#34;Slovakia&#34;,&#34;sovereignty&#34;:&#34;Slovakia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SI&#34;,&#34;iso-a3&#34;:&#34;SVN&#34;,&#34;ISOname&#34;:&#34;Slovenia&#34;,&#34;mapname&#34;:&#34;Slovenia&#34;,&#34;sovereignty&#34;:&#34;Slovenia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SE&#34;,&#34;iso-a3&#34;:&#34;SWE&#34;,&#34;ISOname&#34;:&#34;Sweden&#34;,&#34;mapname&#34;:&#34;Sweden&#34;,&#34;sovereignty&#34;:&#34;Sweden&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;SZ&#34;,&#34;iso-a3&#34;:&#34;SWZ&#34;,&#34;ISOname&#34;:&#34;Swaziland&#34;,&#34;mapname&#34;:&#34;Swaziland&#34;,&#34;sovereignty&#34;:&#34;Swaziland&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SX&#34;,&#34;iso-a3&#34;:&#34;SXM&#34;,&#34;ISOname&#34;:&#34;Sint Maarten (Dutch part)&#34;,&#34;mapname&#34;:&#34;Sint Maarten&#34;,&#34;sovereignty&#34;:&#34;Netherlands&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SC&#34;,&#34;iso-a3&#34;:&#34;SYC&#34;,&#34;ISOname&#34;:&#34;Seychelles&#34;,&#34;mapname&#34;:&#34;Seychelles&#34;,&#34;sovereignty&#34;:&#34;Seychelles&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;SY&#34;,&#34;iso-a3&#34;:&#34;SYR&#34;,&#34;ISOname&#34;:&#34;Syrian Arab Republic&#34;,&#34;mapname&#34;:&#34;Syria&#34;,&#34;sovereignty&#34;:&#34;Syria&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TC&#34;,&#34;iso-a3&#34;:&#34;TCA&#34;,&#34;ISOname&#34;:&#34;Turks and Caicos Islands&#34;,&#34;mapname&#34;:&#34;Turks and Caicos Islands&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TD&#34;,&#34;iso-a3&#34;:&#34;TCD&#34;,&#34;ISOname&#34;:&#34;Chad&#34;,&#34;mapname&#34;:&#34;Chad&#34;,&#34;sovereignty&#34;:&#34;Chad&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TG&#34;,&#34;iso-a3&#34;:&#34;TGO&#34;,&#34;ISOname&#34;:&#34;Togo&#34;,&#34;mapname&#34;:&#34;Togo&#34;,&#34;sovereignty&#34;:&#34;Togo&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TH&#34;,&#34;iso-a3&#34;:&#34;THA&#34;,&#34;ISOname&#34;:&#34;Thailand&#34;,&#34;mapname&#34;:&#34;Thailand&#34;,&#34;sovereignty&#34;:&#34;Thailand&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;TJ&#34;,&#34;iso-a3&#34;:&#34;TJK&#34;,&#34;ISOname&#34;:&#34;Tajikistan&#34;,&#34;mapname&#34;:&#34;Tajikistan&#34;,&#34;sovereignty&#34;:&#34;Tajikistan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TK&#34;,&#34;iso-a3&#34;:&#34;TKL&#34;,&#34;ISOname&#34;:&#34;Tokelau&#34;,&#34;mapname&#34;:&#34;Tokelau&#34;,&#34;sovereignty&#34;:&#34;New Zealand&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TM&#34;,&#34;iso-a3&#34;:&#34;TKM&#34;,&#34;ISOname&#34;:&#34;Turkmenistan&#34;,&#34;mapname&#34;:&#34;Turkmenistan&#34;,&#34;sovereignty&#34;:&#34;Turkmenistan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TL&#34;,&#34;iso-a3&#34;:&#34;TLS&#34;,&#34;ISOname&#34;:&#34;Timor-Leste&#34;,&#34;mapname&#34;:&#34;Timor-Leste&#34;,&#34;sovereignty&#34;:&#34;Timor-Leste&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TO&#34;,&#34;iso-a3&#34;:&#34;TON&#34;,&#34;ISOname&#34;:&#34;Tonga&#34;,&#34;mapname&#34;:&#34;Tonga&#34;,&#34;sovereignty&#34;:&#34;Tonga&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TT&#34;,&#34;iso-a3&#34;:&#34;TTO&#34;,&#34;ISOname&#34;:&#34;Trinidad and Tobago&#34;,&#34;mapname&#34;:&#34;Trinidad&#34;,&#34;sovereignty&#34;:&#34;Trinidad and Tobago&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TT&#34;,&#34;iso-a3&#34;:&#34;TTO&#34;,&#34;ISOname&#34;:&#34;Trinidad and Tobago&#34;,&#34;mapname&#34;:&#34;Tobago&#34;,&#34;sovereignty&#34;:&#34;Trinidad and Tobago&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TN&#34;,&#34;iso-a3&#34;:&#34;TUN&#34;,&#34;ISOname&#34;:&#34;Tunisia&#34;,&#34;mapname&#34;:&#34;Tunisia&#34;,&#34;sovereignty&#34;:&#34;Tunisia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TR&#34;,&#34;iso-a3&#34;:&#34;TUR&#34;,&#34;ISOname&#34;:&#34;Turkey&#34;,&#34;mapname&#34;:&#34;Turkey&#34;,&#34;sovereignty&#34;:&#34;Turkey&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TV&#34;,&#34;iso-a3&#34;:&#34;TUV&#34;,&#34;ISOname&#34;:&#34;Tuvalu&#34;,&#34;mapname&#34;:&#34;Tuvalu&#34;,&#34;sovereignty&#34;:&#34;Tuvalu&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;TW&#34;,&#34;iso-a3&#34;:&#34;TWN&#34;,&#34;ISOname&#34;:&#34;Taiwan&#34;,&#34;mapname&#34;:&#34;Taiwan&#34;,&#34;sovereignty&#34;:&#34;Taiwan&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;TZ&#34;,&#34;iso-a3&#34;:&#34;TZA&#34;,&#34;ISOname&#34;:&#34;Tanzania, United Republic of&#34;,&#34;mapname&#34;:&#34;Tanzania&#34;,&#34;sovereignty&#34;:&#34;Tanzania&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;UG&#34;,&#34;iso-a3&#34;:&#34;UGA&#34;,&#34;ISOname&#34;:&#34;Uganda&#34;,&#34;mapname&#34;:&#34;Uganda&#34;,&#34;sovereignty&#34;:&#34;Uganda&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;UA&#34;,&#34;iso-a3&#34;:&#34;UKR&#34;,&#34;ISOname&#34;:&#34;Ukraine&#34;,&#34;mapname&#34;:&#34;Ukraine&#34;,&#34;sovereignty&#34;:&#34;Ukraine&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;UM&#34;,&#34;iso-a3&#34;:&#34;UMI&#34;,&#34;ISOname&#34;:&#34;United States Minor Outlying Islands&#34;,&#34;mapname&#34;:&#34;US Minor Outlying Islands&#34;,&#34;sovereignty&#34;:&#34;USA&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;UY&#34;,&#34;iso-a3&#34;:&#34;URY&#34;,&#34;ISOname&#34;:&#34;Uruguay&#34;,&#34;mapname&#34;:&#34;Uruguay&#34;,&#34;sovereignty&#34;:&#34;Uruguay&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;US&#34;,&#34;iso-a3&#34;:&#34;USA&#34;,&#34;ISOname&#34;:&#34;United States&#34;,&#34;mapname&#34;:&#34;USA&#34;,&#34;sovereignty&#34;:&#34;USA&#34;,&#34;value&#34;:1},{&#34;a2&#34;:&#34;UZ&#34;,&#34;iso-a3&#34;:&#34;UZB&#34;,&#34;ISOname&#34;:&#34;Uzbekistan&#34;,&#34;mapname&#34;:&#34;Uzbekistan&#34;,&#34;sovereignty&#34;:&#34;Uzbekistan&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;VA&#34;,&#34;iso-a3&#34;:&#34;VAT&#34;,&#34;ISOname&#34;:&#34;Holy See (Vatican City State)&#34;,&#34;mapname&#34;:&#34;Vatican&#34;,&#34;sovereignty&#34;:&#34;Vatican&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;VC&#34;,&#34;iso-a3&#34;:&#34;VCT&#34;,&#34;ISOname&#34;:&#34;Saint Vincent and the Grenadines&#34;,&#34;mapname&#34;:&#34;Saint Vincent&#34;,&#34;sovereignty&#34;:&#34;Saint Vincent and the Grenadines&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;VC&#34;,&#34;iso-a3&#34;:&#34;VCT&#34;,&#34;ISOname&#34;:&#34;Saint Vincent and the Grenadines&#34;,&#34;mapname&#34;:&#34;Grenadines&#34;,&#34;sovereignty&#34;:&#34;Saint Vincent and the Grenadines&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;VE&#34;,&#34;iso-a3&#34;:&#34;VEN&#34;,&#34;ISOname&#34;:&#34;Venezuela, Bolivarian Republic of&#34;,&#34;mapname&#34;:&#34;Venezuela&#34;,&#34;sovereignty&#34;:&#34;Venezuela&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;VG&#34;,&#34;iso-a3&#34;:&#34;VGB&#34;,&#34;ISOname&#34;:&#34;Virgin Islands, British&#34;,&#34;mapname&#34;:&#34;Virgin Islands, British&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;VI&#34;,&#34;iso-a3&#34;:&#34;VIR&#34;,&#34;ISOname&#34;:&#34;Virgin Islands, U.S.&#34;,&#34;mapname&#34;:&#34;Virgin Islands, US&#34;,&#34;sovereignty&#34;:&#34;USA&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;VN&#34;,&#34;iso-a3&#34;:&#34;VNM&#34;,&#34;ISOname&#34;:&#34;Vietnam&#34;,&#34;mapname&#34;:&#34;Vietnam&#34;,&#34;sovereignty&#34;:&#34;Vietnam&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;VU&#34;,&#34;iso-a3&#34;:&#34;VUT&#34;,&#34;ISOname&#34;:&#34;Vanuatu&#34;,&#34;mapname&#34;:&#34;Vanuatu&#34;,&#34;sovereignty&#34;:&#34;Vanuatu&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;WF&#34;,&#34;iso-a3&#34;:&#34;WLF&#34;,&#34;ISOname&#34;:&#34;Wallis and Futuna&#34;,&#34;mapname&#34;:&#34;Wallis and Futuna&#34;,&#34;sovereignty&#34;:&#34;France&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;WS&#34;,&#34;iso-a3&#34;:&#34;WSM&#34;,&#34;ISOname&#34;:&#34;Samoa&#34;,&#34;mapname&#34;:&#34;Samoa&#34;,&#34;sovereignty&#34;:&#34;Samoa&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;XK&#34;,&#34;iso-a3&#34;:&#34;???&#34;,&#34;ISOname&#34;:&#34;Kosovo&#34;,&#34;mapname&#34;:&#34;Kosovo&#34;,&#34;sovereignty&#34;:&#34;Kosovo&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;YE&#34;,&#34;iso-a3&#34;:&#34;YEM&#34;,&#34;ISOname&#34;:&#34;Yemen&#34;,&#34;mapname&#34;:&#34;Yemen&#34;,&#34;sovereignty&#34;:&#34;Yemen&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;ZA&#34;,&#34;iso-a3&#34;:&#34;ZAF&#34;,&#34;ISOname&#34;:&#34;South Africa&#34;,&#34;mapname&#34;:&#34;South Africa&#34;,&#34;sovereignty&#34;:&#34;South Africa&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;ZM&#34;,&#34;iso-a3&#34;:&#34;ZMB&#34;,&#34;ISOname&#34;:&#34;Zambia&#34;,&#34;mapname&#34;:&#34;Zambia&#34;,&#34;sovereignty&#34;:&#34;Zambia&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;ZW&#34;,&#34;iso-a3&#34;:&#34;ZWE&#34;,&#34;ISOname&#34;:&#34;Zimbabwe&#34;,&#34;mapname&#34;:&#34;Zimbabwe&#34;,&#34;sovereignty&#34;:&#34;Zimbabwe&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;??&#34;,&#34;iso-a3&#34;:&#34;??&#34;,&#34;ISOname&#34;:&#34;Akrotiri&#34;,&#34;mapname&#34;:&#34;Cyprus:Akrotiri&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0},{&#34;a2&#34;:&#34;??&#34;,&#34;iso-a3&#34;:&#34;??&#34;,&#34;ISOname&#34;:&#34;Dhekeli&#34;,&#34;mapname&#34;:&#34;Cyprus:Dhekeli&#34;,&#34;sovereignty&#34;:&#34;UK&#34;,&#34;value&#34;:0}],&#34;joinBy&#34;:&#34;iso-a3&#34;,&#34;showInLegend&#34;:false,&#34;nullColor&#34;:&#34;#DADADA&#34;}],&#34;colorAxis&#34;:{&#34;auxpar&#34;:null},&#34;mapNavigation&#34;:{&#34;enabled&#34;:false},&#34;legend&#34;:[&#34;none&#34;]},&#34;theme&#34;:{&#34;chart&#34;:{&#34;backgroundColor&#34;:&#34;transparent&#34;},&#34;colors&#34;:[&#34;#7cb5ec&#34;,&#34;#434348&#34;,&#34;#90ed7d&#34;,&#34;#f7a35c&#34;,&#34;#8085e9&#34;,&#34;#f15c80&#34;,&#34;#e4d354&#34;,&#34;#2b908f&#34;,&#34;#f45b5b&#34;,&#34;#91e8e1&#34;]},&#34;conf_opts&#34;:{&#34;global&#34;:{&#34;Date&#34;:null,&#34;VMLRadialGradientURL&#34;:&#34;http =//code.highcharts.com/list(version)/gfx/vml-radial-gradient.png&#34;,&#34;canvasToolsURL&#34;:&#34;http =//code.highcharts.com/list(version)/modules/canvas-tools.js&#34;,&#34;getTimezoneOffset&#34;:null,&#34;timezoneOffset&#34;:0,&#34;useUTC&#34;:true},&#34;lang&#34;:{&#34;contextButtonTitle&#34;:&#34;Chart context menu&#34;,&#34;decimalPoint&#34;:&#34;.&#34;,&#34;downloadCSV&#34;:&#34;Download CSV&#34;,&#34;downloadJPEG&#34;:&#34;Download JPEG image&#34;,&#34;downloadPDF&#34;:&#34;Download PDF document&#34;,&#34;downloadPNG&#34;:&#34;Download PNG image&#34;,&#34;downloadSVG&#34;:&#34;Download SVG vector image&#34;,&#34;downloadXLS&#34;:&#34;Download XLS&#34;,&#34;drillUpText&#34;:&#34;◁ Back to {series.name}&#34;,&#34;exitFullscreen&#34;:&#34;Exit from full screen&#34;,&#34;exportData&#34;:{&#34;annotationHeader&#34;:&#34;Annotations&#34;,&#34;categoryDatetimeHeader&#34;:&#34;DateTime&#34;,&#34;categoryHeader&#34;:&#34;Category&#34;},&#34;hideData&#34;:&#34;Hide data table&#34;,&#34;invalidDate&#34;:null,&#34;loading&#34;:&#34;Loading...&#34;,&#34;months&#34;:[&#34;January&#34;,&#34;February&#34;,&#34;March&#34;,&#34;April&#34;,&#34;May&#34;,&#34;June&#34;,&#34;July&#34;,&#34;August&#34;,&#34;September&#34;,&#34;October&#34;,&#34;November&#34;,&#34;December&#34;],&#34;noData&#34;:&#34;No data to display&#34;,&#34;numericSymbolMagnitude&#34;:1000,&#34;numericSymbols&#34;:[&#34;k&#34;,&#34;M&#34;,&#34;G&#34;,&#34;T&#34;,&#34;P&#34;,&#34;E&#34;],&#34;printChart&#34;:&#34;Print chart&#34;,&#34;resetZoom&#34;:&#34;Reset zoom&#34;,&#34;resetZoomTitle&#34;:&#34;Reset zoom level 1:1&#34;,&#34;shortMonths&#34;:[&#34;Jan&#34;,&#34;Feb&#34;,&#34;Mar&#34;,&#34;Apr&#34;,&#34;May&#34;,&#34;Jun&#34;,&#34;Jul&#34;,&#34;Aug&#34;,&#34;Sep&#34;,&#34;Oct&#34;,&#34;Nov&#34;,&#34;Dec&#34;],&#34;shortWeekdays&#34;:[&#34;Sat&#34;,&#34;Sun&#34;,&#34;Mon&#34;,&#34;Tue&#34;,&#34;Wed&#34;,&#34;Thu&#34;,&#34;Fri&#34;],&#34;thousandsSep&#34;:&#34; &#34;,&#34;viewData&#34;:&#34;View data table&#34;,&#34;viewFullscreen&#34;:&#34;View in full screen&#34;,&#34;weekdays&#34;:[&#34;Sunday&#34;,&#34;Monday&#34;,&#34;Tuesday&#34;,&#34;Wednesday&#34;,&#34;Thursday&#34;,&#34;Friday&#34;,&#34;Saturday&#34;]}},&#34;type&#34;:&#34;map&#34;,&#34;fonts&#34;:[],&#34;debug&#34;:false},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;To draw this map in R, you will need the following packages:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(highcharter)
library(dplyr)
library(maps)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As usual, you need the packages to be installed on your machine before loading them with &lt;code&gt;library()&lt;/code&gt;. You can &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; with the command &lt;code&gt;install.packages(&#34;name_of_package&#34;)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;After having loaded the packages, we are going to use the dataset called &lt;code&gt;iso3166&lt;/code&gt; from the &lt;code&gt;{maps}&lt;/code&gt; package and rename it &lt;code&gt;dat&lt;/code&gt;. Here are the first 6 rows of the dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iso3166
head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   a2  a3       ISOname               mapname sovereignty
## 1 AW ABW         Aruba                 Aruba Netherlands
## 2 AF AFG   Afghanistan           Afghanistan Afghanistan
## 3 AO AGO        Angola                Angola      Angola
## 4 AI AIA      Anguilla              Anguilla    Anguilla
## 5 AX ALA Aland Islands Finland:Aland Islands     Finland
## 6 AL ALB       Albania               Albania     Albania&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We rename the variable &lt;code&gt;a3&lt;/code&gt; by &lt;code&gt;iso-a3&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- rename(dat, &amp;quot;iso-a3&amp;quot; = a3)
head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   a2 iso-a3       ISOname               mapname sovereignty
## 1 AW    ABW         Aruba                 Aruba Netherlands
## 2 AF    AFG   Afghanistan           Afghanistan Afghanistan
## 3 AO    AGO        Angola                Angola      Angola
## 4 AI    AIA      Anguilla              Anguilla    Anguilla
## 5 AX    ALA Aland Islands Finland:Aland Islands     Finland
## 6 AL    ALB       Albania               Albania     Albania&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We save the visited countries in a vector called &lt;code&gt;countries_visited&lt;/code&gt;. To know the ISO codes of the countries you have visited, check the column &lt;code&gt;ISOname&lt;/code&gt; in the dataset and extract the ISO codes from the column &lt;code&gt;iso-a3&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;countries_visited &amp;lt;- c(&amp;quot;AUS&amp;quot;, &amp;quot;AUT&amp;quot;, &amp;quot;BEL&amp;quot;, &amp;quot;CAN&amp;quot;, &amp;quot;CZE&amp;quot;, &amp;quot;DNK&amp;quot;, &amp;quot;FIN&amp;quot;, &amp;quot;FRA&amp;quot;, &amp;quot;DEU&amp;quot;, &amp;quot;GRC&amp;quot;, &amp;quot;HUN&amp;quot;, &amp;quot;IDN&amp;quot;, &amp;quot;IRL&amp;quot;, &amp;quot;ITA&amp;quot;, &amp;quot;LVA&amp;quot;, &amp;quot;LUX&amp;quot;, &amp;quot;MCO&amp;quot;, &amp;quot;MMR&amp;quot;, &amp;quot;NLD&amp;quot;, &amp;quot;NZL&amp;quot;, &amp;quot;NOR&amp;quot;, &amp;quot;PRT&amp;quot;, &amp;quot;ROU&amp;quot;, &amp;quot;SGP&amp;quot;, &amp;quot;ESP&amp;quot;, &amp;quot;SWE&amp;quot;, &amp;quot;CHE&amp;quot;, &amp;quot;TWN&amp;quot;, &amp;quot;THA&amp;quot;, &amp;quot;GBR&amp;quot;, &amp;quot;USA&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now create a new variable called &lt;code&gt;visited&lt;/code&gt; which equals to 1 if you have visited the country and 0 otherwise:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$visited &amp;lt;- ifelse(dat$`iso-a3` %in% countries_visited, 1, 0)
head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   a2 iso-a3       ISOname               mapname sovereignty visited
## 1 AW    ABW         Aruba                 Aruba Netherlands       0
## 2 AF    AFG   Afghanistan           Afghanistan Afghanistan       0
## 3 AO    AGO        Angola                Angola      Angola       0
## 4 AI    AIA      Anguilla              Anguilla    Anguilla       0
## 5 AX    ALA Aland Islands Finland:Aland Islands     Finland       0
## 6 AL    ALB       Albania               Albania     Albania       0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we are ready to draw the world map thanks to the &lt;code&gt;hcmap()&lt;/code&gt; command from the &lt;code&gt;{highcharter}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hcmap(
  map = &amp;quot;custom/world-highres3&amp;quot;, # high resolution world map
  data = dat, # name of dataset
  joinBy = &amp;quot;iso-a3&amp;quot;,
  value = &amp;quot;visited&amp;quot;,
  showInLegend = FALSE, # hide legend
  nullColor = &amp;quot;#DADADA&amp;quot;,
  download_map_data = TRUE
) %&amp;gt;%
  hc_mapNavigation(enabled = FALSE) %&amp;gt;%
  hc_legend(&amp;quot;none&amp;quot;) %&amp;gt;%
  hc_title(text = &amp;quot;World map&amp;quot;) # title&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change the arguments to your needs and you are good to go.&lt;/p&gt;
&lt;p&gt;To go even further, you can also add a list including all visited countries thanks to this code:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- subset(dat, dat$visited == 1)
sort(unique(dat$ISOname)) # sort to have the visited countries in alphabetical order&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Australia&amp;quot;                                           
##  [2] &amp;quot;Austria&amp;quot;                                             
##  [3] &amp;quot;Belgium&amp;quot;                                             
##  [4] &amp;quot;Canada&amp;quot;                                              
##  [5] &amp;quot;Clipperton Island&amp;quot;                                   
##  [6] &amp;quot;Czech Republic&amp;quot;                                      
##  [7] &amp;quot;Denmark&amp;quot;                                             
##  [8] &amp;quot;Finland&amp;quot;                                             
##  [9] &amp;quot;France&amp;quot;                                              
## [10] &amp;quot;Germany&amp;quot;                                             
## [11] &amp;quot;Greece&amp;quot;                                              
## [12] &amp;quot;Hungary&amp;quot;                                             
## [13] &amp;quot;Indonesia&amp;quot;                                           
## [14] &amp;quot;Ireland&amp;quot;                                             
## [15] &amp;quot;Italy&amp;quot;                                               
## [16] &amp;quot;Latvia&amp;quot;                                              
## [17] &amp;quot;Luxembourg&amp;quot;                                          
## [18] &amp;quot;Monaco&amp;quot;                                              
## [19] &amp;quot;Myanmar&amp;quot;                                             
## [20] &amp;quot;Netherlands&amp;quot;                                         
## [21] &amp;quot;New Zealand&amp;quot;                                         
## [22] &amp;quot;Norway&amp;quot;                                              
## [23] &amp;quot;Portugal&amp;quot;                                            
## [24] &amp;quot;Romania&amp;quot;                                             
## [25] &amp;quot;Singapore&amp;quot;                                           
## [26] &amp;quot;Spain&amp;quot;                                               
## [27] &amp;quot;Sweden&amp;quot;                                              
## [28] &amp;quot;Switzerland&amp;quot;                                         
## [29] &amp;quot;Taiwan&amp;quot;                                              
## [30] &amp;quot;Thailand&amp;quot;                                            
## [31] &amp;quot;United Kingdom of Great Britain and Northern Ireland&amp;quot;
## [32] &amp;quot;United States&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I never went to Clipperton Island, so I’ll remove it from the list:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- subset(dat, dat$ISOname != &amp;quot;Clipperton Island&amp;quot;)
sort(unique(dat$ISOname))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Australia&amp;quot;                                           
##  [2] &amp;quot;Austria&amp;quot;                                             
##  [3] &amp;quot;Belgium&amp;quot;                                             
##  [4] &amp;quot;Canada&amp;quot;                                              
##  [5] &amp;quot;Czech Republic&amp;quot;                                      
##  [6] &amp;quot;Denmark&amp;quot;                                             
##  [7] &amp;quot;Finland&amp;quot;                                             
##  [8] &amp;quot;France&amp;quot;                                              
##  [9] &amp;quot;Germany&amp;quot;                                             
## [10] &amp;quot;Greece&amp;quot;                                              
## [11] &amp;quot;Hungary&amp;quot;                                             
## [12] &amp;quot;Indonesia&amp;quot;                                           
## [13] &amp;quot;Ireland&amp;quot;                                             
## [14] &amp;quot;Italy&amp;quot;                                               
## [15] &amp;quot;Latvia&amp;quot;                                              
## [16] &amp;quot;Luxembourg&amp;quot;                                          
## [17] &amp;quot;Monaco&amp;quot;                                              
## [18] &amp;quot;Myanmar&amp;quot;                                             
## [19] &amp;quot;Netherlands&amp;quot;                                         
## [20] &amp;quot;New Zealand&amp;quot;                                         
## [21] &amp;quot;Norway&amp;quot;                                              
## [22] &amp;quot;Portugal&amp;quot;                                            
## [23] &amp;quot;Romania&amp;quot;                                             
## [24] &amp;quot;Singapore&amp;quot;                                           
## [25] &amp;quot;Spain&amp;quot;                                               
## [26] &amp;quot;Sweden&amp;quot;                                              
## [27] &amp;quot;Switzerland&amp;quot;                                         
## [28] &amp;quot;Taiwan&amp;quot;                                              
## [29] &amp;quot;Thailand&amp;quot;                                            
## [30] &amp;quot;United Kingdom of Great Britain and Northern Ireland&amp;quot;
## [31] &amp;quot;United States&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And finally, count the number of countries visited:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;paste(
  &amp;quot;Total: &amp;quot;,
  length(unique(dat$ISOname)),
  &amp;quot; countries.&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Total:  31  countries.&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In conclusion, here is the entire code to draw a world map with visited countries highlighted, a list of all countries in alphabetical order and the number of countries visited:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(highcharter)
library(dplyr)
library(maps)

dat &amp;lt;- iso3166
dat &amp;lt;- rename(dat, &amp;quot;iso-a3&amp;quot; = a3)
countries_visited &amp;lt;- c(&amp;quot;AUS&amp;quot;, &amp;quot;AUT&amp;quot;, &amp;quot;BEL&amp;quot;, &amp;quot;CAN&amp;quot;, &amp;quot;CZE&amp;quot;, &amp;quot;DNK&amp;quot;, &amp;quot;FIN&amp;quot;, &amp;quot;FRA&amp;quot;, &amp;quot;DEU&amp;quot;, &amp;quot;GRC&amp;quot;, &amp;quot;HUN&amp;quot;, &amp;quot;IDN&amp;quot;, &amp;quot;IRL&amp;quot;, &amp;quot;ITA&amp;quot;, &amp;quot;LVA&amp;quot;, &amp;quot;LUX&amp;quot;, &amp;quot;MCO&amp;quot;, &amp;quot;MMR&amp;quot;, &amp;quot;NLD&amp;quot;, &amp;quot;NZL&amp;quot;, &amp;quot;NOR&amp;quot;, &amp;quot;PRT&amp;quot;, &amp;quot;ROU&amp;quot;, &amp;quot;SGP&amp;quot;, &amp;quot;ESP&amp;quot;, &amp;quot;SWE&amp;quot;, &amp;quot;CHE&amp;quot;, &amp;quot;TWN&amp;quot;, &amp;quot;THA&amp;quot;, &amp;quot;GBR&amp;quot;, &amp;quot;USA&amp;quot;)
dat$visited &amp;lt;- ifelse(dat$`iso-a3` %in% countries_visited, 1, 0)

hcmap(
  map = &amp;quot;custom/world-highres3&amp;quot;, # high resolution world map
  data = dat, # name of dataset
  joinBy = &amp;quot;iso-a3&amp;quot;,
  value = &amp;quot;visited&amp;quot;,
  showInLegend = FALSE, # hide legend
  nullColor = &amp;quot;#DADADA&amp;quot;,
  download_map_data = TRUE
) %&amp;gt;%
  hc_mapNavigation(enabled = FALSE) %&amp;gt;%
  hc_legend(&amp;quot;none&amp;quot;) %&amp;gt;%
  hc_title(text = &amp;quot;World map&amp;quot;) # title

dat &amp;lt;- subset(dat, dat$visited == 1 &amp;amp; dat$ISOname != &amp;quot;Clipperton Island&amp;quot;)
sort(unique(dat$ISOname)) # sort to have the visited countries in alphabetical order

paste(
  &amp;quot;Total: &amp;quot;,
  length(unique(dat$ISOname)),
  &amp;quot; countries.&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thanks for reading. I hope this article helped you to draw a world map with visited countries highlighted in R.&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;
</description>
    </item>
    
    <item>
      <title>Data types in R</title>
      <link>https://statsandr.com/blog/data-types-in-r/</link>
      <pubDate>Mon, 30 Dec 2019 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/data-types-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-data-types-exist-in-r&#34; id=&#34;toc-what-data-types-exist-in-r&#34;&gt;What data types exist in R?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#numeric&#34; id=&#34;toc-numeric&#34;&gt;Numeric&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#integer&#34; id=&#34;toc-integer&#34;&gt;Integer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#character&#34; id=&#34;toc-character&#34;&gt;Character&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#factor&#34; id=&#34;toc-factor&#34;&gt;Factor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#logical&#34; id=&#34;toc-logical&#34;&gt;Logical&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/data-types-in-r_files/0_Lck0ET_fVy_P3VNK.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This article presents the different data types in R. To learn about the different variable types from a statistical point of view, read “&lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;Variable types and examples&lt;/a&gt;”.&lt;/p&gt;
&lt;div id=&#34;what-data-types-exist-in-r&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What data types exist in R?&lt;/h1&gt;
&lt;p&gt;There are the 6 most common data types in R:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Numeric&lt;/li&gt;
&lt;li&gt;Integer&lt;/li&gt;
&lt;li&gt;Complex&lt;/li&gt;
&lt;li&gt;Character&lt;/li&gt;
&lt;li&gt;Factor&lt;/li&gt;
&lt;li&gt;Logical&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Datasets in R are often a combination of these 6 different data types. Below we explore in more detail each data types one by one, except the data type “complex” as we focus on the main ones and this data type is rarely used in practice.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;numeric&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Numeric&lt;/h1&gt;
&lt;p&gt;The most common data type in R is numeric. A variable or a series will be stored as numeric data if the values are numbers or if the values contains decimals. For example, the following two series are stored as numeric by default:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# numeric series without decimals
num_data &amp;lt;- c(3, 7, 2)
num_data&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 7 2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(num_data)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# numeric series with decimals
num_data_dec &amp;lt;- c(3.4, 7.1, 2.9)
num_data_dec&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3.4 7.1 2.9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(num_data_dec)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# also possible to check the class thanks to str()
str(num_data_dec)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  num [1:3] 3.4 7.1 2.9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In other words, if you assign one or several numbers to an object in R, it will be stored as numeric by default (numbers with decimals), unless specified otherwise.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;integer&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Integer&lt;/h1&gt;
&lt;p&gt;Integer data type is actually a special case of numeric data. Integers are numeric data without decimals. It can be used if you are sure that the numbers you store will never contains decimals. For example, let’s say you are interested in the number of children in a sample of 10 families. This variable is a discrete variable (see a reminder on the &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;variable types&lt;/a&gt; if you do not remember what is a discrete variable) and will never have decimals. Therefore, it can be stored as integer data thanks to the &lt;code&gt;as.integer()&lt;/code&gt; command:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;children&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 1 3 2 2 4 4 1 1 1 4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;children &amp;lt;- as.integer(children)
class(children)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;integer&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that if your variable does not have decimals, R will automatically set the type as integers instead of numeric.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;character&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Character&lt;/h1&gt;
&lt;p&gt;The data type character is used when storing text, known as strings in R. The simplest ways to store data under the character format is by using &lt;code&gt;&#34;&#34;&lt;/code&gt; around the piece of text:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;char &amp;lt;- &amp;quot;some text&amp;quot;
char&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;some text&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(char)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to force any kind of data to be stored as character, you can do it by using the command &lt;code&gt;as.character()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;char2 &amp;lt;- as.character(children)
char2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;1&amp;quot; &amp;quot;3&amp;quot; &amp;quot;2&amp;quot; &amp;quot;2&amp;quot; &amp;quot;4&amp;quot; &amp;quot;4&amp;quot; &amp;quot;1&amp;quot; &amp;quot;1&amp;quot; &amp;quot;1&amp;quot; &amp;quot;4&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(char2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that everything inside &lt;code&gt;&#34;&#34;&lt;/code&gt; will be considered as character, no matter if it looks like character or not. For example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;chars &amp;lt;- c(&amp;quot;7.42&amp;quot;)
chars&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;7.42&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(chars)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Furthermore, as soon as there is at least one character value inside a variable or vector, the whole variable or vector will be considered as character:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;char_num &amp;lt;- c(&amp;quot;text&amp;quot;, 1, 3.72, 4)
char_num&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;text&amp;quot; &amp;quot;1&amp;quot;    &amp;quot;3.72&amp;quot; &amp;quot;4&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(char_num)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Last but not least, although space does not matter in numeric data, it does matter for character data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;num_space &amp;lt;- c(1)
num_nospace &amp;lt;- c(1)
# is num_space equal to num_nospace?
num_space == num_nospace&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;char_space &amp;lt;- &amp;quot;text &amp;quot;
char_nospace &amp;lt;- &amp;quot;text&amp;quot;
# is char_space equal to char_nospace?
char_space == char_nospace&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see from the results above, a space within character data (i.e., within &lt;code&gt;&#34;&#34;&lt;/code&gt;) makes it a different string in R!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;factor&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Factor&lt;/h1&gt;
&lt;p&gt;Factor variables are a special case of character variables in the sense that it also contains text. However, factor variables are used when there are a limited number of unique character strings. It often represents a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;categorical variable&lt;/a&gt;. For instance, the gender will usually take on only two values, “female” or “male” (and will be considered as a factor variable) whereas the name will generally have lots of possibilities (and thus will be considered as a character variable). To create a factor variable use the &lt;code&gt;factor()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gender &amp;lt;- factor(c(&amp;quot;female&amp;quot;, &amp;quot;female&amp;quot;, &amp;quot;male&amp;quot;, &amp;quot;female&amp;quot;, &amp;quot;male&amp;quot;))
gender&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] female female male   female male  
## Levels: female male&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To know the different levels of a factor variable, use &lt;code&gt;levels()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;female&amp;quot; &amp;quot;male&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default, the levels are sorted alphabetically. You can reorder the levels with the argument &lt;code&gt;levels&lt;/code&gt; in the &lt;code&gt;factor()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gender &amp;lt;- factor(gender, levels = c(&amp;quot;male&amp;quot;, &amp;quot;female&amp;quot;))
levels(gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;male&amp;quot;   &amp;quot;female&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Character strings can be converted to factors with &lt;code&gt;as.factor()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;text &amp;lt;- c(&amp;quot;test1&amp;quot;, &amp;quot;test2&amp;quot;, &amp;quot;test1&amp;quot;, &amp;quot;test1&amp;quot;) # create a character vector
class(text) # to know the class&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;text_factor &amp;lt;- as.factor(text) # transform to factor
class(text_factor) # recheck the class&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;factor&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The character strings have been transformed to factors, as shown by its class of the type &lt;code&gt;factor&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;logical&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Logical&lt;/h1&gt;
&lt;p&gt;A logical variable is a variable with only two values; &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;value1 &amp;lt;- 7
value2 &amp;lt;- 9

# is value1 greater than value2?
greater &amp;lt;- value1 &amp;gt; value2
greater&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(greater)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;logical&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# is value1 less than or equal to value2?
less &amp;lt;- value1 &amp;lt;= value2
less&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(less)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;logical&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is also possible to transform logical data into numeric data. After the transformation from logical to numeric with the &lt;code&gt;as.numeric()&lt;/code&gt; command, &lt;code&gt;FALSE&lt;/code&gt; values equal to 0 and &lt;code&gt;TRUE&lt;/code&gt; values equal to 1:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;greater_num &amp;lt;- as.numeric(greater)
sum(greater)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;less_num &amp;lt;- as.numeric(less)
sum(less)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Conversely, numeric data can be converted to logical data, with &lt;code&gt;FALSE&lt;/code&gt; for all values equal to 0 and &lt;code&gt;TRUE&lt;/code&gt; for all other values.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- 0
as.logical(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;- 5
as.logical(y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&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 helped you to understand the basic data types in R and their particularities. If you would like to learn more about the different variable types from a statistical point of view, read the article “&lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;Variable types and examples&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;
</description>
    </item>
    
    <item>
      <title>How to create an interactive booklist with automatic Amazon affiliate links in R?</title>
      <link>https://statsandr.com/blog/how-to-create-an-interactive-booklist-with-automatic-amazon-affiliate-links-in-r/</link>
      <pubDate>Thu, 26 Dec 2019 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-create-an-interactive-booklist-with-automatic-amazon-affiliate-links-in-r/</guid>
      <description>
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/htmltools-fill/fill.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/datatables-css/datatables-crosstalk.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/datatables-binding/datatables.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/jquery/jquery-3.6.0.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/dt-core/css/jquery.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/dt-core/css/jquery.dataTables.extra.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-core/js/jquery.dataTables.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/crosstalk/css/crosstalk.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/crosstalk/js/crosstalk.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/jszip/jszip.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/pdfmake/pdfmake.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/pdfmake/vfs_fonts.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/css/buttons.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/js/dataTables.buttons.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/js/buttons.html5.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/js/buttons.colVis.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/dt-ext-buttons/js/buttons.print.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/nouislider/jquery.nouislider.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/nouislider/jquery.nouislider.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/rmarkdown-libs/selectize/selectize.bootstrap3.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/rmarkdown-libs/selectize/selectize.min.js&#34;&gt;&lt;/script&gt;

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#requirements&#34; id=&#34;toc-requirements&#34;&gt;Requirements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#create-a-booklist&#34; id=&#34;toc-create-a-booklist&#34;&gt;Create a booklist&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#create-it-in-excel-then-import-it&#34; id=&#34;toc-create-it-in-excel-then-import-it&#34;&gt;Create it in Excel then import it&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#create-it-directly-in-r&#34; id=&#34;toc-create-it-directly-in-r&#34;&gt;Create it directly in R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#make-it-interactive&#34; id=&#34;toc-make-it-interactive&#34;&gt;Make it interactive&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-urls-with-your-affiliate-link-to-the-table&#34; id=&#34;toc-add-urls-with-your-affiliate-link-to-the-table&#34;&gt;Add URLs with your affiliate link to the table&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#extract-affiliate-link&#34; id=&#34;toc-extract-affiliate-link&#34;&gt;Extract affiliate link&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#append-the-book-title-and-author-to-make-it-automatic&#34; id=&#34;toc-append-the-book-title-and-author-to-make-it-automatic&#34;&gt;Append the book title and author to make it automatic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-links-to-the-interactive-table&#34; id=&#34;toc-add-links-to-the-interactive-table&#34;&gt;Add links to the interactive table&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#final-result&#34; id=&#34;toc-final-result&#34;&gt;Final result&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/how-to-create-an-interactive-booklist-with-automatic-affiliate-links-in-r_files/booklist-with-amazon-affiliate-links.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Booklists are a useful way to share the books you have read and which you recommend to other readers and/or to promote the books you have written. It can be as simple as a list of book titles displayed on your personal website or blog. You may however wish to present this list of books in a more sophisticated way, such as in a table with titles, authors and links to buy it for instance.&lt;/p&gt;
&lt;p&gt;In this blog post I show you how to create an interactive booklist with automatic Amazon affiliate links in R. By interactive, I mean a booklist which allows users to search for books by title or author (like this &lt;a href=&#34;https://www.antoinesoetewey.com/files/booklist.html&#34; target=&#34;_blank&#34;&gt;booklist&lt;/a&gt; for instance). Moreover, by automatic Amazon affiliate links, I mean URLs (with your affiliate link of course) that redirect directly to the book in question on the Amazon webstore, without manually creating a link for each book.&lt;/p&gt;
&lt;p&gt;This technique is especially helpful for those of you who have hundreds of books in their list as you will need to create the URL only once and it will adapt automatically to all books.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;requirements&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Requirements&lt;/h1&gt;
&lt;p&gt;In order to build this augmented booklist with your affiliate link, you need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;an Amazon associates account. Register &lt;a href=&#34;https://affiliate-program.amazon.com&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;here&lt;/a&gt; if you do not have an account yet&lt;/li&gt;
&lt;li&gt;a list of books (which you recommend and/or written by you)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;create-a-booklist&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Create a booklist&lt;/h1&gt;
&lt;p&gt;You have two options:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;create it in Excel then import it into R&lt;/li&gt;
&lt;li&gt;create it directly in R&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;create-it-in-excel-then-import-it&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create it in Excel then import it&lt;/h2&gt;
&lt;p&gt;The easiest way is to follow these steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;open an Excel file and fill it in with two columns: (i) one with the titles and (ii) a second with the authors (see figure below)&lt;/li&gt;
&lt;li&gt;save it in a .csv format (in Excel, File &amp;gt; Save As… &amp;gt; choose the CSV file format and save it)&lt;/li&gt;
&lt;li&gt;import it into R (see &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;how to import a .csv file&lt;/a&gt; if you struggle with the importation)&lt;/li&gt;
&lt;li&gt;(if you need to edit the list in the future, edit it directly in the .csv file and not in the Excel file)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here is how your booklist created in Excel should look like (with I suppose more books in yours):&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-create-an-interactive-booklist-with-automatic-affiliate-links-in-r_files/booklist-csv.png&#34; alt=&#34;Step 1: Booklist created in Excel&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Booklist created in Excel&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;We now import it into RStudio and rename the dataset as &lt;code&gt;dat&lt;/code&gt; (see &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/#user-friendly-way&#34;&gt;here&lt;/a&gt; why I always use a generic name instead of more specific names):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- read.csv(&amp;quot;booklist.csv&amp;quot;, # name of your file with .csv extension
  header = TRUE, # names of variables are present
  sep = &amp;quot;,&amp;quot; # values are separated by a comma
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can always check that your booklist is correctly imported by running &lt;code&gt;head(name_of_dataset)&lt;/code&gt; or &lt;code&gt;View(name_of_dataset)&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;create-it-directly-in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create it directly in R&lt;/h2&gt;
&lt;p&gt;You can create your booklist directly in R with the command &lt;code&gt;data.frame()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Create the data frame named dat
dat &amp;lt;- data.frame(
  &amp;quot;Title&amp;quot; = c(
    &amp;quot;A Random Walk Down Wall Street&amp;quot;,
    &amp;quot;Naked Statistics&amp;quot;,
    &amp;quot;Freakonomics&amp;quot;
  ),
  &amp;quot;Author&amp;quot; = c(
    &amp;quot;Burton G. Malkiel&amp;quot;,
    &amp;quot;Charles Wheelan&amp;quot;,
    &amp;quot;Steven D. Levitt and Stephen J. Dubner&amp;quot;
  ),
  stringsAsFactors = FALSE
)

# Print the data frame
dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                            Title                                 Author
## 1 A Random Walk Down Wall Street                      Burton G. Malkiel
## 2               Naked Statistics                        Charles Wheelan
## 3                   Freakonomics Steven D. Levitt and Stephen J. Dubner&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;make-it-interactive&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Make it interactive&lt;/h1&gt;
&lt;p&gt;In order to be able to search for books by author or title, we use the &lt;code&gt;datatable()&lt;/code&gt; command from the DT package. Below the table with the default options:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(DT)
datatable(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;datatables html-widget html-fill-item&#34; id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:auto;&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;filter&#34;:&#34;none&#34;,&#34;vertical&#34;:false,&#34;data&#34;:[[&#34;1&#34;,&#34;2&#34;,&#34;3&#34;],[&#34;A Random Walk Down Wall Street&#34;,&#34;Naked Statistics&#34;,&#34;Freakonomics&#34;],[&#34;Burton G. Malkiel&#34;,&#34;Charles Wheelan&#34;,&#34;Steven D. Levitt and Stephen J. Dubner&#34;]],&#34;container&#34;:&#34;&lt;table class=\&#34;display\&#34;&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th&gt; &lt;\/th&gt;\n      &lt;th&gt;Title&lt;\/th&gt;\n      &lt;th&gt;Author&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n&lt;\/table&gt;&#34;,&#34;options&#34;:{&#34;columnDefs&#34;:[{&#34;orderable&#34;:false,&#34;targets&#34;:0},{&#34;name&#34;:&#34; &#34;,&#34;targets&#34;:0},{&#34;name&#34;:&#34;Title&#34;,&#34;targets&#34;:1},{&#34;name&#34;:&#34;Author&#34;,&#34;targets&#34;:2}],&#34;order&#34;:[],&#34;autoWidth&#34;:false,&#34;orderClasses&#34;:false}},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;Let’s improve this table by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;removing row numbers&lt;/li&gt;
&lt;li&gt;adding a filter on top of “Title” and “Author” columns&lt;/li&gt;
&lt;li&gt;adding the possibility to copy or download the table&lt;/li&gt;
&lt;li&gt;show only first 5 entries instead of 10&lt;/li&gt;
&lt;li&gt;order books by title in ascending order&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;datatable(dat,
  rownames = FALSE, # remove row numbers
  filter = &amp;quot;top&amp;quot;, # add filter on top of columns
  extensions = &amp;quot;Buttons&amp;quot;, # add download buttons
  options = list(
    autoWidth = TRUE,
    dom = &amp;quot;Blfrtip&amp;quot;, # location of the download buttons
    buttons = c(&amp;quot;copy&amp;quot;, &amp;quot;csv&amp;quot;, &amp;quot;excel&amp;quot;, &amp;quot;pdf&amp;quot;, &amp;quot;print&amp;quot;), # download buttons
    pageLength = 5, # show first 5 entries, default is 10
    order = list(0, &amp;quot;asc&amp;quot;) # order the title column by ascending order
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;datatables html-widget html-fill-item&#34; id=&#34;htmlwidget-2&#34; style=&#34;width:100%;height:auto;&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-2&#34;&gt;{&#34;x&#34;:{&#34;filter&#34;:&#34;top&#34;,&#34;vertical&#34;:false,&#34;filterHTML&#34;:&#34;&lt;tr&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n&lt;\/tr&gt;&#34;,&#34;extensions&#34;:[&#34;Buttons&#34;],&#34;data&#34;:[[&#34;A Random Walk Down Wall Street&#34;,&#34;Naked Statistics&#34;,&#34;Freakonomics&#34;],[&#34;Burton G. Malkiel&#34;,&#34;Charles Wheelan&#34;,&#34;Steven D. Levitt and Stephen J. Dubner&#34;]],&#34;container&#34;:&#34;&lt;table class=\&#34;display\&#34;&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th&gt;Title&lt;\/th&gt;\n      &lt;th&gt;Author&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n&lt;\/table&gt;&#34;,&#34;options&#34;:{&#34;autoWidth&#34;:true,&#34;dom&#34;:&#34;Blfrtip&#34;,&#34;buttons&#34;:[&#34;copy&#34;,&#34;csv&#34;,&#34;excel&#34;,&#34;pdf&#34;,&#34;print&#34;],&#34;pageLength&#34;:5,&#34;order&#34;:[0,&#34;asc&#34;],&#34;columnDefs&#34;:[{&#34;name&#34;:&#34;Title&#34;,&#34;targets&#34;:0},{&#34;name&#34;:&#34;Author&#34;,&#34;targets&#34;:1}],&#34;orderClasses&#34;:false,&#34;orderCellsTop&#34;:true,&#34;lengthMenu&#34;:[5,10,25,50,100]}},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;/div&gt;
&lt;div id=&#34;add-urls-with-your-affiliate-link-to-the-table&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Add URLs with your affiliate link to the table&lt;/h1&gt;
&lt;p&gt;We are now going to add URLs (with your affiliate link) which depend on the title and author of the book in the interactive table presented above. For this, we first need to extract the affiliate link which will serve as the base of the URL, then add the title and author of the book at then end of the URL. The fact that we add the title and author of the book at the end of the URL makes it automatic. Indeed, the final URL will redirect to the search page of the book (thanks to the title and author of the book as keywords) and with your affiliate link included (as we use the affiliate link as the base URL).&lt;/p&gt;
&lt;div id=&#34;extract-affiliate-link&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract affiliate link&lt;/h2&gt;
&lt;p&gt;To extract the affiliate link, follow these steps (see figures below for help):&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Go to your Amazon associates account&lt;/li&gt;
&lt;li&gt;Click on Product Linking &amp;gt; Link to Any Page&lt;/li&gt;
&lt;li&gt;Click on the tab “Link to Search Results”&lt;/li&gt;
&lt;li&gt;Choose “Books &amp;amp; Textbooks” for the product line&lt;/li&gt;
&lt;li&gt;Enter any keywords you want and a name for your link (the two will be change later so it does not matter what you type)&lt;/li&gt;
&lt;li&gt;Click on the button “Get HTML”&lt;/li&gt;
&lt;li&gt;Copy in your clipboard (CTRL+c on Windows or cmd+c on Mac) the code displayed in the Preview (right pane)&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-create-an-interactive-booklist-with-automatic-affiliate-links-in-r_files/get-amazon-affiliate-link.png&#34; alt=&#34;Step 2: Link to Any Page on Amazon associates account&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Link to Any Page on Amazon associates account&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-create-an-interactive-booklist-with-automatic-affiliate-links-in-r_files/create-amazon-affiliate-link.png&#34; alt=&#34;Step 3 to 7: Create Amazon affiliate link for a search page&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3 to 7: Create Amazon affiliate link for a search page&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The code you just copied should look like this (not exactly the same though as it includes your personal affiliate link):&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;a target=&#34;_blank&#34; href=&#34;https://www.amazon.com/gp/search?ie=UTF8&amp;amp;tag=antoinesoetew-20&amp;amp;linkCode=ur2&amp;amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;index=books&amp;amp;keywords=BOOK TITLE&#34;&amp;gt;BOOK TITLE&amp;lt;/a&amp;gt;&amp;lt;img src=&#34;//ir-na.amazon-adsystem.com/e/ir?t=antoinesoetew-20&amp;amp;l=ur2&amp;amp;o=1&#34; width=&#34;1&#34; height=&#34;1&#34; border=&#34;0&#34; alt=&#34;&#34; style=&#34;border:none !important; margin:0px !important;&#34; /&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;From this long code, remove everything which follows &lt;code&gt;keywords=&lt;/code&gt; but keep &lt;code&gt;keywords=&lt;/code&gt; (that is why it does not matter what you typed in step 5 above). Following our example, we are left with this piece of code:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;a target=&#34;_blank&#34; href=&#34;https://www.amazon.com/gp/search?ie=UTF8&amp;amp;tag=antoinesoetew-20&amp;amp;linkCode=ur2&amp;amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;index=books&amp;amp;keywords=&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Copy this shortened code.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;append-the-book-title-and-author-to-make-it-automatic&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Append the book title and author to make it automatic&lt;/h2&gt;
&lt;p&gt;We are now going to concatenate (i.e., append several character strings together) the Amazon affiliate link (the code we just copied), the title and author of the book and then a closing HTML tag with the &lt;code&gt;paste0()&lt;/code&gt; command. The result will be a URL which takes the affiliate link as the base and the title and author of the book as keywords, making it automatic and adapted for every book in your booklist. To do this, run the following command in R:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Do not mix &amp;quot; and &amp;#39;, they are different in this case!
link &amp;lt;- paste0(
  &amp;#39;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;https://www.amazon.com/gp/search?ie=UTF8&amp;amp;tag=antoinesoetew-20&amp;amp;linkCode=ur2&amp;amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;index=books&amp;amp;keywords=&amp;#39;, # affiliate link
  dat$Title, &amp;quot; + &amp;quot;, dat$Author, # book title and author
  &amp;#39;&amp;quot;&amp;gt;Amazon&amp;lt;/a&amp;gt;&amp;#39; # closing HTML tag
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your links should look something like this, with same affiliate links and closing tags for all books but with different keywords, corresponding to book titles and authors:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(link)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;&amp;lt;a target=\&amp;quot;_blank\&amp;quot; href=\&amp;quot;https://www.amazon.com/gp/search?ie=UTF8&amp;amp;tag=antoinesoetew-20&amp;amp;linkCode=ur2&amp;amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;index=books&amp;amp;keywords=A Random Walk Down Wall Street + Burton G. Malkiel\&amp;quot;&amp;gt;Amazon&amp;lt;/a&amp;gt;&amp;quot;   
## [2] &amp;quot;&amp;lt;a target=\&amp;quot;_blank\&amp;quot; href=\&amp;quot;https://www.amazon.com/gp/search?ie=UTF8&amp;amp;tag=antoinesoetew-20&amp;amp;linkCode=ur2&amp;amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;index=books&amp;amp;keywords=Naked Statistics + Charles Wheelan\&amp;quot;&amp;gt;Amazon&amp;lt;/a&amp;gt;&amp;quot;                   
## [3] &amp;quot;&amp;lt;a target=\&amp;quot;_blank\&amp;quot; href=\&amp;quot;https://www.amazon.com/gp/search?ie=UTF8&amp;amp;tag=antoinesoetew-20&amp;amp;linkCode=ur2&amp;amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;index=books&amp;amp;keywords=Freakonomics + Steven D. Levitt and Stephen J. Dubner\&amp;quot;&amp;gt;Amazon&amp;lt;/a&amp;gt;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;add-links-to-the-interactive-table&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Add links to the interactive table&lt;/h2&gt;
&lt;p&gt;Now that the URLs are specific to each book, we can add them to the interactive table built earlier:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$Link &amp;lt;- link&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we can display the interactive table with titles, authors and their URLs:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;datatable(dat,
  rownames = FALSE, # remove row numbers
  filter = &amp;quot;top&amp;quot;, # add filter on top of columns
  extensions = &amp;quot;Buttons&amp;quot;, # add download buttons
  options = list(
    autoWidth = TRUE,
    dom = &amp;quot;Blfrtip&amp;quot;, # location of the download buttons
    buttons = c(&amp;quot;copy&amp;quot;, &amp;quot;csv&amp;quot;, &amp;quot;excel&amp;quot;, &amp;quot;pdf&amp;quot;, &amp;quot;print&amp;quot;), # download buttons
    pageLength = 5, # show first 5 entries, default is 10
    order = list(0, &amp;quot;asc&amp;quot;) # order the title column by ascending order
  ),
  escape = FALSE # to make URLs clickable
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is exactly the same code than before except that we need to add &lt;code&gt;escape = FALSE&lt;/code&gt; to make URLs clickable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;final-result&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Final result&lt;/h1&gt;
&lt;div class=&#34;datatables html-widget html-fill-item&#34; id=&#34;htmlwidget-3&#34; style=&#34;width:100%;height:auto;&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-3&#34;&gt;{&#34;x&#34;:{&#34;filter&#34;:&#34;top&#34;,&#34;vertical&#34;:false,&#34;filterHTML&#34;:&#34;&lt;tr&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n&lt;\/tr&gt;&#34;,&#34;extensions&#34;:[&#34;Buttons&#34;],&#34;data&#34;:[[&#34;A Random Walk Down Wall Street&#34;,&#34;Naked Statistics&#34;,&#34;Freakonomics&#34;],[&#34;Burton G. Malkiel&#34;,&#34;Charles Wheelan&#34;,&#34;Steven D. Levitt and Stephen J. Dubner&#34;],[&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;https://www.amazon.com/gp/search?ie=UTF8&amp;tag=antoinesoetew-20&amp;linkCode=ur2&amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;camp=1789&amp;creative=9325&amp;index=books&amp;keywords=A Random Walk Down Wall Street + Burton G. Malkiel\&#34;&gt;Amazon&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;https://www.amazon.com/gp/search?ie=UTF8&amp;tag=antoinesoetew-20&amp;linkCode=ur2&amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;camp=1789&amp;creative=9325&amp;index=books&amp;keywords=Naked Statistics + Charles Wheelan\&#34;&gt;Amazon&lt;\/a&gt;&#34;,&#34;&lt;a target=\&#34;_blank\&#34; href=\&#34;https://www.amazon.com/gp/search?ie=UTF8&amp;tag=antoinesoetew-20&amp;linkCode=ur2&amp;linkId=a587bdd780cbbfb6d3f4569f7fb358fc&amp;camp=1789&amp;creative=9325&amp;index=books&amp;keywords=Freakonomics + Steven D. Levitt and Stephen J. Dubner\&#34;&gt;Amazon&lt;\/a&gt;&#34;]],&#34;container&#34;:&#34;&lt;table class=\&#34;display\&#34;&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th&gt;Title&lt;\/th&gt;\n      &lt;th&gt;Author&lt;\/th&gt;\n      &lt;th&gt;Link&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n&lt;\/table&gt;&#34;,&#34;options&#34;:{&#34;autoWidth&#34;:true,&#34;dom&#34;:&#34;Blfrtip&#34;,&#34;buttons&#34;:[&#34;copy&#34;,&#34;csv&#34;,&#34;excel&#34;,&#34;pdf&#34;,&#34;print&#34;],&#34;pageLength&#34;:5,&#34;order&#34;:[0,&#34;asc&#34;],&#34;columnDefs&#34;:[{&#34;name&#34;:&#34;Title&#34;,&#34;targets&#34;:0},{&#34;name&#34;:&#34;Author&#34;,&#34;targets&#34;:1},{&#34;name&#34;:&#34;Link&#34;,&#34;targets&#34;:2}],&#34;orderClasses&#34;:false,&#34;orderCellsTop&#34;:true,&#34;lengthMenu&#34;:[5,10,25,50,100]}},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;Check that everything works properly by clicking on different links. If you did not miss any steps, it should redirect you to the Amazon store with the title and author of the book in the search bar and thus the book in question appearing in the search results.&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 helped you to build an interactive booklist with an automated affiliate link to each of the book in your list.&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>Data manipulation in R</title>
      <link>https://statsandr.com/blog/data-manipulation-in-r/</link>
      <pubDate>Tue, 24 Dec 2019 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/data-manipulation-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#vectors&#34; id=&#34;toc-vectors&#34;&gt;Vectors&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#concatenation&#34; id=&#34;toc-concatenation&#34;&gt;Concatenation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#seq-and-rep&#34; id=&#34;toc-seq-and-rep&#34;&gt;&lt;code&gt;seq()&lt;/code&gt; and &lt;code&gt;rep()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#assignment&#34; id=&#34;toc-assignment&#34;&gt;Assignment&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#elements-of-a-vector&#34; id=&#34;toc-elements-of-a-vector&#34;&gt;Elements of a vector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#type-and-length&#34; id=&#34;toc-type-and-length&#34;&gt;Type and length&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#finding-the-vector-type&#34; id=&#34;toc-finding-the-vector-type&#34;&gt;Finding the vector type&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#modifications-of-type-and-length&#34; id=&#34;toc-modifications-of-type-and-length&#34;&gt;Modifications of type and length&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#numerical-operators&#34; id=&#34;toc-numerical-operators&#34;&gt;Numerical operators&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#logical-operators&#34; id=&#34;toc-logical-operators&#34;&gt;Logical operators&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#all-and-any&#34; id=&#34;toc-all-and-any&#34;&gt;&lt;code&gt;all()&lt;/code&gt; and &lt;code&gt;any()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#operations-on-character-strings-vector&#34; id=&#34;toc-operations-on-character-strings-vector&#34;&gt;Operations on character strings vector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#orders-and-vectors&#34; id=&#34;toc-orders-and-vectors&#34;&gt;Orders and vectors&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#factors&#34; id=&#34;toc-factors&#34;&gt;Factors&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#creating-factors&#34; id=&#34;toc-creating-factors&#34;&gt;Creating factors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#properties&#34; id=&#34;toc-properties&#34;&gt;Properties&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#handling&#34; id=&#34;toc-handling&#34;&gt;Handling&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#lists&#34; id=&#34;toc-lists&#34;&gt;Lists&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#creating-lists&#34; id=&#34;toc-creating-lists&#34;&gt;Creating lists&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#handling-1&#34; id=&#34;toc-handling-1&#34;&gt;Handling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#getting-details-on-an-object&#34; id=&#34;toc-getting-details-on-an-object&#34;&gt;Getting details on an object&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data-frames&#34; id=&#34;toc-data-frames&#34;&gt;Data frames&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#line-and-column-names&#34; id=&#34;toc-line-and-column-names&#34;&gt;Line and column names&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#subset-a-data-frame&#34; id=&#34;toc-subset-a-data-frame&#34;&gt;Subset a data frame&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#first-or-last-observations&#34; id=&#34;toc-first-or-last-observations&#34;&gt;First or last observations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#random-sample-of-observations&#34; id=&#34;toc-random-sample-of-observations&#34;&gt;Random sample of observations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#based-on-row-or-column-numbers&#34; id=&#34;toc-based-on-row-or-column-numbers&#34;&gt;Based on row or column numbers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#based-on-variable-names&#34; id=&#34;toc-based-on-variable-names&#34;&gt;Based on variable names&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#based-on-one-or-multiple-criterion&#34; id=&#34;toc-based-on-one-or-multiple-criterion&#34;&gt;Based on one or multiple criterion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#create-a-new-variable&#34; id=&#34;toc-create-a-new-variable&#34;&gt;Create a new variable&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#transform-a-continuous-variable-into-a-categorical-variable&#34; id=&#34;toc-transform-a-continuous-variable-into-a-categorical-variable&#34;&gt;Transform a continuous variable into a categorical variable&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sum-and-mean-in-rows&#34; id=&#34;toc-sum-and-mean-in-rows&#34;&gt;Sum and mean in rows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sum-and-mean-in-column&#34; id=&#34;toc-sum-and-mean-in-column&#34;&gt;Sum and mean in column&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#categorical-variables-and-labels-management&#34; id=&#34;toc-categorical-variables-and-labels-management&#34;&gt;Categorical variables and labels management&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#recode-categorical-variables&#34; id=&#34;toc-recode-categorical-variables&#34;&gt;Recode categorical variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#change-reference-level&#34; id=&#34;toc-change-reference-level&#34;&gt;Change reference level&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#rename-variable-names&#34; id=&#34;toc-rename-variable-names&#34;&gt;Rename variable names&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#create-a-data-frame-manually&#34; id=&#34;toc-create-a-data-frame-manually&#34;&gt;Create a data frame manually&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#merging-two-data-frames&#34; id=&#34;toc-merging-two-data-frames&#34;&gt;Merging two data frames&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-new-observations-from-another-data-frame&#34; id=&#34;toc-add-new-observations-from-another-data-frame&#34;&gt;Add new observations from another data frame&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-new-variables-from-another-data-frame&#34; id=&#34;toc-add-new-variables-from-another-data-frame&#34;&gt;Add new variables from another data frame&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#missing-values&#34; id=&#34;toc-missing-values&#34;&gt;Missing values&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#remove-nas&#34; id=&#34;toc-remove-nas&#34;&gt;Remove NAs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#impute-nas&#34; id=&#34;toc-impute-nas&#34;&gt;Impute NAs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#scale&#34; id=&#34;toc-scale&#34;&gt;Scale&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#dates-and-times&#34; id=&#34;toc-dates-and-times&#34;&gt;Dates and times&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#dates&#34; id=&#34;toc-dates&#34;&gt;Dates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#times&#34; id=&#34;toc-times&#34;&gt;Times&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#extraction-from-dates&#34; id=&#34;toc-extraction-from-dates&#34;&gt;Extraction from dates&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#exporting-and-saving&#34; id=&#34;toc-exporting-and-saving&#34;&gt;Exporting and saving&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#looking-for-help&#34; id=&#34;toc-looking-for-help&#34;&gt;Looking for help&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/data-manipulation-in-rstudio_files/0_voEJp2o-Z2k4-uUd.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that this article is inspired from a workshop entitled “Introduction to data analysis with R”, given by UCLouvain’s Statistical Methodology and Computing Service. See all their workshops on their &lt;a href=&#34;https://sites.uclouvain.be/training/smcs/index.php?l=en&#34; target=&#34;_blank&#34;&gt;website&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Not all data frames are as clean and tidy as you would expect. Therefore, after &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;importing your data frame into RStudio&lt;/a&gt;, most of the time you will need to prepare it before performing any statistical analyses. Data manipulation can even sometimes take longer than the actual analyses when the quality of the data is poor.&lt;/p&gt;
&lt;p&gt;Data manipulation include a broad range of tools and techniques. We present here in details the manipulations that you will most likely need for your projects in R. Do not hesitate to let me know (as a comment at the end of this article for example) if you find other data manipulations essential so that I can add them.&lt;/p&gt;
&lt;p&gt;In this article we show the main functions to manipulate data in R. We first illustrate these functions on vectors, &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factors&lt;/a&gt; and lists. We then illustrate the main functions to manipulate data frames and dates/times in R.&lt;/p&gt;
&lt;p&gt;For those who are interested in going further, see also an introduction to &lt;a href=&#34;https://statsandr.com/blog/introduction-to-data-manipulation-in-r-with-dplyr/&#34;&gt;data manipulation in R with the &lt;code&gt;{dplyr}&lt;/code&gt; package&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;vectors&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Vectors&lt;/h1&gt;
&lt;div id=&#34;concatenation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Concatenation&lt;/h2&gt;
&lt;p&gt;We can concatenate (i.e., combine) numbers or strings with &lt;code&gt;c()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;c(2, 4, -1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2  4 -1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;c(1, 5 / 6, 2^3, -0.05)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  1.0000000  0.8333333  8.0000000 -0.0500000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that by default R displays 7 decimals. You can modify it with &lt;code&gt;options(digits = 2)&lt;/code&gt; (two decimals).&lt;/p&gt;
&lt;p&gt;It is also possible to create a sequence of consecutive &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#integer&#34;&gt;integers&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;1:10&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# is the same than
c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
c(1:10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;seq-and-rep&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;seq()&lt;/code&gt; and &lt;code&gt;rep()&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;seq()&lt;/code&gt; allows to make a vector defined by a sequence. You can either choose the increment:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq(from = 2, to = 5, by = 0.5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2.0 2.5 3.0 3.5 4.0 4.5 5.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or its length:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq(from = 2, to = 5, length.out = 7)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2.0 2.5 3.0 3.5 4.0 4.5 5.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On the other hand, &lt;code&gt;rep()&lt;/code&gt; creates a vector which is the repetition of numbers or strings:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rep(1, times = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 1 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rep(c(&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;), times = c(3, 1, 2))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;A&amp;quot; &amp;quot;A&amp;quot; &amp;quot;A&amp;quot; &amp;quot;B&amp;quot; &amp;quot;C&amp;quot; &amp;quot;C&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also create a vector which is the repetition of numbers and strings:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rep(c(&amp;quot;A&amp;quot;, 2, &amp;quot;C&amp;quot;), times = c(3, 1, 2))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;A&amp;quot; &amp;quot;A&amp;quot; &amp;quot;A&amp;quot; &amp;quot;2&amp;quot; &amp;quot;C&amp;quot; &amp;quot;C&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but in that case, the number 2 will be considered as a string too (and not as a &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#numeric&#34;&gt;numeric&lt;/a&gt;) since there is at least one string in the vector.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;assignment&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Assignment&lt;/h2&gt;
&lt;p&gt;There are three ways to assign an object in R:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;-&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;=&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;assign()&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 1st method
x &amp;lt;- c(2.1, 5, -4, 1, 5)
x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1  5.0 -4.0  1.0  5.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 2nd method
x2 = c(2.1, 5, -4, 1, 5)
x2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1  5.0 -4.0  1.0  5.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 3rd method (much less common)
assign(&amp;quot;x3&amp;quot;, c(2.1, 5, -4, 1, 5))
x3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1  5.0 -4.0  1.0  5.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also assign a vector to another vector, for example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;- c(x, 10, 1 / 4)
y&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.10  5.00 -4.00  1.00  5.00 10.00  0.25&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;elements-of-a-vector&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Elements of a vector&lt;/h2&gt;
&lt;p&gt;We can select one or several elements of a vector by specifying its position between square brackets:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select one element
x[3]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select more than one element with c()
x[c(1, 3, 4)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1 -4.0  1.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that in R the numbering of the indices starts at 1 (and no 0 like other programming languages) so &lt;code&gt;x[1]&lt;/code&gt; gives the first element of the vector &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We can also use &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#logical&#34;&gt;booleans&lt;/a&gt; (i.e., &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;) to select some elements of a vector. This method selects only the elements corresponding to &lt;code&gt;TRUE&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x[c(TRUE, FALSE, TRUE, TRUE, FALSE)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1 -4.0  1.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or we can give the elements to withdraw:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x[-c(2, 4)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1 -4.0  5.0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;type-and-length&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Type and length&lt;/h2&gt;
&lt;p&gt;The main types of a vector are &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#numeric&#34;&gt;numeric&lt;/a&gt;, &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#logical&#34;&gt;logical&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#character&#34;&gt;character&lt;/a&gt;. For more details on each type, see the different &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/&#34;&gt;data types in R&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;class()&lt;/code&gt; gives the vector type:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(2.1, 5, -4, 1, 5, 0)
class(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;- c(x, &amp;quot;Hello&amp;quot;)
class(y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see above, the class of a vector will be numeric only if all of its elements are numeric. As soon as one element is a character, the class of the vector will be a character.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;z &amp;lt;- c(TRUE, FALSE, FALSE)
class(z)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;logical&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;length()&lt;/code&gt; gives the length of a vector:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;length(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 6&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So to select the last element of a vector (in a dynamic way), we can use a combination of &lt;code&gt;length()&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x[length(x)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;finding-the-vector-type&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Finding the vector type&lt;/h2&gt;
&lt;p&gt;We can find the type of a vector with the family of &lt;code&gt;is.type&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.numeric(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.logical(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.character(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or in a more generic way with the &lt;code&gt;is()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot; &amp;quot;vector&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;modifications-of-type-and-length&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Modifications of type and length&lt;/h2&gt;
&lt;p&gt;We can change the type of a vector with the &lt;code&gt;as.numeric()&lt;/code&gt;, &lt;code&gt;as.logical()&lt;/code&gt; and &lt;code&gt;as.character()&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x_character &amp;lt;- as.character(x)
x_character&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2.1&amp;quot; &amp;quot;5&amp;quot;   &amp;quot;-4&amp;quot;  &amp;quot;1&amp;quot;   &amp;quot;5&amp;quot;   &amp;quot;0&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.character(x_character)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x_logical &amp;lt;- as.logical(x)
x_logical&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.logical(x_logical)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is also possible to change its length:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;length(x) &amp;lt;- 4
x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1  5.0 -4.0  1.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, the first elements of the vector are conserved while all others are removed. In this case, the first 4 since we specified a length of 4.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;numerical-operators&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Numerical operators&lt;/h2&gt;
&lt;p&gt;The basic numerical operators such as &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;^&lt;/code&gt; can be applied to vectors:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(2.1, 5, -4, 1)
y &amp;lt;- c(0, -7, 1, 1 / 4)

x + y&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.10 -2.00 -3.00  1.25&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x * y&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]   0.00 -35.00  -4.00   0.25&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x^y&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  1.00e+00  1.28e-05 -4.00e+00  1.00e+00&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is also possible to compute the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#minimum-and-maximum&#34;&gt;minimum, maximum&lt;/a&gt;, sum, product, cumulative sum and cumulative product of a vector:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;min(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;max(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sum(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4.1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;prod(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -42&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;cumsum(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2.1 7.1 3.1 4.1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;cumprod(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]   2.1  10.5 -42.0 -42.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The following mathematical operations can be applied too:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sqrt()&lt;/code&gt; (square root)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cos()&lt;/code&gt; (cosine)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sin()&lt;/code&gt; (sine)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tan()&lt;/code&gt; (tangent)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;log()&lt;/code&gt; (logarithm)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;log10()&lt;/code&gt; (base 10 logarithm)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;exp()&lt;/code&gt; (exponential)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;abs()&lt;/code&gt; (absolute value)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;cos(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.5048461  0.2836622 -0.6536436  0.5403023&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;exp(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]   8.16616991 148.41315910   0.01831564   2.71828183&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you need to round a number, you can use the &lt;code&gt;round()&lt;/code&gt;, &lt;code&gt;floor()&lt;/code&gt; and &lt;code&gt;ceiling()&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round(cos(x), digits = 3) # round to 3 decimals&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.505  0.284 -0.654  0.540&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;floor(cos(x)) # largest integer not greater than x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -1  0 -1  0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ceiling(cos(x)) # smallest integer not less than x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0 1 0 1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;logical-operators&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Logical operators&lt;/h2&gt;
&lt;p&gt;The most common logical operators in R are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Negation: &lt;code&gt;!&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Comparisons: &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; (equality), &lt;code&gt;!=&lt;/code&gt; (difference)&lt;/li&gt;
&lt;li&gt;And: &lt;code&gt;&amp;amp;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Or: &lt;code&gt;|&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1  5.0 -4.0  1.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;= c(1, 6, 3, 4)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE  TRUE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;= 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE FALSE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;(x == 1 | x &amp;gt; 4)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE  TRUE FALSE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;!(x == 1 | x &amp;gt; 4)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  TRUE FALSE  TRUE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;all-and-any&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;all()&lt;/code&gt; and &lt;code&gt;any()&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;As the names suggest, &lt;code&gt;all()&lt;/code&gt; return &lt;code&gt;TRUE&lt;/code&gt; if conditions are met for all elements, whereas &lt;code&gt;any()&lt;/code&gt; returns &lt;code&gt;TRUE&lt;/code&gt; if conditions are met for any of the element of a vector:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1  5.0 -4.0  1.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;= 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE FALSE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;all(x &amp;lt;= 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;any(x &amp;lt;= 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;operations-on-character-strings-vector&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Operations on character strings vector&lt;/h2&gt;
&lt;p&gt;You can paste two vectors (or more) together:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;code &amp;lt;- paste(c(&amp;quot;BE&amp;quot;, &amp;quot;BE&amp;quot;, &amp;quot;FR&amp;quot;, &amp;quot;EN&amp;quot;, &amp;quot;BE&amp;quot;), 1:5, sep = &amp;quot;/&amp;quot;)
code&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;BE/1&amp;quot; &amp;quot;BE/2&amp;quot; &amp;quot;FR/3&amp;quot; &amp;quot;EN/4&amp;quot; &amp;quot;BE/5&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The argument &lt;code&gt;sep&lt;/code&gt; stands for &lt;code&gt;separator&lt;/code&gt; and allows to specify the character(s) or symbol(s) used to separate each character strings.&lt;/p&gt;
&lt;p&gt;If you do not want to specify a separator, you can use &lt;code&gt;sep = &#34;&#34;&lt;/code&gt; or the &lt;code&gt;paste0()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;paste(c(&amp;quot;BE&amp;quot;, &amp;quot;BE&amp;quot;, &amp;quot;FR&amp;quot;, &amp;quot;EN&amp;quot;, &amp;quot;BE&amp;quot;), 1:5, sep = &amp;quot;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;BE1&amp;quot; &amp;quot;BE2&amp;quot; &amp;quot;FR3&amp;quot; &amp;quot;EN4&amp;quot; &amp;quot;BE5&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;paste0(c(&amp;quot;BE&amp;quot;, &amp;quot;BE&amp;quot;, &amp;quot;FR&amp;quot;, &amp;quot;EN&amp;quot;, &amp;quot;BE&amp;quot;), 1:5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;BE1&amp;quot; &amp;quot;BE2&amp;quot; &amp;quot;FR3&amp;quot; &amp;quot;EN4&amp;quot; &amp;quot;BE5&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To find the positions of the elements containing a given string, use the &lt;code&gt;grep()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(&amp;quot;BE&amp;quot;, code)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To extract a character string based on the beginning and the end positions, we can use the &lt;code&gt;substr()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract characters 1 to 3
substr(code,
  start = 1,
  stop = 3
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;BE/&amp;quot; &amp;quot;BE/&amp;quot; &amp;quot;FR/&amp;quot; &amp;quot;EN/&amp;quot; &amp;quot;BE/&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Replace a character string by another one if it exists in the vector by using the &lt;code&gt;sub()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sub(
  pattern = &amp;quot;BE&amp;quot;, # find BE
  replacement = &amp;quot;BEL&amp;quot;, # replace it with BEL
  code
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;BEL/1&amp;quot; &amp;quot;BEL/2&amp;quot; &amp;quot;FR/3&amp;quot;  &amp;quot;EN/4&amp;quot;  &amp;quot;BEL/5&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Split a character string based on a specific symbol with the &lt;code&gt;strsplit()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;strsplit(c(&amp;quot;Rafael Nadal&amp;quot;, &amp;quot;Roger Federer&amp;quot;, &amp;quot;Novak Djokovic&amp;quot;),
  split = &amp;quot; &amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;Rafael&amp;quot; &amp;quot;Nadal&amp;quot; 
## 
## [[2]]
## [1] &amp;quot;Roger&amp;quot;   &amp;quot;Federer&amp;quot;
## 
## [[3]]
## [1] &amp;quot;Novak&amp;quot;    &amp;quot;Djokovic&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;strsplit(code,
  split = &amp;quot;/&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;BE&amp;quot; &amp;quot;1&amp;quot; 
## 
## [[2]]
## [1] &amp;quot;BE&amp;quot; &amp;quot;2&amp;quot; 
## 
## [[3]]
## [1] &amp;quot;FR&amp;quot; &amp;quot;3&amp;quot; 
## 
## [[4]]
## [1] &amp;quot;EN&amp;quot; &amp;quot;4&amp;quot; 
## 
## [[5]]
## [1] &amp;quot;BE&amp;quot; &amp;quot;5&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To transform a character vector to uppercase and lowercase:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;toupper(c(&amp;quot;Rafael Nadal&amp;quot;, &amp;quot;Roger Federer&amp;quot;, &amp;quot;Novak Djokovic&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;RAFAEL NADAL&amp;quot;   &amp;quot;ROGER FEDERER&amp;quot;  &amp;quot;NOVAK DJOKOVIC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tolower(c(&amp;quot;Rafael Nadal&amp;quot;, &amp;quot;Roger Federer&amp;quot;, &amp;quot;Novak Djokovic&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;rafael nadal&amp;quot;   &amp;quot;roger federer&amp;quot;  &amp;quot;novak djokovic&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;orders-and-vectors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Orders and vectors&lt;/h2&gt;
&lt;p&gt;We can sort the elements of a vector from smallest to largest, or from largest to smallest:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(2.1, 5, -4, 1, 1)
sort(x) # smallest to largest&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -4.0  1.0  1.0  2.1  5.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sort(x, decreasing = TRUE) # largest to smallest&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  5.0  2.1  1.0  1.0 -4.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;order()&lt;/code&gt; gives the permutation to apply to the vector in order to sort its elements:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;order(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 4 5 1 2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, the third element of the vector is the smallest and the second element is the largest. This is indicated by the 3 at the beginning of the output, and the 2 at the end of the output.&lt;/p&gt;
&lt;p&gt;Like &lt;code&gt;sort()&lt;/code&gt; the &lt;code&gt;decreasing = TRUE&lt;/code&gt; argument can also be added:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;order(x, decreasing = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2 1 4 5 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case, the 2 in the output indicates that the second element of the vector is the largest, while the 3 indicates that the third element is the smallest.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;rank()&lt;/code&gt; gives the ranks of the elements:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rank(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4.0 5.0 1.0 2.5 2.5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The two last elements of the vector have a rank of 2.5 because they are equal and they come after the first but before the fourth rank.&lt;/p&gt;
&lt;p&gt;We can also reverse the elements (from the last one to the first one):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  2.1  5.0 -4.0  1.0  1.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rev(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  1.0  1.0 -4.0  5.0  2.1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;factors&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Factors&lt;/h1&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;Factors in R&lt;/a&gt; are vectors with a list of levels, also referred as categories. Factors are useful for &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative&lt;/a&gt; data such as the gender, civil status, eye color, etc.&lt;/p&gt;
&lt;div id=&#34;creating-factors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Creating factors&lt;/h2&gt;
&lt;p&gt;We create factors with the &lt;code&gt;factor()&lt;/code&gt; function (do not forget the &lt;code&gt;c()&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;f1 &amp;lt;- factor(c(&amp;quot;T1&amp;quot;, &amp;quot;T3&amp;quot;, &amp;quot;T1&amp;quot;, &amp;quot;T2&amp;quot;))
f1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] T1 T3 T1 T2
## Levels: T1 T2 T3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can of course create a factor from an existing vector:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;v &amp;lt;- c(1, 1, 0, 1, 0)
v2 &amp;lt;- factor(v,
  levels = c(0, 1),
  labels = c(&amp;quot;bad&amp;quot;, &amp;quot;good&amp;quot;)
)
v2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] good good bad  good bad 
## Levels: bad good&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can also specify that the levels are ordered by adding the &lt;code&gt;ordered = TRUE&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;v2 &amp;lt;- factor(v,
  levels = c(0, 1),
  labels = c(&amp;quot;bad&amp;quot;, &amp;quot;good&amp;quot;),
  ordered = TRUE
)
v2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] good good bad  good bad 
## Levels: bad &amp;lt; good&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the order of the levels will follow the order that is specified in the &lt;code&gt;labels&lt;/code&gt; argument.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;properties&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Properties&lt;/h2&gt;
&lt;p&gt;To know the names of the levels:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(f1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;T1&amp;quot; &amp;quot;T2&amp;quot; &amp;quot;T3&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the number of levels:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nlevels(f1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In R, the first level is always the reference level. This reference level can be modified with &lt;code&gt;relevel()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;relevel(f1, ref = &amp;quot;T3&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] T1 T3 T1 T2
## Levels: T3 T1 T2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You see that “T3” is now the first and thus the reference level. Changing the reference level has an impact on the order they are displayed or treated in statistical analyses. Compare, for instance, &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#boxplot&#34;&gt;boxplots&lt;/a&gt; with different reference levels.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;handling&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Handling&lt;/h2&gt;
&lt;p&gt;To know the frequencies for each level:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(f1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## f1
## T1 T2 T3 
##  2  1  1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
summary(f1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## T1 T2 T3 
##  2  1  1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the relative frequencies (i.e., the proportions) can be found with the combination of &lt;code&gt;prop.table()&lt;/code&gt; and &lt;code&gt;table()&lt;/code&gt; or &lt;code&gt;summary()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;prop.table(table(f1))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## f1
##   T1   T2   T3 
## 0.50 0.25 0.25&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
prop.table(summary(f1))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   T1   T2   T3 
## 0.50 0.25 0.25&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember that a factor is coded in R as a numeric vector even though it looks like a character one. We can transform a factor into its numerical equivalent with the &lt;code&gt;as.numeric()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;f1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] T1 T3 T1 T2
## Levels: T1 T2 T3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.numeric(f1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 3 1 2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And a numeric vector can be transformed into a factor with the &lt;code&gt;as.factor()&lt;/code&gt; or &lt;code&gt;factor()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;num &amp;lt;- 1:4
fac &amp;lt;- as.factor(num)
fac&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 3 4
## Levels: 1 2 3 4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fac2 &amp;lt;- factor(num)
fac2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 3 4
## Levels: 1 2 3 4&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The advantage of &lt;code&gt;factor()&lt;/code&gt; is that it is possible to specify a name for each level:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fac2 &amp;lt;- factor(num,
  labels = c(&amp;quot;bad&amp;quot;, &amp;quot;neutral&amp;quot;, &amp;quot;good&amp;quot;, &amp;quot;very good&amp;quot;)
)
fac2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] bad       neutral   good      very good
## Levels: bad neutral good very good&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;lists&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Lists&lt;/h1&gt;
&lt;p&gt;A list is a vector whose elements can be of different natures: a vector, a list, a factor, numeric or character, etc.&lt;/p&gt;
&lt;div id=&#34;creating-lists&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Creating lists&lt;/h2&gt;
&lt;p&gt;The function &lt;code&gt;list()&lt;/code&gt; allows to create lists:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tahiti &amp;lt;- list(
  plane = c(&amp;quot;Airbus&amp;quot;, &amp;quot;Boeing&amp;quot;),
  departure = c(&amp;quot;Brussels&amp;quot;, &amp;quot;Milan&amp;quot;, &amp;quot;Paris&amp;quot;),
  duration = c(15, 11, 14)
)
tahiti&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $plane
## [1] &amp;quot;Airbus&amp;quot; &amp;quot;Boeing&amp;quot;
## 
## $departure
## [1] &amp;quot;Brussels&amp;quot; &amp;quot;Milan&amp;quot;    &amp;quot;Paris&amp;quot;   
## 
## $duration
## [1] 15 11 14&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;handling-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Handling&lt;/h2&gt;
&lt;p&gt;There are several methods to extract elements from a list:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tahiti$departure&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Brussels&amp;quot; &amp;quot;Milan&amp;quot;    &amp;quot;Paris&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
tahiti$de&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Brussels&amp;quot; &amp;quot;Milan&amp;quot;    &amp;quot;Paris&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
tahiti[[2]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Brussels&amp;quot; &amp;quot;Milan&amp;quot;    &amp;quot;Paris&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
tahiti[[&amp;quot;departure&amp;quot;]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Brussels&amp;quot; &amp;quot;Milan&amp;quot;    &amp;quot;Paris&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tahiti[[2]][c(1, 2)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Brussels&amp;quot; &amp;quot;Milan&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To transform a list into a vector:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;v &amp;lt;- unlist(tahiti)
v&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     plane1     plane2 departure1 departure2 departure3  duration1  duration2 
##   &amp;quot;Airbus&amp;quot;   &amp;quot;Boeing&amp;quot; &amp;quot;Brussels&amp;quot;    &amp;quot;Milan&amp;quot;    &amp;quot;Paris&amp;quot;       &amp;quot;15&amp;quot;       &amp;quot;11&amp;quot; 
##  duration3 
##       &amp;quot;14&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.vector(v)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;getting-details-on-an-object&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Getting details on an object&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;attributes()&lt;/code&gt; gives the names of the elements (it can be used on every R object):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;attributes(tahiti)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $names
## [1] &amp;quot;plane&amp;quot;     &amp;quot;departure&amp;quot; &amp;quot;duration&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;str()&lt;/code&gt; gives a short description about the elements (it can also be used on every R object):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(tahiti)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## List of 3
##  $ plane    : chr [1:2] &amp;quot;Airbus&amp;quot; &amp;quot;Boeing&amp;quot;
##  $ departure: chr [1:3] &amp;quot;Brussels&amp;quot; &amp;quot;Milan&amp;quot; &amp;quot;Paris&amp;quot;
##  $ duration : num [1:3] 15 11 14&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data-frames&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Data frames&lt;/h1&gt;
&lt;p&gt;Every imported file in R is a data frame (at least if you do not use a package to &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;import your data in R&lt;/a&gt;). A data frame is a mix of a list and a matrix: it has the shape of a matrix but the columns can have different classes.&lt;/p&gt;
&lt;p&gt;Remember that the gold standard for a &lt;strong&gt;data frame&lt;/strong&gt; is that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;columns&lt;/strong&gt; represent &lt;strong&gt;variables&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;lines&lt;/strong&gt; correspond to &lt;strong&gt;observations&lt;/strong&gt; and&lt;/li&gt;
&lt;li&gt;each &lt;strong&gt;value&lt;/strong&gt; must have its own &lt;strong&gt;cell&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio_files/structure-of-dataset.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Structure of a data frame. Source: R for Data Science by Hadley Wickham &amp;amp; Garrett Grolemund&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Structure of a data frame. Source: R for Data Science by Hadley Wickham &amp;amp; Garrett Grolemund&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;In this article, we use the data frame &lt;code&gt;cars&lt;/code&gt; to illustrate the main data manipulation techniques. Note that the data frame is installed by default in RStudio (so you do not need to import it) and I use the generic name &lt;code&gt;dat&lt;/code&gt; as the name of the data frame throughout the article (see &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/#user-friendly-way&#34;&gt;here&lt;/a&gt; why I always use a generic name instead of more specific names).&lt;/p&gt;
&lt;p&gt;Here is the whole data frame:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- cars # rename the cars data frame with a generic name
dat # display the entire data frame&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 1      4    2
## 2      4   10
## 3      7    4
## 4      7   22
## 5      8   16
## 6      9   10
## 7     10   18
## 8     10   26
## 9     10   34
## 10    11   17
## 11    11   28
## 12    12   14
## 13    12   20
## 14    12   24
## 15    12   28
## 16    13   26
## 17    13   34
## 18    13   34
## 19    13   46
## 20    14   26
## 21    14   36
## 22    14   60
## 23    14   80
## 24    15   20
## 25    15   26
## 26    15   54
## 27    16   32
## 28    16   40
## 29    17   32
## 30    17   40
## 31    17   50
## 32    18   42
## 33    18   56
## 34    18   76
## 35    18   84
## 36    19   36
## 37    19   46
## 38    19   68
## 39    20   32
## 40    20   48
## 41    20   52
## 42    20   56
## 43    20   64
## 44    22   66
## 45    23   54
## 46    24   70
## 47    24   92
## 48    24   93
## 49    24  120
## 50    25   85&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This data frame has 50 observations with 2 variables (&lt;code&gt;speed&lt;/code&gt; and &lt;code&gt;distance&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;You can check the number of observations and variables with &lt;code&gt;nrow()&lt;/code&gt; and &lt;code&gt;ncol()&lt;/code&gt; respectively, or both at the same time with &lt;code&gt;dim()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nrow(dat) # number of rows/observations&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 50&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ncol(dat) # number of columns/variables&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dim(dat) # dimension: number of rows and number of columns&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 50  2&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;line-and-column-names&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Line and column names&lt;/h2&gt;
&lt;p&gt;Before manipulating a data frame, it is interesting to know the line and column names:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dimnames(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
##  [1] &amp;quot;1&amp;quot;  &amp;quot;2&amp;quot;  &amp;quot;3&amp;quot;  &amp;quot;4&amp;quot;  &amp;quot;5&amp;quot;  &amp;quot;6&amp;quot;  &amp;quot;7&amp;quot;  &amp;quot;8&amp;quot;  &amp;quot;9&amp;quot;  &amp;quot;10&amp;quot; &amp;quot;11&amp;quot; &amp;quot;12&amp;quot; &amp;quot;13&amp;quot; &amp;quot;14&amp;quot; &amp;quot;15&amp;quot;
## [16] &amp;quot;16&amp;quot; &amp;quot;17&amp;quot; &amp;quot;18&amp;quot; &amp;quot;19&amp;quot; &amp;quot;20&amp;quot; &amp;quot;21&amp;quot; &amp;quot;22&amp;quot; &amp;quot;23&amp;quot; &amp;quot;24&amp;quot; &amp;quot;25&amp;quot; &amp;quot;26&amp;quot; &amp;quot;27&amp;quot; &amp;quot;28&amp;quot; &amp;quot;29&amp;quot; &amp;quot;30&amp;quot;
## [31] &amp;quot;31&amp;quot; &amp;quot;32&amp;quot; &amp;quot;33&amp;quot; &amp;quot;34&amp;quot; &amp;quot;35&amp;quot; &amp;quot;36&amp;quot; &amp;quot;37&amp;quot; &amp;quot;38&amp;quot; &amp;quot;39&amp;quot; &amp;quot;40&amp;quot; &amp;quot;41&amp;quot; &amp;quot;42&amp;quot; &amp;quot;43&amp;quot; &amp;quot;44&amp;quot; &amp;quot;45&amp;quot;
## [46] &amp;quot;46&amp;quot; &amp;quot;47&amp;quot; &amp;quot;48&amp;quot; &amp;quot;49&amp;quot; &amp;quot;50&amp;quot;
## 
## [[2]]
## [1] &amp;quot;speed&amp;quot; &amp;quot;dist&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To know only the column names:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;speed&amp;quot; &amp;quot;dist&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
colnames(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;speed&amp;quot; &amp;quot;dist&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And to know only the row names:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rownames(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;1&amp;quot;  &amp;quot;2&amp;quot;  &amp;quot;3&amp;quot;  &amp;quot;4&amp;quot;  &amp;quot;5&amp;quot;  &amp;quot;6&amp;quot;  &amp;quot;7&amp;quot;  &amp;quot;8&amp;quot;  &amp;quot;9&amp;quot;  &amp;quot;10&amp;quot; &amp;quot;11&amp;quot; &amp;quot;12&amp;quot; &amp;quot;13&amp;quot; &amp;quot;14&amp;quot; &amp;quot;15&amp;quot;
## [16] &amp;quot;16&amp;quot; &amp;quot;17&amp;quot; &amp;quot;18&amp;quot; &amp;quot;19&amp;quot; &amp;quot;20&amp;quot; &amp;quot;21&amp;quot; &amp;quot;22&amp;quot; &amp;quot;23&amp;quot; &amp;quot;24&amp;quot; &amp;quot;25&amp;quot; &amp;quot;26&amp;quot; &amp;quot;27&amp;quot; &amp;quot;28&amp;quot; &amp;quot;29&amp;quot; &amp;quot;30&amp;quot;
## [31] &amp;quot;31&amp;quot; &amp;quot;32&amp;quot; &amp;quot;33&amp;quot; &amp;quot;34&amp;quot; &amp;quot;35&amp;quot; &amp;quot;36&amp;quot; &amp;quot;37&amp;quot; &amp;quot;38&amp;quot; &amp;quot;39&amp;quot; &amp;quot;40&amp;quot; &amp;quot;41&amp;quot; &amp;quot;42&amp;quot; &amp;quot;43&amp;quot; &amp;quot;44&amp;quot; &amp;quot;45&amp;quot;
## [46] &amp;quot;46&amp;quot; &amp;quot;47&amp;quot; &amp;quot;48&amp;quot; &amp;quot;49&amp;quot; &amp;quot;50&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;subset-a-data-frame&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Subset a data frame&lt;/h2&gt;
&lt;div id=&#34;first-or-last-observations&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;First or last observations&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;To keep only the first 10 observations:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(dat, n = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 1      4    2
## 2      4   10
## 3      7    4
## 4      7   22
## 5      8   16
## 6      9   10
## 7     10   18
## 8     10   26
## 9     10   34
## 10    11   17&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;To keep only the last 5 observations:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tail(dat, n = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 46    24   70
## 47    24   92
## 48    24   93
## 49    24  120
## 50    25   85&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;random-sample-of-observations&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Random sample of observations&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;To draw a sample of 4 observations without replacement:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(dplyr)
sample_n(dat, 4, replace = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed dist
## 1    24  120
## 2    19   46
## 3     4    2
## 4    15   26&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;based-on-row-or-column-numbers&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Based on row or column numbers&lt;/h3&gt;
&lt;p&gt;If you know what observation(s) or column(s) you want to keep, you can use the row or column number(s) to subset your data frame. We illustrate this with several examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;keep all the variables for the &lt;span class=&#34;math inline&#34;&gt;\(3^{rd}\)&lt;/span&gt; observation:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[3, ]&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;keep the &lt;span class=&#34;math inline&#34;&gt;\(2^{nd}\)&lt;/span&gt; variable for all observations:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;You can mix the two above methods to keep only the &lt;span class=&#34;math inline&#34;&gt;\(2^{nd}\)&lt;/span&gt; variable of the &lt;span class=&#34;math inline&#34;&gt;\(3^{rd}\)&lt;/span&gt; observation:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[3, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;keep several observations; for example observations &lt;span class=&#34;math inline&#34;&gt;\(1\)&lt;/span&gt; to &lt;span class=&#34;math inline&#34;&gt;\(5\)&lt;/span&gt;, the &lt;span class=&#34;math inline&#34;&gt;\(10^{th}\)&lt;/span&gt; and the &lt;span class=&#34;math inline&#34;&gt;\(15^{th}\)&lt;/span&gt; observation for all variables:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[c(1:5, 10, 15), ] # do not forget c()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 1      4    2
## 2      4   10
## 3      7    4
## 4      7   22
## 5      8   16
## 10    11   17
## 15    12   28&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;remove observations 5 to 45:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[-c(5:45), ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 1      4    2
## 2      4   10
## 3      7    4
## 4      7   22
## 46    24   70
## 47    24   92
## 48    24   93
## 49    24  120
## 50    25   85&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;tip: to keep only the last observation, use &lt;code&gt;nrow()&lt;/code&gt; instead of the row number:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[nrow(dat), ] # nrow() gives the number of rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 50    25   85&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This way, no matter the number of observations, you will always select the last one. This technique of using a piece of code instead of a specific value is to avoid “hard coding”. Hard coding is generally not recommended (unless you want to specify a parameter that you are sure will never change) because if your data frame changes, you will need to manually edit your code.&lt;/p&gt;
&lt;p&gt;As you probably figured out by now, you can select observations and/or variables of a dataset by running &lt;code&gt;dataset_name[row_number, column_number]&lt;/code&gt;. When the row (column) number is left empty, the entire row (column) is selected.&lt;/p&gt;
&lt;p&gt;Note that all examples presented above also work for matrices:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mat &amp;lt;- matrix(c(-1, 2, 0, 3), ncol = 2, nrow = 2)
mat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2]
## [1,]   -1    0
## [2,]    2    3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mat[1, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;based-on-variable-names&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Based on variable names&lt;/h3&gt;
&lt;p&gt;To select one variable of the dataset based on its name rather than on its column number, use &lt;code&gt;dataset_name$variable_name&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$speed&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  4  4  7  7  8  9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15
## [26] 15 16 16 17 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24 24 24 25&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Accessing variables inside a data frame with this second method is strongly recommended compared to the first if you intend to modify the structure of your database. Indeed, if a column is added or removed in the data frame, the numbering will change. Therefore, variables are generally referred to by its name rather than by its position (column number). In addition, it is easier to understand and interpret code with the name of the variable written (another reason to call variables with a concise but clear name). There is only one reason why I would still use the column number; if the variables names are expected to change while the structure of the data frame will not change.&lt;/p&gt;
&lt;p&gt;To select variables, it is also possible to use the &lt;code&gt;select()&lt;/code&gt; command from the powerful &lt;code&gt;dplyr&lt;/code&gt; package (for compactness only the first 6 observations are displayed thanks to the &lt;code&gt;head()&lt;/code&gt; command):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(select(dat, speed))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed
## 1     4
## 2     4
## 3     7
## 4     7
## 5     8
## 6     9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is equivalent than removing the distance variable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(select(dat, -dist))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed
## 1     4
## 2     4
## 3     7
## 4     7
## 5     8
## 6     9&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;based-on-one-or-multiple-criterion&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Based on one or multiple criterion&lt;/h3&gt;
&lt;p&gt;Instead of subsetting a data frame based on row/column numbers or variable names, you can also subset it based on one or multiple criterion:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;keep only observations with speed larger than 20. The first argument refers to the name of the data frame, while the second argument refers to the subset criteria:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;subset(dat, dat$speed &amp;gt; 20)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 44    22   66
## 45    23   54
## 46    24   70
## 47    24   92
## 48    24   93
## 49    24  120
## 50    25   85&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;keep only observations with distance smaller than or equal to 50 &lt;strong&gt;and&lt;/strong&gt; speed equal to 10. Note the &lt;code&gt;==&lt;/code&gt; (and not &lt;code&gt;=&lt;/code&gt;) for the equal criteria:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;subset(dat, dat$dist &amp;lt;= 50 &amp;amp; dat$speed == 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed dist
## 7    10   18
## 8    10   26
## 9    10   34&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;|&lt;/code&gt; to keep only observations with distance smaller than 20 &lt;strong&gt;or&lt;/strong&gt; speed equal to 10:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;subset(dat, dat$dist &amp;lt; 20 | dat$speed == 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 1      4    2
## 2      4   10
## 3      7    4
## 5      8   16
## 6      9   10
## 7     10   18
## 8     10   26
## 9     10   34
## 10    11   17
## 12    12   14&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;to filter out some observations, use &lt;code&gt;!=&lt;/code&gt;. For instance, to keep observations with speed not equal to 24 and distance not equal to 120 (for compactness only the last 6 observations are displayed thanks to the &lt;code&gt;tail()&lt;/code&gt; command):&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tail(subset(dat, dat$speed != 24 &amp;amp; dat$dist != 120))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist
## 41    20   52
## 42    20   56
## 43    20   64
## 44    22   66
## 45    23   54
## 50    25   85&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that it is also possible to subset a data frame with &lt;code&gt;split()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;split(dat, dat$factor_variable)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above code will split your data frame into several lists, one for each level of the factor variable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;create-a-new-variable&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create a new variable&lt;/h2&gt;
&lt;p&gt;Often, a data frame can be enhanced by creating new variables based on other variables from the initial data frame, or simply by adding a new variable manually.&lt;/p&gt;
&lt;p&gt;In this example, we create two new variables; one being the speed times the distance (which we call &lt;code&gt;speed_dist&lt;/code&gt;) and the other being a categorization of the speed (which we call &lt;code&gt;speed_cat&lt;/code&gt;). We then display the first 6 observations of this new data frame with the 4 variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create new variable speed_dist
dat$speed_dist &amp;lt;- dat$speed * dat$dist

# create new variable speed_cat
# with ifelse(): if dat$speed &amp;gt; 7, then speed_cat is &amp;quot;high speed&amp;quot;, otherwise it is &amp;quot;low_speed&amp;quot;
dat$speed_cat &amp;lt;- factor(ifelse(dat$speed &amp;gt; 7,
  &amp;quot;high speed&amp;quot;, &amp;quot;low speed&amp;quot;
))

# display first 6 observations
head(dat) # 6 is the default in head()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed dist speed_dist  speed_cat
## 1     4    2          8  low speed
## 2     4   10         40  low speed
## 3     7    4         28  low speed
## 4     7   22        154  low speed
## 5     8   16        128 high speed
## 6     9   10         90 high speed&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note than in programming, a character string is generally surrounded by quotes (e.g., &lt;code&gt;&#34;character string&#34;&lt;/code&gt;) and R is not an exception.&lt;/p&gt;
&lt;div id=&#34;transform-a-continuous-variable-into-a-categorical-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Transform a continuous variable into a categorical variable&lt;/h3&gt;
&lt;p&gt;To transform a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;continuous variable&lt;/a&gt; into a categorical variable (also known as &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative variable&lt;/a&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$speed_quali &amp;lt;- cut(dat$speed,
  breaks = c(0, 12, 15, 19, 26), # cut points
  right = FALSE # closed on the left, open on the right
)

dat[c(1:2, 23:24, 49:50), ] # display some observations&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    speed dist speed_dist  speed_cat speed_quali
## 1      4    2          8  low speed      [0,12)
## 2      4   10         40  low speed      [0,12)
## 23    14   80       1120 high speed     [12,15)
## 24    15   20        300 high speed     [15,19)
## 49    24  120       2880 high speed     [19,26)
## 50    25   85       2125 high speed     [19,26)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This transformation is for example often done on age, when the age (a continuous variable) is transformed into a qualitative variable representing different age groups.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;sum-and-mean-in-rows&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Sum and mean in rows&lt;/h3&gt;
&lt;p&gt;In survey with Likert scale (used in psychology, among others), it is often the case that we need to compute a score for each respondents based on multiple questions. The score is usually the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#mean&#34;&gt;mean&lt;/a&gt; or the sum of all the questions of interest.&lt;/p&gt;
&lt;p&gt;This can be done with &lt;code&gt;rowMeans()&lt;/code&gt; and &lt;code&gt;rowSums()&lt;/code&gt;. For instance, let’s compute the mean and the sum of the variables &lt;code&gt;speed&lt;/code&gt;, &lt;code&gt;dist&lt;/code&gt; and &lt;code&gt;speed_dist&lt;/code&gt; (variables must be numeric of course as a sum and a mean cannot be computed on qualitative variables!) for each row and store them under the variables &lt;code&gt;mean_score&lt;/code&gt; and &lt;code&gt;total_score&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$mean_score &amp;lt;- rowMeans(dat[, 1:3]) # variables speed, dist and speed_dist correspond to variables 1 to 3
dat$total_score &amp;lt;- rowSums(dat[, 1:3])

head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed dist speed_dist  speed_cat speed_quali mean_score total_score
## 1     4    2          8  low speed      [0,12)   4.666667          14
## 2     4   10         40  low speed      [0,12)  18.000000          54
## 3     7    4         28  low speed      [0,12)  13.000000          39
## 4     7   22        154  low speed      [0,12)  61.000000         183
## 5     8   16        128 high speed      [0,12)  50.666667         152
## 6     9   10         90 high speed      [0,12)  36.333333         109&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;sum-and-mean-in-column&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Sum and mean in column&lt;/h3&gt;
&lt;p&gt;It is also possible to compute the mean and sum by column with &lt;code&gt;colMeans()&lt;/code&gt; and &lt;code&gt;colSums()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;colMeans(dat[, 1:3])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      speed       dist speed_dist 
##      15.40      42.98     769.64&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;colSums(dat[, 1:3])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      speed       dist speed_dist 
##        770       2149      38482&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is equivalent than:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(dat$speed)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 15.4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sum(dat$speed)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 770&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but it allows to do it for several variables at a time.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;categorical-variables-and-labels-management&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Categorical variables and labels management&lt;/h2&gt;
&lt;p&gt;For categorical variables, it is a good practice to use the factor format and to name the different levels of the variables.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;for this example, let’s create another new variable called &lt;code&gt;dist_cat&lt;/code&gt; based on the distance and then change its format from numeric to factor (while also specifying the labels of the levels):&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create new variable dist_cat
dat$dist_cat &amp;lt;- ifelse(dat$dist &amp;lt; 15,
  1, 2
)

# change from numeric to factor and specify the labels
dat$dist_cat &amp;lt;- factor(dat$dist_cat,
  levels = c(1, 2),
  labels = c(&amp;quot;small distance&amp;quot;, &amp;quot;big distance&amp;quot;) # follow the order of the levels
)

head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed dist speed_dist  speed_cat speed_quali mean_score total_score
## 1     4    2          8  low speed      [0,12)   4.666667          14
## 2     4   10         40  low speed      [0,12)  18.000000          54
## 3     7    4         28  low speed      [0,12)  13.000000          39
## 4     7   22        154  low speed      [0,12)  61.000000         183
## 5     8   16        128 high speed      [0,12)  50.666667         152
## 6     9   10         90 high speed      [0,12)  36.333333         109
##         dist_cat
## 1 small distance
## 2 small distance
## 3 small distance
## 4   big distance
## 5   big distance
## 6 small distance&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;to check the format of a variable:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(dat$dist_cat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;factor&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
str(dat$dist_cat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  Factor w/ 2 levels &amp;quot;small distance&amp;quot;,..: 1 1 1 2 2 1 2 2 2 2 ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will be sufficient if you need to format only a limited number of variables. However, if you need to do it for a large amount of categorical variables, it quickly becomes time consuming to write the same code many times. As you can imagine, it possible to format many variables without having to write the entire code for each variable one by one by using the &lt;code&gt;within()&lt;/code&gt; command:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- within(dat, {
  speed_cat &amp;lt;- factor(speed_cat, labels = c(
    &amp;quot;high speed&amp;quot;,
    &amp;quot;low speed&amp;quot;
  ))
  dist_cat &amp;lt;- factor(dist_cat, labels = c(
    &amp;quot;small distance&amp;quot;,
    &amp;quot;big distance&amp;quot;
  ))
})

head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed dist speed_dist  speed_cat speed_quali mean_score total_score
## 1     4    2          8  low speed      [0,12)   4.666667          14
## 2     4   10         40  low speed      [0,12)  18.000000          54
## 3     7    4         28  low speed      [0,12)  13.000000          39
## 4     7   22        154  low speed      [0,12)  61.000000         183
## 5     8   16        128 high speed      [0,12)  50.666667         152
## 6     9   10         90 high speed      [0,12)  36.333333         109
##         dist_cat
## 1 small distance
## 2 small distance
## 3 small distance
## 4   big distance
## 5   big distance
## 6 small distance&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;#39;data.frame&amp;#39;:	50 obs. of  8 variables:
##  $ speed      : num  4 4 7 7 8 9 10 10 10 11 ...
##  $ dist       : num  2 10 4 22 16 10 18 26 34 17 ...
##  $ speed_dist : num  8 40 28 154 128 90 180 260 340 187 ...
##  $ speed_cat  : Factor w/ 2 levels &amp;quot;high speed&amp;quot;,&amp;quot;low speed&amp;quot;: 2 2 2 2 1 1 1 1 1 1 ...
##  $ speed_quali: Factor w/ 4 levels &amp;quot;[0,12)&amp;quot;,&amp;quot;[12,15)&amp;quot;,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ mean_score : num  4.67 18 13 61 50.67 ...
##  $ total_score: num  14 54 39 183 152 109 208 296 384 215 ...
##  $ dist_cat   : Factor w/ 2 levels &amp;quot;small distance&amp;quot;,..: 1 1 1 2 2 1 2 2 2 2 ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, if you want to transform several numeric variables into categorical variables without changing the labels, it is best to use the &lt;code&gt;transform()&lt;/code&gt; function. We illustrate this function with the &lt;code&gt;mpg&lt;/code&gt; data frame from the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt;&lt;/a&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)
mpg &amp;lt;- transform(mpg,
  cyl = factor(cyl),
  drv = factor(drv),
  fl = factor(fl),
  class = factor(class)
)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;recode-categorical-variables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Recode categorical variables&lt;/h3&gt;
&lt;p&gt;It is possible to recode labels of a categorical variable if you are not satisfied with the current labels. In this example, we change the labels as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;“small distance” becomes “short distance”&lt;/li&gt;
&lt;li&gt;“big distance” becomes “large distance”&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$dist_cat &amp;lt;- recode(dat$dist_cat,
  &amp;quot;small distance&amp;quot; = &amp;quot;short distance&amp;quot;,
  &amp;quot;big distance&amp;quot; = &amp;quot;large distance&amp;quot;
)

head(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   speed dist speed_dist  speed_cat speed_quali mean_score total_score
## 1     4    2          8  low speed      [0,12)   4.666667          14
## 2     4   10         40  low speed      [0,12)  18.000000          54
## 3     7    4         28  low speed      [0,12)  13.000000          39
## 4     7   22        154  low speed      [0,12)  61.000000         183
## 5     8   16        128 high speed      [0,12)  50.666667         152
## 6     9   10         90 high speed      [0,12)  36.333333         109
##         dist_cat
## 1 short distance
## 2 short distance
## 3 short distance
## 4 large distance
## 5 large distance
## 6 short distance&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;change-reference-level&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Change reference level&lt;/h3&gt;
&lt;p&gt;For some analyses, you might want to change the order of the levels. For example, if you are analyzing data about a control group and a treatment group, you may want to set the control group as the reference group. By default, levels are ordered by alphabetical order or by its numeric value if it was transformed from numeric to factor.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;to check the current order of the levels (the first level being the reference):&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(dat$dist_cat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;short distance&amp;quot; &amp;quot;large distance&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case, “short distance” being the first level it is the reference level. It is the first level because it was initially set with a value equal to 1 when creating the variable.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;to change the reference level:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$dist_cat &amp;lt;- relevel(dat$dist_cat, ref = &amp;quot;large distance&amp;quot;)

levels(dat$dist_cat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;large distance&amp;quot; &amp;quot;short distance&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Large distance is now the first and thus the reference level.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;rename-variable-names&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Rename variable names&lt;/h2&gt;
&lt;p&gt;To rename variable names as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;dist &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; distance&lt;/li&gt;
&lt;li&gt;speed_dist &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; speed_distance&lt;/li&gt;
&lt;li&gt;dist_cat &lt;span class=&#34;math inline&#34;&gt;\(\rightarrow\)&lt;/span&gt; distance_cat&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;use the &lt;code&gt;rename()&lt;/code&gt; command from the &lt;code&gt;dplyr&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- rename(dat,
  distance = dist,
  speed_distance = speed_dist,
  distance_cat = dist_cat
)

names(dat) # display variable names&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;speed&amp;quot;          &amp;quot;distance&amp;quot;       &amp;quot;speed_distance&amp;quot; &amp;quot;speed_cat&amp;quot;     
## [5] &amp;quot;speed_quali&amp;quot;    &amp;quot;mean_score&amp;quot;     &amp;quot;total_score&amp;quot;    &amp;quot;distance_cat&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;create-a-data-frame-manually&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create a data frame manually&lt;/h2&gt;
&lt;p&gt;Although most analyses are performed on an imported data frame, it is also possible to create a data frame directly in R:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Create the data frame named dat with 2 variables
dat &amp;lt;- data.frame(
  &amp;quot;variable1&amp;quot; = c(6, 12, NA, 3), # presence of 1 missing value (NA)
  &amp;quot;variable2&amp;quot; = c(3, 7, 9, 1)
)

# Print the data frame
dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   variable1 variable2
## 1         6         3
## 2        12         7
## 3        NA         9
## 4         3         1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;merging-two-data-frames&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Merging two data frames&lt;/h2&gt;
&lt;p&gt;By default, the merge is done on the common variables (variables that have the same name). However, if they do not have the same name, it is still possible to merge the two data frames by specifying their names:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat1 &amp;lt;- data.frame(
  person = c(1:4),
  treatment = c(&amp;quot;T1&amp;quot;, &amp;quot;T2&amp;quot;)
)

dat1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   person treatment
## 1      1        T1
## 2      2        T2
## 3      3        T1
## 4      4        T2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat2 &amp;lt;- data.frame(
  patient = c(1:4),
  age = c(56, 23, 32, 19),
  gender = c(&amp;quot;M&amp;quot;, &amp;quot;F&amp;quot;, &amp;quot;F&amp;quot;, &amp;quot;M&amp;quot;)
)

dat2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   patient age gender
## 1       1  56      M
## 2       2  23      F
## 3       3  32      F
## 4       4  19      M&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We want to merge the two data frames by the subject number, but this number is referred as &lt;code&gt;person&lt;/code&gt; in the first data frame and &lt;code&gt;patient&lt;/code&gt; in the second data frame, so we need to indicate it:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;merge(
  x = dat1, y = dat2,
  by.x = &amp;quot;person&amp;quot;, by.y = &amp;quot;patient&amp;quot;,
  all = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   person treatment age gender
## 1      1        T1  56      M
## 2      2        T2  23      F
## 3      3        T1  32      F
## 4      4        T2  19      M&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;add-new-observations-from-another-data-frame&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Add new observations from another data frame&lt;/h2&gt;
&lt;p&gt;In order to add new observations from another data frame, the two data frames need to have the same column names (but they can be in a different order):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   person treatment
## 1      1        T1
## 2      2        T2
## 3      3        T1
## 4      4        T2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat3 &amp;lt;- data.frame(
  person = 5:8,
  treatment = c(&amp;quot;T3&amp;quot;)
)

dat3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   person treatment
## 1      5        T3
## 2      6        T3
## 3      7        T3
## 4      8        T3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rbind(dat1, dat3) # r stands for row, so we bind data frames by row&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   person treatment
## 1      1        T1
## 2      2        T2
## 3      3        T1
## 4      4        T2
## 5      5        T3
## 6      6        T3
## 7      7        T3
## 8      8        T3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, data for persons 5 to 8 have been added at the end of the data frame &lt;code&gt;dat1&lt;/code&gt; (because &lt;code&gt;dat1&lt;/code&gt; comes before &lt;code&gt;dat3&lt;/code&gt; in the &lt;code&gt;rbind()&lt;/code&gt; function).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;add-new-variables-from-another-data-frame&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Add new variables from another data frame&lt;/h2&gt;
&lt;p&gt;It is also possible to add new variables to a data frame with the &lt;code&gt;cbind()&lt;/code&gt; function. Unlike &lt;code&gt;rbind()&lt;/code&gt;, column names do not have to be the same since they are added next to each other:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   patient age gender
## 1       1  56      M
## 2       2  23      F
## 3       3  32      F
## 4       4  19      M&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   person treatment
## 1      5        T3
## 2      6        T3
## 3      7        T3
## 4      8        T3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;cbind(dat2, dat3) # c stands for column, so we bind data frames by column&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   patient age gender person treatment
## 1       1  56      M      5        T3
## 2       2  23      F      6        T3
## 3       3  32      F      7        T3
## 4       4  19      M      8        T3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to add only a specific variable from another data frame:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat_cbind &amp;lt;- cbind(dat2, dat3$treatment)

dat_cbind&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   patient age gender dat3$treatment
## 1       1  56      M             T3
## 2       2  23      F             T3
## 3       3  32      F             T3
## 4       4  19      M             T3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(dat_cbind)[4] &amp;lt;- &amp;quot;treatment&amp;quot;

dat_cbind&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   patient age gender treatment
## 1       1  56      M        T3
## 2       2  23      F        T3
## 3       3  32      F        T3
## 4       4  19      M        T3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or more simply with the &lt;code&gt;data.frame()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data.frame(dat2,
  treatment = dat3$treatment
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   patient age gender treatment
## 1       1  56      M        T3
## 2       2  23      F        T3
## 3       3  32      F        T3
## 4       4  19      M        T3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;missing-values&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Missing values&lt;/h1&gt;
&lt;p&gt;Missing values (represented by NA in RStudio, for “Not Applicable”) are often problematic for many analyses because many computations including a missing value has a missing value for result.&lt;/p&gt;
&lt;p&gt;For instance, the mean of a series or variable with at least one NA will give a NA as a result. The data frame &lt;code&gt;dat&lt;/code&gt; created in the previous section is used for this example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   variable1 variable2
## 1         6         3
## 2        12         7
## 3        NA         9
## 4         3         1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(dat$variable1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;na.omit()&lt;/code&gt; function avoids the NA result, doing as if there was no missing value:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(na.omit(dat$variable1))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Moreover, most basic functions include an argument to deal with missing values:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(dat$variable1, na.rm = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;is.na()&lt;/code&gt; indicates if an element is a missing value or not:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.na(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      variable1 variable2
## [1,]     FALSE     FALSE
## [2,]     FALSE     FALSE
## [3,]      TRUE     FALSE
## [4,]     FALSE     FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that “NA” as a string is not considered as a missing value:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;- c(&amp;quot;NA&amp;quot;, &amp;quot;2&amp;quot;)

is.na(y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To check whether there is at least one missing value in a vector or data frame:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;anyNA(dat$variable2) # check for NA in variable2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;anyNA(dat) # check for NA in the whole data frame&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or
any(is.na(dat)) # check for NA in the whole data frame&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nonetheless, data frames with NAs are still problematic for some types of analysis. Several alternatives exist to remove or impute missing values.&lt;/p&gt;
&lt;div id=&#34;remove-nas&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Remove NAs&lt;/h2&gt;
&lt;p&gt;A simple solution is to remove all observations (i.e., rows) containing at least one missing value. This is done by keeping only observations with complete cases:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat_complete &amp;lt;- dat[complete.cases(dat), ]
dat_complete&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   variable1 variable2
## 1         6         3
## 2        12         7
## 4         3         1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Be careful when removing observations with missing values, especially if missing values are not “missing at random”. It is not because it is possible (and easy) to remove them, that you should do it in all cases. This is, however, beyond the scope of the present article.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;impute-nas&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Impute NAs&lt;/h2&gt;
&lt;p&gt;Instead of removing observations with at least one NA, it is possible to impute them, that is, replace them by some values such as the median or the mode of the variable. This can be done easily with the command &lt;code&gt;impute()&lt;/code&gt; from the package &lt;code&gt;Hmisc&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(Hmisc)

# impute NA with default method (median/mode)
variable1 &amp;lt;- impute(dat$variable1)

# create data frame with imputed data
dat_imputed &amp;lt;- data.frame(variable1,
  variable2 = dat$variable2
)

dat_imputed&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   variable1 variable2
## 1         6         3
## 2        12         7
## 3         6         9
## 4         3         1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When the median/mode method is used (the default), character vectors and factors are imputed with the mode. Numeric and integer vectors are imputed with the median. Again, use imputations carefully. Other packages offer more advanced imputation techniques. However, we keep it simple and straightforward for this article as advanced imputations is beyond the scope of introductory data manipulations in R.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;scale&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Scale&lt;/h1&gt;
&lt;p&gt;&lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/#probabilities-and-standard-normal-distribution&#34;&gt;Scaling&lt;/a&gt; (also referred as standardizing) a variable is often used before a Principal Component Analysis (PCA)&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; when variables of a data frame have different units. Remember that scaling a variable means that it will compute the mean and the standard deviation of that variable. Then each value (so each row) of that variable is “scaled” by subtracting the mean and dividing by the standard deviation of that variable. Formally:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[z = \frac{x - \bar{x}}{s}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(\bar{x}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(s\)&lt;/span&gt; are the mean and the standard deviation of the variable, respectively.&lt;/p&gt;
&lt;p&gt;To scale one or more variables in R use &lt;code&gt;scale()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat_scaled &amp;lt;- scale(dat_imputed)

head(dat_scaled)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    variable1  variable2
## 1 -0.1986799 -0.5477226
## 2  1.3907590  0.5477226
## 3 -0.1986799  1.0954451
## 4 -0.9933993 -1.0954451&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;dates-and-times&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Dates and times&lt;/h1&gt;
&lt;div id=&#34;dates&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Dates&lt;/h2&gt;
&lt;p&gt;In R the default date format follows the rules of the ISO 8601 international standard which expresses a day as “2001-02-13” (yyyy-mm-dd).&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;Date can be defined by a string of characters or a number. For example, October 1st, 2016:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.Date(&amp;quot;01/10/16&amp;quot;, format = &amp;quot;%d/%m/%y&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2016-10-01&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.Date(274, origin = &amp;quot;2016-01-01&amp;quot;) # there are 274 days between the origin and October 1st, 2016&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2016-10-01&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;times&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Times&lt;/h2&gt;
&lt;p&gt;An example with date and time vectors:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dates &amp;lt;- c(&amp;quot;02/27/92&amp;quot;, &amp;quot;02/27/99&amp;quot;, &amp;quot;01/14/92&amp;quot;)
times &amp;lt;- c(&amp;quot;23:03:20&amp;quot;, &amp;quot;22:29:56&amp;quot;, &amp;quot;01:03:30&amp;quot;)

x &amp;lt;- paste(dates, times)
x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;02/27/92 23:03:20&amp;quot; &amp;quot;02/27/99 22:29:56&amp;quot; &amp;quot;01/14/92 01:03:30&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;strptime(x,
  format = &amp;quot;%m/%d/%y %H:%M:%S&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1992-02-27 23:03:20 CET&amp;quot; &amp;quot;1999-02-27 22:29:56 CET&amp;quot;
## [3] &amp;quot;1992-01-14 01:03:30 CET&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Find more information on how to express a date and time format with &lt;code&gt;help(strptime)&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;extraction-from-dates&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extraction from dates&lt;/h2&gt;
&lt;p&gt;We can extract:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;weekdays&lt;/li&gt;
&lt;li&gt;months&lt;/li&gt;
&lt;li&gt;quarters&lt;/li&gt;
&lt;li&gt;years&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;- strptime(x,
  format = &amp;quot;%m/%d/%y %H:%M:%S&amp;quot;
)

y&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1992-02-27 23:03:20 CET&amp;quot; &amp;quot;1999-02-27 22:29:56 CET&amp;quot;
## [3] &amp;quot;1992-01-14 01:03:30 CET&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;weekdays(y, abbreviate = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Thursday&amp;quot; &amp;quot;Saturday&amp;quot; &amp;quot;Tuesday&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;months(y, abbreviate = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;February&amp;quot; &amp;quot;February&amp;quot; &amp;quot;January&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quarters(y, abbreviate = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Q1&amp;quot; &amp;quot;Q1&amp;quot; &amp;quot;Q1&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;format(y, &amp;quot;%Y&amp;quot;) # 4-digit year&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1992&amp;quot; &amp;quot;1999&amp;quot; &amp;quot;1992&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;format(y, &amp;quot;%y&amp;quot;) # 2-digit year&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;92&amp;quot; &amp;quot;99&amp;quot; &amp;quot;92&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;exporting-and-saving&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Exporting and saving&lt;/h1&gt;
&lt;p&gt;If a copy-paste is not sufficient, you can save an object in R format with &lt;code&gt;save()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;save(dat, file = &amp;quot;dat.Rdata&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or using &lt;code&gt;write.table()&lt;/code&gt;, &lt;code&gt;write.csv()&lt;/code&gt; or &lt;code&gt;write.xlsx()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# in a text format
write.table(dat, &amp;quot;dat.txt&amp;quot;, row = FALSE, sep = &amp;quot;\t&amp;quot;, quote = FALSE)

# in csv
write.csv(dat, file = &amp;quot;dat.csv&amp;quot;, row.names = FALSE, quote = FALSE)

# in excel
# install.packages(&amp;quot;openxlsx&amp;quot;)
library(openxlsx)
write.xlsx(dat, file = &amp;quot;dat.xlsx&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you need to send every results into a file instead of the console:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sink(&amp;quot;filename&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Don’t forget to stop it with &lt;code&gt;sink()&lt;/code&gt;.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;looking-for-help&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Looking for help&lt;/h1&gt;
&lt;p&gt;You can always find some help about:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a function: &lt;code&gt;?function&lt;/code&gt; or &lt;code&gt;help(function)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;a package: &lt;code&gt;help(package = packagename)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;a concept: &lt;code&gt;help.search(&#34;concept&#34;)&lt;/code&gt; or &lt;code&gt;apropos(&#34;concept&#34;)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Otherwise, Google is your best friend!&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 helped you to manipulate your data in RStudio. For those who are interested in going further, see also an introduction to &lt;a href=&#34;https://statsandr.com/blog/introduction-to-data-manipulation-in-r-with-dplyr/&#34;&gt;data manipulation in R with the &lt;code&gt;{dplyr}&lt;/code&gt; package&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now that you know &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;how to import a data frame into R&lt;/a&gt; and how to manipulate it, the next step would probably be to learn how to perform &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics in R&lt;/a&gt;. If you are looking for more advanced statistical analyses using R, see all &lt;a href=&#34;https://statsandr.com/tags/r/&#34;&gt;articles about R&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;Principal Component Analysis (PCA) is a useful technique for exploratory data analysis, allowing a better visualization of the variation present in a data frame with a large number of variables. When there are many variables, the data cannot easily be illustrated in their raw format. To counter this, the PCA takes a data frame with many variables and simplifies it by transforming the original variables into a smaller number of “principal components”. The first dimension contains the most variance in the data frame and so on, and the dimensions are uncorrelated. Note that PCA is done on quantitative variables.&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;For your information, note that this date format is not the same for every software! Excel, for instance, uses a different format.&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>How to import an Excel file in RStudio?</title>
      <link>https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/</link>
      <pubDate>Wed, 18 Dec 2019 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#transform-an-excel-file-to-a-csv-file&#34; id=&#34;toc-transform-an-excel-file-to-a-csv-file&#34;&gt;Transform an Excel file to a CSV file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#r-working-directory&#34; id=&#34;toc-r-working-directory&#34;&gt;R working directory&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#get-working-directory&#34; id=&#34;toc-get-working-directory&#34;&gt;Get working directory&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#set-working-directory&#34; id=&#34;toc-set-working-directory&#34;&gt;Set working directory&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#user-friendly-method&#34; id=&#34;toc-user-friendly-method&#34;&gt;User-friendly method&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#via-the-console&#34; id=&#34;toc-via-the-console&#34;&gt;Via the console&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#via-the-text-editor&#34; id=&#34;toc-via-the-text-editor&#34;&gt;Via the text editor&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#import-your-dataset&#34; id=&#34;toc-import-your-dataset&#34;&gt;Import your dataset&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#user-friendly-way&#34; id=&#34;toc-user-friendly-way&#34;&gt;User-friendly way&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#via-the-text-editor-1&#34; id=&#34;toc-via-the-text-editor-1&#34;&gt;Via the text editor&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#import-spss-.sav-files&#34; id=&#34;toc-import-spss-.sav-files&#34;&gt;Import SPSS (.sav) files&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/how-to-import-an-excel-file-in-rstudio_files/how-to-import-an-excel-file-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;As we have seen in this article on &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;how to install R and RStudio&lt;/a&gt;, R is useful for many kind of computational tasks and statistical analyses. However, it would not be so powerful and useful without the possibility to import datasets into R. As you will most likely use R with your own data, being able to import it into R is crucial for any user.&lt;/p&gt;
&lt;p&gt;In this article I present two different ways to import an Excel file; (i) via the text editor and (ii) in a more “user-friendly” way. I also discuss about the main advantages and disadvantages of both methods. Note that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to import a dataset often depends on the format of the file (Excel, CSV, text, SPSS, Stata, etc.). I focus here only on Excel files as it is the most common type of file for a dataset&lt;/li&gt;
&lt;li&gt;There are several other ways to import an Excel file (probably even some I am not aware of), but I present the two most simple yet robust ways to import such files&lt;/li&gt;
&lt;li&gt;No matter what type of file and how you import it, there is one gold standard regarding how datasets are structured: columns correspond to variables, rows correspond to observations (in the broad sense of the term) and each value must have its own cell (known as tidy format):&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio_files/structure-of-dataset.png&#34; alt=&#34;Structure of a dataset. Source: R for Data Science by Hadley Wickham &amp;amp; Garrett Grolemund&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Structure of a dataset. Source: R for Data Science by Hadley Wickham &amp;amp; Garrett Grolemund&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;transform-an-excel-file-to-a-csv-file&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Transform an Excel file to a CSV file&lt;/h1&gt;
&lt;p&gt;Before dealing with the importation, the first thing is to change the format of your Excel file to a CSV format.&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; CSV format is the standard when working with datasets and programming languages as it is a more robust format compared to Excel.&lt;/p&gt;
&lt;p&gt;If your file is already in the CSV format (with the extension .csv), you can skip this section. If the file is not in the CSV format (for example the extension is .xlsx) you can easily transform it to CSV by following these steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Open your Excel file&lt;/li&gt;
&lt;li&gt;Click on File &amp;gt; Save as&lt;/li&gt;
&lt;li&gt;Choose the format .csv&lt;/li&gt;
&lt;li&gt;Click on Save&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Check that your file finishes with the extension .csv. If that is the case, your file is now ready to be imported. But first, let me introduce an important concept when importing datasets into RStudio, the working directory.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;r-working-directory&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;R working directory&lt;/h1&gt;
&lt;p&gt;Although programming languages may be very powerful, it often needs our help and importing a dataset is not an exception. Indeed, before importing your data, you must tell RStudio where your file is located (so let RStudio know in which folder to look for your dataset). But before this, let me introduce the &lt;strong&gt;working directory&lt;/strong&gt;. The working directory is the location (in your computer) of where RStudio is currently working (in fact RStudio is not working across your entire computer; it is working inside one folder of your computer). Concerning this working directory, there are two functions that we will need:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;getwd()&lt;/code&gt; (&lt;code&gt;wd&lt;/code&gt; stands for working directory)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;setwd()&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;get-working-directory&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Get working directory&lt;/h2&gt;
&lt;p&gt;In most cases, when you open RStudio, the working directory (so where it is currently working) is different than where your dataset is located. To know what is the working directory RStudio is currently using, run &lt;code&gt;getwd()&lt;/code&gt;. On MacOS, this function will most likely render a location such as &lt;code&gt;&#34;/Users/yourname/&#34;&lt;/code&gt;, while on Windows it will most likely render &lt;code&gt;&#34;c:/Documents/&#34;&lt;/code&gt;. Do not worry if your working directory is different, the most important is to set the working directory correctly (so where your file is located) and not where it is now.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;set-working-directory&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Set working directory&lt;/h2&gt;
&lt;p&gt;As mentioned earlier, your dataset is most likely located in a different location than your working directory. Without any action from you, RStudio will never be able to import your file as it is not looking in the correct folder (you will encounter the following error in the console: cannot open file ‘data.csv’: No such file or directory). Now, in order to specify the correct location of your file (that is, to tell RStudio in which folder it should look for your dataset), you have three options:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the user-friendly method&lt;/li&gt;
&lt;li&gt;via the console&lt;/li&gt;
&lt;li&gt;via the text editor (see below why it is my preferred option)&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;user-friendly-method&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;User-friendly method&lt;/h3&gt;
&lt;p&gt;To set the correct folder, so to set the working directory equal to the folder where your file is located, follow these steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;In the lower right pane of RStudio, click on the tab “Files”&lt;/li&gt;
&lt;li&gt;Click on “Home” next to the house icon&lt;/li&gt;
&lt;li&gt;Go to the folder where your dataset is located&lt;/li&gt;
&lt;li&gt;Click on “More”&lt;/li&gt;
&lt;li&gt;Click on “Set As Working Directory”&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio_files/set-working-directory-rstudio.png&#34; alt=&#34;Set working directory in RStudio (user-friendly method)&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Set working directory in RStudio (user-friendly method)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Alternatively, you can also set the working directory by clicking on Session &amp;gt; Set Working Directory &amp;gt; Choose Directory…&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio_files/set-working-directory2-rstudio.png&#34; alt=&#34;Set working directory in RStudio (user-friendly method)&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Set working directory in RStudio (user-friendly method)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As you can see in the console, any of the two methods will actually execute the code &lt;code&gt;setwd()&lt;/code&gt; with the path to the folder you specified. So by clicking on the buttons you actually asked RStudio to write a line of code for you. This method has the advantage that you do not need to remember the code and that you will not make a mistake in the name of the path to your folder. The disadvantage is that if you leave RStudio and open it again later, you will have to specify the working directory again as RStudio did not save your actions via the buttons.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;via-the-console&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Via the console&lt;/h3&gt;
&lt;p&gt;You can specify the working directory by running &lt;code&gt;setwd(path/to/folder)&lt;/code&gt; directly in the console, with &lt;code&gt;path/to/folder&lt;/code&gt; being the path to the folder containing your dataset. However, you will need to run the command again when reopening RStudio.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;via-the-text-editor&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Via the text editor&lt;/h3&gt;
&lt;p&gt;This method is actually a combination of the two above:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Set the working directory by following the exact same steps than for the user-friendly method (via the buttons)&lt;/li&gt;
&lt;li&gt;Copy the code executed in the console and paste it in the text editor (i.e., your script)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I recommend this method for several reasons. First, you do not need to remember the &lt;code&gt;setwd()&lt;/code&gt; function. Second, you will not make typos in the path of your folder (path which can sometimes be quite long if you have folders inside folders). Third, when saving your script (which I assume you do otherwise you would lose all your work), you also save the actions you just made via the buttons. So when you reopen your script in the future, no matter what is the current directory, by executing your script (which now include the line of code for setting the working directory), you will at the same time specify the working directory you selected for this project.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;import-your-dataset&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Import your dataset&lt;/h1&gt;
&lt;p&gt;Now that you have transformed your Excel file into a CSV file and you have specified the folder containing your data by setting the working directory, you are now ready to actually import your dataset. Remind that there are two methods to import a file:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;in a user-friendly way&lt;/li&gt;
&lt;li&gt;via the text editor (see also below why it is my preferred option)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;No matter which method you choose, it is a good practice to first open your file in TextEdit (on Mac) or Notepad (on Windows) in order to see the raw data. If you open the file in Excel you will see the data already formatted and thus miss some important information needed for the importation. Below an example of raw data:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio_files/raw-data3.png&#34; alt=&#34;Example of raw data&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Example of raw data&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;There are a few things we need to look for in order to properly import our dataset:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Are the variables names present?&lt;/li&gt;
&lt;li&gt;How are the values separated? Comma, semicolon, whitespace, tab?&lt;/li&gt;
&lt;li&gt;Is the decimal a point or a comma?&lt;/li&gt;
&lt;li&gt;How are specified missing values? Empty cells, NA, null, O, other?&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;user-friendly-way&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;User-friendly way&lt;/h2&gt;
&lt;p&gt;As shown below, simply click on the file &amp;gt; Import Dataset…&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio_files/import-data-rstudio.png&#34; alt=&#34;Import dataset in RStudio&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Import dataset in RStudio&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A window which looks like this will open:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio_files/import-window-rstudio.png&#34; alt=&#34;Import window in RStudio&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Import window in RStudio&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;From this window, you can have a preview of your data, and more importantly, check whether your data seems to have been imported correctly. If your data have been correctly imported, you can click on “Import”. If this is not the case, you can change the import options at the bottom of the window (below the data preview) corresponding to the information you gathered when looking at the raw data. Below, the import options you will most likely use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Name: set the name of your data set (default is the name of the file). Avoid special characters and long names (as you will have to type the name of your dataset several times). I personally rename my datasets with a generic name such as “dat”, others use “df” (for dataframe), “data”, or even “my_data”. You could use more explicit names such as “tennis_data” if you are using data on tennis matches for example. However, the main drawback with using specific names for datasets is that if, for instance, you want to reuse the code you created while analysing tennis data on other datasets, you will need to edit your code by replacing all occurrences of “tennis_data” by the name of your new dataset&lt;/li&gt;
&lt;li&gt;Skip: specify the number of top rows you want to skip (default is 0). Most of the time, 0 is fine. However, if your file contains some blank rows at the top (or information you want to disregard), set the number of rows to skip&lt;/li&gt;
&lt;li&gt;First Row as Names: specify whether the variables names are present or not (default is that variables names are present)&lt;/li&gt;
&lt;li&gt;Delimiter: the character which separate the values. From our raw data above, you can see that the delimiter is a comma (“,”). Change it to semicolon if your values are separated by “;”&lt;/li&gt;
&lt;li&gt;NA: how missing values are specified (default is empty cells). From our raw data above, you can see that missing values are simply empty cells, so leave NA to default or change it to “empty”. Change this option if missing values in your raw data are coded as “NA” or “0” (tip: do not code yourself missing values as “0”, otherwise you will not be able to distinguish the true zero values and the missing values)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After changing the import options corresponding to your data, click on “Import”. You should now see your dataset in a new window and from there you can start analyzing your data.&lt;/p&gt;
&lt;p&gt;This user-friendly method has the advantage that you do not need to remember the code (see the next section for the entire code). However, the main drawback is that your import options will not be saved for a future usage so you will need to import your dataset manually each time you open RStudio.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;via-the-text-editor-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Via the text editor&lt;/h2&gt;
&lt;p&gt;Similarly to setting the working directory, I also recommend using the text editor instead of the user-friendly method for the simple reason that you can save your import options when using the text editor (and not when using the user-friendly method). Saving your import options in your script (thanks to a line of code) allows you to quickly import your dataset the exact same way without having to repeat all the necessary steps every time you import your dataset. The command to import a CSV file is &lt;code&gt;read.csv()&lt;/code&gt; (or &lt;code&gt;read.csv2()&lt;/code&gt; which is equivalent but with other default import options). Here is an example with the same file than in the user-friendly method:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- read.csv(
  file = &amp;quot;data.csv&amp;quot;,
  header = TRUE,
  sep = &amp;quot;,&amp;quot;,
  dec = &amp;quot;.&amp;quot;,
  stringsAsFactors = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dat &amp;lt;-&lt;/code&gt;: name of the dataset in RStudio. This means that after importation, I will need to refer to the dataset by calling &lt;code&gt;dat&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;file =&lt;/code&gt;: name of the file in the working directory. Do not forget “” around the name, the extension .csv at the end and the fact that RStudio is case sensitive (&lt;code&gt;&#34;Data.csv&#34;&lt;/code&gt; will give an &lt;a href=&#34;https://statsandr.com/blog/top-10-errors-in-r/&#34;&gt;error&lt;/a&gt;) and space sensitive inside “” (&lt;code&gt;&#34;data .csv&#34;&lt;/code&gt; will also throw an error). In our case the file is named “data.csv” so &lt;code&gt;file = &#34;data.csv&#34;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;header =&lt;/code&gt;: are variables names present? The default is &lt;code&gt;TRUE&lt;/code&gt;, change it to &lt;code&gt;FALSE&lt;/code&gt; if it is not the case in your dataset (&lt;code&gt;TRUE&lt;/code&gt; and &lt;code&gt;FALSE&lt;/code&gt; are always in capital letters, &lt;code&gt;true&lt;/code&gt; will not work!)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sep =&lt;/code&gt;: separator. Equivalent to delimiter in the user-friendly method. Do not forget the ““. In our dataset the separator of the values is a comma so &lt;code&gt;sep = &#34;,&#34;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dec =&lt;/code&gt;: decimal. Do not forget the ““. In our dataset, the decimal for the numeric values is a point, so &lt;code&gt;dec = &#34;.&#34;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;stringsAsFactors =&lt;/code&gt;: should character vectors be converted to factors? The default option used to be &lt;code&gt;TRUE&lt;/code&gt;, but since R version 4.0.0 it is &lt;code&gt;FALSE&lt;/code&gt; by default. If all your character vectors are actually &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;qualitative variables&lt;/a&gt; (so &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factors&lt;/a&gt; in R), set it to &lt;code&gt;TRUE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;I do not write that missing values are coded as empty cells in my dataset because it is the default&lt;/li&gt;
&lt;li&gt;Last but not least, do not forget that the arguments are separated by a comma&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Other arguments exist, run &lt;code&gt;?read.csv&lt;/code&gt; to see all of them.&lt;/p&gt;
&lt;p&gt;After the importation you can check whether your data have been correctly imported by running &lt;code&gt;View(dat)&lt;/code&gt; where &lt;code&gt;dat&lt;/code&gt; is the name you chose for your data. A window, similar than for the user-friendly method, will display your data. Alternatively you can also run &lt;code&gt;head(dat)&lt;/code&gt; to see the first 6 rows and check that it corresponds to your Excel file. If something is not correct, edit the import options and check again. If your dataset has been correctly imported, you can now start analyzing your data. See other &lt;a href=&#34;https://statsandr.com/tags/R/&#34;&gt;articles on R&lt;/a&gt; if you want to learn how.&lt;/p&gt;
&lt;p&gt;The advantage of importing your dataset directly via the code in the text editor is that your import options will be saved for a future usage, preventing you from importing it manually every time you open your script. You will, however, need to remember the function &lt;code&gt;read.csv()&lt;/code&gt; (not the arguments since you can always check them in the help documentation).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;import-spss-.sav-files&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Import SPSS (.sav) files&lt;/h1&gt;
&lt;p&gt;Only Excel files are covered in details here. However, SPSS files (.sav) can also be read in R by using the following command:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(foreign)
dat &amp;lt;- read.spss(
  file = &amp;quot;filename.sav&amp;quot;,
  use.value.labels = TRUE,
  to.data.frame = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;read.spss()&lt;/code&gt; function outputs a data table which retrieves all the characteristics of the .sav file, including the names given for the different levels of the categorical variables and the characteristics of the variables. If you need more information about this command, see the help documentation (&lt;code&gt;library(foreign)&lt;/code&gt; then &lt;code&gt;?read.spss&lt;/code&gt;).&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 helped you to import an Excel file in RStudio. Now that your dataset is correctly imported, learn &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;how to manipulate it&lt;/a&gt; or how to perform &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics in R&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;I am aware that it is possible to import an Excel directly into R without converting it in a CSV file, with the &lt;code&gt;read_excel()&lt;/code&gt; function from the &lt;code&gt;{readxl}&lt;/code&gt; package for instance. However, CSV format is the standard and more importantly, importing a CSV does not require to &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;install and load a package&lt;/a&gt; (which is sometimes confusing for beginners).&lt;a href=&#34;#fnref1&#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>How to install R and RStudio?</title>
      <link>https://statsandr.com/blog/how-to-install-r-and-rstudio/</link>
      <pubDate>Tue, 17 Dec 2019 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-install-r-and-rstudio/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-is-r-and-rstudio&#34; id=&#34;toc-what-is-r-and-rstudio&#34;&gt;What is R and RStudio?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#r&#34; id=&#34;toc-r&#34;&gt;R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#rstudio&#34; id=&#34;toc-rstudio&#34;&gt;RStudio&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-to-install-r-and-rstudio&#34; id=&#34;toc-how-to-install-r-and-rstudio&#34;&gt;How to install R and RStudio?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#the-main-components-of-rstudio&#34; id=&#34;toc-the-main-components-of-rstudio&#34;&gt;The main components of RStudio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#examples-of-code&#34; id=&#34;toc-examples-of-code&#34;&gt;Examples of code&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#calculator&#34; id=&#34;toc-calculator&#34;&gt;Calculator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#comments&#34; id=&#34;toc-comments&#34;&gt;Comments&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#store-and-print-values&#34; id=&#34;toc-store-and-print-values&#34;&gt;Store and print values&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#vectors&#34; id=&#34;toc-vectors&#34;&gt;Vectors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#matrices&#34; id=&#34;toc-matrices&#34;&gt;Matrices&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#generate-random-values&#34; id=&#34;toc-generate-random-values&#34;&gt;Generate random values&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#plot&#34; id=&#34;toc-plot&#34;&gt;Plot&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/how-to-install-r-and-rstudio_files/0_vZhfBRnPyxoGbiQj.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that this article is inspired from the lecture notes of Prof. Johan Segers and my personal notes as teaching assistant for his course entitled “Multivariate statistical analysis” given at UCLouvain.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;what-is-r-and-rstudio&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What is R and RStudio?&lt;/h1&gt;
&lt;div id=&#34;r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;R&lt;/h2&gt;
&lt;p&gt;The statistical program &lt;strong&gt;R&lt;/strong&gt; is nothing more than a programming language, mainly used for data manipulation and to perform statistical analyses. At the time of writing, this language is (one of) the leading program in statistics, although not the only programming language used by statisticians.&lt;/p&gt;
&lt;p&gt;In order to use R, we need two things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a text editor in which to write our code&lt;/li&gt;
&lt;li&gt;a place to run this code&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RStudio&lt;/h2&gt;
&lt;p&gt;This is where RStudio comes handy.&lt;/p&gt;
&lt;p&gt;RStudio is an integrated development environment (IDE) for R. R and RStudio work together. R is a program that runs all your code, and RStudio is another program that allows you to control R in a more comfortable and friendly way. RStudio has the advantage of offering both a powerful text editor for writing your code and a place to run the code written in this editor.&lt;/p&gt;
&lt;p&gt;For these reasons, I highly recommend using RStudio instead of R. I use RStudio (and not R) on a daily basis and you will see that all &lt;a href=&#34;https://statsandr.com/blog/&#34;&gt;articles&lt;/a&gt; on this blog is written in RStudio.&lt;/p&gt;
&lt;p&gt;Note that RStudio requires the prior installation of the R software provided by CRAN in order to be able to function properly. Just installing RStudio on your personal computer is not enough. See the next section on how to install both.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;how-to-install-r-and-rstudio&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How to install R and RStudio?&lt;/h1&gt;
&lt;p&gt;You can download R at &lt;a href=&#34;https://cran.r-project.org/mirrors.html&#34; target=&#34;_blank&#34;&gt;https://cran.r-project.org/mirrors.html&lt;/a&gt;. Select the CRAN mirror site closest to your country. If there are more than one links for your country, simply select one:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/how-to-install-R-RStudio.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Select the CRAN mirror site closest to your country&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Select the CRAN mirror site closest to your country&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Then in the box labeled “Download and Install R” (located at the top), click on the link corresponding to your operating system (Windows, Mac or Linux):&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/how-to-install-R-RStudio_2.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Click on the link corresponding to your operating system&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Click on the link corresponding to your operating system&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Now that R is installed on your computer, you can download RStudio. You can download the free version of RStudio (which is totally enough for most users, including me!) on their &lt;a href=&#34;https://www.rstudio.com/products/rstudio/download/#download&#34; target=&#34;_blank&#34;&gt;website&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-main-components-of-rstudio&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;The main components of RStudio&lt;/h1&gt;
&lt;p&gt;Now that both programs are installed on your computer, let’s dive into the main components of RStudio.&lt;/p&gt;
&lt;p&gt;By default, the RStudio window has three panes:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The console (red pane)&lt;/li&gt;
&lt;li&gt;The environment (green pane)&lt;/li&gt;
&lt;li&gt;Files, plots, help, etc. (blue pane)&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/R%20Studio.png&#34; style=&#34;width:100.0%&#34; alt=&#34;RStudio window&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;RStudio window&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The console (red pane) is where you can execute your code (more information on the red and blue panes later). By default, the text editor does not open automatically. To open it, click on File &amp;gt; New File &amp;gt; R Script or click on the button representing a white sheet marked with a small green cross in the upper left corner, then on R Script:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/open_text_editor.png&#34; style=&#34;width:100.0%&#34; alt=&#34;New R script in RStudio&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;New R script in RStudio&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;A new pane (in orange below), also known as the text editor, opens in which you will be able to write your code. The code will be executed and the results displayed in the console (red pane).&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/text_editor.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Write and execute your code in RStudio&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Write and execute your code in RStudio&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Note that you can also write code in the console (red pane). However, I strongly recommend writing your code in the text editor (orange pane) because you can save the code written in the text editor (and thus execute it again later), while you cannot save the code written in the console.&lt;/p&gt;
&lt;p&gt;To execute code written in the text editor (orange pane), you have two options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Type your code and then press the “Run” button (see below) or use the keyboard shortcut CTRL + Enter (cmd + Enter on Mac). &lt;strong&gt;Only the chunk&lt;/strong&gt; of code where your cursor is located will then be executed.&lt;/li&gt;
&lt;li&gt;Type your code and select in the text editor the part you want to execute and then press the “Run” button or use the keyboard shortcut CTRL + Enter (cmd + Enter on Mac). All the &lt;strong&gt;selected&lt;/strong&gt; code will be executed&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/run.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Run code in RStudio&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Run code in RStudio&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;For example, try typing &lt;code&gt;1+1&lt;/code&gt; in the text editor and execute it by clicking on “Run” (or CTRL/cmd + Enter). You should see the result &lt;code&gt;2&lt;/code&gt; in the console, as shown in the screenshot below:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/example%20of%20code%20executed%20in%20RStudio.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Example of code executed in RStudio&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Example of code executed in RStudio&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The text editor and the console are the panes you will use most often. The two other panes (the blue and green panes introduced earlier) will however still be very useful when using RStudio.&lt;/p&gt;
&lt;p&gt;The environment (green pane) displays all values stored by RStudio. For example, if you type and execute the code &lt;code&gt;a = 1&lt;/code&gt;, RStudio will store the value &lt;code&gt;1&lt;/code&gt; for &lt;code&gt;a&lt;/code&gt;, as shown in the screenshot below:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/environment%20pane%20in%20RStudio2.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Environment pane in RStudio&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Environment pane in RStudio&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;This means that you can now perform any computations with &lt;code&gt;a&lt;/code&gt;, such that if you execute &lt;code&gt;a + 1&lt;/code&gt;, RStudio will render &lt;code&gt;2&lt;/code&gt; in the console. In this pane you can also see a tab with a history of the code executed and a button to import a dataset (more on &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;).&lt;/p&gt;
&lt;p&gt;The last pane (blue) is where you will find everything else such as your files, the plots, the packages, the help documentation, etc. I discuss about the Files tab in more detail &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;here&lt;/a&gt; so let’s discuss about the other tabs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Plot: where you will see the rendered plots. For instance, run &lt;code&gt;plot(1:10)&lt;/code&gt; and you should see it in this tab. If you plotted more than one plots, you can navigate between them by clicking on the arrows. You can open the plot in a new window by clicking on Zoom and export your plot by clicking on Export. Those buttons are located just under the Plot tab (see figure below)&lt;/li&gt;
&lt;li&gt;Packages: where you see all your installed packages. Only fundamental functionalities come with R. Everything else must be installed from packages. Remind that R is open source; everyone can write code and publish it as a package. You are then able to use this package (and all functions built inside this package) for free. Some packages are installed by default, all others must be installed by running &lt;code&gt;install.packages(&#34;name of the package&#34;)&lt;/code&gt; (do not forget &lt;code&gt;&#34;&#34;&lt;/code&gt; around the name of the package!). Once the package is installed, you must load the package and only after it has been loaded you can use all the functions it contains. To load a package, run &lt;code&gt;library(name of the package)&lt;/code&gt; (this time &lt;code&gt;&#34;&#34;&lt;/code&gt; around the name of the package are optional, but can still be used if you wish). You also have the possibility to install and load packages via the buttons under the Packages tab. For this, click on the button Install under Packages, type the name of the package you want to install and then click on Install. You will see that the code appears in the console. To load the package, find the package you want to load in the Packages window (you can use the search box), then click on the checkbox next to the name of the package. Again, the code is run in the console. See the figures below if needed. Note that you will need to install packages &lt;strong&gt;only once&lt;/strong&gt;,&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; but load packages &lt;strong&gt;each time&lt;/strong&gt; you open RStudio. Furthermore, note that an internet connection is required to install a package, while it is not required to load a package&lt;/li&gt;
&lt;li&gt;Help: documentation about all functions written for R. To access the help of a function, run &lt;code&gt;help(&#34;name of the function&#34;)&lt;/code&gt; or simply &lt;code&gt;?name of the function&lt;/code&gt;. For example, to see the help about the mean function, run &lt;code&gt;?mean&lt;/code&gt;. You can also press F1 while having your cursor on a function&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/plot-buttons-rstudio.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Plot buttons in RStudio&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Plot buttons in RStudio&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/install-packages-rstudio1.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Step 1: click on the Install button&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: click on the Install button&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/install-packages-rstudio2.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Step 2: type the name of the package and click on Install&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: type the name of the package and click on Install&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/install-packages-rstudio3.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Step 3: load your package by clicking on the box next to the package’s name&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: load your package by clicking on the box next to the package’s name&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;examples-of-code&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Examples of code&lt;/h1&gt;
&lt;p&gt;Now that you have installed R and RStudio and you know its main components, below are some examples of basic code.&lt;/p&gt;
&lt;p&gt;More advanced code and analyses are presented in &lt;a href=&#34;https://statsandr.com/tags/R/&#34;&gt;other articles about R&lt;/a&gt;, and in particular in this article about &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;data manipulation in R&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;calculator&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Calculator&lt;/h2&gt;
&lt;p&gt;Compute &lt;span class=&#34;math inline&#34;&gt;\(5*5\)&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;5 * 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 25&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Compute &lt;span class=&#34;math inline&#34;&gt;\(\frac{1}{\sqrt{50\pi}}\, e^{-\frac{(10 - 11)^2}{50}}\)&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;1 / sqrt(50 * pi) * exp(-(10 - 11)^2 / 50)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.07820854&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, some values like &lt;span class=&#34;math inline&#34;&gt;\(\pi\)&lt;/span&gt; are stored by default so you do not need to specify its value. Note that RStudio is case sensitive, but not space sensitive. This means that &lt;code&gt;pi&lt;/code&gt; is different than &lt;code&gt;Pi&lt;/code&gt; but &lt;code&gt;5*5&lt;/code&gt; gives the same result than &lt;code&gt;5 * 5&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;comments&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Comments&lt;/h2&gt;
&lt;p&gt;To add comments in your code, use &lt;code&gt;#&lt;/code&gt; before the code:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# A comment
# Another comment
1 + 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;store-and-print-values&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Store and print values&lt;/h2&gt;
&lt;p&gt;Note that in order to store a value inside an object, using &lt;code&gt;=&lt;/code&gt; or &lt;code&gt;&amp;lt;-&lt;/code&gt; is equivalent. I however recommend using &lt;code&gt;&amp;lt;-&lt;/code&gt; to follow the guidelines of R programming. You can name your objects (A and B in our case) as you like. However, it is recommended to use short and concise names (as you will most likely type them several times) and avoid special characters.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;A &amp;lt;- 5
B &amp;lt;- 6&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When storing values, RStudio does not display it on the console. To store a value AND print it in the console, use:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;(A &amp;lt;- 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 5&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;A &amp;lt;- 5
A&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 5&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;vectors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Vectors&lt;/h2&gt;
&lt;p&gt;It is also possible to store more than one value inside an object via the function &lt;code&gt;c()&lt;/code&gt; (c stands for combine).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;A &amp;lt;- c(1 / 2, -1, 0)
A&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  0.5 -1.0  0.0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;matrices&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Matrices&lt;/h2&gt;
&lt;p&gt;Or create a matrix via &lt;code&gt;matrix()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;my_mat &amp;lt;- matrix(c(-1, 2, 0, 3), ncol = 2, nrow = 2)
my_mat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2]
## [1,]   -1    0
## [2,]    2    3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can access the help of this function via &lt;code&gt;?matrix&lt;/code&gt; or &lt;code&gt;help(&#34;matrix&#34;)&lt;/code&gt;. Note that inside a function, you can have multiple arguments separated by a comma. Inside &lt;code&gt;matrix()&lt;/code&gt;, the first argument is the vector &lt;code&gt;c(-1, 2, 0, 3)&lt;/code&gt;, the second is &lt;code&gt;ncol = 2&lt;/code&gt; and the third is &lt;code&gt;nrow = 2&lt;/code&gt;. For all functions in RStudio, you can specify an argument by its order inside the function or by the name of the argument. If you specify the name of the argument, the order does not matter anymore, so &lt;code&gt;matrix(c(-1, 2, 0, 3), ncol = 2, nrow = 2)&lt;/code&gt; is equivalent to &lt;code&gt;matrix(c(-1, 2, 0, 3), nrow = 2, ncol = 2)&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;my_mat2 &amp;lt;- matrix(c(-1, 2, 0, 3), nrow = 2, ncol = 2)
my_mat2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2]
## [1,]   -1    0
## [2,]    2    3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;my_mat == my_mat2 # is my_mat equal to my_mat2?&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2]
## [1,] TRUE TRUE
## [2,] TRUE TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;generate-random-values&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Generate random values&lt;/h2&gt;
&lt;p&gt;To generate 10 values based on a &lt;a href=&#34;https://statsandr.com/blog/do-my-data-follow-a-normal-distribution-a-note-on-the-most-widely-used-distribution-and-how-to-test-for-normality-in-r/&#34;&gt;normal distribution&lt;/a&gt; with mean &lt;span class=&#34;math inline&#34;&gt;\(\mu = 400\)&lt;/span&gt; and standard deviation &lt;span class=&#34;math inline&#34;&gt;\(\sigma = 10\)&lt;/span&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;my_vec &amp;lt;- rnorm(10, mean = 400, sd = 10)
# Display only the first 5 values:
head(my_vec, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 413.7096 394.3530 403.6313 406.3286 404.0427&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Display only the last 5 values:
tail(my_vec, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 398.9388 415.1152 399.0534 420.1842 399.3729&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will have different values than mine due to the fact that they are randomly generated. If you want to make sure to have always the same random values, use &lt;code&gt;set.seed()&lt;/code&gt; (with any numeric inside the brackets). For instance, with the following code, you should have the exact same values, no matter where and when you run it:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;set.seed(42)
rnorm(3, mean = 10, sd = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12.741917  8.870604 10.726257&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Plot&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(my_vec,
  type = &amp;quot;l&amp;quot;, # &amp;quot;l&amp;quot; stands for line
  main = &amp;quot;Plot title&amp;quot;,
  ylab = &amp;quot;Y-axis label&amp;quot;,
  xlab = &amp;quot;X-axis label&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio_files/figure-html/unnamed-chunk-12-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&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 this article helped you to install R and RStudio.&lt;/p&gt;
&lt;p&gt;This is only a very limited introduction to the possibilities of RStudio. If you want to learn more, I recommend that you read other &lt;a href=&#34;https://statsandr.com/tags/R/&#34;&gt;articles related to R&lt;/a&gt;, starting with &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;how to import an Excel file&lt;/a&gt; or &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;how to manipulate a dataset in R&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;Actually you will need to reinstall your packages for each new R update. However, if you work on the same R version, you need to install your packages only once but load them everytime you open RStudio.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>