-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVisualize_data.html
More file actions
561 lines (527 loc) · 52.9 KB
/
Copy pathVisualize_data.html
File metadata and controls
561 lines (527 loc) · 52.9 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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.2.269">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Deepsha Menghani and Riesling Meyer">
<meta name="dcterms.date" content="2023-02-24">
<meta name="description" content="This article shows the different data analysis possible through the Ravelry API">
<title>Gaining insights using Ggplot2 for an end-to-end data science portfolio project</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script src="Visualize_data_files/libs/clipboard/clipboard.min.js"></script>
<script src="Visualize_data_files/libs/quarto-html/quarto.js"></script>
<script src="Visualize_data_files/libs/quarto-html/popper.min.js"></script>
<script src="Visualize_data_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="Visualize_data_files/libs/quarto-html/anchor.min.js"></script>
<link href="Visualize_data_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="Visualize_data_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="Visualize_data_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="Visualize_data_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="Visualize_data_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script src="Visualize_data_files/libs/htmlwidgets-1.5.4/htmlwidgets.js"></script>
<link href="Visualize_data_files/libs/datatables-css-0.0.0/datatables-crosstalk.css" rel="stylesheet">
<script src="Visualize_data_files/libs/datatables-binding-0.25/datatables.js"></script>
<script src="Visualize_data_files/libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<link href="Visualize_data_files/libs/dt-core-1.11.3/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="Visualize_data_files/libs/dt-core-1.11.3/css/jquery.dataTables.extra.css" rel="stylesheet">
<script src="Visualize_data_files/libs/dt-core-1.11.3/js/jquery.dataTables.min.js"></script>
<link href="Visualize_data_files/libs/crosstalk-1.2.0/css/crosstalk.min.css" rel="stylesheet">
<script src="Visualize_data_files/libs/crosstalk-1.2.0/js/crosstalk.min.js"></script>
</head>
<body class="fullcontent">
<header id="title-block-header" class="quarto-title-block default page-columns page-full">
<div class="quarto-title-banner page-columns page-full">
<div class="quarto-title column-body">
<h1 class="title">Gaining insights using Ggplot2 for an end-to-end data science portfolio project</h1>
<div>
<div class="description">
This article shows the different data analysis possible through the Ravelry API
</div>
</div>
</div>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Author</div>
<div class="quarto-title-meta-contents">
<p>Deepsha Menghani and Riesling Meyer </p>
</div>
</div>
<div>
<div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents">
<p class="date">February 24, 2023</p>
</div>
</div>
</div>
</header><div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<main class="content quarto-banner-title-block" id="quarto-document-content">
<div class="cell" data-layout-align="center" data-paged.print="false">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># For EDA</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyverse)</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(DT)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(lubridate)</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyquant)</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(viridis)</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(thematic)</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidytext)</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(magick)</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggimage)</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(cropcircles)</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="co"># For interacting between python and R</span></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(reticulate)</span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="co"># For storing any secret keys required by API calls</span></span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(dotenv)</span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a><span class="fu">source</span>(<span class="st">"./data_cleaning_functions.R"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><a href="https://medium.com/@menghani.deepsha">Deepsha Menghani</a> and <a href="https://medium.com/@rieslingfyi">Riesling Walker</a> worked together on a Microsoft Global Hackathon project to analyze data around a common passion using Python and R. Through this work, we wanted to create an end-to-end data science portfolio project that highlights our ability to learn relevant techniques for different parts of the project and drives data-based decisions.</p>
<section id="portfolio-project-goal" class="level3">
<h3 class="anchored" data-anchor-id="portfolio-project-goal">Portfolio project goal</h3>
<p>A portfolio project allows you to demonstrate your abilities as a data scientist through practical examples. Our goal with this project was to build and showcase the following skills:</p>
<p>1. Pulling data with API calls in Python using Flask.</p>
<p>2. Accessing the output of Python API calls from R easily using Reticulate.</p>
<p>3. Analyzing our project data using Ggplot2 in R and wrapping the portfolio project with data-driven insights.</p>
<p>This is the final article in a three-part series aimed at going in-depth into each of the above steps within our project. You can find the first article in the series <a href="https://medium.com/data-science-at-microsoft/how-to-access-an-api-for-first-time-api-users-879002f5f58d?source=friends_link&sk=c2763957800727392111bfe47da08fb3">here</a>, which provides a handy overview of APIs and a step-by-step guide on how to use APIs in Python for first-time API users. The second article in the series found <a href="https://medium.com/data-science-at-microsoft/collaborating-between-python-and-r-using-reticulate-25246b367957?source=friends_link&sk=9ad8362575bbd914f0e1f5a8c26ba257">here</a> goes over how we used Reticulate to call Python functions in R to get the relevant data into data frames for visualization using ggplot2 along with numerous debugging examples. Finally, this article focuses on how we asked relevant questions from our data that are centered around the primary business decision we are trying to drive.</p>
</section>
<section id="project-details" class="level3">
<h3 class="anchored" data-anchor-id="project-details">Project details</h3>
<p>For a portfolio project, we wanted to pick something that allowed us to build and showcase the skills noted above as well as have fun exploring data around our common hobby. So, we decided to use our data science skills to analyze our knitting queues on <a href="https://www.ravelry.com/groups/ravelry-api">Ravelry</a>, a social networking and organizational website for yarn-related crafts.</p>
<p>Ravelry has an API that enables access to its data. If you would like to execute this project end to end on your own, you will need to generate your own <a href="https://www.ravelry.com/groups/ravelry-api">Ravelry API credentials</a>. This step is very quick.</p>
</section>
<section id="where-to-find-the-code-files" class="level3">
<h3 class="anchored" data-anchor-id="where-to-find-the-code-files">Where to find the code files</h3>
<p>You can find the code to recreate everything in this article at this <a href="https://github.com/deepshamenghani/R_Python_Reticulate">Github repo</a>.</p>
</section>
<section id="our-primary-business-decision" class="level3">
<h3 class="anchored" data-anchor-id="our-primary-business-decision">Our primary business decision</h3>
<p>With the Ravelry API providing knitting queue data, we wanted to use analytics to figure out what yarn to buy for a friend as a gift. With this business decision in mind, we took the following steps.</p>
<p>Note that this specific project was a one-time analysis. However, it could be expanded to build a yarn recommendation engine to recommend yarn quantities and weight for any given Ravelry username.</p>
<section id="step-1-sourcing-data-from-the-ravelry-api-in-python" class="level4">
<h4 class="anchored" data-anchor-id="step-1-sourcing-data-from-the-ravelry-api-in-python">Step 1: Sourcing data from the Ravelry API in Python</h4>
<p>Using the Ravelry API through Flask in Python, we defined functions that output relevant information.</p>
<p>For more information about what APIs are, how to get started with APIs, and the steps we took to build our function calls (along with great knitting photos), you can see our first <a href="https://medium.com/data-science-at-microsoft/how-to-access-an-api-for-first-time-api-users-879002f5f58d">article</a>, which also serves as a how-to guide for first-time API users.</p>
</section>
<section id="step-2-calling-python-functions-from-r-to-enable-exploratory-data-analysis-with-ggplot2" class="level4">
<h4 class="anchored" data-anchor-id="step-2-calling-python-functions-from-r-to-enable-exploratory-data-analysis-with-ggplot2">Step 2: Calling Python functions from R to enable exploratory data analysis with ggplot2</h4>
<p>With the completed execution of the API calls that returned data as a Python data frame, we wanted to pull that data into R so that we cold analyze it using ggplot2. </p>
<p>Reticulate makes it extremely easy to collaborate and talk between the two languages of Python and R. In this step, we used Reticulate to call Python functions in R to get the relevant data into R data frames that we could then use to visualize using ggplot2. Additionally, we combined datasets over multiple pages using purr mapping functions, bypassed errors using possibly, and mitigated other bugs and quirks that we encountered while using APIs and combining R and Python.</p>
<p>For a more detailed explanation of why we chose two languages for this portfolio project, and for more details about this step along with code, please see our article <a href="https://medium.com/data-science-at-microsoft/collaborating-between-python-and-r-using-reticulate-25246b367957?source=friends_link&sk=9ad8362575bbd914f0e1f5a8c26ba257">here</a>.</p>
</section>
<section id="step-3-data-exploration-and-recommendation" class="level4">
<h4 class="anchored" data-anchor-id="step-3-data-exploration-and-recommendation">Step 3: Data exploration and recommendation</h4>
<p>With our data now in R, it's easy to explore using summary statistics and data visualizations using ggplot2. Using this information, we can draw conclusions about what kind of yarn to buy for a friend.</p>
<p>In this article, we focus on the questions we tried to answer through the data available to us, specifically to drive our business decision.</p>
<blockquote class="blockquote">
<p>Business case</p>
</blockquote>
<p>For the sake of this "business case" of buying yarn for a friend, Deepsha is looking to buy Riesling some yarn and is comparing their individual queuing patterns to gain insight.</p>
<p>With so much data available through the API, it was necessary to differentiate between doing a merely interesting versus truly impactful analysis, an ability that comes in handy for all our data science projects.</p>
<p>Our Ravelry usernames are "rieslingm" and "yarnsandcoffee". For our visualizations, we plotted the Ravelry behavior of both of us as users to be able to compare, although this analysis could have been done with only one username. We refer to these usernames as "Riesling" and "Deepsha" in all visualizations for readability.</p>
<blockquote class="blockquote">
<p>Cleaning the data</p>
</blockquote>
<p>First, we cleaned the data to ensure the columns were in the right formats and the data was ready to make our visuals. Some examples of this included simplifying yarn weight categories, clarifying labels and descriptions, parsing relevant information like pattern author, and combining Deepsha and Riesling's projects into one table. This cleaned up table is called 'projects_queued', and the code below for the plots reference this table.</p>
<p>Note: You can check out the code to clean the data at this <a href="https://github.com/deepshamenghani/R_Python_Reticulate">GitHub repo</a>; in this article we share the code for specifically creating the plots.</p>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
</div>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
<div class="cell-output-display">
<div id="htmlwidget-8afe5a356414928171b6" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-8afe5a356414928171b6">{"x":{"filter":"none","vertical":false,"data":[["1","2","3","4"],["Riesling","Deepsha","Deepsha","Deepsha"],["2022-05-01","2022-04-30","2022-04-30","2022-04-29"],["Double thick hat","Just Like Heaven Sweater","The All That Tee","Mapala Sweater Mohair Edition"],["Kareema Ali","ShanaKay Salmon","ShanaKay Salmon","rosa p."],["Child","Pullover","Tee","Pullover"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th> <\/th>\n <th>username<\/th>\n <th>created_at<\/th>\n <th>pattern<\/th>\n <th>pattern_author.name<\/th>\n <th>pattern_type.name<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"columnDefs":[{"orderable":false,"targets":0}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
<p><br></p>
<blockquote class="blockquote">
<p>Question: Is Riesling still active?</p>
</blockquote>
<p>While Deepsha knows that Riesling uses Ravelry, Deepsha wants to know whether Riesling has recently continued to add projects to her knitting queue before Deepsha jumps into analyzing Riesling's queue. To confirm that, Deepsha plotted their number of queued projects over time.</p>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>patterns_added_by_date_tbl <span class="ot"><-</span> data_cleaned <span class="sc">%>%</span> </span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">count</span>(username,month_year) </span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>patterns_added_by_date_plot <span class="ot"><-</span> patterns_added_by_date_tbl <span class="sc">%>%</span> </span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(month_year, n, <span class="at">color =</span> username, <span class="at">label =</span> username)) <span class="sc">+</span> </span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">stat_smooth</span>(<span class="at">inherit.aes =</span> <span class="cn">TRUE</span>, <span class="at">se =</span> <span class="cn">FALSE</span>, <span class="at">span =</span> <span class="fl">0.3</span>, <span class="at">show.legend =</span> <span class="cn">TRUE</span>) <span class="sc">+</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_date</span>(<span class="at">date_labels =</span> <span class="st">"%b-%y"</span>, <span class="at">breaks =</span> <span class="st">"3 month"</span>) <span class="sc">+</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_tq</span>() <span class="sc">+</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(</span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.text.x =</span> <span class="fu">element_text</span>(<span class="at">angle =</span> <span class="dv">45</span>, <span class="at">hjust =</span> <span class="dv">1</span>),</span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.title.y =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.title.x =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a> <span class="at">panel.grid =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.position =</span> <span class="st">"none"</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">title =</span> <span class="st">"Count of patterns added to queue"</span>) <span class="sc">+</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_color_tq</span>() <span class="sc">+</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> geomtextpath<span class="sc">::</span><span class="fu">geom_textpath</span>(<span class="at">size =</span> <span class="dv">5</span>, <span class="at">text_only =</span> <span class="cn">TRUE</span>, <span class="at">text_smoothing =</span> <span class="dv">50</span>, <span class="at">padding =</span> <span class="fu">unit</span>(<span class="fl">0.05</span>, <span class="st">"inch"</span>), <span class="at">vjust=</span><span class="sc">-</span><span class="fl">0.5</span>)</span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a>patterns_added_by_date_plot</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Visualize_data_files/figure-html/unnamed-chunk-2-1.png" class="img-fluid figure-img" width="576"></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
</div>
<p>It is interesting to note that both Deepsha and Riesling had a "pandemic year" hobby jump. It is more relevant, though, that Riesling has continued to add projects to her queue recently, so Deepsha can analyze her more recent projects to figure out a perfect yarn gift.</p>
<blockquote class="blockquote">
<p>Question: What yarn weight does Riesling like now?</p>
</blockquote>
<p>Yarn weight describes the thickness of yarn. While looking for a gift, it is important for Deepsha to figure out what yarn weight she should get for Riesling as that varies a lot between projects. For this, Deepsha looked at five of the most common yarn weight categories ranging from very thin yarn (Lace weight) to very thick yarn (Bulky weight).</p>
<p>She looked at Riesling's queued projects and the yarn weight that these projects require. She also wanted to understand whether Riesling's preferences for projects with specific yarn weights have evolved over time. For this she calculated the percentage of projects added with each of these yarn weights and then plotted how that percentage changed over time.</p>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>yarn_weights_over_time <span class="ot"><-</span> <span class="fu">yarn_weights_clean_func</span>(data_cleaned) </span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>label_data <span class="ot"><-</span> yarn_weights_over_time <span class="sc">%>%</span> </span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(quarter_year <span class="sc">==</span> <span class="fu">as.Date</span>(<span class="st">"2022-04-01"</span>)) <span class="sc">%>%</span> </span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">arrange</span>(username, <span class="fu">desc</span>(yarn_weight_category)) <span class="sc">%>%</span> </span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(username) <span class="sc">%>%</span> </span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">yend =</span> <span class="fu">cumsum</span>(percentage)) <span class="sc">%>%</span> </span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ystart =</span> <span class="fu">lag</span>(yend)) <span class="sc">%>%</span> </span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">ungroup</span>() <span class="sc">%>%</span> </span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(username <span class="sc">==</span> <span class="st">"Riesling"</span> <span class="sc">&</span> yarn_category <span class="sc">==</span> <span class="st">"DK"</span> <span class="sc">|</span> username <span class="sc">==</span> <span class="st">"Deepsha"</span> <span class="sc">&</span> yarn_category <span class="sc">==</span> <span class="st">"Fingering"</span>) <span class="sc">%>%</span> </span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">perc_label =</span> <span class="fu">str_glue</span>(<span class="st">"{scales::percent(percentage)} </span><span class="sc">\n</span><span class="st"> {yarn_category} "</span>)) </span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a>yarn_weights_plot <span class="ot"><-</span> yarn_weights_over_time <span class="sc">%>%</span> </span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x=</span>quarter_year, <span class="at">y=</span>percentage, <span class="at">fill=</span>yarn_weight_category)) <span class="sc">+</span> </span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_area</span>(<span class="at">color =</span> <span class="st">"black"</span>, <span class="at">alpha=</span><span class="fl">0.4</span>) <span class="sc">+</span></span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span> username, <span class="at">scales =</span> <span class="st">"free_x"</span>) <span class="sc">+</span></span>
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_viridis</span>(<span class="at">discrete =</span> T) <span class="sc">+</span></span>
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span></span>
<span id="cb3-19"><a href="#cb3-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_date</span>(<span class="at">date_labels =</span> <span class="st">"%b-%y"</span>, <span class="at">breaks =</span> <span class="fu">seq</span>(<span class="fu">as.Date</span>(<span class="st">"2020-09-01"</span>), <span class="fu">as.Date</span>(<span class="st">"2022-08-01"</span>),<span class="at">by =</span> <span class="st">"20 month"</span>), <span class="at">limits =</span> <span class="fu">c</span>(<span class="fu">as.Date</span>(<span class="st">"2020-05-01"</span>), <span class="fu">as.Date</span>(<span class="st">"2022-08-01"</span>))) <span class="sc">+</span></span>
<span id="cb3-20"><a href="#cb3-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(</span>
<span id="cb3-21"><a href="#cb3-21" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.text.x =</span> <span class="fu">element_text</span>(<span class="at">angle =</span> <span class="dv">0</span>, <span class="at">hjust =</span> <span class="dv">1</span>), <span class="at">axis.title.y =</span> <span class="fu">element_blank</span>(), <span class="at">axis.title.x =</span> <span class="fu">element_blank</span>(), <span class="at">legend.position =</span> <span class="st">"bottom"</span>, <span class="at">panel.grid =</span> <span class="fu">element_blank</span>(), <span class="at">text =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">15</span>), <span class="at">strip.text.x =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">20</span>)) <span class="sc">+</span></span>
<span id="cb3-22"><a href="#cb3-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">title =</span> <span class="st">"Percantage of yarn weight (thickness) added to queue over time"</span>, <span class="at">caption =</span> <span class="st">"Lace (thinnest) to Bulky (thickest)"</span>, <span class="at">fill =</span> <span class="st">"Yarn thickness"</span>) <span class="sc">+</span></span>
<span id="cb3-23"><a href="#cb3-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_y_continuous</span>(<span class="at">labels =</span> scales<span class="sc">::</span>percent) <span class="sc">+</span></span>
<span id="cb3-24"><a href="#cb3-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> label_data <span class="sc">%>%</span> <span class="fu">filter</span>(username <span class="sc">==</span> <span class="st">"Deepsha"</span>), <span class="fu">aes</span>(<span class="at">x =</span> quarter_year, <span class="at">xend =</span> quarter_year, <span class="at">y =</span> ystart, <span class="at">yend=</span> yend), <span class="at">colour =</span> <span class="st">"forestgreen"</span>, <span class="at">size =</span> <span class="dv">2</span>) <span class="sc">+</span></span>
<span id="cb3-25"><a href="#cb3-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> label_data <span class="sc">%>%</span> <span class="fu">filter</span>(username <span class="sc">==</span> <span class="st">"Riesling"</span>), <span class="fu">aes</span>(<span class="at">x =</span> quarter_year, <span class="at">xend =</span> quarter_year, <span class="at">y =</span> ystart, <span class="at">yend=</span> yend), <span class="at">colour =</span> <span class="st">"#008080"</span>, <span class="at">size =</span> <span class="dv">2</span>) <span class="sc">+</span></span>
<span id="cb3-26"><a href="#cb3-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_label</span>(<span class="at">data =</span> label_data, <span class="fu">aes</span>(<span class="at">x =</span> quarter_year, <span class="at">y=</span> yend, <span class="at">label =</span> perc_label), <span class="at">color =</span> <span class="st">"black"</span>, <span class="at">alpha =</span> <span class="fl">0.2</span>, <span class="at">hjust =</span> <span class="sc">-</span><span class="fl">0.1</span>, <span class="at">vjust =</span> <span class="dv">3</span>, <span class="at">size =</span> <span class="dv">4</span>,<span class="at">show.legend =</span> <span class="cn">FALSE</span>)</span>
<span id="cb3-27"><a href="#cb3-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-28"><a href="#cb3-28" aria-hidden="true" tabindex="-1"></a>yarn_weights_plot</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Visualize_data_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid figure-img" width="1152"></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
</div>
<p>Deepsha and Riesling both moved from thicker yarn to thinner yarn as they gained experience. This is the case with a lot of people learning knitting as a new hobby, as they tend to start with thicker yarn to make it easier to pick up the craft.</p>
<p>Unlike Deepsha, who has been queuing a lot more fingering weight yarn lately, Riesling has been queuing more lace and DK weight. So, if Deepsha wants to get a gift for Riesling, rather than her new favorite yarn weight (fingering), she should opt for DK or lace. Good thing she checked the data!</p>
<blockquote class="blockquote">
<p>Question: How much yarn should be in the gift?</p>
</blockquote>
<p>The amount of yarn required to make something can vary drastically between projects. Knitters would rather <em>not</em> get yarn than get too little yarn to accomplish their favorite project. So, it is important for Deepsha to know what type of projects Riesling likes to make, so that she can figure out what quantity of yarn to buy her.</p>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>top_patterns_by_user <span class="ot"><-</span> <span class="fu">top_patterns_clean_func</span>(data_cleaned)</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>top_patterns_plot <span class="ot"><-</span> top_patterns_by_user <span class="sc">%>%</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(pattern_type.name, n, <span class="at">fill =</span> common_flag)) <span class="sc">+</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="at">show.legend =</span> <span class="cn">FALSE</span>, <span class="at">alpha =</span> <span class="dv">1</span>, <span class="at">width =</span> <span class="fl">0.7</span>) <span class="sc">+</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span>username, <span class="at">scales =</span> <span class="st">"free_x"</span>) <span class="sc">+</span></span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_text</span>(<span class="fu">aes</span>(<span class="at">label=</span>n, <span class="at">vjust=</span><span class="sc">-</span><span class="dv">1</span>)) <span class="sc">+</span></span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_reordered</span>() <span class="sc">+</span></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(<span class="st">"gray"</span>,<span class="st">"#008080"</span>)) <span class="sc">+</span></span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(</span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.text.x =</span> <span class="fu">element_text</span>(<span class="at">angle =</span> <span class="dv">45</span>, <span class="at">hjust =</span> <span class="dv">1</span>), <span class="at">axis.text.y =</span> <span class="fu">element_blank</span>(), <span class="at">axis.title.y =</span> <span class="fu">element_blank</span>(), <span class="at">axis.ticks =</span> <span class="fu">element_blank</span>(), <span class="at">panel.grid =</span> <span class="fu">element_blank</span>(), <span class="at">panel.background =</span> <span class="fu">element_rect</span>(<span class="at">fill =</span> <span class="st">"white"</span>), <span class="at">strip.background =</span><span class="fu">element_rect</span>(<span class="at">fill=</span><span class="st">"#008080"</span>, <span class="at">size =</span> <span class="dv">15</span>), <span class="at">strip.text =</span> <span class="fu">element_text</span>(<span class="at">colour =</span> <span class="st">'white'</span>, <span class="at">size =</span> <span class="dv">12</span>)</span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="st">"Number of pattern types added to queue"</span>, <span class="at">x =</span> <span class="cn">NULL</span>,</span>
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"The most common pattern types added by Ravelry User"</span></span>
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">ylim</span>(<span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">300</span>)) </span>
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-19"><a href="#cb4-19" aria-hidden="true" tabindex="-1"></a>top_patterns_plot</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Visualize_data_files/figure-html/unnamed-chunk-6-1.png" class="img-fluid figure-img" width="576"></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
</div>
<p>Deepsha and Riesling have three pattern types in common among their top favorite patterns. Even though Riesling has the most shawls/wraps in her queue, she also has a lot of pullovers. Because Deepsha also has a lot of pullovers, she's probably familiar with how much yarn goes into one of those, so she will be more likely to buy the right yarn quantity for that item.</p>
<blockquote class="blockquote">
<p>Question: What pattern should Deepsha get for Riesling?</p>
</blockquote>
<p>Finally, Deepsha has decided to be extra generous and buy Riesling a gift card for a pattern to use with the new yarn. So, she must figure out which designer to buy a gift card from. For this, Deepsha needed to look at what designer projects are most common in Riesling's queue.</p>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>top_n_authors_tbl <span class="ot"><-</span> <span class="fu">top_authors_clean_func</span>(data_cleaned, <span class="at">top_n =</span> <span class="dv">5</span>)</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>top_n_authors_plot <span class="ot"><-</span> top_n_authors_tbl <span class="sc">%>%</span> </span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(pattern_author.name, n, <span class="at">fill =</span> username)) <span class="sc">+</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_text</span>(<span class="fu">aes</span>(<span class="at">x =</span> pattern_author.name, <span class="at">y =</span> n<span class="sc">+</span><span class="dv">7</span>, <span class="at">label =</span> <span class="fu">str_glue</span>(<span class="st">"{author} ({n})"</span>)), <span class="at">color =</span> <span class="st">"gray2"</span>, <span class="at">size =</span> <span class="dv">8</span>) <span class="sc">+</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="fu">aes</span>(<span class="at">fill =</span> username), <span class="at">show.legend =</span> <span class="cn">FALSE</span>, <span class="at">alpha =</span> .<span class="dv">2</span>, <span class="at">width =</span> .<span class="dv">5</span>) <span class="sc">+</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="at">data =</span> (top_n_authors_tbl <span class="sc">%>%</span> <span class="fu">filter</span>(pattern_author.name <span class="sc">%>%</span> <span class="fu">str_detect</span>(<span class="st">"Andrea"</span>))), <span class="fu">aes</span>(<span class="at">fill =</span> username), <span class="at">show.legend =</span> <span class="cn">FALSE</span>, <span class="at">alpha =</span> .<span class="dv">6</span>, <span class="at">width =</span> .<span class="dv">5</span>) <span class="sc">+</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span>username, <span class="at">scales =</span> <span class="st">"free_y"</span>, <span class="at">nrow =</span> <span class="dv">2</span>) <span class="sc">+</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">coord_flip</span>() <span class="sc">+</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_reordered</span>() <span class="sc">+</span></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_y_continuous</span>(<span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">0</span>)) <span class="sc">+</span></span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span></span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(</span>
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.title.x =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.text.y =</span> <span class="fu">element_blank</span>(), </span>
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.title.y =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb5-17"><a href="#cb5-17" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.text.x =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb5-18"><a href="#cb5-18" aria-hidden="true" tabindex="-1"></a> <span class="at">panel.grid =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb5-19"><a href="#cb5-19" aria-hidden="true" tabindex="-1"></a> <span class="at">text =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">20</span>, <span class="at">color =</span> <span class="st">"gray2"</span>), <span class="at">strip.text.x =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">30</span>, <span class="at">color =</span> <span class="st">"#83919a"</span>, <span class="at">hjust =</span> <span class="dv">0</span>)</span>
<span id="cb5-20"><a href="#cb5-20" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb5-21"><a href="#cb5-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(<span class="st">"#008080"</span>,<span class="st">"yellow4"</span>)) <span class="sc">+</span></span>
<span id="cb5-22"><a href="#cb5-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb5-23"><a href="#cb5-23" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb5-24"><a href="#cb5-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_image</span>(<span class="fu">aes</span>(<span class="at">x =</span> pattern_author.name, <span class="at">y =</span> n, <span class="at">image =</span> <span class="fu">circle_crop</span>(<span class="fu">paste0</span>(<span class="st">"Images/"</span>, author, <span class="st">".jpg"</span>))),</span>
<span id="cb5-25"><a href="#cb5-25" aria-hidden="true" tabindex="-1"></a> <span class="at">asp =</span> <span class="dv">15</span><span class="sc">/</span><span class="dv">8</span>,</span>
<span id="cb5-26"><a href="#cb5-26" aria-hidden="true" tabindex="-1"></a> <span class="at">size =</span> <span class="fl">0.11</span>) <span class="sc">+</span></span>
<span id="cb5-27"><a href="#cb5-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">ylim</span>(<span class="dv">0</span>,<span class="dv">37</span>) </span>
<span id="cb5-28"><a href="#cb5-28" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-29"><a href="#cb5-29" aria-hidden="true" tabindex="-1"></a>top_n_authors_plot</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Visualize_data_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid figure-img" width="1344"></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-layout-align="center" data-fig.showtext="true">
</div>
<p>Deepsha has a few authors to choose from, but she also might take this opportunity to introduce Riesling to her own favorite designer, PetiteKnit! Riesling and Deepsha also have a common pattern author that they both like: Andrea Mowry. Deepsha can decide to give Riesling an Andrea Mowry gift card so they could knit a pattern of hers together!</p>
<blockquote class="blockquote">
<p>The final business decision (drumroll!!!)</p>
</blockquote>
<p>Overall, through this data exploration project, Deepsha now has a lot of information to take to her local yarn store to buy Riesling a wonderful gift! She will likely buy 1,400 yards of DK weight yarn for an Andrea Mowry pullover.</p>
</section>
</section>
<section id="whats-next" class="level3">
<h3 class="anchored" data-anchor-id="whats-next">What's next?</h3>
<p>While Deepsha was able to get the answer to what her friend's favorite yarn is so that she can give Riesling a meaningful gift, there is so much more that is possible with the Ravelry API data. For example:</p>
<p>· Use the above logic to recommend yarn and projects to Ravelry users.</p>
<p>· Understand what day of the week and time of day people are most actively using Ravelry to add projects to their queues.</p>
<p>· Create space on the Ravelry platform for new designers to thrive by enabling them to be discovered through relevant recommendations by their Ravelry friends.</p>
<p>We hope this article inspires you to create a fun portfolio project with the information and learning shared by <a href="https://medium.com/@rieslingfyi">Riesling</a> and <a href="https://medium.com/@menghani.deepsha">Deepsha</a>. If you want to learn how to create your data science portfolio website easily with Quarto, you can check out <a href="https://www.youtube.com/watch?v=xtSFXtDf4cM&t=43s">this talk</a> Deepsha did for Posit PBC (previously RStudio). It has live coding, so make sure to come with some popcorn!</p>
<p>Follow <a href="https://medium.com/@menghani.deepsha">Deepsha</a>, <a href="https://medium.com/@rieslingfyi">Riesling</a>, or <a href="https://medium.com/data-science-at-microsoft">Data Science @ Microsoft</a> (all on Medium.com) to see the previous articles in this series.</p>
<p><br>
</p>
</section>
</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const clipboard = new window.ClipboardJS('.code-copy-button', {
target: function(trigger) {
return trigger.previousElementSibling;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
let tooltip;
if (window.bootstrap) {
button.setAttribute("data-bs-toggle", "tooltip");
button.setAttribute("data-bs-placement", "left");
button.setAttribute("data-bs-title", "Copied!");
tooltip = new bootstrap.Tooltip(button,
{ trigger: "manual",
customClass: "code-copy-button-tooltip",
offset: [0, -8]});
tooltip.show();
}
setTimeout(function() {
if (tooltip) {
tooltip.hide();
button.removeAttribute("data-bs-title");
button.removeAttribute("data-bs-toggle");
button.removeAttribute("data-bs-placement");
}
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
function tippyHover(el, contentFn) {
const config = {
allowHTML: true,
content: contentFn,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start'
};
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
return note.innerHTML;
});
}
const findCites = (el) => {
const parentEl = el.parentElement;
if (parentEl) {
const cites = parentEl.dataset.cites;
if (cites) {
return {
el,
cites: cites.split(' ')
};
} else {
return findCites(el.parentElement)
}
} else {
return undefined;
}
};
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const citeInfo = findCites(ref);
if (citeInfo) {
tippyHover(citeInfo.el, function() {
var popup = window.document.createElement('div');
citeInfo.cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
}
});
</script>
</div> <!-- /content -->
</body></html>