-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathAssociation-Mining-With-R.html
More file actions
375 lines (355 loc) · 107 KB
/
Copy pathAssociation-Mining-With-R.html
File metadata and controls
375 lines (355 loc) · 107 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<!DOCTYPE html>
<html lang="en">
<head>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag("consent","default",{ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied",wait_for_update:1500});</script>
<script defer src="/www/consent-banner.js?v=2"></script>
<title>Association Rule Mining in R - Complete Guide with Examples</title>
<meta charset="utf-8">
<meta name="Description" content="Learn association mining and market basket analysis in R with the Apriori algorithm. Step-by-step tutorial with practical examples and R code.">
<meta name="Keywords" content="R, Tutorial, Machine learning, Statistics, Data Mining, Analytics, Data science, Linear Regression, Logistic Regression, Time series, Forecasting">
<meta name="Distribution" content="Global">
<meta name="Author" content="Selva Prabhakaran">
<meta name="Robots" content="index, follow">
<!-- Open Graph -->
<meta property="og:title" content="Association Rule Mining in R - Complete Guide with Examples">
<meta property="og:description" content="Learn association mining and market basket analysis in R with the Apriori algorithm. Step-by-step tutorial with practical examples and R code.">
<meta property="og:type" content="article">
<meta property="og:url" content="https://r-statistics.co/Association-Mining-With-R.html">
<meta property="og:site_name" content="r-statistics.co">
<meta property="og:image" content="https://r-statistics.co/screenshots/iconb-64.png?v=2">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Association Rule Mining in R - Complete Guide with Examples">
<meta name="twitter:description" content="Learn association mining and market basket analysis in R with the Apriori algorithm. Step-by-step tutorial with practical examples and R code.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/screenshots/iconb-64.png?v=2" type="image/x-icon" />
<link rel="canonical" href="https://r-statistics.co/Association-Mining-With-R.html">
<link href="www/bootstrap.min.css" rel="stylesheet">
<link href="www/highlight.css" rel="stylesheet">
<link href="css/main.css?v=20" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter+Tight:wght@500;600;700&family=Inter:wght@400;450;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
<link href="/www/tutorial-jel.css?v=7" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Inconsolata:400,700'
rel='stylesheet' type='text/css'>
<!-- Color Script -->
<style type="text/css">
a {
color: #3675C5;
color: rgb(25, 145, 248);
color: #4582ec;
color: #3F73D8;
}
li {
line-height: 1.65;
}
/* reduce spacing around math formula*/
.MathJax_Display {
margin: 0em 0em;
}
</style>
<!-- Add Google search -->
<script language="Javascript" type="text/javascript">
function my_search_google()
{
var query = document.getElementById("my-google-search").value;
window.open("https://google.com/search?q=" + query
+ "%20site:" + "https://r-statistics.co");
}
</script>
<!-- JSON-LD Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": ["TechArticle", "LearningResource"],
"headline": "Association Rule Mining in R - Complete Guide with Examples",
"description": "Learn association mining and market basket analysis in R with the Apriori algorithm. Step-by-step tutorial with practical examples and R code.",
"author": {"@type": "Person", "name": "Selva Prabhakaran"},
"publisher": {"@type": "Organization", "name": "r-statistics.co"},
"url": "https://r-statistics.co/Association-Mining-With-R.html",
"datePublished": "2016-01-01",
"dateModified": "2026-03-29",
"inLanguage": "en",
"educationalLevel": "Intermediate",
"programmingLanguage": "R"
}
</script>
</head>
<body class="layout-v2" data-page="tutorial">
<div class="mobile-sidebar-overlay" id="mobile-sidebar"><div class="mobile-sidebar-panel"><button class="mobile-sidebar-close" id="mobile-sidebar-close">×</button><div class="mnav-section"><h6 class="mnav-title">Navigate</h6><a class="mnav-link" href="/roadmap/">Roadmap</a><a class="mnav-link" href="/tutorials/">Tutorials</a><a class="mnav-link" href="/exercises/">Exercises</a><a class="mnav-link" href="/tools/">Tools</a><a class="mnav-link mnav-cta" href="/pricing.html">Get certified</a></div><div id="mobile-sidebar-content"></div></div></div>
<div class="container">
<header class="site-masthead"><div class="site-masthead-inner">
<button id="mobile-menu-btn" class="masthead-menu-btn" aria-label="Menu">☰</button>
<a class="masthead-wordmark" href="/"><span class="masthead-mark">R</span><span class="masthead-name">r‑statistics<span class="masthead-tld">.co</span></span></a>
<nav class="masthead-nav"><a class="masthead-nav-link" href="/roadmap/">Roadmap</a><a class="masthead-nav-link" href="/tutorials/">Tutorials</a><a class="masthead-nav-link" href="/exercises/">Exercises</a><a class="masthead-nav-link" href="/tools/">Tools</a></nav>
<div class="masthead-tools"><form onsubmit="my_search_google(); return false;" class="masthead-search"><input type="text" id="my-google-search" placeholder="Search…" aria-label="Search"><span class="kbd-hint" aria-hidden="true">/</span></form>
<a class="masthead-cta" href="/pricing.html">Get certified</a>
<button id="dark-mode-toggle" class="masthead-icon-btn" aria-label="Toggle dark mode">☽</button>
<span class="auth-anon"><a href="/signin.html" class="masthead-auth-link">Sign in</a></span><span class="auth-user"></span>
</div></div></header>
<div class="row">
<div class="col-xs-12 col-sm-3" id="nav">
<div id="sidebar-nav"><div class="continue-chip" data-continue-chip><span class="chip-label">Continue reading</span><a href="#" data-continue-link></a></div><div class="sidebar-tabs" role="tablist"><button class="sidebar-tab active" data-tab="posts" type="button" role="tab" onclick="var n=this.dataset.tab;document.querySelectorAll('.sidebar-tab').forEach(function(x){x.classList.toggle('active',x.dataset.tab===n)});document.querySelectorAll('.sidebar-panel').forEach(function(p){p.classList.toggle('active',p.dataset.panel===n)});try{localStorage.setItem('rstat_sidebar_tab',n)}catch(e){}">Posts</button><button class="sidebar-tab" data-tab="tools" type="button" role="tab" onclick="var n=this.dataset.tab;document.querySelectorAll('.sidebar-tab').forEach(function(x){x.classList.toggle('active',x.dataset.tab===n)});document.querySelectorAll('.sidebar-panel').forEach(function(p){p.classList.toggle('active',p.dataset.panel===n)});try{localStorage.setItem('rstat_sidebar_tab',n)}catch(e){}">Tools</button></div><div class="sidebar-panel active" data-panel="posts"><ul class="sidebar-menu list-unstyled"><li class="sidebar-section expanded"><div class="sidebar-section-header"><span class="sidebar-chevron">▸</span><span class="sec-num">1.</span> <span class="sec-title-t">Learn R</span><span class="section-meta" data-section-meta></span></div><ul class="sidebar-section-items list-unstyled"><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec0sub1" data-collapsed="false"><span class="subsec-chevron">▼</span> Getting Started</li><li data-subkey="sec0sub1"><a href="/Is-R-Worth-Learning-in-2026.html"><span class="progress-dot"></span>Is R Worth Learning?</a></li><li data-subkey="sec0sub1"><a href="/Install-R-and-RStudio-2026.html"><span class="progress-dot"></span>Install R & RStudio</a></li><li data-subkey="sec0sub1"><a href="/RStudio-IDE-Tour.html"><span class="progress-dot"></span>RStudio IDE Tour</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec0sub2" data-collapsed="false"><span class="subsec-chevron">▼</span> R Fundamentals</li><li data-subkey="sec0sub2"><a href="/R-Syntax-101.html"><span class="progress-dot"></span>R Syntax 101</a></li><li data-subkey="sec0sub2"><a href="/R-Data-Types.html"><span class="progress-dot"></span>R Data Types</a></li><li data-subkey="sec0sub2"><a href="/R-Vectors.html"><span class="progress-dot"></span>R Vectors</a></li><li data-subkey="sec0sub2"><a href="/R-Matrices.html"><span class="progress-dot"></span>R Matrices</a></li><li data-subkey="sec0sub2"><a href="/R-Factors.html"><span class="progress-dot"></span>R Factors</a></li><li data-subkey="sec0sub2"><a href="/R-Data-Frames.html"><span class="progress-dot"></span>R Data Frames</a></li><li data-subkey="sec0sub2"><a href="/R-Lists.html"><span class="progress-dot"></span>R Lists</a></li><li data-subkey="sec0sub2"><a href="/R-Control-Flow.html"><span class="progress-dot"></span>R Control Flow</a></li><li data-subkey="sec0sub2"><a href="/R-Special-Values.html"><span class="progress-dot"></span>R Special Values</a></li><li data-subkey="sec0sub2"><a href="/R-Type-Coercion.html"><span class="progress-dot"></span>R Type Coercion</a></li><li data-subkey="sec0sub2"><a href="/R-Functions.html"><span class="progress-dot"></span>Writing R Functions</a></li><li data-subkey="sec0sub2" class="is-quiz"><a href="/R-Beginner-Exercises-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec0sub3" data-collapsed="false"><span class="subsec-chevron">▼</span> Working Effectively</li><li data-subkey="sec0sub3"><a href="/R-Subsetting.html"><span class="progress-dot"></span>R Subsetting</a></li><li data-subkey="sec0sub3"><a href="/Getting-Help-in-R.html"><span class="progress-dot"></span>Getting Help in R</a></li><li data-subkey="sec0sub3"><a href="/R-Project-Structure.html"><span class="progress-dot"></span>R Project Structure</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec0sub4" data-collapsed="false"><span class="subsec-chevron">▼</span> R Career & Resources</li><li data-subkey="sec0sub4"><a href="/R-vs-Python.html"><span class="progress-dot"></span>R vs Python</a></li><li data-subkey="sec0sub4"><a href="/How-to-Learn-R.html"><span class="progress-dot"></span>How to Learn R</a></li><li data-subkey="sec0sub4"><a href="/R-for-Excel-Users.html"><span class="progress-dot"></span>R for Excel Users</a></li><li data-subkey="sec0sub4"><a href="/R-Interview-Questions.html"><span class="progress-dot"></span>R Interview Questions</a></li><li data-subkey="sec0sub4" class="is-quiz"><a href="/R-Interview-Questions-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec0sub4"><a href="/R-Cheat-Sheet.html"><span class="progress-dot"></span>R Cheat Sheet</a></li></ul></li><li class="sidebar-section expanded"><div class="sidebar-section-header"><span class="sidebar-chevron">▸</span><span class="sec-num">2.</span> <span class="sec-title-t">Data Wrangling</span><span class="section-meta" data-section-meta></span></div><ul class="sidebar-section-items list-unstyled"><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec1sub1" data-collapsed="false"><span class="subsec-chevron">▼</span> Import & Setup</li><li data-subkey="sec1sub1"><a href="/Importing-Data-in-R.html"><span class="progress-dot"></span>Importing Data</a></li><li data-subkey="sec1sub1"><a href="/R-Pipe-Operator.html"><span class="progress-dot"></span>Pipe Operator</a></li><li data-subkey="sec1sub1"><a href="/Tidy-Data-in-R.html"><span class="progress-dot"></span>Tidy Data</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec1sub2" data-collapsed="false"><span class="subsec-chevron">▼</span> dplyr Essentials</li><li data-subkey="sec1sub2"><a href="/dplyr-filter-select.html"><span class="progress-dot"></span>dplyr filter & select</a></li><li data-subkey="sec1sub2"><a href="/dplyr-mutate-rename.html"><span class="progress-dot"></span>dplyr mutate & rename</a></li><li data-subkey="sec1sub2"><a href="/dplyr-group-by-summarise.html"><span class="progress-dot"></span>dplyr group_by & summarise</a></li><li data-subkey="sec1sub2"><a href="/dplyr-arrange-slice.html"><span class="progress-dot"></span>dplyr arrange & slice</a></li><li data-subkey="sec1sub2"><a href="/dplyr-across.html"><span class="progress-dot"></span>dplyr across()</a></li><li data-subkey="sec1sub2"><a href="/dplyr-case-when.html"><span class="progress-dot"></span>dplyr case_when()</a></li><li data-subkey="sec1sub2" class="is-quiz"><a href="/dplyr-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec1sub3" data-collapsed="false"><span class="subsec-chevron">▼</span> Join & Reshape</li><li data-subkey="sec1sub3"><a href="/R-Joins.html"><span class="progress-dot"></span>R Joins</a></li><li data-subkey="sec1sub3"><a href="/pivot_longer-pivot_wider-Reshape-Data-in-R.html"><span class="progress-dot"></span>pivot_longer & pivot_wider</a></li><li data-subkey="sec1sub3"><a href="/tidyr-separate-unite-Split-Combine-Columns-in-R.html"><span class="progress-dot"></span>separate() & unite()</a></li><li data-subkey="sec1sub3" class="is-quiz"><a href="/tidyr-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec1sub4" data-collapsed="false"><span class="subsec-chevron">▼</span> Clean & Quality</li><li data-subkey="sec1sub4"><a href="/Missing-Values-in-R-Detect-Count-Remove-Impute-NA.html"><span class="progress-dot"></span>Missing Values (NA)</a></li><li data-subkey="sec1sub4"><a href="/Data-Quality-Checking-in-R.html"><span class="progress-dot"></span>Data Quality Checking</a></li><li data-subkey="sec1sub4"><a href="/janitor-Package-in-R.html"><span class="progress-dot"></span>janitor Package</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec1sub5" data-collapsed="false"><span class="subsec-chevron">▼</span> Strings & Dates</li><li data-subkey="sec1sub5"><a href="/stringr-in-R.html"><span class="progress-dot"></span>stringr</a></li><li data-subkey="sec1sub5"><a href="/R-Regex-stringr-Pattern-Matching.html"><span class="progress-dot"></span>Regex Patterns</a></li><li data-subkey="sec1sub5"><a href="/lubridate-in-R.html"><span class="progress-dot"></span>lubridate</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec1sub6" data-collapsed="false"><span class="subsec-chevron">▼</span> Scale & Connect</li><li data-subkey="sec1sub6"><a href="/DBI-in-R.html"><span class="progress-dot"></span>DBI & Databases</a></li><li data-subkey="sec1sub6"><a href="/DuckDB-in-R.html"><span class="progress-dot"></span>DuckDB & duckplyr</a></li><li data-subkey="sec1sub6"><a href="/Web-Scraping-in-R-with-rvest.html"><span class="progress-dot"></span>Web Scraping (rvest)</a></li><li data-subkey="sec1sub6"><a href="/REST-APIs-in-R-with-httr2.html"><span class="progress-dot"></span>REST APIs (httr2)</a></li><li data-subkey="sec1sub6"><a href="/Data-Wrangling-dplyr-Course.html"><span class="progress-dot"></span>Data Wrangling with dplyr (Course)</a></li><li data-subkey="sec1sub6"><a href="/Join-Reshape-Course.html"><span class="progress-dot"></span>Join & Reshape (Course)</a></li><li data-subkey="sec1sub6"><a href="/data-table-Course.html"><span class="progress-dot"></span>data.table (Course)</a></li><li data-subkey="sec1sub6"><a href="/Report-Tables-Course.html"><span class="progress-dot"></span>Report-Ready Tables (Course)</a></li><li data-subkey="sec1sub6"><a href="/Communicate-Automate-Course.html"><span class="progress-dot"></span>Communicate & Automate (Course)</a></li></ul></li><li class="sidebar-section expanded"><div class="sidebar-section-header"><span class="sidebar-chevron">▸</span><span class="sec-num">3.</span> <span class="sec-title-t">Statistics</span><span class="section-meta" data-section-meta></span></div><ul class="sidebar-section-items list-unstyled"><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec2sub1" data-collapsed="false"><span class="subsec-chevron">▼</span> EDA & Data Quality</li><li data-subkey="sec2sub1"><a href="/Automated-EDA-in-R.html"><span class="progress-dot"></span>Automated EDA</a></li><li data-subkey="sec2sub1"><a href="/Missing-Data-Visualization-in-R-naniar.html"><span class="progress-dot"></span>Missing Data Viz (naniar)</a></li><li data-subkey="sec2sub1"><a href="/Outlier-Detection-in-R.html"><span class="progress-dot"></span>Outlier Detection</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec2sub2" data-collapsed="false"><span class="subsec-chevron">▼</span> Probability</li><li data-subkey="sec2sub2"><a href="/Sample-Spaces-Events-and-Probability-Axioms-in-R-With-Monte-Carlo-Proof.html"><span class="progress-dot"></span>Probability Axioms</a></li><li data-subkey="sec2sub2"><a href="/Conditional-Probability-in-R.html"><span class="progress-dot"></span>Conditional Probability</a></li><li data-subkey="sec2sub2"><a href="/Random-Variables-in-R.html"><span class="progress-dot"></span>Random Variables</a></li><li data-subkey="sec2sub2"><a href="/Binomial-and-Poisson-Distributions-in-R.html"><span class="progress-dot"></span>Binomial vs Poisson</a></li><li data-subkey="sec2sub2"><a href="/Normal-t-F-and-Chi-Squared-Distributions-in-R.html"><span class="progress-dot"></span>Normal, t, F, Chi-Squared</a></li><li data-subkey="sec2sub2"><a href="/Central-Limit-Theorem-in-R.html"><span class="progress-dot"></span>Central Limit Theorem</a></li><li data-subkey="sec2sub2"><a href="/Sampling-Distributions-in-R.html"><span class="progress-dot"></span>Sampling Distributions</a></li><li data-subkey="sec2sub2"><a href="/Law-of-Large-Numbers-vs-CLT-in-R.html"><span class="progress-dot"></span>LLN vs CLT</a></li><li data-subkey="sec2sub2"><a href="/What-Is-Probability-Simulation-First-Intuition-in-R-Before-the-Formulas.html"><span class="progress-dot"></span>Probability (Simulation-First)</a></li><li data-subkey="sec2sub2"><a href="/Expected-Value-and-Variance-in-R.html"><span class="progress-dot"></span>Expected Value and Variance</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec2sub3" data-collapsed="false"><span class="subsec-chevron">▼</span> Inference & Estimation</li><li data-subkey="sec2sub3"><a href="/Maximum-Likelihood-Estimation-in-R.html"><span class="progress-dot"></span>Maximum Likelihood Estimation</a></li><li data-subkey="sec2sub3"><a href="/Hypothesis-Testing-in-R.html"><span class="progress-dot"></span>Hypothesis Testing</a></li><li data-subkey="sec2sub3"><a href="/Sample-Size-Planning-in-R.html"><span class="progress-dot"></span>Sample Size Planning</a></li><li data-subkey="sec2sub3"><a href="/Which-Statistical-Test-in-R.html"><span class="progress-dot"></span>Choosing the Right Test</a></li><li data-subkey="sec2sub3"><a href="/Statistical-Tests-in-R.html"><span class="progress-dot"></span>Statistical Tests</a></li><li data-subkey="sec2sub3"><a href="/Measures-of-Association-in-R.html"><span class="progress-dot"></span>Measures of Association</a></li><li data-subkey="sec2sub3"><a href="/Point-Estimation-in-R.html"><span class="progress-dot"></span>Point Estimation</a></li><li data-subkey="sec2sub3"><a href="/Confidence-Intervals-in-R.html"><span class="progress-dot"></span>Confidence Intervals</a></li><li data-subkey="sec2sub3"><a href="/Type-I-and-Type-II-Errors-in-R.html"><span class="progress-dot"></span>Type I and II Errors</a></li><li data-subkey="sec2sub3"><a href="/Statistical-Power-Analysis-in-R.html"><span class="progress-dot"></span>Power Analysis</a></li><li data-subkey="sec2sub3"><a href="/Effect-Size-in-R.html"><span class="progress-dot"></span>Effect Size</a></li><li data-subkey="sec2sub3"><a href="/t-Tests-in-R.html"><span class="progress-dot"></span>t-Tests</a></li><li data-subkey="sec2sub3"><a href="/Proportion-Tests-in-R.html"><span class="progress-dot"></span>Proportion Tests</a></li><li data-subkey="sec2sub3"><a href="/Normality-and-Variance-Tests-in-R.html"><span class="progress-dot"></span>Normality & Variance Tests</a></li><li data-subkey="sec2sub3"><a href="/Chi-Square-Tests-in-R.html"><span class="progress-dot"></span>Chi-Square Tests</a></li><li data-subkey="sec2sub3"><a href="/Wilcoxon-Mann-Whitney-and-Kruskal-Wallis-in-R.html"><span class="progress-dot"></span>Wilcoxon, Mann-Whitney & Kruskal-Wallis</a></li><li data-subkey="sec2sub3"><a href="/Multiple-Comparisons-in-R.html"><span class="progress-dot"></span>Multiple Testing Correction</a></li><li data-subkey="sec2sub3" class="is-quiz"><a href="/Hypothesis-Testing-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec2sub4" data-collapsed="false"><span class="subsec-chevron">▼</span> Regression</li><li data-subkey="sec2sub4"><a href="/Linear-Regression.html"><span class="progress-dot"></span>Linear Regression</a></li><li data-subkey="sec2sub4"><a href="/Logistic-Regression-With-R.html"><span class="progress-dot"></span>Logistic Regression</a></li><li data-subkey="sec2sub4"><a href="/Variable-Selection-and-Importance-With-R.html"><span class="progress-dot"></span>Feature Selection</a></li><li data-subkey="sec2sub4"><a href="/Model-Selection-in-R.html"><span class="progress-dot"></span>Model Selection</a></li><li data-subkey="sec2sub4"><a href="/Missing-Value-Treatment-With-R.html"><span class="progress-dot"></span>Missing Value Treatment</a></li><li data-subkey="sec2sub4"><a href="/Outlier-Treatment-With-R.html"><span class="progress-dot"></span>Outlier Analysis</a></li><li data-subkey="sec2sub4"><a href="/adv-regression-models.html"><span class="progress-dot"></span>Advanced Regression Models</a></li><li data-subkey="sec2sub4" class="is-quiz"><a href="/Linear-Regression-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec2sub5" data-collapsed="false"><span class="subsec-chevron">▼</span> Reporting</li><li data-subkey="sec2sub5"><a href="/Statistical-Consulting-in-R.html"><span class="progress-dot"></span>Statistical Consulting</a></li><li data-subkey="sec2sub5"><a href="/Statistical-Report-Writing-in-R.html"><span class="progress-dot"></span>Statistical Report Writing</a></li><li data-subkey="sec2sub5"><a href="/Bootstrap-Confidence-Intervals-in-R.html"><span class="progress-dot"></span>Bootstrap Confidence Intervals</a></li><li data-subkey="sec2sub5"><a href="/Reporting-Statistics-in-R.html"><span class="progress-dot"></span>Reporting Statistics</a></li><li data-subkey="sec2sub5"><a href="/Correlation-in-R.html"><span class="progress-dot"></span>Correlation (Pearson, Spearman, Kendall)</a></li><li data-subkey="sec2sub5"><a href="/Linear-Regression-Assumptions-in-R.html"><span class="progress-dot"></span>Linear Regression Assumptions</a></li><li data-subkey="sec2sub5"><a href="/Dummy-Variables-in-R.html"><span class="progress-dot"></span>Dummy Variables in R</a></li><li data-subkey="sec2sub5"><a href="/Interaction-Effects-in-R.html"><span class="progress-dot"></span>Interaction Effects</a></li><li data-subkey="sec2sub5"><a href="/Regression-Diagnostics-in-R.html"><span class="progress-dot"></span>Regression Diagnostics</a></li><li data-subkey="sec2sub5"><a href="/Logistic-Regression-in-R.html"><span class="progress-dot"></span>Logistic Regression (glm + ROC)</a></li><li data-subkey="sec2sub5"><a href="/Variable-Selection-in-R.html"><span class="progress-dot"></span>Variable Selection</a></li><li data-subkey="sec2sub5"><a href="/Poisson-Regression-in-R.html"><span class="progress-dot"></span>Poisson Regression</a></li><li data-subkey="sec2sub5"><a href="/Ridge-and-Lasso-Regression-in-R.html"><span class="progress-dot"></span>Ridge & Lasso Regression</a></li><li data-subkey="sec2sub5"><a href="/Polynomial-and-Spline-Regression-in-R.html"><span class="progress-dot"></span>Polynomial & Splines</a></li><li data-subkey="sec2sub5"><a href="/Regression-Tables-in-R.html"><span class="progress-dot"></span>Regression Tables (3 packages)</a></li><li data-subkey="sec2sub5"><a href="/One-Way-ANOVA-in-R.html"><span class="progress-dot"></span>One-Way ANOVA</a></li><li data-subkey="sec2sub5"><a href="/Post-Hoc-Tests-After-ANOVA.html"><span class="progress-dot"></span>Post-Hoc Tests After ANOVA</a></li><li data-subkey="sec2sub5"><a href="/Two-Way-ANOVA-in-R.html"><span class="progress-dot"></span>Two-Way ANOVA</a></li><li data-subkey="sec2sub5"><a href="/Repeated-Measures-ANOVA-in-R.html"><span class="progress-dot"></span>Repeated Measures ANOVA</a></li><li data-subkey="sec2sub5"><a href="/ANCOVA-in-R.html"><span class="progress-dot"></span>ANCOVA</a></li><li data-subkey="sec2sub5"><a href="/Experimental-Design-Principles-in-R.html"><span class="progress-dot"></span>Experimental Design in R</a></li><li data-subkey="sec2sub5"><a href="/Factorial-Experiments-in-R.html"><span class="progress-dot"></span>Factorial Designs (2^k)</a></li><li data-subkey="sec2sub5"><a href="/AB-Testing-in-R.html"><span class="progress-dot"></span>A/B Testing</a></li><li data-subkey="sec2sub5"><a href="/MANOVA-in-R.html"><span class="progress-dot"></span>MANOVA</a></li><li data-subkey="sec2sub5"><a href="/Mixed-ANOVA-in-R.html"><span class="progress-dot"></span>Mixed ANOVA</a></li><li data-subkey="sec2sub5"><a href="/Multivariate-Statistics-in-R.html"><span class="progress-dot"></span>Multivariate Distances & Hotelling's T²</a></li><li data-subkey="sec2sub5"><a href="/PCA-in-R.html"><span class="progress-dot"></span>PCA with prcomp()</a></li><li data-subkey="sec2sub5"><a href="/Interpreting-PCA-Results-in-R.html"><span class="progress-dot"></span>Interpreting PCA Output</a></li><li data-subkey="sec2sub5"><a href="/Exploratory-Factor-Analysis-in-R.html"><span class="progress-dot"></span>Exploratory Factor Analysis</a></li><li data-subkey="sec2sub5"><a href="/CFA-and-Structural-Equation-Modeling-in-R.html"><span class="progress-dot"></span>SEM and CFA (lavaan)</a></li><li data-subkey="sec2sub5"><a href="/Linear-Discriminant-Analysis-in-R.html"><span class="progress-dot"></span>LDA (Linear Discriminant Analysis)</a></li><li data-subkey="sec2sub5"><a href="/Cluster-Analysis-in-R.html"><span class="progress-dot"></span>Clustering (k-Means / HC / DBSCAN)</a></li><li data-subkey="sec2sub5"><a href="/Correspondence-Analysis-in-R.html"><span class="progress-dot"></span>Correspondence Analysis</a></li><li data-subkey="sec2sub5"><a href="/t-SNE-and-UMAP-in-R.html"><span class="progress-dot"></span>t-SNE and UMAP</a></li><li data-subkey="sec2sub5"><a href="/Simple-Linear-Regression-in-R.html"><span class="progress-dot"></span>Simple Linear Regression</a></li><li data-subkey="sec2sub5"><a href="/Multiple-Regression-in-R.html"><span class="progress-dot"></span>Multiple Regression</a></li><li data-subkey="sec2sub5"><a href="/Robust-Regression-in-R.html"><span class="progress-dot"></span>Robust Regression (rlm)</a></li><li data-subkey="sec2sub5"><a href="/factoextra-and-FactoMineR.html"><span class="progress-dot"></span>factoextra (PCA + Clusters)</a></li><li data-subkey="sec2sub5"><a href="/Categorical-Data-in-R.html"><span class="progress-dot"></span>Categorical Data (Tables & Mosaic)</a></li><li data-subkey="sec2sub5"><a href="/Chi-Square-Test-of-Independence-in-R.html"><span class="progress-dot"></span>Chi-Square Test of Independence</a></li><li data-subkey="sec2sub5"><a href="/Chi-Square-Goodness-of-Fit-Test-in-R.html"><span class="progress-dot"></span>Chi-Square Goodness-of-Fit</a></li><li data-subkey="sec2sub5"><a href="/Fishers-Exact-Test-in-R.html"><span class="progress-dot"></span>Fisher's Exact Test</a></li><li data-subkey="sec2sub5"><a href="/Odds-Ratios-and-Relative-Risk-in-R.html"><span class="progress-dot"></span>Odds Ratios & Relative Risk</a></li><li data-subkey="sec2sub5"><a href="/Logistic-Regression-in-R-2.html"><span class="progress-dot"></span>Logistic Regression (Diagnostics)</a></li><li data-subkey="sec2sub5"><a href="/Poisson-and-Negative-Binomial-Regression.html"><span class="progress-dot"></span>Poisson & Negative Binomial Regression</a></li><li data-subkey="sec2sub5"><a href="/Multinomial-and-Ordinal-Logistic-Regression-in-R.html"><span class="progress-dot"></span>Multinomial & Ordinal Logistic Regression</a></li><li data-subkey="sec2sub5"><a href="/When-to-Use-Nonparametric-Tests-in-R.html"><span class="progress-dot"></span>When to Use Nonparametric Tests</a></li><li data-subkey="sec2sub5"><a href="/Wilcoxon-Signed-Rank-Test-in-R.html"><span class="progress-dot"></span>Wilcoxon Signed-Rank Test</a></li><li data-subkey="sec2sub5"><a href="/Mann-Whitney-U-Test-in-R.html"><span class="progress-dot"></span>Mann-Whitney U Test</a></li><li data-subkey="sec2sub5"><a href="/Kruskal-Wallis-Test-in-R-2.html"><span class="progress-dot"></span>Kruskal-Wallis Test</a></li><li data-subkey="sec2sub5"><a href="/Friedman-Test-in-R.html"><span class="progress-dot"></span>Friedman Test</a></li><li data-subkey="sec2sub5"><a href="/Spearman-and-Kendall-Correlation-in-R.html"><span class="progress-dot"></span>Spearman & Kendall Correlation</a></li><li data-subkey="sec2sub5"><a href="/Bootstrap-in-R.html"><span class="progress-dot"></span>Bootstrap (boot package)</a></li><li data-subkey="sec2sub5"><a href="/Quantile-Regression-in-R-2.html"><span class="progress-dot"></span>Quantile Regression</a></li><li data-subkey="sec2sub5"><a href="/Matrix-Operations-in-R.html"><span class="progress-dot"></span>Matrix Operations in R</a></li><li data-subkey="sec2sub5"><a href="/Solving-Linear-Systems-in-R.html"><span class="progress-dot"></span>Solving Linear Systems in R</a></li><li data-subkey="sec2sub5"><a href="/Eigenvalues-and-Eigenvectors-in-R.html"><span class="progress-dot"></span>Eigenvalues & Eigenvectors in R</a></li><li data-subkey="sec2sub5"><a href="/Singular-Value-Decomposition-in-R.html"><span class="progress-dot"></span>Singular Value Decomposition in R</a></li><li data-subkey="sec2sub5"><a href="/Projections-and-the-Hat-Matrix-in-R.html"><span class="progress-dot"></span>Projections & the Hat Matrix</a></li><li data-subkey="sec2sub5"><a href="/QR-Decomposition-in-R.html"><span class="progress-dot"></span>QR Decomposition in R</a></li><li data-subkey="sec2sub5"><a href="/Quadratic-Forms-in-R.html"><span class="progress-dot"></span>Quadratic Forms</a></li><li data-subkey="sec2sub5"><a href="/Matrix-Derivatives-and-the-Hessian-in-R.html"><span class="progress-dot"></span>Matrix Derivatives & Hessian</a></li><li data-subkey="sec2sub5"><a href="/Exponential-Family-Distributions-in-R.html"><span class="progress-dot"></span>Exponential Family Distributions</a></li><li data-subkey="sec2sub5"><a href="/Sufficient-Statistics-in-R.html"><span class="progress-dot"></span>Sufficient Statistics</a></li><li data-subkey="sec2sub5"><a href="/Complete-and-Ancillary-Statistics-in-R.html"><span class="progress-dot"></span>Complete & Ancillary Statistics</a></li><li data-subkey="sec2sub5"><a href="/UMVUE-in-R-2.html"><span class="progress-dot"></span>UMVUE (Rao-Blackwell & Lehmann-Scheffé)</a></li><li data-subkey="sec2sub5"><a href="/Cramer-Rao-Lower-Bound-in-R-2.html"><span class="progress-dot"></span>Cramér-Rao Lower Bound</a></li><li data-subkey="sec2sub5"><a href="/Asymptotic-Theory-in-R-2.html"><span class="progress-dot"></span>Asymptotic Theory</a></li><li data-subkey="sec2sub5"><a href="/Neyman-Pearson-Lemma-in-R-2.html"><span class="progress-dot"></span>Neyman-Pearson Lemma</a></li><li data-subkey="sec2sub5"><a href="/Likelihood-Ratio-Tests-and-Pivotal-Methods.html"><span class="progress-dot"></span>Likelihood Ratio & Pivotal Methods</a></li><li data-subkey="sec2sub5"><a href="/Decision-Theory-in-R.html"><span class="progress-dot"></span>Decision Theory</a></li><li data-subkey="sec2sub5"><a href="/Asymptotic-Relative-Efficiency-in-R.html"><span class="progress-dot"></span>Asymptotic Relative Efficiency</a></li><li data-subkey="sec2sub5"><a href="/Bayes-Theorem-in-R.html"><span class="progress-dot"></span>Bayes' Theorem</a></li><li data-subkey="sec2sub5"><a href="/Bayesian-Statistics-in-R.html"><span class="progress-dot"></span>Bayesian Statistics</a></li><li data-subkey="sec2sub5"><a href="/Conjugate-Priors-in-R.html"><span class="progress-dot"></span>Conjugate Priors</a></li><li data-subkey="sec2sub5"><a href="/Grid-Approximation-in-R.html"><span class="progress-dot"></span>Grid Approximation</a></li><li data-subkey="sec2sub5"><a href="/MCMC-in-R.html"><span class="progress-dot"></span>MCMC in R</a></li><li data-subkey="sec2sub5"><a href="/Gibbs-Sampling-in-R.html"><span class="progress-dot"></span>Gibbs Sampling</a></li><li data-subkey="sec2sub5"><a href="/Hamiltonian-Monte-Carlo-in-R.html"><span class="progress-dot"></span>Hamiltonian Monte Carlo</a></li><li data-subkey="sec2sub5"><a href="/Stan-in-R.html"><span class="progress-dot"></span>Stan</a></li><li data-subkey="sec2sub5"><a href="/brms-in-R.html"><span class="progress-dot"></span>brms</a></li><li data-subkey="sec2sub5"><a href="/Choosing-Priors-in-R.html"><span class="progress-dot"></span>Choosing Priors</a></li><li data-subkey="sec2sub5"><a href="/Prior-Predictive-Checks-in-R.html"><span class="progress-dot"></span>Prior Predictive Checks</a></li><li data-subkey="sec2sub5"><a href="/Compare-Bayesian-Models-in-R.html"><span class="progress-dot"></span>Compare Bayesian Models</a></li><li data-subkey="sec2sub5"><a href="/Posterior-Predictive-Checks-in-R.html"><span class="progress-dot"></span>Posterior Predictive Checks</a></li><li data-subkey="sec2sub5"><a href="/Bayesian-Linear-Regression-in-R.html"><span class="progress-dot"></span>Bayesian Linear Regression</a></li><li data-subkey="sec2sub5"><a href="/Bayesian-Logistic-Regression-in-R.html"><span class="progress-dot"></span>Bayesian Logistic Regression</a></li><li data-subkey="sec2sub5"><a href="/Bayesian-Hierarchical-Models-in-R.html"><span class="progress-dot"></span>Bayesian Hierarchical Models</a></li><li data-subkey="sec2sub5"><a href="/Multilevel-Models-in-R.html"><span class="progress-dot"></span>Multilevel Models</a></li><li data-subkey="sec2sub5"><a href="/Bayesian-ANOVA-in-R.html"><span class="progress-dot"></span>Bayesian ANOVA</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec2sub6" data-collapsed="false"><span class="subsec-chevron">▼</span> Machine Learning</li><li data-subkey="sec2sub6"><a href="/Random-Forest-Course.html"><span class="progress-dot"></span>Random Forests (Course)</a></li><li data-subkey="sec2sub6"><a href="/R-Gradient-Boosting-Course.html"><span class="progress-dot"></span>Gradient Boosting (Course)</a></li><li data-subkey="sec2sub6"><a href="/R-tidymodels-Course.html"><span class="progress-dot"></span>tidymodels (Course)</a></li><li data-subkey="sec2sub6" class="is-quiz"><a href="/Machine-Learning-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec2sub6"><a href="/T-Test-Course.html"><span class="progress-dot"></span>The t-test (Lesson)</a></li></ul></li><li class="sidebar-section"><div class="sidebar-section-header"><span class="sidebar-chevron">▸</span><span class="sec-num">4.</span> <span class="sec-title-t">Visualization</span><span class="section-meta" data-section-meta></span></div><ul class="sidebar-section-items list-unstyled"><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec3sub1" data-collapsed="false"><span class="subsec-chevron">▼</span> ggplot2 Foundations</li><li data-subkey="sec3sub1"><a href="/ggplot2-Grammar-of-Graphics.html"><span class="progress-dot"></span>Grammar of Graphics</a></li><li data-subkey="sec3sub1"><a href="/ggplot2-Getting-Started.html"><span class="progress-dot"></span>ggplot2 Getting Started</a></li><li data-subkey="sec3sub1"><a href="/ggplot2-Aesthetics-aes-Map-Data.html"><span class="progress-dot"></span>ggplot2 Aesthetics (aes)</a></li><li data-subkey="sec3sub1"><a href="/ggplot2-Colours.html"><span class="progress-dot"></span>ggplot2 Colours</a></li><li data-subkey="sec3sub1"><a href="/ggplot2-Scales.html"><span class="progress-dot"></span>ggplot2 Scales</a></li><li data-subkey="sec3sub1"><a href="/ggplot2-Themes-in-R.html"><span class="progress-dot"></span>ggplot2 Themes</a></li><li data-subkey="sec3sub1"><a href="/ggplot2-Labels-and-Annotations.html"><span class="progress-dot"></span>Labels & Annotations</a></li><li data-subkey="sec3sub1"><a href="/ggplot2-Facets.html"><span class="progress-dot"></span>ggplot2 Facets</a></li><li data-subkey="sec3sub1" class="is-quiz"><a href="/ggplot2-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec3sub2" data-collapsed="false"><span class="subsec-chevron">▼</span> Core Charts</li><li data-subkey="sec3sub2"><a href="/ggplot2-Scatter-Plots.html"><span class="progress-dot"></span>Scatter Plots</a></li><li data-subkey="sec3sub2"><a href="/ggplot2-Line-Charts.html"><span class="progress-dot"></span>Line Charts</a></li><li data-subkey="sec3sub2"><a href="/ggplot2-Bar-Charts.html"><span class="progress-dot"></span>Bar Charts</a></li><li data-subkey="sec3sub2"><a href="/ggplot2-Distribution-Charts.html"><span class="progress-dot"></span>Distribution Charts</a></li><li data-subkey="sec3sub2"><a href="/Error-Bars-in-R.html"><span class="progress-dot"></span>Error Bars</a></li><li data-subkey="sec3sub2"><a href="/geom_smooth-in-R.html"><span class="progress-dot"></span>geom_smooth()</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec3sub3" data-collapsed="false"><span class="subsec-chevron">▼</span> Distributions & Groups</li><li data-subkey="sec3sub3"><a href="/Violin-Plot-in-R.html"><span class="progress-dot"></span>Violin Plot</a></li><li data-subkey="sec3sub3"><a href="/Ridgeline-Plot-in-R.html"><span class="progress-dot"></span>Ridgeline Plot</a></li><li data-subkey="sec3sub3"><a href="/Lollipop-Chart-in-R.html"><span class="progress-dot"></span>Lollipop Chart</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec3sub4" data-collapsed="false"><span class="subsec-chevron">▼</span> Relationships</li><li data-subkey="sec3sub4"><a href="/Bubble-Chart-in-R.html"><span class="progress-dot"></span>Bubble Chart</a></li><li data-subkey="sec3sub4"><a href="/Heatmap-in-R.html"><span class="progress-dot"></span>Heatmap in R</a></li><li data-subkey="sec3sub4"><a href="/Correlation-Matrix-Plot-in-R.html"><span class="progress-dot"></span>Correlation Matrix</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec3sub5" data-collapsed="false"><span class="subsec-chevron">▼</span> Advanced Charts</li><li data-subkey="sec3sub5"><a href="/Pie-Donut-Chart-in-R.html"><span class="progress-dot"></span>Pie & Donut Chart</a></li><li data-subkey="sec3sub5"><a href="/Treemap-in-R.html"><span class="progress-dot"></span>Treemap</a></li><li data-subkey="sec3sub5"><a href="/Waffle-Chart-in-R.html"><span class="progress-dot"></span>Waffle Chart</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec3sub6" data-collapsed="false"><span class="subsec-chevron">▼</span> Exploratory Analysis</li><li data-subkey="sec3sub6"><a href="/Exploratory-Data-Analysis-in-R.html"><span class="progress-dot"></span>EDA (7-Step Framework)</a></li><li data-subkey="sec3sub6"><a href="/Univariate-EDA-in-R.html"><span class="progress-dot"></span>Univariate EDA</a></li><li data-subkey="sec3sub6"><a href="/Bivariate-EDA-in-R.html"><span class="progress-dot"></span>Bivariate EDA</a></li><li data-subkey="sec3sub6"><a href="/Descriptive-Statistics-in-R.html"><span class="progress-dot"></span>Descriptive Statistics</a></li><li data-subkey="sec3sub6"><a href="/Correlation-Analysis-in-R.html"><span class="progress-dot"></span>Correlation Analysis</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec3sub7" data-collapsed="false"><span class="subsec-chevron">▼</span> Interactive & Maps</li><li data-subkey="sec3sub7"><a href="/Combining-ggplot2-with-plotly.html"><span class="progress-dot"></span>ggplot2 + plotly Interactive</a></li><li data-subkey="sec3sub7"><a href="/Interactive-Maps-in-R-with-leaflet.html"><span class="progress-dot"></span>Leaflet Interactive Maps</a></li><li data-subkey="sec3sub7"><a href="/Spatial-Data-in-R-with-sf.html"><span class="progress-dot"></span>Spatial Data (sf)</a></li><li data-subkey="sec3sub7"><a href="/Choropleth-Maps-in-R.html"><span class="progress-dot"></span>Choropleth Maps (sf)</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec3sub8" data-collapsed="false"><span class="subsec-chevron">▼</span> Customization & Reference</li><li data-subkey="sec3sub8"><a href="/ggplot2-Legends-in-R.html"><span class="progress-dot"></span>ggplot2 Legends</a></li><li data-subkey="sec3sub8"><a href="/ggplot2-Secondary-Axis.html"><span class="progress-dot"></span>Secondary Axis</a></li><li data-subkey="sec3sub8"><a href="/ggplot2-Log-Scale.html"><span class="progress-dot"></span>Log Scale</a></li><li data-subkey="sec3sub8"><a href="/patchwork-Package.html"><span class="progress-dot"></span>patchwork (Combine Plots)</a></li><li data-subkey="sec3sub8"><a href="/Publication-Quality-Figures-in-R.html"><span class="progress-dot"></span>Publication-Ready Figures</a></li><li data-subkey="sec3sub8"><a href="/ggplot2-cheatsheet.html"><span class="progress-dot"></span>ggplot2 Quickref</a></li><li data-subkey="sec3sub8"><a href="/Advanced-ggplot2-Course.html"><span class="progress-dot"></span>Advanced ggplot2 (Course)</a></li><li data-subkey="sec3sub8"><a href="/ggplot2-Course.html"><span class="progress-dot"></span>ggplot2 (Course)</a></li><li data-subkey="sec3sub8"><a href="/Dashboards-Course.html"><span class="progress-dot"></span>Interactive Dashboards (Course)</a></li></ul></li><li class="sidebar-section"><div class="sidebar-section-header"><span class="sidebar-chevron">▸</span><span class="sec-num">5.</span> <span class="sec-title-t">Time Series</span><span class="section-meta" data-section-meta></span></div><ul class="sidebar-section-items list-unstyled"><li data-subkey="sec4sub0"><a href="/Time-Series-Analysis-With-R.html"><span class="progress-dot"></span>Time Series Analysis</a></li><li data-subkey="sec4sub0"><a href="/Time-Series-Forecasting-With-R.html"><span class="progress-dot"></span>Time Series Forecasting</a></li><li data-subkey="sec4sub0"><a href="/Time-Series-Forecasting-With-R-part2.html"><span class="progress-dot"></span>More Time Series Forecasting</a></li><li data-subkey="sec4sub0" class="is-quiz"><a href="/Time-Series-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li></ul></li><li class="sidebar-section"><div class="sidebar-section-header"><span class="sidebar-chevron">▸</span><span class="sec-num">6.</span> <span class="sec-title-t">Advanced R</span><span class="section-meta" data-section-meta></span></div><ul class="sidebar-section-items list-unstyled"><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec5sub1" data-collapsed="false"><span class="subsec-chevron">▼</span> Functional Programming</li><li data-subkey="sec5sub1"><a href="/Functional-Programming-in-R.html"><span class="progress-dot"></span>Functional Programming</a></li><li data-subkey="sec5sub1" class="is-quiz"><a href="/R-Functional-Programming-Exercises-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec5sub1"><a href="/purrr-map-Variants.html"><span class="progress-dot"></span>purrr map() Variants</a></li><li data-subkey="sec5sub1"><a href="/R-Anonymous-Functions.html"><span class="progress-dot"></span>R Anonymous Functions</a></li><li data-subkey="sec5sub1"><a href="/R-Function-Factories.html"><span class="progress-dot"></span>R Function Factories</a></li><li data-subkey="sec5sub1"><a href="/R-Function-Operators.html"><span class="progress-dot"></span>R Function Operators</a></li><li data-subkey="sec5sub1"><a href="/Reduce-Filter-Map-in-R.html"><span class="progress-dot"></span>Reduce, Filter, Map</a></li><li data-subkey="sec5sub1"><a href="/Memoization-in-R.html"><span class="progress-dot"></span>Memoization in R</a></li><li data-subkey="sec5sub1"><a href="/Writing-Composable-R-Code.html"><span class="progress-dot"></span>Composable R Code</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec5sub2" data-collapsed="false"><span class="subsec-chevron">▼</span> OOP in R</li><li data-subkey="sec5sub2"><a href="/OOP-in-R.html"><span class="progress-dot"></span>OOP in R: S3/S4/R6</a></li><li data-subkey="sec5sub2"><a href="/S3-Classes-in-R.html"><span class="progress-dot"></span>S3 Classes</a></li><li data-subkey="sec5sub2"><a href="/S3-Method-Dispatch-in-R.html"><span class="progress-dot"></span>S3 Method Dispatch</a></li><li data-subkey="sec5sub2"><a href="/S4-Classes-in-R.html"><span class="progress-dot"></span>S4 Classes</a></li><li data-subkey="sec5sub2"><a href="/S4-Methods-in-R.html"><span class="progress-dot"></span>S4 Methods & Dispatch</a></li><li data-subkey="sec5sub2"><a href="/R6-Classes-in-R.html"><span class="progress-dot"></span>R6 Classes</a></li><li data-subkey="sec5sub2"><a href="/R6-Advanced.html"><span class="progress-dot"></span>R6 Advanced</a></li><li data-subkey="sec5sub2"><a href="/Operator-Overloading-in-R.html"><span class="progress-dot"></span>Operator Overloading</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec5sub3" data-collapsed="false"><span class="subsec-chevron">▼</span> How R Works</li><li data-subkey="sec5sub3"><a href="/R-Names-and-Values.html"><span class="progress-dot"></span>R Names & Values</a></li><li data-subkey="sec5sub3"><a href="/R-Assignment-Deep-Dive.html"><span class="progress-dot"></span>R Assignment Deep Dive</a></li><li data-subkey="sec5sub3"><a href="/R-Memory-lobstr.html"><span class="progress-dot"></span>R Memory & lobstr</a></li><li data-subkey="sec5sub3"><a href="/R-Environments.html"><span class="progress-dot"></span>R Environments</a></li><li data-subkey="sec5sub3"><a href="/R-Lexical-Scoping.html"><span class="progress-dot"></span>Lexical Scoping</a></li><li data-subkey="sec5sub3"><a href="/R-Closures.html"><span class="progress-dot"></span>R Closures</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec5sub4" data-collapsed="false"><span class="subsec-chevron">▼</span> Debugging & Performance</li><li data-subkey="sec5sub4"><a href="/R-Conditions-System.html"><span class="progress-dot"></span>Conditions System</a></li><li data-subkey="sec5sub4"><a href="/R-Debugging.html"><span class="progress-dot"></span>Debugging R Code</a></li><li data-subkey="sec5sub4"><a href="/R-Common-Errors.html"><span class="progress-dot"></span>50 Common R Errors</a></li><li data-subkey="sec5sub4"><a href="/Parallel-Computing-With-R.html"><span class="progress-dot"></span>Parallel Computing</a></li><li data-subkey="sec5sub4"><a href="/Strategies-To-Improve-And-Speedup-R-Code.html"><span class="progress-dot"></span>Speedup R Code</a></li><li data-subkey="sec5sub4" class="is-quiz"><a href="/Shiny-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li></ul></li><li class="sidebar-section expanded"><div class="sidebar-section-header"><span class="sidebar-chevron">▸</span><span class="sec-num">7.</span> <span class="sec-title-t">Classic Tutorials</span><span class="section-meta" data-section-meta></span></div><ul class="sidebar-section-items list-unstyled"><li data-subkey="sec6sub0"><a href="/R-Tutorial.html"><span class="progress-dot"></span>R Tutorial (Classic)</a></li><li data-subkey="sec6sub0"><a href="/ggplot2-Tutorial-With-R.html"><span class="progress-dot"></span>ggplot2 Short Tutorial</a></li><li data-subkey="sec6sub0"><a href="/Complete-Ggplot2-Tutorial-Part1-With-R-Code.html"><span class="progress-dot"></span>ggplot2 Tutorial 1 - Intro</a></li><li data-subkey="sec6sub0"><a href="/Complete-Ggplot2-Tutorial-Part2-Customizing-Theme-With-R-Code.html"><span class="progress-dot"></span>ggplot2 Tutorial 2 - Theme</a></li><li data-subkey="sec6sub0"><a href="/Top50-Ggplot2-Visualizations-MasterList-R-Code.html"><span class="progress-dot"></span>ggplot2 Tutorial 3 - Masterlist</a></li><li data-subkey="sec6sub0"><a href="/Association-Mining-With-R.html" class="active"><span class="progress-dot"></span>Association Mining</a></li><li data-subkey="sec6sub0"><a href="/Multi-Dimensional-Scaling-With-R.html"><span class="progress-dot"></span>Multi Dimensional Scaling</a></li><li data-subkey="sec6sub0"><a href="/Optimization-With-R.html"><span class="progress-dot"></span>Optimization</a></li><li data-subkey="sec6sub0"><a href="/Information-Value-With-R.html"><span class="progress-dot"></span>InformationValue Package</a></li></ul></li><li class="sidebar-section"><div class="sidebar-section-header"><span class="sidebar-chevron">▸</span><span class="sec-num">8.</span> <span class="sec-title-t">Practice Exercises</span><span class="section-meta" data-section-meta></span></div><ul class="sidebar-section-items list-unstyled"><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec7sub1" data-collapsed="false"><span class="subsec-chevron">▼</span> Mastery Quizzes (Certificate)</li><li data-subkey="sec7sub1" class="is-quiz"><a href="/R-Beginner-Exercises-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/dplyr-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/ggplot2-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/Hypothesis-Testing-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/Linear-Regression-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/Machine-Learning-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/tidyr-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/Time-Series-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/Shiny-Exercises-in-R-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/R-Interview-Questions-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li data-subkey="sec7sub1" class="is-quiz"><a href="/R-Functional-Programming-Exercises-quiz.html"><span class="quiz-marker" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2 4 5.1v5.7c0 4.9 3.4 8.4 8 9.9 4.6-1.5 8-5 8-9.9V5.1L12 2z"/></svg></span>Quiz</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec7sub2" data-collapsed="false"><span class="subsec-chevron">▼</span> R Fundamentals</li><li data-subkey="sec7sub2"><a href="/R-Basics-Exercises.html"><span class="progress-dot"></span>R Basics (15 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Vectors-Exercises.html"><span class="progress-dot"></span>R Vectors (12 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Data-Frames-Exercises.html"><span class="progress-dot"></span>R Data Frames (15 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Lists-Exercises.html"><span class="progress-dot"></span>R Lists (10 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Control-Flow-Exercises.html"><span class="progress-dot"></span>R Control Flow (12 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Functions-Exercises.html"><span class="progress-dot"></span>R Functions (10 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-String-Exercises.html"><span class="progress-dot"></span>R Strings (10 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Date-Time-Exercises.html"><span class="progress-dot"></span>R Date & Time (10 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Apply-Exercises.html"><span class="progress-dot"></span>R apply Family (12 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Subsetting-Exercises.html"><span class="progress-dot"></span>R Subsetting (10 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-Functional-Programming-Exercises.html"><span class="progress-dot"></span>Functional Programming (10 problems)</a></li><li data-subkey="sec7sub2"><a href="/R-OOP-Exercises.html"><span class="progress-dot"></span>OOP in R (8 problems)</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec7sub3" data-collapsed="false"><span class="subsec-chevron">▼</span> Data Wrangling</li><li data-subkey="sec7sub3"><a href="/R-Data-Import-Exercises.html"><span class="progress-dot"></span>Data Import (10 problems)</a></li><li data-subkey="sec7sub3"><a href="/dplyr-Exercises.html"><span class="progress-dot"></span>dplyr (15 problems)</a></li><li data-subkey="sec7sub3"><a href="/dplyr-filter-select-Exercises.html"><span class="progress-dot"></span>dplyr filter() & select() (12 problems)</a></li><li data-subkey="sec7sub3"><a href="/dplyr-group-by-summarise-Exercises.html"><span class="progress-dot"></span>dplyr group_by() & summarise() (10 problems)</a></li><li data-subkey="sec7sub3"><a href="/dplyr-Join-Exercises.html"><span class="progress-dot"></span>dplyr Joins (10 problems)</a></li><li data-subkey="sec7sub3"><a href="/data-table-Exercises.html"><span class="progress-dot"></span>data.table (12 problems)</a></li><li data-subkey="sec7sub3"><a href="/purrr-Exercises.html"><span class="progress-dot"></span>purrr (10 problems)</a></li><li data-subkey="sec7sub3"><a href="/tidyr-Reshaping-Exercises.html"><span class="progress-dot"></span>tidyr Reshaping (10 problems)</a></li><li data-subkey="sec7sub3"><a href="/Missing-Data-in-R-Exercises.html"><span class="progress-dot"></span>Missing Data in R (10 problems)</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec7sub4" data-collapsed="false"><span class="subsec-chevron">▼</span> Visualization</li><li data-subkey="sec7sub4"><a href="/ggplot2-Exercises.html"><span class="progress-dot"></span>ggplot2 (15 problems)</a></li><li data-subkey="sec7sub4"><a href="/ggplot2-Geom-Exercises.html"><span class="progress-dot"></span>ggplot2 Geoms (12 problems)</a></li><li data-subkey="sec7sub4"><a href="/ggplot2-Aesthetics-Exercises.html"><span class="progress-dot"></span>ggplot2 Aesthetics (10 problems)</a></li><li data-subkey="sec7sub4"><a href="/ggplot2-Customization-Exercises.html"><span class="progress-dot"></span>ggplot2 Customization (10 problems)</a></li><li data-subkey="sec7sub4"><a href="/ggplot2-Facet-Exercises.html"><span class="progress-dot"></span>ggplot2 Facets (8 problems)</a></li><li data-subkey="sec7sub4"><a href="/R-Visualization-Project.html"><span class="progress-dot"></span>R Visualization Project (5 charts)</a></li><li class="sidebar-divider sidebar-subsection-toggle" data-subkey="sec7sub5" data-collapsed="false"><span class="subsec-chevron">▼</span> Statistics</li><li data-subkey="sec7sub5"><a href="/Probability-in-R-Exercises.html"><span class="progress-dot"></span>Probability in R Exercises</a></li><li data-subkey="sec7sub5"><a href="/R-Probability-Distributions-Exercises.html"><span class="progress-dot"></span>R Probability Distributions (12 problems)</a></li><li data-subkey="sec7sub5"><a href="/Binomial-Distribution-Exercises-in-R.html"><span class="progress-dot"></span>Binomial Distribution Exercises</a></li><li data-subkey="sec7sub5"><a href="/Poisson-Distribution-Exercises-in-R.html"><span class="progress-dot"></span>Poisson Distribution Exercises</a></li><li data-subkey="sec7sub5"><a href="/Central-Limit-Theorem-Exercises-in-R.html"><span class="progress-dot"></span>Central Limit Theorem Exercises</a></li><li data-subkey="sec7sub5"><a href="/Hypothesis-Testing-Exercises-in-R.html"><span class="progress-dot"></span>Hypothesis Testing Exercises</a></li><li data-subkey="sec7sub5"><a href="/t-Test-Exercises-in-R.html"><span class="progress-dot"></span>t-Test Exercises (12 problems)</a></li><li data-subkey="sec7sub5"><a href="/Chi-Square-Test-Exercises-in-R.html"><span class="progress-dot"></span>Chi-Square Exercises (10 problems)</a></li><li data-subkey="sec7sub5"><a href="/Confidence-Interval-Exercises-in-R.html"><span class="progress-dot"></span>Confidence Interval (10 problems)</a></li><li data-subkey="sec7sub5"><a href="/Power-Analysis-Exercises-in-R.html"><span class="progress-dot"></span>Power Analysis Exercises (8 problems)</a></li><li data-subkey="sec7sub5"><a href="/Nonparametric-Tests-Exercises-in-R.html"><span class="progress-dot"></span>Nonparametric Exercises (10 problems)</a></li><li data-subkey="sec7sub5"><a href="/Multiple-Testing-Exercises-in-R.html"><span class="progress-dot"></span>Multiple Testing (8 problems)</a></li><li data-subkey="sec7sub5"><a href="/Multiple-Regression-Exercises-in-R.html"><span class="progress-dot"></span>Multiple Regression Exercises</a></li><li data-subkey="sec7sub5"><a href="/Logistic-Regression-Exercises-in-R.html"><span class="progress-dot"></span>Logistic Regression Exercises (10 problems)</a></li><li data-subkey="sec7sub5"><a href="/Regression-Diagnostics-Exercises-in-R.html"><span class="progress-dot"></span>Regression Diagnostics Exercises</a></li><li data-subkey="sec7sub5"><a href="/Ridge-and-Lasso-Exercises-in-R.html"><span class="progress-dot"></span>Ridge & Lasso Exercises</a></li><li data-subkey="sec7sub5"><a href="/GLM-Exercises-in-R.html"><span class="progress-dot"></span>GLM Exercises (10 problems)</a></li><li data-subkey="sec7sub5"><a href="/ANOVA-Exercises-in-R.html"><span class="progress-dot"></span>ANOVA Exercises (15 problems)</a></li><li data-subkey="sec7sub5"><a href="/Post-Hoc-Tests-Exercises-in-R.html"><span class="progress-dot"></span>Post-Hoc Tests Exercises (8 problems)</a></li><li data-subkey="sec7sub5"><a href="/Repeated-Measures-Exercises-in-R.html"><span class="progress-dot"></span>Repeated Measures (8 problems)</a></li><li data-subkey="sec7sub5"><a href="/Experimental-Design-Exercises-in-R.html"><span class="progress-dot"></span>Experimental Design Exercises (8 problems)</a></li><li data-subkey="sec7sub5"><a href="/AB-Testing-Exercises-in-R.html"><span class="progress-dot"></span>A/B Testing Exercises (8 problems)</a></li><li data-subkey="sec7sub5"><a href="/Linear-Regression-Exercises-in-R.html"><span class="progress-dot"></span>Linear Regression (15 problems)</a></li><li data-subkey="sec7sub5"><a href="/PCA-Exercises-in-R.html"><span class="progress-dot"></span>PCA Exercises (10 problems)</a></li><li data-subkey="sec7sub5"><a href="/Cluster-Analysis-Exercises-in-R.html"><span class="progress-dot"></span>Clustering Exercises (10 problems)</a></li><li data-subkey="sec7sub5"><a href="/SEM-Exercises-in-R.html"><span class="progress-dot"></span>SEM Exercises (8 problems)</a></li><li data-subkey="sec7sub5"><a href="/A-B-Testing-Exercises-in-R.html"><span class="progress-dot"></span>A/B Testing Exercises</a></li><li data-subkey="sec7sub5"><a href="/API-Calls-Exercises-in-R.html"><span class="progress-dot"></span>API Calls Exercises</a></li><li data-subkey="sec7sub5"><a href="/ARIMA-Exercises-in-R.html"><span class="progress-dot"></span>ARIMA Exercises</a></li><li data-subkey="sec7sub5"><a href="/Apply-Family-Exercises-in-R.html"><span class="progress-dot"></span>Apply Family Exercises</a></li><li data-subkey="sec7sub5"><a href="/Bayesian-Statistics-Exercises-in-R.html"><span class="progress-dot"></span>Bayesian Statistics Exercises</a></li><li data-subkey="sec7sub5"><a href="/Clustering-Exercises-in-R.html"><span class="progress-dot"></span>Clustering Exercises</a></li><li data-subkey="sec7sub5"><a href="/Correlation-Exercises-in-R.html"><span class="progress-dot"></span>Correlation Exercises</a></li><li data-subkey="sec7sub5"><a href="/Cross-Validation-Exercises-in-R.html"><span class="progress-dot"></span>Cross Validation Exercises</a></li><li data-subkey="sec7sub5"><a href="/Data-Cleaning-Exercises-in-R.html"><span class="progress-dot"></span>Data Cleaning Exercises</a></li><li data-subkey="sec7sub5"><a href="/Data-Visualization-Exercises-in-R.html"><span class="progress-dot"></span>Data Viz Exercises</a></li><li data-subkey="sec7sub5"><a href="/Data-Wrangling-Exercises-in-R.html"><span class="progress-dot"></span>Data Wrangling Exercises</a></li><li data-subkey="sec7sub5"><a href="/Decision-Tree-Exercises-in-R.html"><span class="progress-dot"></span>Decision Tree Exercises</a></li><li data-subkey="sec7sub5"><a href="/EDA-Exercises-in-R.html"><span class="progress-dot"></span>EDA Exercises</a></li><li data-subkey="sec7sub5"><a href="/GAM-Exercises-in-R.html"><span class="progress-dot"></span>GAM Exercises</a></li><li data-subkey="sec7sub5"><a href="/Machine-Learning-Exercises-in-R.html"><span class="progress-dot"></span>Machine Learning Exercises</a></li><li data-subkey="sec7sub5"><a href="/Mixed-Effects-Models-Exercises-in-R.html"><span class="progress-dot"></span>Mixed Effects Exercises</a></li><li data-subkey="sec7sub5"><a href="/Network-Analysis-Exercises-in-R.html"><span class="progress-dot"></span>Network Analysis Exercises</a></li><li data-subkey="sec7sub5"><a href="/Parallel-Computing-in-R-Exercises.html"><span class="progress-dot"></span>Parallel Computing Exercises</a></li><li data-subkey="sec7sub5"><a href="/Poisson-Regression-Exercises-in-R.html"><span class="progress-dot"></span>Poisson Regression</a></li><li data-subkey="sec7sub5"><a href="/Probability-Distributions-Exercises-in-R.html"><span class="progress-dot"></span>Probability Distributions</a></li><li data-subkey="sec7sub5"><a href="/R-Beginner-Exercises.html"><span class="progress-dot"></span>R Beginner Exercises</a></li><li data-subkey="sec7sub5"><a href="/R-Debugging-Exercises.html"><span class="progress-dot"></span>R Debugging Exercises</a></li><li data-subkey="sec7sub5"><a href="/R-Markdown-Exercises.html"><span class="progress-dot"></span>R Markdown Exercises</a></li><li data-subkey="sec7sub5"><a href="/R-Package-Development-Exercises.html"><span class="progress-dot"></span>R Package Development</a></li><li data-subkey="sec7sub5"><a href="/R-Performance-Optimization-Exercises.html"><span class="progress-dot"></span>R Performance Exercises</a></li><li data-subkey="sec7sub5"><a href="/R-for-Biostatistics-Exercises.html"><span class="progress-dot"></span>R for Biostatistics</a></li><li data-subkey="sec7sub5"><a href="/R-for-Data-Science-Exercises.html"><span class="progress-dot"></span>R for Data Science Exercises</a></li><li data-subkey="sec7sub5"><a href="/R-for-Finance-Exercises.html"><span class="progress-dot"></span>R for Finance Exercises</a></li><li data-subkey="sec7sub5"><a href="/R-for-Genomics-Exercises.html"><span class="progress-dot"></span>R for Genomics</a></li><li data-subkey="sec7sub5"><a href="/R-for-Healthcare-Exercises.html"><span class="progress-dot"></span>R for Healthcare Exercises</a></li><li data-subkey="sec7sub5"><a href="/R-for-Marketing-Analytics-Exercises.html"><span class="progress-dot"></span>R for Marketing Analytics</a></li><li data-subkey="sec7sub5"><a href="/R-for-Sports-Analytics-Exercises.html"><span class="progress-dot"></span>R for Sports Analytics</a></li><li data-subkey="sec7sub5"><a href="/Random-Forest-Exercises-in-R.html"><span class="progress-dot"></span>Random Forest Exercises</a></li><li data-subkey="sec7sub5"><a href="/Regex-Exercises-in-R.html"><span class="progress-dot"></span>Regex Exercises</a></li><li data-subkey="sec7sub5"><a href="/Sampling-Methods-Exercises-in-R.html"><span class="progress-dot"></span>Sampling Methods Exercises</a></li><li data-subkey="sec7sub5"><a href="/Shiny-Exercises-in-R.html"><span class="progress-dot"></span>Shiny Exercises</a></li><li data-subkey="sec7sub5"><a href="/Spatial-Analysis-Exercises-in-R.html"><span class="progress-dot"></span>Spatial Analysis Exercises</a></li><li data-subkey="sec7sub5"><a href="/Survey-Analysis-in-R-Exercises.html"><span class="progress-dot"></span>Survey Analysis Exercises</a></li><li data-subkey="sec7sub5"><a href="/Survival-Analysis-Exercises-in-R.html"><span class="progress-dot"></span>Survival Analysis Exercises</a></li><li data-subkey="sec7sub5"><a href="/Text-Mining-Exercises-in-R.html"><span class="progress-dot"></span>Text Mining Exercises</a></li><li data-subkey="sec7sub5"><a href="/Time-Series-Exercises-in-R.html"><span class="progress-dot"></span>Time Series Exercises</a></li><li data-subkey="sec7sub5"><a href="/Web-Scraping-Exercises-in-R.html"><span class="progress-dot"></span>Web Scraping Exercises</a></li><li data-subkey="sec7sub5"><a href="/XGBoost-Exercises-in-R.html"><span class="progress-dot"></span>XGBoost Exercises</a></li><li data-subkey="sec7sub5"><a href="/broom-Exercises-in-R.html"><span class="progress-dot"></span>broom Exercises</a></li><li data-subkey="sec7sub5"><a href="/caret-Exercises-in-R.html"><span class="progress-dot"></span>caret Exercises</a></li><li data-subkey="sec7sub5"><a href="/data.table-Exercises-in-R.html"><span class="progress-dot"></span>data.table Exercises</a></li><li data-subkey="sec7sub5"><a href="/dbplyr-SQL-Exercises-in-R.html"><span class="progress-dot"></span>dbplyr / SQL Exercises</a></li><li data-subkey="sec7sub5"><a href="/dplyr-Exercises-in-R.html"><span class="progress-dot"></span>dplyr Exercises</a></li><li data-subkey="sec7sub5"><a href="/dplyr-Group-By-Exercises-in-R.html"><span class="progress-dot"></span>dplyr group_by Exercises</a></li><li data-subkey="sec7sub5"><a href="/dplyr-Joins-Exercises-in-R.html"><span class="progress-dot"></span>dplyr Joins Exercises</a></li><li data-subkey="sec7sub5"><a href="/dplyr-Window-Functions-Exercises-in-R.html"><span class="progress-dot"></span>dplyr Window Functions Exercises</a></li><li data-subkey="sec7sub5"><a href="/forcats-Exercises-in-R.html"><span class="progress-dot"></span>forcats Exercises</a></li><li data-subkey="sec7sub5"><a href="/ggplot2-Bar-Chart-Exercises-in-R.html"><span class="progress-dot"></span>ggplot2 Bar Chart Exercises</a></li><li data-subkey="sec7sub5"><a href="/ggplot2-Color-Scales-Exercises-in-R.html"><span class="progress-dot"></span>ggplot2 Color Scales Exercises</a></li><li data-subkey="sec7sub5"><a href="/ggplot2-Exercises-in-R.html"><span class="progress-dot"></span>ggplot2 Exercises</a></li><li data-subkey="sec7sub5"><a href="/ggplot2-Facets-Exercises-in-R.html"><span class="progress-dot"></span>ggplot2 Facets Exercises</a></li><li data-subkey="sec7sub5"><a href="/ggplot2-Heatmap-Exercises-in-R.html"><span class="progress-dot"></span>ggplot2 Heatmap Exercises</a></li><li data-subkey="sec7sub5"><a href="/ggplot2-Themes-Exercises-in-R.html"><span class="progress-dot"></span>ggplot2 Themes Exercises</a></li><li data-subkey="sec7sub5"><a href="/gt-Tables-Exercises-in-R.html"><span class="progress-dot"></span>gt Tables Exercises</a></li><li data-subkey="sec7sub5"><a href="/leaflet-Exercises-in-R.html"><span class="progress-dot"></span>leaflet Exercises</a></li><li data-subkey="sec7sub5"><a href="/lubridate-Exercises-in-R.html"><span class="progress-dot"></span>lubridate Exercises</a></li><li data-subkey="sec7sub5"><a href="/plotly-Exercises-in-R.html"><span class="progress-dot"></span>plotly Exercises</a></li><li data-subkey="sec7sub5"><a href="/purrr-Exercises-in-R.html"><span class="progress-dot"></span>purrr Exercises</a></li><li data-subkey="sec7sub5"><a href="/readr-Exercises-in-R.html"><span class="progress-dot"></span>readr Exercises</a></li><li data-subkey="sec7sub5"><a href="/stringr-Exercises-in-R.html"><span class="progress-dot"></span>stringr Exercises</a></li><li data-subkey="sec7sub5"><a href="/testthat-Exercises-in-R.html"><span class="progress-dot"></span>testthat Exercises</a></li><li data-subkey="sec7sub5"><a href="/tidymodels-Exercises-in-R.html"><span class="progress-dot"></span>tidymodels Exercises</a></li><li data-subkey="sec7sub5"><a href="/tidyr-Exercises-in-R.html"><span class="progress-dot"></span>tidyr Exercises</a></li><li data-subkey="sec7sub5"><a href="/tidyr-Nest-Unnest-Exercises-in-R.html"><span class="progress-dot"></span>tidyr Nest/Unnest Exercises</a></li><li data-subkey="sec7sub5"><a href="/tidyr-Pivot-Exercises-in-R.html"><span class="progress-dot"></span>tidyr Pivot Exercises</a></li><li data-subkey="sec7sub5"><a href="/tidyverse-Exercises-in-R.html"><span class="progress-dot"></span>Tidyverse Exercises</a></li><li data-subkey="sec7sub5"><a href="/Date-Time-Manipulation-Exercises-in-R.html"><span class="progress-dot"></span>Date-Time Manipulation Exercises</a></li><li data-subkey="sec7sub5"><a href="/Loops-vs-Vectorization-Exercises-in-R.html"><span class="progress-dot"></span>Loops vs Vectorization Exercises</a></li></ul></li></ul><div class="sidebar-subscribe"><p>Stay up-to-date. <a href="https://docs.google.com/forms/d/1xkMYkLNFU9U39Dd8S_2JC0p8B5t6_Yq6zUQjanQQJpY/viewform">Subscribe!</a></p><p><a href="https://docs.google.com/forms/d/13GrkCFcNa-TOIllQghsz2SIEbc-YqY9eJX02B19l5Ow/viewform">Chat!</a></p></div></div><div class="sidebar-panel" data-panel="tools"><ul class="sidebar-tools-list list-unstyled"><li class="sidebar-divider"><span class="subsec-chevron">▼</span> Calculators</li><li><a href="/tools/ab-test-calculator.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="3.5" width="4" height="9" rx="0.5"/><rect x="9.5" y="3.5" width="4" height="9" rx="0.5"/></svg></span><span class="tool-label">A/B Test Calculator</span></a></li><li><a href="/tools/t-test-calculator.html"><span class="tool-icon"></span><span class="tool-label">t-Test Calculator</span></a></li><li><a href="/tools/chi-square-calculator.html"><span class="tool-icon"></span><span class="tool-label">Chi-Square Test</span></a></li><li><a href="/tools/confidence-interval-calculator.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.5 4v8M3.5 4H5M3.5 12H5"/><circle cx="8" cy="8" r="1.4" fill="currentColor" stroke="none"/><path d="M12.5 4v8M12.5 4H11M12.5 12H11"/></svg></span><span class="tool-label">Confidence Interval</span></a></li><li><a href="/tools/bootstrap-ci-calculator.html"><span class="tool-icon"></span><span class="tool-label">Bootstrap CI</span></a></li><li><a href="/tools/effect-size-converter.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.5 5.5h11M11 3l2.5 2.5L11 8"/><path d="M13.5 10.5h-11M5 8l-2.5 2.5L5 13"/></svg></span><span class="tool-label">Effect Size Converter</span></a></li><li><a href="/tools/power-analysis.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 2L4 9h3.5L7 14l5-7H8.5z"/></svg></span><span class="tool-label">Power Analysis</span></a></li><li><a href="/tools/survival-power-calculator.html"><span class="tool-icon"></span><span class="tool-label">Survival Power</span></a></li><li><a href="/tools/type-i-ii-error-visualizer.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12c1.5 0 2-2 3.5-2S7 12 8 12s2-8 3.5-8S13 12 14.5 12"/><line x1="8" y1="2" x2="8" y2="14" stroke-dasharray="2 2"/></svg></span><span class="tool-label">Type I / II Error</span></a></li><li><a href="/tools/z-score-percentile.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 13c2 0 3-1 4-3s1.5-6 2-6 .5 6 2 6 2.5 0 4 0"/><path d="M2 13.5h12"/></svg></span><span class="tool-label">Z-Score & Percentile</span></a></li><li><a href="/tools/equivalence-noninferiority-calculator.html"><span class="tool-icon"></span><span class="tool-label">Equivalence / NI</span></a></li><li><a href="/tools/outlier-detection-calculator.html"><span class="tool-icon"></span><span class="tool-label">Outlier Detection</span></a></li><li><a href="/tools/roc-auc-calculator.html"><span class="tool-icon"></span><span class="tool-label">ROC / AUC</span></a></li><li class="sidebar-divider"><span class="subsec-chevron">▼</span> Bayesian</li><li><a href="/tools/bayes-theorem-calculator.html"><span class="tool-icon"></span><span class="tool-label">Bayes Theorem</span></a></li><li><a href="/tools/bayes-factor-calculator.html"><span class="tool-icon"></span><span class="tool-label">Bayes Factor</span></a></li><li class="sidebar-divider"><span class="subsec-chevron">▼</span> Interpreters</li><li><a href="/tools/lm-output-interpreter.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 13.5L14 3"/><circle cx="4" cy="11.5" r="1" fill="currentColor" stroke="none"/><circle cx="7.5" cy="9" r="1" fill="currentColor" stroke="none"/><circle cx="11" cy="6.5" r="1" fill="currentColor" stroke="none"/></svg></span><span class="tool-label">lm() Output</span></a></li><li><a href="/tools/glm-output-interpreter.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 13C5 13 5 3 8 3s3 10 6 10"/><path d="M2 13.5h12"/></svg></span><span class="tool-label">glm() Output</span></a></li><li><a href="/tools/anova-output-interpreter.html"><span class="tool-icon"></span><span class="tool-label">ANOVA Output</span></a></li><li><a href="/tools/vif-interpreter.html"><span class="tool-icon"></span><span class="tool-label">VIF / Multicollinearity</span></a></li><li><a href="/tools/confusion-matrix-interpreter.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="2.5" width="4.5" height="4.5"/><rect x="9" y="2.5" width="4.5" height="4.5"/><rect x="2.5" y="9" width="4.5" height="4.5"/><rect x="9" y="9" width="4.5" height="4.5"/></svg></span><span class="tool-label">Confusion Matrix</span></a></li><li><a href="/tools/diagnostic-plot-interpreter.html"><span class="tool-icon"></span><span class="tool-label">Diagnostic Plots</span></a></li><li class="sidebar-divider"><span class="subsec-chevron">▼</span> Pickers</li><li><a href="/tools/normality-test-picker.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 13c2 0 3-1 4-3s1.5-6 2-6 .5 6 2 6 2.5 0 4 0"/><circle cx="13" cy="4" r="1.6" fill="currentColor" stroke="none"/></svg></span><span class="tool-label">Normality Test</span></a></li><li><a href="/tools/nonparametric-test-picker.html"><span class="tool-icon"></span><span class="tool-label">Non-Parametric Test</span></a></li><li><a href="/tools/multiple-testing-correction.html"><span class="tool-icon"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.5 4l2 2 3-3M2.5 8l2 2 3-3M2.5 12l2 2 3-3"/><path d="M10.5 4h3M10.5 8h3M10.5 12h3"/></svg></span><span class="tool-label">Multiple Testing</span></a></li><li class="sidebar-divider"><span class="subsec-chevron">▼</span> Time series</li><li><a href="/tools/ts-stationarity-calculator.html"><span class="tool-icon"></span><span class="tool-label">TS Stationarity</span></a></li><li class="sidebar-divider"><span class="subsec-chevron">▼</span> Utilities</li><li><a href="/tools/dag-confounder-picker.html"><span class="tool-icon"></span><span class="tool-label">DAG Confounder Picker</span></a></li><li><a href="/tools/reprex-builder.html"><span class="tool-icon"></span><span class="tool-label">Reprex Builder</span></a></li></ul></div></div>
</div>
<div id="content" class="col-xs-12 col-sm-7">
<h1>Association Mining (Market Basket Analysis)</h1>
<blockquote>
<p>Association mining is commonly used to make product recommendations by identifying products that are frequently bought together. But, if you are not careful, the rules can give misleading results in certain cases.</p>
</blockquote>
<p>Association mining is usually done on transactions data from a retail market or from an online e-commerce store. Since most transactions data is large, the <code>apriori</code> algorithm makes it easier to find these patterns or <em>rules</em> quickly.</p>
<p>So, What is a <em>rule</em>?</p>
<p>A rule is a notation that represents which item/s is frequently bought with what item/s. It has an <em>LHS</em> and an <em>RHS</em> part and can be represented as follows:</p>
<p><strong>itemset A => itemset B</strong></p>
<p>This means, the item/s on the right were frequently purchased along with items on the left.</p>
<h2>How to measure the strength of a rule?</h2>
<p>The <code>apriori()</code> generates the most relevent set of rules from a given transaction data. It also shows the <em>support</em>, <em>confidence</em> and <em>lift</em> of those rules. These three measure can be used to decide the relative strength of the rules. So what do these terms mean?</p>
<p>Lets consider the rule <strong>A => B</strong> in order to compute these metrics.</p>
<p><br /><span class="math display">$$Support = \frac{Number\ of\ transactions\ with\ both\ A\ and\ B}{Total\ number\ of\ transactions} = P\left(A \cap B\right)$$</span><br /></p>
<p><br /><span class="math display">$$Confidence = \frac{Number\ of\ transactions\ with\ both\ A\ and\ B}{Total\ number\ of\ transactions\ with\ A} = \frac{P\left(A \cap B\right)}{P\left(A\right)}$$</span><br /></p>
<p><br /><span class="math display">$$Expected Confidence = \frac{Number\ of\ transactions\ with\ B}{Total\ number\ of\ transactions} = P\left(B\right)$$</span><br /></p>
<p><br /><span class="math display">$$Lift = \frac{Confidence}{Expected\ Confidence} = \frac{P\left(A \cap B\right)}{P\left(A\right).P\left(B\right)}$$</span><br /></p>
<p><em>Lift</em> is the factor by which, the co-occurence of A and B exceeds the expected probability of A and B co-occuring, had they been independent. So, higher the lift, higher the chance of A and B occurring together.</p>
<p>Lets see how to get the rules, confidence, lift etc using the <code>arules</code> package in R.</p>
<h2>Example</h2>
<h4>Transactions data</h4>
<p>Lets play with the <code>Groceries</code> data that comes with the <code>arules</code> pkg. Unlike dataframe, using <code>head(Groceries)</code> does not display the transaction items in the data. To view the transactions, use the <code>inspect()</code> function instead.</p>
<p>Since association mining deals with transactions, the data has to be converted to one of class <code>transactions</code>, made available in R through the <code>arules</code> pkg. This is a necessary step because the <code>apriori()</code> function accepts transactions data of class <code>transactions</code> only.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(arules)
<span class="kw">class</span>(Groceries)
<span class="co">#> [1] "transactions"</span>
<span class="co">#> attr(,"package")</span>
<span class="co">#> [1] "arules"</span>
<span class="kw">inspect</span>(<span class="kw">head</span>(Groceries, <span class="dv">3</span>))
<span class="co">#> items </span>
<span class="co">#> 1 {citrus fruit, </span>
<span class="co">#> semi-finished bread, </span>
<span class="co">#> margarine, </span>
<span class="co">#> ready soups} </span>
<span class="co">#> 2 {tropical fruit, </span>
<span class="co">#> yogurt, </span>
<span class="co">#> coffee} </span>
<span class="co">#> 3 {whole milk} </span></code></pre></div>
<p>If you have to read data from a file as a transactions data, use <code>read.transactions()</code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tdata <-<span class="st"> </span><span class="kw">read.transactions</span>(<span class="st">"transactions_data.txt"</span>, <span class="dt">sep=</span><span class="st">"</span><span class="ch">\t</span><span class="st">"</span>)</code></pre></div>
<p>If you already have your transactions stored as a dataframe, you could convert it to class <code>transactions</code> as follows,</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tData <-<span class="st"> </span><span class="kw">as</span> (myDataFrame, <span class="st">"transactions"</span>) <span class="co"># convert to 'transactions' class</span></code></pre></div>
<p>Here are couple more utility functions that are good to know:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">size</span>(<span class="kw">head</span>(Groceries)) <span class="co"># number of items in each observation</span>
<span class="co">#> [1] 4 3 1 4 4 5</span>
<span class="kw">LIST</span>(<span class="kw">head</span>(Groceries, <span class="dv">3</span>)) <span class="co"># convert 'transactions' to a list, note the LIST in CAPS</span>
<span class="co">#> [[1]]</span>
<span class="co">#> [1] "citrus fruit" "semi-finished bread" "margarine" </span>
<span class="co">#> [4] "ready soups" </span>
<span class="co">#> </span>
<span class="co">#> [[2]]</span>
<span class="co">#> [1] "tropical fruit" "yogurt" "coffee" </span>
<span class="co">#> </span>
<span class="co">#> [[3]]</span>
<span class="co">#> [1] "whole milk"</span></code></pre></div>
<h2>How to see the most frequent items?</h2>
<p>The <code>eclat()</code> takes in a transactions object and gives the most frequent items in the data based the support you provide to the <code>supp</code> argument. The <code>maxlen</code> defines the maximum number of items in each itemset of frequent items.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">frequentItems <-<span class="st"> </span><span class="kw">eclat</span> (Groceries, <span class="dt">parameter =</span> <span class="kw">list</span>(<span class="dt">supp =</span> <span class="fl">0.07</span>, <span class="dt">maxlen =</span> <span class="dv">15</span>)) <span class="co"># calculates support for frequent items</span>
<span class="kw">inspect</span>(frequentItems)
<span class="co">#> items support </span>
<span class="co">#> 1 {other vegetables,whole milk} 0.07483477</span>
<span class="co">#> 2 {whole milk} 0.25551601</span>
<span class="co">#> 3 {other vegetables} 0.19349263</span>
<span class="co">#> 4 {rolls/buns} 0.18393493</span>
<span class="co">#> 5 {yogurt} 0.13950178</span>
<span class="co">#> 6 {soda} 0.17437722</span>
<span class="kw">itemFrequencyPlot</span>(Groceries, <span class="dt">topN=</span><span class="dv">10</span>, <span class="dt">type=</span><span class="st">"absolute"</span>, <span class="dt">main=</span><span class="st">"Item Frequency"</span>) <span class="co"># plot frequent items</span></code></pre></div>
<p><img src='screenshots/item_frequency_plot_arules.png' width='528' height='289' alt="Item Frequency Plot Arules" /></p>
<h1>How to get the product recommendation rules?</h1>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">rules <-<span class="st"> </span><span class="kw">apriori</span> (Groceries, <span class="dt">parameter =</span> <span class="kw">list</span>(<span class="dt">supp =</span> <span class="fl">0.001</span>, <span class="dt">conf =</span> <span class="fl">0.5</span>)) <span class="co"># Min Support as 0.001, confidence as 0.8.</span>
rules_conf <-<span class="st"> </span><span class="kw">sort</span> (rules, <span class="dt">by=</span><span class="st">"confidence"</span>, <span class="dt">decreasing=</span><span class="ot">TRUE</span>) <span class="co"># 'high-confidence' rules.</span>
<span class="kw">inspect</span>(<span class="kw">head</span>(rules_conf)) <span class="co"># show the support, lift and confidence for all rules</span>
<span class="co">#> lhs rhs support confidence lift </span>
<span class="co">#> 113 {rice,sugar} => {whole milk} 0.001220132 1 3.913649</span>
<span class="co">#> 258 {canned fish,hygiene articles} => {whole milk} 0.001118454 1 3.913649</span>
<span class="co">#> 1487 {root vegetables,butter,rice} => {whole milk} 0.001016777 1 3.913649</span>
<span class="co">#> 1646 {root vegetables,whipped/sour cream,flour} => {whole milk} 0.001728521 1 3.913649</span>
<span class="co">#> 1670 {butter,soft cheese,domestic eggs} => {whole milk} 0.001016777 1 3.913649</span>
<span class="co">#> 1699 {citrus fruit,root vegetables,soft cheese} => {other vegetables} 0.001016777 1 5.168156</span>
rules_lift <-<span class="st"> </span><span class="kw">sort</span> (rules, <span class="dt">by=</span><span class="st">"lift"</span>, <span class="dt">decreasing=</span><span class="ot">TRUE</span>) <span class="co"># 'high-lift' rules.</span>
<span class="kw">inspect</span>(<span class="kw">head</span>(rules_lift)) <span class="co"># show the support, lift and confidence for all rules</span>
<span class="co">#> lhs rhs support confidence lift </span>
<span class="co">#> 53 {Instant food products,soda} => {hamburger meat} 0.001220 0.6315789 18.995</span>
<span class="co">#> 37 {soda,popcorn} => {salty snack} 0.001220 0.6315789 16.697</span>
<span class="co">#> 444 {flour,baking powder} => {sugar} 0.001016 0.5555556 16.408</span>
<span class="co">#> 327 {ham,processed cheese} => {white bread} 0.001931 0.6333333 15.045</span>
<span class="co">#> 55 {whole milk,Instant food products} => {hamburger meat} 0.001525 0.5000000 15.038</span>
<span class="co">#> 4807 {other vegetables,curd,yogurt,whipped/sour cream} => {cream cheese } 0.001016 0.5882353 14.834</span></code></pre></div>
<p>The rules with confidence of 1 (see <code>rules_conf</code> above) imply that, whenever the LHS item was purchased, the RHS item was also purchased 100% of the time.</p>
<p>A rule with a lift of 18 (see <code>rules_lift</code> above) imply that, the items in LHS and RHS are 18 times more likely to be purchased together compared to the purchases when they are assumed to be unrelated.</p>
<h2>How To Control The Number Of Rules in Output ?</h2>
<p>Adjust the <code>maxlen</code>, <code>supp</code> and <code>conf</code> arguments in the <code>apriori</code> function to control the number of rules generated. You will have to adjust this based on the sparesness of you data.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">rules <-<span class="st"> </span><span class="kw">apriori</span>(Groceries, <span class="dt">parameter =</span> <span class="kw">list</span> (<span class="dt">supp =</span> <span class="fl">0.001</span>, <span class="dt">conf =</span> <span class="fl">0.5</span>, <span class="dt">maxlen=</span><span class="dv">3</span>)) <span class="co"># maxlen = 3 limits the elements in a rule to 3</span></code></pre></div>
<ol style="list-style-type: decimal">
<li>To get <strong>‘strong‘</strong> rules, increase the value of <em>‘conf’</em> parameter.</li>
<li>To get <strong>‘longer‘</strong> rules, increase <em>‘maxlen’</em>.</li>
</ol>
<h2>How To Remove Redundant Rules ?</h2>
<p>Sometimes it is desirable to remove the rules that are subset of larger rules. To do so, use the below code to filter the redundant rules.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">subsetRules <-<span class="st"> </span><span class="kw">which</span>(<span class="kw">colSums</span>(<span class="kw">is.subset</span>(rules, rules)) ><span class="st"> </span><span class="dv">1</span>) <span class="co"># get subset rules in vector</span>
<span class="kw">length</span>(subsetRules) <span class="co">#> 3913</span>
rules <-<span class="st"> </span>rules[-subsetRules] <span class="co"># remove subset rules. </span></code></pre></div>
<h2>How to Find Rules Related To Given Item/s ?</h2>
<p>This can be achieved by modifying the <code>appearance</code> parameter in the <code>apriori()</code> function. For example,</p>
<h4>To find what factors influenced purchase of product X</h4>
<p>To find out what customers had purchased before buying ‘Whole Milk’. This will help you understand the patterns that led to the purchase of ‘whole milk’.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">rules <-<span class="st"> </span><span class="kw">apriori</span> (<span class="dt">data=</span>Groceries, <span class="dt">parameter=</span><span class="kw">list</span> (<span class="dt">supp=</span><span class="fl">0.001</span>,<span class="dt">conf =</span> <span class="fl">0.08</span>), <span class="dt">appearance =</span> <span class="kw">list</span> (<span class="dt">default=</span><span class="st">"lhs"</span>,<span class="dt">rhs=</span><span class="st">"whole milk"</span>), <span class="dt">control =</span> <span class="kw">list</span> (<span class="dt">verbose=</span>F)) <span class="co"># get rules that lead to buying 'whole milk'</span>
rules_conf <-<span class="st"> </span><span class="kw">sort</span> (rules, <span class="dt">by=</span><span class="st">"confidence"</span>, <span class="dt">decreasing=</span><span class="ot">TRUE</span>) <span class="co"># 'high-confidence' rules.</span>
<span class="kw">inspect</span>(<span class="kw">head</span>(rules_conf))
<span class="co">#> lhs rhs support confidence lift </span>
<span class="co">#> 196 {rice,sugar} => {whole milk} 0.001220132 1 3.913649</span>
<span class="co">#> 323 {canned fish,hygiene articles} => {whole milk} 0.001118454 1 3.913649</span>
<span class="co">#> 1643 {root vegetables,butter,rice} => {whole milk} 0.001016777 1 3.913649</span>
<span class="co">#> 1705 {root vegetables,whipped/sour cream,flour} => {whole milk} 0.001728521 1 3.913649</span>
<span class="co">#> 1716 {butter,soft cheese,domestic eggs} => {whole milk} 0.001016777 1 3.913649</span>
<span class="co">#> 1985 {pip fruit,butter,hygiene articles} => {whole milk} 0.001016777 1 3.913649</span></code></pre></div>
<h4>To find out what products were purchased after/along with product X</h4>
<p>The is a case to find out <em>the Customers who bought ‘Whole Milk’ also bought . .</em> In the equation, ‘whole milk’ is in LHS (left hand side).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">rules <-<span class="st"> </span><span class="kw">apriori</span> (<span class="dt">data=</span>Groceries, <span class="dt">parameter=</span><span class="kw">list</span> (<span class="dt">supp=</span><span class="fl">0.001</span>,<span class="dt">conf =</span> <span class="fl">0.15</span>,<span class="dt">minlen=</span><span class="dv">2</span>), <span class="dt">appearance =</span> <span class="kw">list</span>(<span class="dt">default=</span><span class="st">"rhs"</span>,<span class="dt">lhs=</span><span class="st">"whole milk"</span>), <span class="dt">control =</span> <span class="kw">list</span> (<span class="dt">verbose=</span>F)) <span class="co"># those who bought 'milk' also bought..</span>
rules_conf <-<span class="st"> </span><span class="kw">sort</span> (rules, <span class="dt">by=</span><span class="st">"confidence"</span>, <span class="dt">decreasing=</span><span class="ot">TRUE</span>) <span class="co"># 'high-confidence' rules.</span>
<span class="kw">inspect</span>(<span class="kw">head</span>(rules_conf))
<span class="co">#> lhs rhs support confidence lift </span>
<span class="co">#> 6 {whole milk} => {other vegetables} 0.07483477 0.2928770 1.5136341</span>
<span class="co">#> 5 {whole milk} => {rolls/buns} 0.05663447 0.2216474 1.2050318</span>
<span class="co">#> 4 {whole milk} => {yogurt} 0.05602440 0.2192598 1.5717351</span>
<span class="co">#> 2 {whole milk} => {root vegetables} 0.04890696 0.1914047 1.7560310</span>
<span class="co">#> 1 {whole milk} => {tropical fruit} 0.04229792 0.1655392 1.5775950</span>
<span class="co">#> 3 {whole milk} => {soda} 0.04006101 0.1567847 0.8991124</span></code></pre></div>
<p>One drawback with this is, you will get only 1 item on the RHS, irrespective of the support, confidence or minlen parameters.</p>
<h2>Caveat with using Lift</h2>
<p>The directionality of the rule is lost when <em>lift</em> is used. That is, the lift of any rule, <em>A => B</em> and the rule <em>B => A</em> will be the same. See the calculation below:</p>
<h4><em>A -> B</em></h4>
<ul>
<li><p>Support: <span class="math inline"><em>P</em>(<em>A</em>∩<em>B</em>)</span></p></li>
<li><p>Confidence: <span class="math inline">$\frac{P\left( A \cap B \right)}{P\left( A \right)}$</span></p></li>
<li><p>Expected Confidence: <span class="math inline"><em>P</em>(<em>B</em>)</span></p></li>
<li><p>Lift: <span class="math inline">$\frac{Confidence}{Expected\ Confidence}$</span> = <span class="math inline">$\frac{P\left( A \cap B \right)}{P\left( A \right).P\left( B \right)}$</span></p></li>
</ul>
<h4><em>B -> A</em></h4>
<ul>
<li><p>Support: <span class="math inline"><em>P</em>(<em>A</em>∩<em>B</em>)</span></p></li>
<li><p>Confidence: <span class="math inline">$\frac{P\left( A \cap B \right)}{P\left( B \right)}$</span></p></li>
<li><p>Expected Confidence: <span class="math inline"><em>P</em>(<em>B</em>)</span></p></li>
<li><p>Lift: <span class="math inline">$\frac{Confidence}{Expected\ Confidence}$</span> = <span class="math inline">$\frac{P\left( A \cap B \right)}{P\left( A \right).P\left( B \right)}$</span></p></li>
</ul>
<h4>Important Note</h4>
<p>For both rules <em>A -> B</em> and <em>B -> A</em>, the value of <em>lift</em> and support turns out to be the same. This means we cannot use lift to make recommendation for a particular <em>directional</em> ‘rule’. It can merely be used to club frequently bought items into groups.</p>
<h2>Caveat with using Confidence</h2>
<p>The <em>confidence</em> of a rule can be a misleading measure while making product recommendations in real world problems, especially while making <em>add-ons</em> product recommendations. Lets consider the following data with 4 transactions, involving IPhones and Headsets:</p>
<ol style="list-style-type: decimal">
<li>Iphone, Headset</li>
<li>Iphone, Headset</li>
<li>Iphone</li>
<li>Iphone</li>
</ol>
<p>We can create 2 rules for these transactions as shown below:</p>
<ol style="list-style-type: decimal">
<li><em>Iphone -> Headset</em></li>
<li><em>Headset -> IPhone</em></li>
</ol>
<p>In real world, it would be realistic to recommend <em>headphones</em> to a person who just bought an <em>iPhone</em> and not the other way around. Imagine being recommended an iPhone when you just finished purchasing a pair of headphones. Not nice!.</p>
<p>While selecting rules from the <code>apriori</code> output, you might guess that higher the confidence a rule has, better is the rule. But for cases like this, the headset -> iPhone rule will have a higher confidence (2 times) over iPhone -> headset. Can you see why? The calculation below show how.</p>
<h4>Confidence Calculation:</h4>
<p><strong>iPhone -> Headset</strong>: <span class="math inline">$\frac{P(iPhone\ \cap\ Headset)}{P(iPhone)}$</span> = 0.5 / 1 = <strong>0.5</strong></p>
<p><strong>Headset -> iPhone</strong>: <span class="math inline">$\frac{P(iPhone\ \cap\ Headset)}{P(Headset)}$</span> = 0.5 / 0.5 = <strong>1.0</strong></p>
<p>As, you can see, the <em>headset -> iPhone</em> recommendation has a higher confidence, which is misleading and unrealistic. So, confidence should not be the <em>only measure</em> you should use to make product recommendations.</p>
<p>So, you probably need to check more criteria such as the price of products, product types etc before recommending items, especially in cross selling cases.</p>
</div>
<div class="col-sm-2 hidden-xs" id="toc-sidebar">
<div id="toc-wrapper">
<h5 class="toc-title">On this page</h5>
<ul class="list-unstyled" id="toc"></ul>
</div>
</div>
</div>
</div> <!-- /container -->
<!-- SITE-FOOTER-V2 -->
<style>
.rsft{background:#101a30;color:#aeb9d4;font-size:14px;font-family:'IBM Plex Sans',-apple-system,Segoe UI,Roboto,Arial,sans-serif;line-height:1.6;margin-top:64px}
.rsft a{text-decoration:none;transition:color .14s}
.rsft-in{max-width:1060px;margin:0 auto;padding:46px 26px 0;display:grid;grid-template-columns:1.7fr 1fr 1fr 1fr;gap:32px}
.rsft-bm{display:inline-flex;align-items:center;gap:9px;font-family:'IBM Plex Serif',Georgia,serif;font-weight:700;font-size:18px;color:#fff}
.rsft-mk{position:relative;display:inline-flex;align-items:center;justify-content:center;font-family:'Inter Tight','Inter','IBM Plex Sans',sans-serif;font-weight:700;font-size:22px;line-height:1;color:#fff;letter-spacing:-.04em;padding-right:.16em}.rsft-mk::after{content:'';position:absolute;right:0;bottom:.06em;width:.2em;height:.2em;border-radius:50%;background:#33ab70}
.rsft-tag{margin:14px 0 16px;color:#aeb9d4;font-size:13.5px;max-width:300px;line-height:1.6}
.rsft-soc{display:flex;gap:10px}
.rsft-soc a{min-width:34px;height:34px;padding:0 10px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;background:rgba(255,255,255,.06);color:#eef2fb;border:1px solid rgba(255,255,255,.10);font-size:12px;font-weight:600}
.rsft-soc a:hover{background:rgba(255,255,255,.13)}
.rsft-col h4{font-size:12px;letter-spacing:.1em;text-transform:uppercase;color:#eef2fb;margin:4px 0 14px;font-weight:600}
.rsft-col a{display:block;color:#aeb9d4;margin-bottom:10px;font-size:13.5px}
.rsft-col a:hover{color:#fff}
.rsft-bot{max-width:1060px;margin:30px auto 0;padding:18px 26px;border-top:1px solid rgba(255,255,255,.10);display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap;font-size:12.5px;color:#8a96b5}
.rsft-bot a{color:#8a96b5}.rsft-bot a:hover{color:#fff}
@media(max-width:720px){.rsft-in{grid-template-columns:1fr 1fr}.rsft-brandcol{grid-column:1/-1}}
</style>
<footer class="rsft" role="contentinfo">
<div class="rsft-in">
<div class="rsft-brandcol">
<a class="rsft-bm" href="/"><span class="rsft-mk">R</span>r-statistics<span style="color:#7da2ff">.co</span></a>
<p class="rsft-tag">Learn R and statistics the practical way: runnable tutorials, auto-graded exercises, free tools, and shareable certificates.</p>
<div class="rsft-soc"><a href="/feed.xml" aria-label="RSS feed">RSS</a><a href="https://github.com/selva86" rel="noopener" aria-label="GitHub">GitHub</a></div>
</div>
<div class="rsft-col"><h4>Explore</h4><a href="/posts/">All Tutorials</a><a href="/tools/">All Tools</a><a href="/about/">About</a></div>
<div class="rsft-col"><h4>Popular tools</h4><a href="/tools/t-test-calculator.html">t-Test Calculator</a><a href="/tools/ab-test-calculator.html">A/B Test Calculator</a><a href="/tools/confidence-interval-calculator.html">Confidence Intervals</a></div>
<div class="rsft-col"><h4>Site</h4><a href="/pricing.html">Pricing</a><a href="/feedback.html">Feedback</a><a href="/privacy.html">Privacy</a><a href="/terms-of-service.html">Terms</a></div>
</div>
<div class="rsft-bot">
<span>© 2016-2026 r-statistics.co</span>
<span>Content licensed under <a href="https://creativecommons.org/licenses/by-nc/3.0/" rel="noopener">CC BY-NC 3.0</a></span>
</div>
</footer>
<!-- /SITE-FOOTER-V2 -->
<script src="//code.jquery.com/jquery.js"></script>
<script src="www/bootstrap.min.js"></script>
<script src="www/toc.js?v=5"></script>
<!-- MathJax Script -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- Google Analytics (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-D5XKCMN7FR"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-D5XKCMN7FR');
</script>
<style type="text/css">
/* reduce spacing around math formula*/
.MathJax_Display {
margin: 0em 0em;
}
body {
font-family: 'Helvetica Neue', Roboto, Arial, sans-serif;
font-size: 16px;
line-height: 27px;
font-weight: 400;
}
blockquote p {
line-height: 1.75;
color: #717171;
}
.well li{
line-height: 28px;
}
li.dropdown-header {
display: block;
padding: 0px;
font-size: 14px;
}
</style>
<script>
(function(){function w(){var t=document.querySelectorAll('.sidebar-tab'),p=document.querySelectorAll('.sidebar-panel');if(!t.length||!p.length)return false;function a(n){t.forEach(function(x){x.classList.toggle('active',x.getAttribute('data-tab')===n)});p.forEach(function(x){x.classList.toggle('active',x.getAttribute('data-panel')===n)})}var tp=location.pathname.indexOf('/tools/')===0;if(tp){a('tools')}else{try{var pin=localStorage.getItem('rstat_sidebar_tab');if(pin==='tools'||pin==='posts')a(pin)}catch(e){}}t.forEach(function(x){if(x.dataset.wired)return;x.dataset.wired='1';x.addEventListener('click',function(){var n=x.getAttribute('data-tab');a(n);try{localStorage.setItem('rstat_sidebar_tab',n)}catch(e){}})});return true}if(!w()){if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',w);else setTimeout(w,50)}})();
</script> <!-- Cloudflare Web Analytics (cookieless; no consent required) -->
<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "edf7e3d50c3e4130a913e7f144643624"}'></script>
<script>(function(){var b=document.getElementById('mobile-menu-btn'),o=document.getElementById('mobile-sidebar'),c=document.getElementById('mobile-sidebar-close'),mc=document.getElementById('mobile-sidebar-content');function op(){var s=document.getElementById('sidebar-nav');if(s&&mc&&!mc.children.length)mc.innerHTML=s.innerHTML;o&&o.classList.add('open');}b&&b.addEventListener('click',op);c&&c.addEventListener('click',function(){o.classList.remove('open');});o&&o.addEventListener('click',function(e){if(e.target===o)o.classList.remove('open');});var d=document.getElementById('dark-mode-toggle');try{if(localStorage.getItem('rstat_dark')==='1')document.documentElement.classList.add('dark');}catch(e){}d&&d.addEventListener('click',function(){var on=document.documentElement.classList.toggle('dark');try{localStorage.setItem('rstat_dark',on?'1':'0');}catch(e){}});})();</script>
<script defer src="/www/auth-hydrate.js?v=11"></script><script defer src="/www/practice-nav.js?v=6"></script><script defer src="/www/persona-menu.js?v=5"></script>
<script defer src="/www/google-onetap.js?v=1"></script><script defer src="/www/signin-nudge.js?v=15"></script><script defer src="/www/xp-chip.js?v=1"></script>
</body>
</html>