forked from CrumpLab/LabJournalWebsite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Journal.knit.html
971 lines (880 loc) · 53.2 KB
/
Journal.knit.html
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
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Assignments</title>
<script src="site_libs/header-attrs-2.11/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="site_libs/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
pre code {
padding: 0;
}
</style>
<style type="text/css">
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #adb5bd;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script type="text/javascript">
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark it active
menuAnchor.tab('show');
// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
var style = document.createElement('style');
var pt = "padding-top: " + navHeight + "px; ";
var mt = "margin-top: -" + navHeight + "px; ";
var css = "";
// offset scroll position for anchor links (for fixed navbar)
for (var i = 1; i <= 6; i++) {
css += ".section h" + i + "{ " + pt + mt + "}\n";
}
style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
document.head.appendChild(style);
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
@media print {
.toc-content {
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
float: right;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">MyLabJournal</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">Home</a>
</li>
<li>
<a href="Journal.html">Journal</a>
</li>
<li>
<a href="Links.html">Links</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div id="header">
<h1 class="title toc-ignore">Assignments</h1>
</div>
<p>This page will contain all the assignments you submit for the class.</p>
<div id="instructions-for-all-assignments" class="section level3">
<h3>Instructions for all assignments</h3>
<p>I want you to submit your assignment as a PDF, so I can keep a record of what the code looked like that day. I also want you to include your answers on your personal GitHub website. This will be good practice for editing your website and it will help you produce something you can keep after the class is over.</p>
<ol style="list-style-type: decimal">
<li><p>Download the Assignment1.Rmd file from Canvas. You can use this as a template for writing your answers. It’s the same as what you can see on my website in the Assignments tab. Once we’re done with this I’ll edit the text on the website to include the solutions.</p></li>
<li><p>On RStudio, open a new R script in RStudio (File > New File > R Script). This is where you can test out your R code. You’ll write your R commands and draw plots here.</p></li>
<li><p>Once you have finalized your code, copy and paste your results into this template (Assignment 1.Rmd). For example, if you produced a plot as the solution to one of the problems, you can copy and paste the R code in R markdown by using the <code>``{r} ```</code> command. Answer the questions in full sentences and Save.</p></li>
<li><p>Produce a PDF file with your answers. To do this, knit to PDF (use Knit button at the top of RStudio), locate the PDF file in your docs folder (it’s in the same folder as the Rproj), and submit that on on Canvas in Assignment 1.</p></li>
<li><p>Build Website, go to GitHub desktop, commit and push. Now your solutions should be on your website as well.</p></li>
</ol>
</div>
<div id="assignment-1" class="section level1">
<h1>Assignment 1</h1>
<p><strong>Collaborators: Lorem Ipsum. </strong></p>
<p>This assignment is due on Canvas on Monday 9/20 before class, at 10:15 am. Include the name of anyone with whom you collaborated at the top of the assignment.</p>
<div id="problem-1" class="section level3">
<h3>Problem 1</h3>
<p>Install the datasets package on the console below using <code>install.packages("datasets")</code>. Now load the library.</p>
<pre class="r"><code>library(datasets)</code></pre>
<p>Load the USArrests dataset and rename it <code>dat</code>. Note that this dataset comes with R, in the package datasets, so there’s no need to load data from your computer. Why is it useful to rename the dataset?</p>
<p>It is useful to rename datasets because it gives us a shorthand to work with. So in this case, instead of referring to the data with “USArrests” we can ref to it with dat.</p>
<pre class="r"><code>dat <- USArrests</code></pre>
</div>
<div id="problem-2" class="section level3">
<h3>Problem 2</h3>
<p>Use this command to make the state names into a new variable called State.</p>
<pre class="r"><code>dat$state <- tolower(rownames(USArrests))</code></pre>
<p>This dataset has the state names as row names, so we just want to make them into a new variable. We also make them all lower case, because that will help us draw a map later - the map function requires the states to be lower case.</p>
<p>List the variables contained in the dataset <code>USArrests</code>.</p>
<pre class="r"><code>summary(dat)</code></pre>
<pre><code>## Murder Assault UrbanPop Rape
## Min. : 0.800 Min. : 45.0 Min. :32.00 Min. : 7.30
## 1st Qu.: 4.075 1st Qu.:109.0 1st Qu.:54.50 1st Qu.:15.07
## Median : 7.250 Median :159.0 Median :66.00 Median :20.10
## Mean : 7.788 Mean :170.8 Mean :65.54 Mean :21.23
## 3rd Qu.:11.250 3rd Qu.:249.0 3rd Qu.:77.75 3rd Qu.:26.18
## Max. :17.400 Max. :337.0 Max. :91.00 Max. :46.00</code></pre>
<pre class="r"><code>names(dat)</code></pre>
<pre><code>## [1] "Murder" "Assault" "UrbanPop" "Rape"</code></pre>
<p>The four variables are “Murder”, “Assault”, “UrbanPop”, and “Rape” (and the state variable which we created).</p>
</div>
<div id="problem-3" class="section level3">
<h3>Problem 3</h3>
<p>What type of variable (from the DVB chapter) is <code>Murder</code>?</p>
<p>Answer: It is a quantitative variable because this variable is representing some numerical value in relation to a state.</p>
<p>What R Type of variable is it?</p>
<p>Answer: This variable is a character because the word murder itself is represented in a string format.</p>
</div>
<div id="problem-4" class="section level3">
<h3>Problem 4</h3>
<p>What information is contained in this dataset, in general? What do the numbers mean?</p>
<p>Answer: The dataset contains information about murder, assault, and rape. Additionally, it seems to give us some numbers for a states urban population to help see the relation aswell. These numbers show us the relationship with often they are occuring) of these different variables in different states. For example a number for murder is telling it there was some amount of murders within this state (and we can compare this to other states by seeing how much more or less these crimes occur in other states).</p>
</div>
<div id="problem-5" class="section level3">
<h3>Problem 5</h3>
<p>Draw a histogram of <code>Murder</code> with proper labels and title.</p>
<pre class="r"><code>hist(dat$Murder, main = "Histogram of Murder", xlab = "States")</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-5-1.pdf" /><!-- --></p>
</div>
<div id="problem-6" class="section level3">
<h3>Problem 6</h3>
<p>Please summarize <code>Murder</code> quantitatively. What are its mean and median? What is the difference between mean and median? What is a quartile, and why do you think R gives you the 1st Qu. and 3rd Qu.?</p>
<pre class="r"><code> summary(dat$Murder)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.800 4.075 7.250 7.788 11.250 17.400</code></pre>
<p>Min. 1st Qu. Median Mean 3rd Qu. Max. 0.800 4.075 7.250 7.788 11.250 17.400</p>
<p>The mean is 7.788 and the median and 7.250. The mean is the average of the dataset while the median gives us a central value of our dataset. A quartile tells us the variability around the median. So the 1st and 3rd quartiles show us the variability before the median is reached and after the median is reached. R gives us this data to show us where it might be more or less skewed.</p>
</div>
<div id="problem-7" class="section level3">
<h3>Problem 7</h3>
<p>Repeat the same steps you followed for <code>Murder</code>, for the variables <code>Assault</code> and <code>Rape</code>. Now plot all three histograms together. You can do this by using the command <code>par(mfrow=c(3,1))</code> and then plotting each of the three.</p>
<p>Answer (for data on the other two variables) : For assaults, the mean is 170.8 and the median and 159.0.</p>
<p>For rapes, the mean is 21.23 and the median and 20.10.</p>
<pre class="r"><code>summary(dat$Murder)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.800 4.075 7.250 7.788 11.250 17.400</code></pre>
<pre class="r"><code>summary(dat$Assault)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 45.0 109.0 159.0 170.8 249.0 337.0</code></pre>
<pre class="r"><code>summary(dat$Rape)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 7.30 15.07 20.10 21.23 26.18 46.00</code></pre>
<pre class="r"><code>par(mfrow=c(3,1))
hist(dat$Assault, main = "Histogram of Assault", xlab = "States")
hist(dat$Murder, main = "Histogram of Murder", xlab = "States")
hist(dat$Rape, main = "Histogram of Rape", xlab = "States")</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-7-1.pdf" /><!-- --></p>
<p>What does the command par do, in your own words (you can look this up by asking R <code>?par</code>)?</p>
<p>Answer: It helps us combine multiple plots that we created into one big vertical plot.</p>
<p>What can you learn from plotting the histograms together?</p>
<p>Answer: We can see the correlation between the data. If there are some points where there is a peak at the same time then we can generalize and say that state could be more dangerous than others. This could work likewise for the converse situation.</p>
</div>
<div id="problem-8" class="section level3">
<h3>Problem 8</h3>
<p>In the console below (not in text), type <code>install.packages("maps")</code> and press Enter, and then type <code>install.packages("ggplot2")</code> and press Enter. This will install the packages so you can load the libraries.</p>
<p>Run this code:</p>
<pre class="r"><code>library('maps')
library('ggplot2')
ggplot(dat, aes(map_id=state, fill=Murder)) +
geom_map(map=map_data("state")) +
expand_limits(x=map_data("state")$long, y=map_data("state")$lat)</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-8-1.pdf" /><!-- --></p>
<p>What does this code do? Explain what each line is doing.</p>
<p>Answer: The first two lines import the libraries map and ggplot2. Line 154 imports dat wants to define the map id of states with murder. The second line is filling out map with state data.The third line maps it out in a x and y axis so we can see the data in states.</p>
</div>
</div>
<div id="assignment-2" class="section level1">
<h1>Assignment 2</h1>
<div id="problem-1-load-data" class="section level2">
<h2>Problem 1: Load data</h2>
<p>Set your working directory to the folder where you downloaded the data.</p>
<pre class="r"><code>setwd("/Users/akshatshah/Desktop/upenn/crim250/LabJournal")</code></pre>
</div>
<div id="read-the-data" class="section level2">
<h2>Read the data</h2>
<pre class="r"><code>dat <- read.csv(file = 'dat.nsduh.small.1.csv')</code></pre>
<p>What are the dimensions of the dataset?</p>
<pre class="r"><code>dim(dat)</code></pre>
<pre><code>## [1] 171 7</code></pre>
<p>Answer: There are 171 rows and 7 columns in this dataset.</p>
<pre class="r"><code>names(dat)</code></pre>
<pre><code>## [1] "mjage" "cigage" "iralcage" "age2" "sexatract" "speakengl"
## [7] "irsex"</code></pre>
</div>
<div id="problem-2-variables" class="section level2">
<h2>Problem 2: Variables</h2>
<p>Describe the variables in the dataset.</p>
<p>The variables are mjage, ciage, iralcage, age2, sexatract, speakengl, and irsex. They each tell us different things. Mjage tells how old someone was when they first starting using marijuana. Ciage tells how old someone was when they first starting smoking cigs every day. iralcage tells how old someone was when they tried alcohol. age2 tells us hpw old the person currently is. However, this gives us a range because a person could have changes their choice based on previous responses and the questions they say. Irsex tells us their gender. sexatract tells us describes their attraction/sexuality. speakengl tells how well the individual speaks english.</p>
<p>What is this dataset about? Who collected the data, what kind of sample is it, and what was the purpose of generating the data?</p>
<p>This dataset is a survey about national drug use and health. The data is sponsored by the United States Health and Human Services. The sample is a scientific random sample of household addresses. This data gives us a state and nationwide statistics on drug use. This information is used to help with prevention, trend studies, and inform public health policy.</p>
</div>
<div id="problem-3-age-and-gender" class="section level2">
<h2>Problem 3: Age and gender</h2>
<p>What is the age distribution of the sample like? Make sure you read the codebook to know what the variable values mean.</p>
<p>The age distribution is more towards the 13-17 year old range. However, when we look at this data we should understand that it can be more of a range since participants could change their answers based on the decisions on they made or what they see fit.</p>
<p>Do you think this age distribution representative of the US population? Why or why not?</p>
<p>I believe this data not a good representative of the US population. We are looking at a younger population that makes up around 35% of the age distribution. So we are leaving out a large majority that can help us see more trends.</p>
<p>Is the sample balanced in terms of gender? If not, are there more females or males?</p>
<p>I believe this data is pretty balanced. There is a pretty even distribution but for some of the ages we can see that there is a clear majority like for 17.</p>
<p>Use this code to draw a stacked bar plot to view the relationship between sex and age. What can you conclude from this plot?</p>
<pre class="r"><code>tab.agesex <- table(dat$irsex, dat$age2)
barplot(tab.agesex,
main = "Stacked barchart",
xlab = "Age category", ylab = "Frequency",
legend.text = rownames(tab.agesex),
beside = FALSE) # Stacked bars (default)</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-13-1.pdf" /><!-- --></p>
</div>
<div id="problem-4-substance-use" class="section level2">
<h2>Problem 4: Substance use</h2>
<p>For which of the three substances included in the dataset (marijuana, alcohol, and cigarettes) do individuals tend to use the substance earlier?</p>
<pre class="r"><code>summary(dat)</code></pre>
<pre><code>## mjage cigage iralcage age2
## Min. : 7.00 Min. :10.00 Min. : 5.00 Min. : 4.00
## 1st Qu.:14.00 1st Qu.:15.00 1st Qu.:13.00 1st Qu.:13.00
## Median :16.00 Median :17.00 Median :15.00 Median :15.00
## Mean :15.99 Mean :17.65 Mean :14.95 Mean :13.98
## 3rd Qu.:17.50 3rd Qu.:19.00 3rd Qu.:17.00 3rd Qu.:15.00
## Max. :35.00 Max. :50.00 Max. :23.00 Max. :17.00
## sexatract speakengl irsex
## Min. : 1.00 Min. :1.00 Min. :1.000
## 1st Qu.: 1.00 1st Qu.:1.00 1st Qu.:1.000
## Median : 1.00 Median :1.00 Median :1.000
## Mean : 3.07 Mean :1.07 Mean :1.468
## 3rd Qu.: 1.00 3rd Qu.:1.00 3rd Qu.:2.000
## Max. :99.00 Max. :3.00 Max. :2.000</code></pre>
<p>Looking at the summary of the data, we can see on average what is used earlier on. Alcohol seems to be used the earliest at an average of 14.95. Then it is mjage at 15.99 Finally, it is cigage at 17.65.</p>
</div>
<div id="problem-5-sexual-attraction" class="section level2">
<h2>Problem 5: Sexual attraction</h2>
<p>What does the distribution of sexual attraction look like? Is this what you expected?</p>
<pre class="r"><code>table(dat$sexatract)</code></pre>
<pre><code>##
## 1 2 3 4 5 6 99
## 136 16 9 3 3 1 3</code></pre>
<p>We see that the largest amount of people (136) chose 1. Yes, this is what I expected since it is the norm to be heterosexual.</p>
<p>What is the distribution of sexual attraction by gender?</p>
<pre class="r"><code>table(dat$sexatract, dat$irsex)</code></pre>
<pre><code>##
## 1 2
## 1 82 54
## 2 3 13
## 3 0 9
## 4 1 2
## 5 2 1
## 6 1 0
## 99 2 1</code></pre>
<p>By gender, the distribution is the same in that the majority of both gender are attracted to the opposite gender. However, more females chose other options.</p>
</div>
<div id="problem-6-english-speaking" class="section level2">
<h2>Problem 6: English speaking</h2>
<p>What does the distribution of English speaking look like in the sample? Is this what you might expect for a random sample of the US population?</p>
<pre class="r"><code>table(dat$speakengl)</code></pre>
<pre><code>##
## 1 2 3
## 161 8 2</code></pre>
<p>The majority of people chose that they speak english very well. And there were very few who chose well and not well (10 total). This is probably what I would expect since it is the dominant language.</p>
<p>Are there more English speaker females or males?</p>
<pre class="r"><code>table(dat$speakengl, dat$irsex)</code></pre>
<pre><code>##
## 1 2
## 1 84 77
## 2 7 1
## 3 0 2</code></pre>
<p>There are more English speakers who are male than female.</p>
</div>
</div>
<div id="exam-1" class="section level1">
<h1>Exam 1</h1>
<div id="instructions" class="section level2">
<h2>Instructions</h2>
<ol style="list-style-type: lower-alpha">
<li><p>Create a folder in your computer (a good place would be under Crim 250, Exams).</p></li>
<li><p>Download the dataset from the Canvas website (fatal-police-shootings-data.csv) onto that folder, and save your Exam 1.Rmd file in the same folder.</p></li>
<li><p>Download the README.md file. This is the codebook.</p></li>
<li><p>Load the data into an R data frame.</p></li>
</ol>
<pre class="r"><code>dat <- read.csv(file = "Crim 250 - Exam 1/fatal-police-shootings-data.csv")</code></pre>
</div>
<div id="problem-1-10-points" class="section level2">
<h2>Problem 1 (10 points)</h2>
<ol style="list-style-type: lower-alpha">
<li>Describe the dataset. This is the source: <a href="https://github.com/washingtonpost/data-police-shootings" class="uri">https://github.com/washingtonpost/data-police-shootings</a> . Write two sentences (max.) about this.</li>
</ol>
<p>This is a dataset that is compiled by the Washington Post of victims of fatal police shootings. At each row, we are given a victim’s name and data on the situation that was at hand.</p>
<ol start="2" style="list-style-type: lower-alpha">
<li>How many observations are there in the data frame?</li>
</ol>
<pre class="r"><code>dim((dat))</code></pre>
<pre><code>## [1] 6594 17</code></pre>
<p>We know there are 6594 rows and 17 columns. We know that the number of observations are the number of rows. Therefore there are 6593 observations (not including the first row since this is the title of the columns).</p>
<ol start="3" style="list-style-type: lower-alpha">
<li>Look at the names of the variables in the data frame. Describe what “body_camera”, “flee”, and “armed” represent, according to the codebook. Again, only write one sentence (max) per variable.</li>
</ol>
<pre class="r"><code>names(dat)</code></pre>
<pre><code>## [1] "id" "name"
## [3] "date" "manner_of_death"
## [5] "armed" "age"
## [7] "gender" "race"
## [9] "city" "state"
## [11] "signs_of_mental_illness" "threat_level"
## [13] "flee" "body_camera"
## [15] "longitude" "latitude"
## [17] "is_geocoding_exact"</code></pre>
<p>Body camera is a variable that is telling us if an officer was wearing a body camera and if it was recording what happened.</p>
<p>Flee is a variable that was indicating if the victim was moving away, and if they were fleeing this tells us by what method.</p>
<p>Armed is a variable that tells if the officer believe they had some tool that could inflict damage.</p>
<ol start="4" style="list-style-type: lower-alpha">
<li>What are three weapons that you are surprised to find in the “armed” variable? Make a table of the values in “armed” to see the options.</li>
</ol>
<pre class="r"><code>table(dat$armed)</code></pre>
<pre><code>##
## air conditioner
## 207 1
## air pistol Airsoft pistol
## 1 3
## ax barstool
## 24 1
## baseball bat baseball bat and bottle
## 20 1
## baseball bat and fireplace poker baseball bat and knife
## 1 1
## baton BB gun
## 6 15
## BB gun and vehicle bean-bag gun
## 1 1
## beer bottle binoculars
## 3 1
## blunt object bottle
## 5 1
## bow and arrow box cutter
## 1 13
## brick car, knife and mace
## 2 1
## carjack chain
## 1 3
## chain saw chainsaw
## 2 1
## chair claimed to be armed
## 4 1
## contractor's level cordless drill
## 1 1
## crossbow crowbar
## 9 5
## fireworks flagpole
## 1 1
## flashlight garden tool
## 2 2
## glass shard grenade
## 4 1
## gun gun and car
## 3798 12
## gun and knife gun and machete
## 22 3
## gun and sword gun and vehicle
## 1 17
## guns and explosives hammer
## 3 18
## hand torch hatchet
## 1 14
## hatchet and gun ice pick
## 2 1
## incendiary device knife
## 2 955
## knife and vehicle lawn mower blade
## 1 2
## machete machete and gun
## 51 1
## meat cleaver metal hand tool
## 6 2
## metal object metal pipe
## 5 16
## metal pole metal rake
## 4 1
## metal stick microphone
## 3 1
## motorcycle nail gun
## 1 1
## oar pellet gun
## 1 3
## pen pepper spray
## 1 2
## pick-axe piece of wood
## 4 7
## pipe pitchfork
## 7 2
## pole pole and knife
## 3 2
## railroad spikes rock
## 1 7
## samurai sword scissors
## 4 9
## screwdriver sharp object
## 16 14
## shovel spear
## 7 2
## stapler straight edge razor
## 1 5
## sword Taser
## 23 34
## tire iron toy weapon
## 4 226
## unarmed undetermined
## 421 188
## unknown weapon vehicle
## 82 213
## vehicle and gun vehicle and machete
## 8 1
## walking stick wasp spray
## 1 1
## wrench
## 1</code></pre>
<p>I am suprised to see pen, binoculars, and contractor’s level.</p>
</div>
<div id="problem-2-10-points" class="section level2">
<h2>Problem 2 (10 points)</h2>
<ol style="list-style-type: lower-alpha">
<li>Describe the age distribution of the sample. Is this what you would expect to see?</li>
</ol>
<pre class="r"><code>hist(dat$age, main = "Histogram of Age Distribution", xlab = "Age (in years)", xlim = c(0, 100))</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-23-1.pdf" /><!-- --></p>
<p>This distribution is skewed to the right. This isn’t exactly what I expected, (I thought it would be skewed even more to the right.) because I believed that victims would be a lot younger.</p>
<ol start="2" style="list-style-type: lower-alpha">
<li>To understand the center of the age distribution, would you use a mean or a median, and why? Find the one you picked.</li>
</ol>
<pre class="r"><code>summary(dat$age)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 6.00 27.00 35.00 37.12 45.00 91.00 308</code></pre>
<p>I would use mean to understand the center of the age distribution because I don’t believe there are enough outliers/extremes that would skew this result substantially. The mean gives us an average over our data. We can see that the average age of victims for police fatal shootings were 37.12 years old.</p>
<ol start="3" style="list-style-type: lower-alpha">
<li>Describe the gender distribution of the sample. Do you find this surprising?</li>
</ol>
<pre class="r"><code>table(dat$gender)</code></pre>
<pre><code>##
## F M
## 3 293 6298</code></pre>
<p>Within this dataset, there are significantly more men than women (6005 more). This is not surprising because statistics have shown that men have been higher arrest rate than women. Since men have a higher arrest rate than women and more encounters with police, I expected there to be more men than women within this dataset. Additonally, there were 3 blank indexes for this data and it was not taken into account for the calculations above since it is inconclusive.</p>
</div>
<div id="problem-3-10-points" class="section level2">
<h2>Problem 3 (10 points)</h2>
<ol style="list-style-type: lower-alpha">
<li>How many police officers had a body camera, according to news reports? What proportion is this of all the incidents in the data? Are you surprised that it is so high or low?</li>
</ol>
<pre class="r"><code>table(dat$body_camera)</code></pre>
<pre><code>##
## False True
## 5684 910</code></pre>
<p>Only 910 officers had a body camera according to this dataset. This means that only 14% of incidents had a body camera. This is extremely suprising that is so low because people are losing their lives and a proportion of officers have no concrete evidence of the situation due to no body camera.</p>
<ol start="2" style="list-style-type: lower-alpha">
<li>In how many of the incidents was the victim fleeing? What proportion is this of the total number of incidents in the data? Is this what you would expect?</li>
</ol>
<pre class="r"><code>table(dat$flee)</code></pre>
<pre><code>##
## Car Foot Not fleeing Other
## 491 1058 845 3952 248</code></pre>
<p>Out of 6103 incidents that recorded something in the fleeing category, 2151 victims were fleeing. This means about 35% of people who were a victim of a fatal police shooting were fleeing. I suspected a larger proportion of people were fleeing, but this dataset refutes that idea. Additionally, there is 491 indexes of data that are blank for fleeing, so this was removed from the total number of incidents and the proportion since it is inconclusive.</p>
</div>
<div id="problem-4-10-points---answer-only-one-of-these-a-or-b." class="section level2">
<h2>Problem 4 (10 points) - Answer only one of these (a or b).</h2>
<ol style="list-style-type: lower-alpha">
<li>Describe the relationship between the variables “body camera” and “flee” using a stacked barplot. What can you conclude from this relationship?</li>
</ol>
<p><em>Hint 1: The categories along the x-axis are the options for “flee”, each bar contains information about whether the police officer had a body camera (vertically), and the height along the y-axis shows the frequency of that category).</em></p>
<p><em>Hint 2: Also, if you are unsure about the syntax for barplot, run ?barplot in R and see some examples at the bottom of the documentation. This is usually a good way to look up the syntax of R code. You can also Google it.</em></p>
<p><strong>Your answer here.</strong></p>
<ol start="2" style="list-style-type: lower-alpha">
<li>Describe the relationship between age and race by using a boxplot. What can you conclude from this relationship?</li>
</ol>
<p><em>Hint 1: The categories along the x-axis are the race categories and the height along the y-axis is age.</em></p>
<p><em>Hint 2: Also, if you are unsure about the syntax for boxplot, run ?boxplot in R and see some examples at the bottom of the documentation. This is usually a good way to look up the syntax of R code. You can also Google it.</em></p>
<pre class="r"><code>boxplot(dat$age~factor(dat$race), ylab = "Age", xlab = "Race")</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-29-1.pdf" /><!-- --></p>
<p>We see from the data that some races have a slightly lower mean age than others. For examples, the mean age for white people looks to be around 40, while the mean age for black people seems to be about 35. Additionally, some races have a lot more outliers than others. For example, asian people have no outliers while black people have a lot of outliers. It is hard to make a concrete conclusion based on this relationship, but we can observe that there are clear small differences that we can observe (as stated above) from the different races and their ages. Furthermore, the first category simple represent people who did not have a specified age (left blank in the dataset). I did not omit this data because I think it could still be important to see this in relation to the other data.</p>
</div>
<div id="extra-credit-10-points" class="section level2">
<h2>Extra credit (10 points)</h2>
<ol style="list-style-type: lower-alpha">
<li>What does this code tell us?</li>
</ol>
<pre class="r"><code>mydates <- as.Date(dat$date)
head(mydates)
(mydates[length(mydates)] - mydates[1])</code></pre>
<p>This data tells us how long it has been since the first entry within this dataset to the most recent entry within the dataset. We are taking the first index because the 0th index states the name of each column, and we are taking the last index to get the last entry. The difference is 2458 days which is about 6.7 years. This makes sense because this dataset was created in 2015 and we are about 6 and 3/4 years from this time.</p>
<ol start="2" style="list-style-type: lower-alpha">
<li>On Friday, a new report was published that was described as follows by The Guardian: “More than half of US police killings are mislabelled or not reported, study finds.” Without reading this article now (due to limited time), why do you think police killings might be mislabelled or underreported?</li>
</ol>
<p>I believe this is because of bias. Police who have been apart of police killings are going to defend themselves. In order to do so, they might underreport or mislabel the incident in order to save face and justify the actions they took. Additionally, co workers of police who have been apart of such an incident may look to defend each other building even more of a bias.</p>
<ol start="3" style="list-style-type: lower-alpha">
<li>Regarding missing values in problem 4, do you see any? If so, do you think that’s all that’s missing from the data?</li>
</ol>
<p>In problem 4, there were clear missing values (race was not defined). I believe there is more missing from the data. If we were to look closer into the data we can see that sometimes, for example, gender isn’t specified. Additionally, another data that has missing values is fleeing (491 are blank).</p>
</div>
</div>
<div id="exam-2" class="section level1">
<h1>Exam 2</h1>
<div id="instructions-1" class="section level2">
<h2>Instructions</h2>
<ol style="list-style-type: lower-alpha">
<li><p>Create a folder in your computer (a good place would be under Crim 250, Exams).</p></li>
<li><p>Download the dataset from the Canvas website (sim.data.csv) onto that folder, and save your Exam 2.Rmd file in the same folder.</p></li>
<li><p>Data description: This dataset provides (simulated) data about 200 police departments in one year. It contains information about the funding received by the department as well as incidents of police brutality. Suppose this dataset (sim.data.csv) was collected by researchers to answer this question: <strong>“Does having more funding in a police department lead to fewer incidents of police brutality?”</strong></p></li>
<li><p>Codebook:</p></li>
</ol>
<ul>
<li>funds: How much funding the police department received in that year in millions of dollars.</li>
<li>po.brut: How many incidents of police brutality were reported by the department that year.</li>
<li>po.dept.code: Police department code</li>
</ul>
</div>
<div id="problem-1-eda-10-points" class="section level2">
<h2>Problem 1: EDA (10 points)</h2>
<p>Describe the dataset and variables. Perform exploratory data analysis for the two variables of interest: funds and po.brut.</p>
<pre class="r"><code>dat <- read.csv(file = 'sim.data.csv')
names(dat)</code></pre>
<pre><code>## [1] "po.dept.code" "funds" "po.brut"</code></pre>
<pre class="r"><code>summary(dat)</code></pre>
<pre><code>## po.dept.code funds po.brut
## Min. : 1.00 Min. :21.40 Min. : 0.00
## 1st Qu.: 50.75 1st Qu.:51.67 1st Qu.:14.00
## Median :100.50 Median :59.75 Median :19.00
## Mean :100.50 Mean :61.04 Mean :18.14
## 3rd Qu.:150.25 3rd Qu.:72.17 3rd Qu.:22.00
## Max. :200.00 Max. :99.70 Max. :29.00</code></pre>
<pre class="r"><code>dim(dat)</code></pre>
<pre><code>## [1] 200 3</code></pre>
<pre class="r"><code>plot(dat$funds, dat$po.brut, main="Relationship between Police Department Funding (in millions) and Police Bruality (per year)", xlab="Amount of funding", ylab="Number of police brutality incidences per year")</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-31-1.pdf" /><!-- --></p>
<pre class="r"><code>cor(dat$funds, dat$po.brut)</code></pre>
<pre><code>## [1] -0.9854706</code></pre>
<p>The dataset has three different variables consisting of the department code, funds, and police brutality. There are 200 observations of different police departments and the number of incidences where police brutality occurred. We see that on average a department gets around 61 million dollars in funding and will have about 18 incidences of police brutality that year. We can see from the graph that there is a clear decrease in the number of police brutality incidences as the amount of funding goes up. Furthermore, we can see that the correlation between these two values is a -0.98 which indicates there is a extremely strong linear relationship (in this case it is a negative one).</p>
</div>
<div id="problem-2-linear-regression-30-points" class="section level2">
<h2>Problem 2: Linear regression (30 points)</h2>
<ol style="list-style-type: lower-alpha">
<li>Perform a simple linear regression to answer the question of interest. To do this, name your linear model “reg.output” and write the summary of the regression by using “summary(reg.output)”.</li>
</ol>
<pre class="r"><code># Remember to remove eval=FALSE!!
reg.output <- lm(formula = dat$po.brut ~ dat$funds, data = dat)
summary(reg.output)</code></pre>
<pre><code>##
## Call:
## lm(formula = dat$po.brut ~ dat$funds, data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.9433 -0.2233 0.2544 0.5952 1.1803
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 40.543069 0.282503 143.51 <2e-16 ***
## dat$funds -0.367099 0.004496 -81.64 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9464 on 198 degrees of freedom
## Multiple R-squared: 0.9712, Adjusted R-squared: 0.971
## F-statistic: 6666 on 1 and 198 DF, p-value: < 2.2e-16</code></pre>
<p><strong>Your answer here.</strong></p>
<ol start="2" style="list-style-type: lower-alpha">
<li>Report the estimated coefficient, standard error, and p-value of the slope. Is the relationship between funds and incidents statistically significant? Explain.</li>
</ol>
<p>The estimated coefficient for the slope is -0.367 while the estimated coefficient for the intercept is 40.54. The p-value for the slope is less than 2 x 10^-16 (this is the same of the intercept as well). These slope has a standard error of 0.0045 which means that regression we have is very close to the actual value. This means that there exists a linear relationship between the funds and the incidents statically as each of these p-values are less than 0.05. This means that we can reject the null hypothesis and assert that there is a linear relationship.</p>
<ol start="3" style="list-style-type: lower-alpha">
<li>Draw a scatterplot of po.brut (y-axis) and funds (x-axis). Right below your plot command, use abline to draw the fitted regression line, like this:</li>
</ol>
<pre class="r"><code># Remember to remove eval=FALSE!!
plot(dat$funds, dat$po.brut, main="Relationship between Police Department Funding (in millions) and Police Bruality (per year)", xlab="Amount of funding", ylab="Number of police brutality incidences per year")
abline(reg.output, col = "red", lwd=2)</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-33-1.pdf" /><!-- --> Does the line look like a good fit? Why or why not?</p>
<p>For the middle values, the line follows the data precisely. However if we look at the the tail-end of both sides of the data we can see that it isn’t as precise anymore. I believe that this line is an okay fit given it can follow the distribution on average but when it gets to parts of the data where we do not have as much information (the tail ends), the predicted value isn’t as correct.</p>
<ol start="4" style="list-style-type: lower-alpha">
<li>Are the four assumptions of linear regression satisfied? To answer this, draw the relevant plots. (Write a maximum of one sentence per assumption.) If not, what might you try to do to improve this (if you had more time)?</li>
</ol>
<pre class="r"><code>plot(dat$funds, reg.output$residuals, main="Residuals vs. x", xlab="x, Scaled speed", ylab="Residuals")
abline(h = 0, lty="dashed")</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-34-1.pdf" /><!-- --></p>
<pre class="r"><code>plot(reg.output, which=1)</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-34-2.pdf" /><!-- --></p>
<pre class="r"><code>plot(dat$funds, dat$po.brut, main="Relationship between funding and police brutality", xlab = "Amount of funding", ylab = "Number of police brutality incidences per year")</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-34-3.pdf" /><!-- --></p>
<pre class="r"><code>plot(reg.output, which=3)</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-34-4.pdf" /><!-- --></p>
<pre class="r"><code>plot(reg.output, which=5)</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-34-5.pdf" /><!-- --></p>
<pre class="r"><code>plot(reg.output, which=2)</code></pre>
<p><embed src="Journal_files/figure-latex/unnamed-chunk-34-6.pdf" /><!-- --></p>
<p>1.Linearly Assumption: This assumption doesn’t hold because we can clearly see that the red line for the graph on residuals vs fitted is not flat and the residuals vs x has a pattern, therefore this means there is non constant variance.</p>
<p>2.Independence assumption : This doesn’t hold because there is a pattern in our graph for residuals vs x.</p>
<p>3.Equal variance assumption : This assumption probably doesn’t hold because our scale-location plot isn’t straight and there is a pattern with it.</p>
<p>4.Normal Population Assumption : When we look at our normal qq plot, we see that the there is a left skew (the left and the right ends of the tail are lighter and smaller than the normal distribution).</p>
<p>The four assumptions were not satisfied, next time I would try and get more data or I could try and use a different model that would help us see a better relationship, if there exists one.</p>
<ol start="5" style="list-style-type: lower-alpha">
<li>Answer the question of interest based on your analysis.</li>
</ol>
<p>Because our assumptions do not hold, we can’t use this linear regression model to determine if more funding will lead to a decrease of police brutality. This means the results that we obtained to reject the null hypothesis can not be used and it is inconclusive. The results we obtained are misleading.</p>
</div>
<div id="problem-3-data-ethics-10-points" class="section level2">
<h2>Problem 3: Data ethics (10 points)</h2>
<p>Describe the dataset. Considering our lecture on data ethics, what concerns do you have about the dataset? Once you perform your analysis to answer the question of interest using this dataset, what concerns might you have about the results?</p>
<p>This dataset gives us the funding a police department receives and the amount of police brutality that occurs. From our data ethics lecture, an issue we could come across is correlation doesn’t imply causation. So even though we have a very high correlation, this doesn’t necessary mean that the two variables are related. People could potentially look at this correlation and see the regression without realizing that our assumption didn’t hold.</p>
<p>This matters because people could use this data or data like this to push a false narrative that could damage people. This is an important example to see that we have to check everything because if we forget and show some false information it could cause people to believe ideas that are not true.</p>
<p><span class="math display">\[\\[2in]\]</span></p>
</div>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
<script>
$(document).ready(function () {
// temporarily add toc-ignore selector to headers for the consistency with Pandoc
$('.unlisted.unnumbered').addClass('toc-ignore')
// move toc-ignore selectors from section div to header
$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "h1",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = true;
options.smoothScroll = true;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>