forked from saundersg/Statistics-Notebook
-
Notifications
You must be signed in to change notification settings - Fork 3
/
GraphicalSummaries.html
executable file
·3149 lines (3052 loc) · 171 KB
/
GraphicalSummaries.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
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Graphical Summaries</title>
<script src="site_libs/header-attrs-2.14/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/cerulean.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>
<script src="site_libs/htmlwidgets-1.5.4/htmlwidgets.js"></script>
<script src="site_libs/plotly-binding-4.10.0/plotly.js"></script>
<script src="site_libs/typedarray-0.1/typedarray.min.js"></script>
<link href="site_libs/crosstalk-1.2.0/css/crosstalk.min.css" rel="stylesheet" />
<script src="site_libs/crosstalk-1.2.0/js/crosstalk.min.js"></script>
<link href="site_libs/plotly-htmlwidgets-css-2.5.1/plotly-htmlwidgets.css" rel="stylesheet" />
<script src="site_libs/plotly-main-2.5.1/plotly-latest.min.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;
}
.sourceCode {
overflow: visible;
}
</style>
<style type="text/css" data-origin="pandoc">
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
{ background-color: #f8f8f8; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ef2929; } /* Alert */
code span.an { color: #8f5902; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #c4a000; } /* Attribute */
code span.bn { color: #0000cf; } /* BaseN */
code span.cf { color: #204a87; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4e9a06; } /* Char */
code span.cn { color: #000000; } /* Constant */
code span.co { color: #8f5902; font-style: italic; } /* Comment */
code span.cv { color: #8f5902; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #8f5902; font-weight: bold; font-style: italic; } /* Documentation */
code span.dt { color: #204a87; } /* DataType */
code span.dv { color: #0000cf; } /* DecVal */
code span.er { color: #a40000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #0000cf; } /* Float */
code span.fu { color: #000000; } /* Function */
code span.im { } /* Import */
code span.in { color: #8f5902; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #204a87; font-weight: bold; } /* Keyword */
code span.op { color: #ce5c00; font-weight: bold; } /* Operator */
code span.ot { color: #8f5902; } /* Other */
code span.pp { color: #8f5902; font-style: italic; } /* Preprocessor */
code span.sc { color: #000000; } /* SpecialChar */
code span.ss { color: #4e9a06; } /* SpecialString */
code span.st { color: #4e9a06; } /* String */
code span.va { color: #000000; } /* Variable */
code span.vs { color: #4e9a06; } /* VerbatimString */
code span.wa { color: #8f5902; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
for (var j = 0; j < rules.length; j++) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue;
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') continue;
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
<link rel="stylesheet" href="styles.css" type="text/css" />
<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;
}
details > summary > p:only-child {
display: inline;
}
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-bs-toggle="collapse" data-target="#navbar" data-bs-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">Statistics Notebook</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
R Help
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="RCommands.html">R Commands</a>
</li>
<li>
<a href="RMarkdownHints.html">R Markdown Hints</a>
</li>
<li>
<a href="RCheatSheetsAndNotes.html">R Cheatsheets & Notes</a>
</li>
<li>
<a href="DataSources.html">Data Sources</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Describing Data
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="GraphicalSummaries.html">Graphical Summaries</a>
</li>
<li>
<a href="NumericalSummaries.html">Numerical Summaries</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Making Inference
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="MakingInference.html">Making Inference</a>
</li>
<li>
<a href="tTests.html">t Tests</a>
</li>
<li>
<a href="WilcoxonTests.html">Wilcoxon Tests</a>
</li>
<li>
<a href="Kruskal.html">Kruskal-Wallis Test</a>
</li>
<li>
<a href="ANOVA.html">ANOVA</a>
</li>
<li>
<a href="LinearRegression.html">Linear Regression</a>
</li>
<li>
<a href="LogisticRegression.html">Logistic Regression</a>
</li>
<li>
<a href="ChiSquaredTests.html">Chi Squared Tests</a>
</li>
<li>
<a href="PermutationTests.html">Randomization</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Analyses
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="./Analyses/StudentHousing.html">Good Example Analysis</a>
</li>
<li>
<a href="./Analyses/StudentHousingPOOR.html">Poor Example Analysis</a>
</li>
<li>
<a href="./Analyses/Rent.html">Rent</a>
</li>
<li>
<a href="./Analyses/Stephanie.html">Stephanie</a>
</li>
<li>
<a href="./Analyses/t Tests/HighSchoolSeniors.html">High School Seniors</a>
</li>
<li>
<a href="./Analyses/Wilcoxon Tests/RecallingWords.html">Recalling Words</a>
</li>
<li>
<a href="./Analyses/ANOVA/MyTwoWayANOVA.html">My Two-way ANOVA</a>
</li>
<li>
<a href="./Analyses/Kruskal-Wallis Test/Food.html">Food</a>
</li>
<li>
<a href="./Analyses/Linear Regression/MySimpleLinearRegression.html">My Simple Linear Regression</a>
</li>
<li>
<a href="./Analyses/Linear Regression/CarPrices.html">Car Prices</a>
</li>
<li>
<a href="./Analyses/Logistic Regression/MyLogisticRegression.html">My Logistic Regression</a>
</li>
<li>
<a href="./Analyses/Chi Squared Tests/MyChiSquaredTest.html">My Chi-sqaured Test</a>
</li>
</ul>
</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">Graphical Summaries</h1>
</div>
<script type="text/javascript">
function showhide(id) {
var e = document.getElementById(id);
e.style.display = (e.style.display == 'block') ? 'none' : 'block';
}
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>
<hr />
<p>There are many ways to display data. The fundamental idea is that the
graphical depiction of data should communicate the truth the data has to
offer about the situation of interest.</p>
<hr />
<div id="histograms"
class="section level3 tabset tabset-fade tabset-pills">
<h3 class="tabset tabset-fade tabset-pills">Histograms</h3>
<div style="float:left;width:125px;">
<p><img src="GraphicalSummaries_files/figure-html/unnamed-chunk-2-1.png" width="96" /></p>
</div>
<p><strong>1 Quantitative Variable</strong></p>
<div id="overview" class="section level4">
<h4>Overview</h4>
<div style="padding-left:125px;">
<p>Great for showing the distribution of data for a single quantitative
variable when the sample size is large. Dotplots are a good alternative
for smaller sample sizes. Gives a good feel for the <a
href="NumericalSummaries.html#mean">mean</a> and <a
href="NumericalSummaries.html#sd">standard deviation</a> of the
data.</p>
</div>
<hr />
</div>
<div id="r-instructions" class="section level4">
<h4>R Instructions</h4>
<div style="padding-left:125px;">
<div class="tab">
<p><button class="tablinks" onclick="openTab(event, 'BaseHistogram')">Base
R</button>
<button class="tablinks" onclick="openTab(event, 'ggplot2Histogram')">ggplot2</button>
<button class="tablinks" onclick="openTab(event, 'plotlyHistogram')">plotly</button></p>
</div>
<div id="BaseHistogram" class="tabcontent">
<p>
<p>To make a histogram in R use the function:</p>
<p><code>hist(object)</code></p>
<ul>
<li><code>object</code> must be quantitative data. R refers to this as a
“numeric vector.” Usually this will be the column of a dataset accessed
with the <code>$</code> sign by
<code>hist(dataSetName$columnName)</code>.</li>
</ul>
<p>Type <code>?hist</code> in your <strong>R Console</strong> to open
the help file in R.</p>
<p><br/></p>
<p><strong>Example Code</strong></p>
<p>Hover your mouse over the example codes to learn more. Click on them
to see what they create.</p>
<p><em>Basic histogram</em></p>
<a href="javascript:showhide('hist1')">
<div class="hoverchunk">
<p><span class="tooltipr"> hist <span class="tooltiprtext">An R function
“hist” used to create a histogram.</span> </span><span class="tooltipr">
( <span class="tooltiprtext">Parenthesis to begin the function. Must
touch the last letter of the function.</span> </span><span
class="tooltipr"> airquality <span class="tooltiprtext">“airquality” is
a dataset. Type “View(airquality)” in R to see it.</span> </span><span
class="tooltipr"> $ <span class="tooltiprtext">The $ allows us to access
any variable from the airquality dataset.</span> </span><span
class="tooltipr"> Temp <span class="tooltiprtext">“Temp” is a
quantitative variable (numeric vector) from the “airquality”
dataset.</span> </span><span class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the hist
function.</span> </span><span class="tooltipr"> <br />
<span class="tooltiprtext">Press Enter to run the code.</span>
</span><span class="tooltipr" style="float:right;"> … <span
class="tooltiprtext">Click to View Output.</span> </span></p>
</div>
</a>
<div id="hist1" style="display:none;">
<p><img src="GraphicalSummaries_files/figure-html/unnamed-chunk-3-1.png" width="672" /></p>
</div>
<p><br/></p>
<p><em>Change Color</em></p>
<a href="javascript:showhide('hist3')">
<div class="hoverchunk">
<p><span class="tooltipr"> hist(airquality$Temp, <span
class="tooltiprtext">This code was explained in the first example
code.</span> </span><span class="tooltipr"> col=“skyblue” <span
class="tooltiprtext">col= allows us to specify the color of the plot
using a named color. The name of the color must be placed in quotations.
Type “colors()” in R to see color options.</span> </span><span
class="tooltipr"> ) <span class="tooltiprtext">Functions always end with
a closing parenthesis.</span> </span><span class="tooltipr"> <br />
<span class="tooltiprtext">Press Enter to run the code.</span>
</span><span class="tooltipr" style="float:right;"> … <span
class="tooltiprtext">Click to View Output.</span> </span></p>
</div>
</a>
<div id="hist3" style="display:none;">
<p><img src="GraphicalSummaries_files/figure-html/unnamed-chunk-4-1.png" width="672" /></p>
</div>
<p><br/></p>
<p><em>Add Titles</em></p>
<a href="javascript:showhide('hist2')">
<div class="hoverchunk">
<p><span class="tooltipr"> hist(airquality$Temp <span
class="tooltiprtext">This part was explained in the first example
code.</span> </span><span class="tooltipr"> , <span
class="tooltiprtext">The comma allows us to specify optional commands to
the function. The space after the comma is not required. It just looks
nice.</span> </span><span class="tooltipr"> col=“skyblue”<span
class="tooltiprtext">col= allows us to specify the color of the plot
using a named color. The name of the color must be placed in quotations.
Type “colors()” in R to see color options.</span> </span><span
class="tooltipr"> , <span class="tooltiprtext">A comma must always be
used to separate additional commands.</span> </span><span
class="tooltipr"> xlab=“Temperature” <span class="tooltiprtext">xlab=
stands for “x label.” Use it to specify the text to print on the plot
under the x-axis. The desired text must always be in quotations.</span>
</span><span class="tooltipr"> , <span class="tooltiprtext">A comma
must always be used to separate additional commands.</span> </span><span
class="tooltipr"> main=“La Guardia Airport Daily Mean Temperatures”
<span class="tooltiprtext">main= lets us specify the “main” title to be
placed above the plot. The desired text must always be placed in
quotations.</span> </span><span class="tooltipr"> ) <span
class="tooltiprtext">Functions must always end with a closing
parenthesis.</span> </span><span class="tooltipr"> <br />
<span class="tooltiprtext">Press Enter to run the code.</span>
</span><span class="tooltipr" style="float:right;"> … <span
class="tooltiprtext">Click to View Output.</span> </span></p>
</div>
</a>
<div id="hist2" style="display:none;">
<p><img src="GraphicalSummaries_files/figure-html/unnamed-chunk-5-1.png" width="672" /></p>
</div>
</p>
</div>
<div id="ggplot2Histogram" class="tabcontent">
<p>
<p>To make a histogram in R using the ggplot approach, first ensure</p>
<p><code>library(ggplot2)</code></p>
<p>is loaded. Then,</p>
<p><code>ggplot(data, aes(x=column)) +</code></p>
<p> <code>geom_histogram()</code></p>
<ul>
<li><code>data</code> is the name of your dataset.</li>
<li><code>column</code> is a column of data from your dataset that is
quantitative.</li>
<li>The aesthetic helper function <code>aes(x= )</code> is how you tell
the gpplot to make the x-axis become your <code>column</code> of
data.</li>
<li>The geometry helper function <code>geom_histogram()</code> causes
the ggplot to become a histogram.</li>
</ul>
<p><br></p>
<p><strong>Example Code</strong></p>
<p>Hover your mouse over the example codes to learn more. Click on them
to see what they create.</p>
<p><em>Basic Histogram</em></p>
<a href="javascript:showhide('hist1ggplot')">
<div class="hoverchunk">
<p><span class="tooltipr"> ggplot <span class="tooltiprtext">An R
function “ggplot” used to create a framework for a graphic that will
have elements added to it with the <code>+</code> sign.</span>
</span><span class="tooltipr"> ( <span class="tooltiprtext">Parenthesis
to begin the function. Must touch the last letter of the
function.</span> </span><span class="tooltipr"> airquality <span
class="tooltiprtext">“airquality” is a dataset. Type “View(airquality)”
in R to see it.</span> </span><span class="tooltipr"> , <span
class="tooltiprtext">The comma allows us to specify optional commands to
the function. The space after the comma is not required. It just looks
nice.</span> </span><span class="tooltipr"> aes( <span
class="tooltiprtext">The <code>aes</code> or “aesthetics” function
allows you to tell the ggplot how it should appear. This includes things
like what the x-axis or y-axis should become.</span> </span><span
class="tooltipr"> x=Temp <span class="tooltiprtext">“x=” declares which
variable will become the x-axis of the graphic.</span> </span><span
class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the aes
function.</span> </span><span class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the ggplot
function.</span> </span><span class="tooltipr"> + <span
class="tooltiprtext">The addition symbol <code>+</code> is used to add
further elements to the ggplot.</span> </span><br/><span
class="tooltipr"> geom_histogram() <span class="tooltiprtext">The
“geom_histogram()” function causes the ggplot to become a histogram.
There are many other “geom_” functions that could be used.</span>
</span><span class="tooltipr"> <br />
<span class="tooltiprtext">Press Enter to run the code.</span>
</span><span class="tooltipr" style="float:right;"> … <span
class="tooltiprtext">Click to View Output.</span> </span></p>
</div>
</a>
<div id="hist1ggplot" style="display:none;">
<p><img src="GraphicalSummaries_files/figure-html/unnamed-chunk-6-1.png" width="672" /></p>
</div>
<p><br/></p>
<p><em>Change Bin Width and Color</em></p>
<a href="javascript:showhide('hist2ggplot')">
<div class="hoverchunk">
<p><span class="tooltipr"> ggplot <span class="tooltiprtext">An R
function “ggplot” used to create a framework for a graphic that will
have elements added to it with the <code>+</code> sign.</span>
</span><span class="tooltipr"> ( <span class="tooltiprtext">Parenthesis
to begin the function. Must touch the last letter of the
function.</span> </span><span class="tooltipr"> airquality <span
class="tooltiprtext">“airquality” is a dataset. Type “View(airquality)”
in R to see it.</span> </span><span class="tooltipr"> , <span
class="tooltiprtext">The comma allows us to specify optional commands to
the function. The space after the comma is not required. It just looks
nice.</span> </span><span class="tooltipr"> aes( <span
class="tooltiprtext">The <code>aes</code> or “aesthetics” function
allows you to tell the ggplot how it should appear. This includes things
like what the x-axis or y-axis should become.</span> </span><span
class="tooltipr"> x=Temp <span class="tooltiprtext">“x=” declares which
variable will become the x-axis of the graphic.</span> </span><span
class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the aes
function.</span> </span><span class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the ggplot
function.</span> </span><span class="tooltipr"> + <span
class="tooltiprtext">The addition symbol <code>+</code> is used to add
further elements to the ggplot.</span> </span><br/><span
class="tooltipr"> geom_histogram( <span class="tooltiprtext">The
“geom_histogram()” function causes the ggplot to become a histogram.
There are many other “geom_” functions that could be used.</span>
</span><span class="tooltipr"> binwidth=5, <span
class="tooltiprtext">The “binwidth” command controls the width of the
bars in the histogram.</span> </span><span class="tooltipr">
fill=“skyblue”, <span class="tooltiprtext">The “fill” command controls
the color of the insides of each bar.</span> </span><span
class="tooltipr"> color=“black” <span class="tooltiprtext">The “color”
command controls the color of the edges of each bar.</span> </span><span
class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the geom_histogram
function.</span> </span><span class="tooltipr"> <br />
<span class="tooltiprtext">Press Enter to run the code.</span>
</span><span class="tooltipr" style="float:right;"> … <span
class="tooltiprtext">Click to View Output.</span> </span></p>
</div>
</a>
<div id="hist2ggplot" style="display:none;">
<p><img src="GraphicalSummaries_files/figure-html/unnamed-chunk-7-1.png" width="672" /></p>
</div>
<p><br/></p>
<p><em>Add Titles</em></p>
<a href="javascript:showhide('hist3ggplot')">
<div class="hoverchunk">
<p><span class="tooltipr"> ggplot <span class="tooltiprtext">An R
function “ggplot” used to create a framework for a graphic that will
have elements added to it with the <code>+</code> sign.</span>
</span><span class="tooltipr"> ( <span class="tooltiprtext">Parenthesis
to begin the function. Must touch the last letter of the
function.</span> </span><span class="tooltipr"> airquality <span
class="tooltiprtext">“airquality” is a dataset. Type “View(airquality)”
in R to see it.</span> </span><span class="tooltipr"> , <span
class="tooltiprtext">The comma allows us to specify optional commands to
the function. The space after the comma is not required. It just looks
nice.</span> </span><span class="tooltipr"> aes( <span
class="tooltiprtext">The <code>aes</code> or “aesthetics” function
allows you to tell the ggplot how it should appear. This includes things
like what the x-axis or y-axis should become.</span> </span><span
class="tooltipr"> x=Temp <span class="tooltiprtext">“x=” declares which
variable will become the x-axis of the graphic.</span> </span><span
class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the aes
function.</span> </span><span class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the ggplot
function.</span> </span><span class="tooltipr"> + <span
class="tooltiprtext">The addition symbol <code>+</code> is used to add
further elements to the ggplot.</span> </span><br/><span
class="tooltipr"> geom_histogram( <span class="tooltiprtext">The
“geom_histogram()” function causes the ggplot to become a histogram.
There are many other “geom_” functions that could be used.</span>
</span><span class="tooltipr"> binwidth=5, <span
class="tooltiprtext">The “binwidth” command controls the width of the
bars in the histogram.</span> </span><span class="tooltipr">
fill=“skyblue”, <span class="tooltiprtext">The “fill” command controls
the color of the insides of each bar.</span> </span><span
class="tooltipr"> color=“black” <span class="tooltiprtext">The “color”
command controls the color of the edges of each bar.</span> </span><span
class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the geom_histogram
function.</span> </span><span class="tooltipr"> + <span
class="tooltiprtext">The addition symbol <code>+</code> is used to add
further elements to the ggplot.</span> </span><br/><span
class="tooltipr"> labs( <span class="tooltiprtext">The “labs”
function is used to add labels to the plot, like a main title, x-label
and y-label.</span> </span><span class="tooltipr"> title=“La Guardia
Airport Daily Mean Temperature”, <span class="tooltiprtext">The
“title=” command allows you to control the main title at the top of the
graphic.</span> </span><span class="tooltipr"> x=“Temperature”, <span
class="tooltiprtext">The “x=” command allows you to control the x-label
of the graphic.</span> </span><span class="tooltipr"> y=“Number of Days”
<span class="tooltiprtext">The “y=” command allows you to control the
y-label of the graphic.</span> </span><span class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the labs
function.</span> </span><span class="tooltipr"> <br />
<span class="tooltiprtext">Press Enter to run the code.</span>
</span><span class="tooltipr" style="float:right;"> … <span
class="tooltiprtext">Click to View Output.</span> </span></p>
</div>
</a>
<div id="hist3ggplot" style="display:none;">
<p><img src="GraphicalSummaries_files/figure-html/unnamed-chunk-8-1.png" width="672" /></p>
</div>
<p><br/></p>
<p><strong>Gallery</strong></p>
<p>See some ideas from past students…</p>
<p><a href="javascript:showhide('histogramgalleryggplot')">Show/Hide
Gallery</a></p>
<div id="histogramgalleryggplot" style="display:none;">
<p>Hover to see code. Copy the code into R. Play with it. Modify it to
create your own graph.</p>
<p><span class="tooltipgallery">
<img class="gallerygraphs" src="Images/histogramggplotgallery1.png"><br />
<span class="tooltipgallerytext">
<code>ggplot(airquality, aes(x = Temp)) +</code> <br/>
<code>geom_histogram(binwidth=5, fill = "skyblue", color = "black") +</code>
<br/>
<code>labs(title = "La Guardia Airport Daily Mean Temperature",</code>
<br/> <code>x = "Temperature", y = "Number of Days") +</code> <br/>
<code>theme_bw() +</code> <br/>
<code>theme(plot.title = element_text(size = 14, face = "bold", hjust = .5),</code>
<br/> <code>panel.grid.major = element_line(color = "grey80"))</code>
<br/> </span> </span></p>
<p><span class="tooltipgallery">
<img class="gallerygraphs" src="Images/histogramggplotgallery2.png"><br />
<span class="tooltipgallerytext"> <code>ggplot(airquality) +</code>
<br/>
<code>geom_histogram(aes(x = Temp, fill = Temp > median(Temp)), color = "black", binwidth = 2) +</code>
<br/>
<code>labs(title = "La Guardia Airport Daily Mean Temperature",</code>
<br/> <code>x = "Temperature", y = "Number of Days") +</code> <br/>
<code>theme_bw() +</code> <br/>
<code>theme(plot.title = element_text(size = 14, face = "bold", hjust = .5),</code>
<br/> <code>panel.grid.major = element_line(color = "grey80"),</code>
<br/> <code>legend.position = "none") +</code> <br/>
<code>geom_vline(xintercept = 72, linetype = "dashed", size = 1.5, color = "black") +</code>
<br/>
<code>geom_vline(xintercept = 85, linetype = "dashed", size = 1.5, color = "black") +</code>
<br/> <code>geom_text(x = 71, y = 10, label = "Q1") +</code> <br/>
<code>geom_text(x = 86, y = 10, label = "Q3")</code> <br/> </span>
</span></p>
<p><span class="tooltipgallery">
<img class="gallerygraphs" src="Images/histogramggplotgallery3.png"><br />
<span class="tooltipgallerytext">
<code>ggplot(airquality, aes(x = Temp)) +</code> <br/>
<code>geom_histogram(aes(fill = Temp > median(Temp)), color = "black", binwidth = 2) +</code>
<br/>
<code>labs(title = "La Guardia Airport Daily Mean Temperature",</code>
<br/>
<code>x = "Temperature", y = "Number of Days", fill = "Temperature") +</code>
<br/> <code>theme_bw() +</code> <br/>
<code>theme(plot.title = element_text(size = 10, face = "bold", hjust = .5),</code>
<br/>
<code>panel.grid.major = element_line(color = "grey80")) +</code> <br/>
<code>scale_fill_manual(values = c("steelblue2","brown1"),labels=c("< 79 Degrees","> 79 Degrees")) +</code>
<br/>
<code>geom_vline(xintercept = 72, linetype = "dashed", size = 1.5, color = "black") +</code>
<br/>
<code>geom_vline(xintercept = 85, linetype = "dashed", size = 1.5, color = "black") +</code>
<br/> <code>geom_text(x = 71, y = 10, label = "Q1") +</code> <br/>
<code>geom_text(x = 86, y = 10, label = "Q3")</code> <br/> </span>
</span></p>
<p><span class="tooltipgallery">
<img class="gallerygraphs" src="Images/histogramggplotgallery4.png"><br />
<span class="tooltipgallerytext">
<code>ggplot(airquality, aes(x = Temp)) +</code> <br/>
<code>geom_histogram(aes(fill = Temp > median(Temp)), color = "black", binwidth = 3) +</code>
<br/>
<code>labs(title = "Temperature of La Guardia Airport by Month",</code>
<br/>
<code>x = "Temperature", y = "Number of Days", fill = "Temperature") +</code>
<br/> <code>theme_bw() +</code> <br/>
<code>theme(plot.title = element_text(size = 16, face = "bold", hjust = .5),</code>
<br/>
<code>panel.grid.major = element_line(color = "grey80")) +</code> <br/>
<code>scale_fill_manual(values = c("steelblue2","brown1"),labels=c("< 79 Degrees","> 79 Degrees")) +</code>
<br/> <code>facet_grid(~Month) +</code> <br/>
<code>geom_vline(xintercept = 77.88, linetype = "dashed", size = 1.5, color = "black") +</code>
<br/> <code>geom_text(x = 69, y = 10, label = "Mean = \n 77.88")</code>
<br/> </span> </span></p>
</div>
</p>
</div>
<div id="plotlyHistogram" class="tabcontent">
<p>
<p>To make a histogram in plotly first load</p>
<p><code>library(plotly)</code></p>
<p>Then, use the function:</p>
<p><code>plot_ly(dataName, x=~columnName, type="histogram")</code></p>
<ul>
<li><code>dataName</code> is the name of a data set</li>
<li><code>columnName</code> must be the name of a column of quantitative
data. R refers to this as a “numeric vector.”</li>
<li><code>type="histogram"</code> tells the plot_ly(…) function to
create a histogram.</li>
</ul>
<p>Visit <a
href="https://plotly.com/r/histograms/">plotly.com/r/histograms</a> for
more details.</p>
<p><br/></p>
<p><strong>Example Code</strong></p>
<p>Hover your mouse over the example codes to learn more. Click on them
to see what they create.</p>
<p><em>Basic histogram</em></p>
<a href="javascript:showhide('plotlyhist1')">
<div class="hoverchunk">
<p><span class="tooltipr"> plot_ly <span class="tooltiprtext">An R
function “plot_ly” from library(plotly) used to create any plotly
plot.</span> </span><span class="tooltipr"> ( <span
class="tooltiprtext">Parenthesis to begin the function. Must touch the
last letter of the function.</span> </span><span class="tooltipr">
airquality, <span class="tooltiprtext">“airquality” is a dataset. Type
“View(airquality)” in R to see it.</span> </span><span class="tooltipr">
x= <span class="tooltiprtext">The x= allows us to declare which column
of the data set will become the x-axis of the histogram.</span>
</span><span class="tooltipr"> ~Temp, <span
class="tooltiprtext">“Temp” is a quantitative variable (numeric vector)
from the “airquality” dataset. The <code>~</code> is required before
column names inside all plot_ly(…) commands.</span> </span><span
class="tooltipr"> type=“histogram” <span class="tooltiprtext">This
option tells the plot_ly(…) function what “type” of graph to make. In
this case, a histogram.</span> </span><span class="tooltipr"> )<br />
<span class="tooltiprtext">Closing parenthsis for the plot_ly
function.</span> </span><span class="tooltipr"> <br />
<span class="tooltiprtext">Press Enter to run the code.</span>
</span><span class="tooltipr" style="float:right;"> … <span
class="tooltiprtext">Click to View Output.</span> </span></p>
</div>
</a>
<div id="plotlyhist1" style="display:none;">
<div id="htmlwidget-a1f479421eab3b77f503" style="width:672px;height:480px;" class="plotly html-widget"></div>
<script type="application/json" data-for="htmlwidget-a1f479421eab3b77f503">{"x":{"visdat":{"1109e600890f0":["function () ","plotlyVisDat"]},"cur_data":"1109e600890f0","attrs":{"1109e600890f0":{"x":{},"alpha_stroke":1,"sizes":[10,100],"spans":[1,20],"type":"histogram"}},"layout":{"margin":{"b":40,"l":60,"t":25,"r":10},"xaxis":{"domain":[0,1],"automargin":true,"title":"Temp"},"yaxis":{"domain":[0,1],"automargin":true},"hovermode":"closest","showlegend":false},"source":"A","config":{"modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"data":[{"x":[67,72,74,62,56,66,65,59,61,69,74,69,66,68,58,64,66,57,68,62,59,73,61,61,57,58,57,67,81,79,76,78,74,67,84,85,79,82,87,90,87,93,92,82,80,79,77,72,65,73,76,77,76,76,76,75,78,73,80,77,83,84,85,81,84,83,83,88,92,92,89,82,73,81,91,80,81,82,84,87,85,74,81,82,86,85,82,86,88,86,83,81,81,81,82,86,85,87,89,90,90,92,86,86,82,80,79,77,79,76,78,78,77,72,75,79,81,86,88,97,94,96,94,91,92,93,93,87,84,80,78,75,73,81,76,77,71,71,78,67,76,68,82,64,71,81,69,63,70,77,75,76,68],"type":"histogram","marker":{"color":"rgba(31,119,180,1)","line":{"color":"rgba(31,119,180,1)"}},"error_y":{"color":"rgba(31,119,180,1)"},"error_x":{"color":"rgba(31,119,180,1)"},"xaxis":"x","yaxis":"y","frame":null}],"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.20000000000000001,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
</div>
<p><br/></p>
<p><em>Change Color</em></p>
<a href="javascript:showhide('plotlyhist3')">
<div class="hoverchunk">