-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1164 lines (1074 loc) · 114 KB
/
index.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>Baltimore Nonprofit Analysis</title>
<script src="site_libs/header-attrs-2.26/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/cosmo.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.13.2/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/navigation-1.1/codefolding.js"></script>
<script src="site_libs/navigation-1.1/sourceembed.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: #204a87; } /* 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: #8f5902; } /* 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: #204a87; font-weight: bold; } /* 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: #ce5c00; font-weight: bold; } /* 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; }
var j = 0;
while (j < rules.length) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") {
j++;
continue;
}
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') {
j++;
continue;
}
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
<style type="text/css">
#rmd-source-code {
display: none;
}
</style>
<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 the anchor link active (and if it's in a dropdown, also mark that active)
var dropdown = menuAnchor.closest('li.dropdown');
if (window.bootstrap) { // Bootstrap 4+
menuAnchor.addClass('active');
dropdown.find('> .dropdown-toggle').addClass('active');
} else { // Bootstrap 3
menuAnchor.parent().addClass('active');
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, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
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: "\e258";
font-family: 'Glyphicons Halflings';
border: none;
}
.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">
.code-folding-btn { margin-bottom: 4px; }
</style>
<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">Baltimore nonprofits assets analysis</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">Analysis</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div id="header">
<div class="btn-group pull-right float-right">
<button type="button" class="btn btn-default btn-xs btn-secondary btn-sm dropdown-toggle" data-toggle="dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span>Code</span> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right" style="min-width: 50px;">
<li><a id="rmd-download-source" href="#">Download Rmd</a></li>
</ul>
</div>
<h1 class="title toc-ignore">Baltimore Nonprofit Analysis</h1>
</div>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">library</span>(readxl)</span>
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a><span class="fu">library</span>(here)</span>
<span id="cb1-3"><a href="#cb1-3" tabindex="-1"></a><span class="fu">library</span>(tidyverse)</span>
<span id="cb1-4"><a href="#cb1-4" tabindex="-1"></a><span class="fu">library</span>(stringr)</span>
<span id="cb1-5"><a href="#cb1-5" tabindex="-1"></a><span class="fu">library</span>(naniar)</span></code></pre></div>
<div id="data-import" class="section level1">
<h1>Data Import</h1>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a>df_simplified<span class="ot"><-</span><span class="fu">read_excel</span>(here<span class="sc">::</span><span class="fu">here</span>(<span class="st">"Nonprofit_Baltimore_Analysis.xlsx"</span>), <span class="at">sheet =</span> <span class="dv">3</span>)</span></code></pre></div>
<pre><code>## Warning: Expecting numeric in W4084 / R4084C23: got 'of art'</code></pre>
<p>Information about the data: Here’s an <a
href="https://nccs.urban.org/nccs/datasets/bmf/">article</a> describing
some of the datasets from the IRS 990s. We’re using the Business Master
File (BMF). There’s a section titled “Minimum Filing Threshold” that
explains a data limitation (and why we’re seeing so many 0’s). See <a
href="https://www.irs.gov/charities-non-profits/exempt-organizations-annual-reporting-requirements-overview-annual-return-filing-exceptions">here</a>
for more info.</p>
<p>It seems that if there is a value less than 50,000 other than zero,
it must mean that the organization decided to submit to the IRS, because
otherwise they would be listed as a zero. It is not possible to
distinguish a true zero from a zero due to not meeting the threshold of
50,000 and just not submitting. See <a
href="https://github.com/jhudsl/Baltimore_nonprofits_assets/blob/8094191b88bcef6503c132c7cc73408c12ddc916/Guide_to_Using_NCCS_Data_202.pdf">this
guide</a>, page 5 in the “minimum filing threshold” section.</p>
<p>It therefore makes sense to remove zero values and to report this
caveat that the data is incomplete because many nonprofits that had
assets less than 50,000 are not included.</p>
<p>However for the high vs nonhigh asset we could keep these - because
zero values would still be less than the threshold regardless.</p>
<p>Adding to this NA values can be considered less than 50000, as
organizations are not required to report an amount if they have less
than 50000.</p>
</div>
<div id="tidying-data-and-exploratory-analysis" class="section level1">
<h1>Tidying data and Exploratory Analysis</h1>
<div id="asset-amount" class="section level2">
<h2>Asset amount</h2>
<p>First let’s check how many zero values there are for asset
amounts.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a>df_simplified <span class="sc">%>%</span> <span class="fu">filter</span>(ASSET_AMT<span class="sc">==</span><span class="dv">0</span>)<span class="sc">%>%</span> <span class="fu">nrow</span>()</span></code></pre></div>
<pre><code>## [1] 1218</code></pre>
<p>Now we will check if there are <code>NA</code> values for asset
amounts.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" tabindex="-1"></a><span class="fu">gg_miss_var</span>(df_simplified)</span></code></pre></div>
<p><img src="index_files/figure-html/unnamed-chunk-4-1.png" width="672" /></p>
<p>Yes, indeed there are…</p>
<p>NA and zero values likely mean the nonprofit did not need to submit
to the IRS. It is impossible to know however, if a zero is actually a
true zero. NA values could mean something else.</p>
<p>Thus, we will recode asset amount based on a threshold of greater
than or equal to 500,000 as high asset and less than 500,000 (including
zero) as not high asset. Note we keep our NA values with this
recoding.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" tabindex="-1"></a>df_simplified<span class="ot"><-</span>df_simplified <span class="sc">%>%</span></span>
<span id="cb7-2"><a href="#cb7-2" tabindex="-1"></a> <span class="co"># modify Asset amount variable to be numeric</span></span>
<span id="cb7-3"><a href="#cb7-3" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_AMT =</span> <span class="fu">as.numeric</span>(ASSET_AMT)) <span class="sc">%>%</span></span>
<span id="cb7-4"><a href="#cb7-4" tabindex="-1"></a> <span class="co">#create a variable about high asset amount (threshold being $500,000)</span></span>
<span id="cb7-5"><a href="#cb7-5" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_High =</span> <span class="fu">case_when</span>(ASSET_AMT <span class="sc">>=</span> <span class="dv">500000</span> <span class="sc">~</span> <span class="cn">TRUE</span>,</span>
<span id="cb7-6"><a href="#cb7-6" tabindex="-1"></a> ASSET_AMT <span class="sc"><</span> <span class="dv">500000</span> <span class="sc">~</span> <span class="cn">FALSE</span>))</span></code></pre></div>
<p>Here we can see the NA values:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" tabindex="-1"></a><span class="fu">table</span>(df_simplified<span class="sc">$</span>ASSET_High, <span class="at">useNA =</span> <span class="st">"always"</span>)</span></code></pre></div>
<pre><code>##
## FALSE TRUE <NA>
## 1954 761 1368</code></pre>
<p>Now we will replace <code>NA</code> values with <code>False</code> as
well:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" tabindex="-1"></a> df_simplified <span class="ot"><-</span> df_simplified <span class="sc">%>%</span> </span>
<span id="cb10-2"><a href="#cb10-2" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_High =</span> <span class="fu">replace_na</span>(ASSET_High, <span class="cn">FALSE</span>)) <span class="co">#NA values will be coded as not high asset (if no cases match the other two ASSET_AMT statements then code as FALSE) based on the above logic</span></span></code></pre></div>
<p>Check that this worked and that there are no NA values now:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" tabindex="-1"></a><span class="fu">table</span>(df_simplified<span class="sc">$</span>ASSET_High, <span class="at">useNA =</span> <span class="st">"always"</span>)</span></code></pre></div>
<pre><code>##
## FALSE TRUE <NA>
## 3322 761 0</code></pre>
<p>Now we will convert these to text as another variable and also create
a log version of the asset amount to normalize it, as plots and analysis
may be easier to interpret if there are many values that are high or
low.</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" tabindex="-1"></a> df_simplified<span class="ot"><-</span>df_simplified <span class="sc">%>%</span></span>
<span id="cb13-2"><a href="#cb13-2" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_High_text =</span> <span class="fu">case_when</span>(ASSET_High <span class="sc">==</span> <span class="cn">TRUE</span> <span class="sc">~</span> <span class="st">"High Asset"</span>,</span>
<span id="cb13-3"><a href="#cb13-3" tabindex="-1"></a> ASSET_High <span class="sc">==</span> <span class="cn">FALSE</span> <span class="sc">~</span> <span class="st">"Low Asset"</span>)) <span class="sc">%>%</span></span>
<span id="cb13-4"><a href="#cb13-4" tabindex="-1"></a> <span class="co"># we will also create new log of asset amount variable</span></span>
<span id="cb13-5"><a href="#cb13-5" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_AMT_log =</span> <span class="fu">log</span>(ASSET_AMT))</span></code></pre></div>
</div>
<div id="neighborhood-category" class="section level2">
<h2>Neighborhood category</h2>
<p>Next we will modify the data to include a variable about the
percentage of African American/Black people.</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" tabindex="-1"></a><span class="co"># create new Percent_AA variable by converting</span></span>
<span id="cb14-2"><a href="#cb14-2" tabindex="-1"></a><span class="co">#`Normalized African American Population` variable </span></span>
<span id="cb14-3"><a href="#cb14-3" tabindex="-1"></a><span class="co">#into a percentage and rounding</span></span>
<span id="cb14-4"><a href="#cb14-4" tabindex="-1"></a> df_simplified<span class="ot"><-</span>df_simplified <span class="sc">%>%</span></span>
<span id="cb14-5"><a href="#cb14-5" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Percent_AA =</span> </span>
<span id="cb14-6"><a href="#cb14-6" tabindex="-1"></a> <span class="fu">round</span>(<span class="st">`</span><span class="at">Normalized African American Population</span><span class="st">`</span><span class="sc">*</span><span class="dv">100</span>, <span class="at">digits =</span> <span class="dv">1</span>)) <span class="sc">%>%</span></span>
<span id="cb14-7"><a href="#cb14-7" tabindex="-1"></a></span>
<span id="cb14-8"><a href="#cb14-8" tabindex="-1"></a> <span class="co"># create new Majority_AA variable that indicates if Percent_AA is greater than or equal to 50% or not</span></span>
<span id="cb14-9"><a href="#cb14-9" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Majority_AA =</span> <span class="fu">case_when</span>(</span>
<span id="cb14-10"><a href="#cb14-10" tabindex="-1"></a> Percent_AA <span class="sc">>=</span> <span class="dv">50</span> <span class="sc">~</span> <span class="st">"Yes"</span>, </span>
<span id="cb14-11"><a href="#cb14-11" tabindex="-1"></a> Percent_AA <span class="sc"><</span> <span class="dv">50</span> <span class="sc">~</span> <span class="st">"No"</span>)) <span class="sc">%>%</span></span>
<span id="cb14-12"><a href="#cb14-12" tabindex="-1"></a> <span class="co"># create a new variable about this in text</span></span>
<span id="cb14-13"><a href="#cb14-13" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Neighborhood =</span> <span class="fu">case_when</span>(</span>
<span id="cb14-14"><a href="#cb14-14" tabindex="-1"></a> Percent_AA <span class="sc">>=</span> <span class="dv">50</span> <span class="sc">~</span> <span class="st">"Majority</span><span class="sc">\n</span><span class="st">Black"</span>, </span>
<span id="cb14-15"><a href="#cb14-15" tabindex="-1"></a> Percent_AA <span class="sc"><</span> <span class="dv">50</span> <span class="sc">~</span> <span class="st">"Majority</span><span class="sc">\n</span><span class="st">Non-Black"</span>)) <span class="sc">%>%</span> </span>
<span id="cb14-16"><a href="#cb14-16" tabindex="-1"></a> <span class="co"># make this a factor and order by level appearance in the data</span></span>
<span id="cb14-17"><a href="#cb14-17" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Neighborhood =</span> <span class="fu">as_factor</span>(Neighborhood),</span>
<span id="cb14-18"><a href="#cb14-18" tabindex="-1"></a> <span class="at">Neighborhood =</span> forcats<span class="sc">::</span><span class="fu">fct_inorder</span>(Neighborhood))</span></code></pre></div>
</div>
<div id="quantile-data" class="section level2">
<h2>Quantile data</h2>
<p>To group the data by quantiles, we first remove organizations with
zero assets because we don’t know if zero values are real. If assets are
under 50,000, organizations can report as zero also.</p>
<p>Similarly, NA values could be anything between 0 and less than
50,000. Thus we aren’t sure what those asset amounts are.</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" tabindex="-1"></a> <span class="co"># make a new dataframe without zeros and NA asset amounts</span></span>
<span id="cb15-2"><a href="#cb15-2" tabindex="-1"></a>df_simplified_no_zero<span class="ot"><-</span>df_simplified <span class="sc">%>%</span></span>
<span id="cb15-3"><a href="#cb15-3" tabindex="-1"></a> <span class="fu">drop_na</span>(ASSET_AMT) <span class="sc">%>%</span> <span class="co">#redundant but shows we are dropping NA values</span></span>
<span id="cb15-4"><a href="#cb15-4" tabindex="-1"></a> <span class="fu">filter</span>(ASSET_AMT<span class="sc">></span><span class="dv">0</span>) <span class="sc">%>%</span> <span class="co"># ASSET_AMT must be greater than zero</span></span>
<span id="cb15-5"><a href="#cb15-5" tabindex="-1"></a> <span class="co"># get quartiles</span></span>
<span id="cb15-6"><a href="#cb15-6" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_quartile =</span> <span class="fu">ntile</span>(ASSET_AMT, <span class="dv">4</span>)) <span class="sc">%>%</span></span>
<span id="cb15-7"><a href="#cb15-7" tabindex="-1"></a> <span class="co"># create new quartile variable that specifies quartiles by text</span></span>
<span id="cb15-8"><a href="#cb15-8" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_quartile_text =</span> <span class="fu">case_when</span>(ASSET_quartile <span class="sc">==</span> <span class="dv">1</span> <span class="sc">~</span> <span class="st">"1st_Quartile"</span>,</span>
<span id="cb15-9"><a href="#cb15-9" tabindex="-1"></a> ASSET_quartile <span class="sc">==</span> <span class="dv">2</span> <span class="sc">~</span> <span class="st">"2nd_Quartile"</span>,</span>
<span id="cb15-10"><a href="#cb15-10" tabindex="-1"></a> ASSET_quartile <span class="sc">==</span> <span class="dv">3</span> <span class="sc">~</span> <span class="st">"3rd_Quartile"</span>,</span>
<span id="cb15-11"><a href="#cb15-11" tabindex="-1"></a> ASSET_quartile <span class="sc">==</span> <span class="dv">4</span> <span class="sc">~</span> <span class="st">"4th_Quartile"</span>))</span>
<span id="cb15-12"><a href="#cb15-12" tabindex="-1"></a></span>
<span id="cb15-13"><a href="#cb15-13" tabindex="-1"></a><span class="co">#Now check:</span></span>
<span id="cb15-14"><a href="#cb15-14" tabindex="-1"></a><span class="fu">table</span>(df_simplified_no_zero<span class="sc">$</span>ASSET_quartile, <span class="at">useNA =</span> <span class="st">"always"</span>)</span></code></pre></div>
<pre><code>##
## 1 2 3 4 <NA>
## 375 374 374 374 0</code></pre>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" tabindex="-1"></a>df_simplified_no_zero<span class="sc">%>%</span> <span class="fu">group_by</span>(ASSET_quartile_text) <span class="sc">%>%</span> <span class="fu">summarise</span>(<span class="at">range =</span> <span class="fu">range</span>(ASSET_AMT))</span></code></pre></div>
<pre><code>## Warning: Returning more (or less) than 1 row per `summarise()` group was deprecated in
## dplyr 1.1.0.
## ℹ Please use `reframe()` instead.
## ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()`
## always returns an ungrouped data frame and adjust accordingly.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.</code></pre>
<pre><code>## `summarise()` has grouped output by 'ASSET_quartile_text'. You can override
## using the `.groups` argument.</code></pre>
<pre><code>## # A tibble: 8 × 2
## # Groups: ASSET_quartile_text [4]
## ASSET_quartile_text range
## <chr> <dbl>
## 1 1st_Quartile 1
## 2 1st_Quartile 77638
## 3 2nd_Quartile 77996
## 4 2nd_Quartile 528175
## 5 3rd_Quartile 529732
## 6 3rd_Quartile 3783266
## 7 4th_Quartile 3804811
## 8 4th_Quartile 3267270835</code></pre>
<p>Without removal (except NAs)- since these asset amounts might
influence quartiles.</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" tabindex="-1"></a>df_simplified_no_removal<span class="ot"><-</span>df_simplified <span class="sc">%>%</span></span>
<span id="cb21-2"><a href="#cb21-2" tabindex="-1"></a> <span class="fu">drop_na</span>(ASSET_AMT) <span class="sc">%>%</span> <span class="co">#dropping NA values</span></span>
<span id="cb21-3"><a href="#cb21-3" tabindex="-1"></a> <span class="co"># get quartiles</span></span>
<span id="cb21-4"><a href="#cb21-4" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_quartile =</span> <span class="fu">ntile</span>(ASSET_AMT, <span class="dv">4</span>)) <span class="sc">%>%</span></span>
<span id="cb21-5"><a href="#cb21-5" tabindex="-1"></a> <span class="co"># create new quartile variable that specifies quartiles by text</span></span>
<span id="cb21-6"><a href="#cb21-6" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ASSET_quartile_text =</span> <span class="fu">case_when</span>(ASSET_quartile <span class="sc">==</span> <span class="dv">1</span> <span class="sc">~</span> <span class="st">"1st_Quartile"</span>,</span>
<span id="cb21-7"><a href="#cb21-7" tabindex="-1"></a> ASSET_quartile <span class="sc">==</span> <span class="dv">2</span> <span class="sc">~</span> <span class="st">"2nd_Quartile"</span>,</span>
<span id="cb21-8"><a href="#cb21-8" tabindex="-1"></a> ASSET_quartile <span class="sc">==</span> <span class="dv">3</span> <span class="sc">~</span> <span class="st">"3rd_Quartile"</span>,</span>
<span id="cb21-9"><a href="#cb21-9" tabindex="-1"></a> ASSET_quartile <span class="sc">==</span> <span class="dv">4</span> <span class="sc">~</span> <span class="st">"4th_Quartile"</span>))</span>
<span id="cb21-10"><a href="#cb21-10" tabindex="-1"></a></span>
<span id="cb21-11"><a href="#cb21-11" tabindex="-1"></a><span class="co">#Now check:</span></span>
<span id="cb21-12"><a href="#cb21-12" tabindex="-1"></a><span class="fu">table</span>(df_simplified_no_removal<span class="sc">$</span>ASSET_quartile, <span class="at">useNA =</span> <span class="st">"always"</span>)</span></code></pre></div>
<pre><code>##
## 1 2 3 4 <NA>
## 679 679 679 678 0</code></pre>
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" tabindex="-1"></a>df_simplified_no_removal <span class="sc">%>%</span> <span class="fu">group_by</span>(ASSET_quartile_text) <span class="sc">%>%</span> <span class="fu">summarise</span>(<span class="at">range =</span> <span class="fu">range</span>(ASSET_AMT))</span></code></pre></div>
<pre><code>## Warning: Returning more (or less) than 1 row per `summarise()` group was deprecated in
## dplyr 1.1.0.
## ℹ Please use `reframe()` instead.
## ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()`
## always returns an ungrouped data frame and adjust accordingly.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.</code></pre>
<pre><code>## `summarise()` has grouped output by 'ASSET_quartile_text'. You can override
## using the `.groups` argument.</code></pre>
<pre><code>## # A tibble: 8 × 2
## # Groups: ASSET_quartile_text [4]
## ASSET_quartile_text range
## <chr> <dbl>
## 1 1st_Quartile 0
## 2 1st_Quartile 0
## 3 2nd_Quartile 0
## 4 2nd_Quartile 8141
## 5 3rd_Quartile 8251
## 6 3rd_Quartile 735297
## 7 4th_Quartile 738933
## 8 4th_Quartile 3267270835</code></pre>
<p>Turns out this doesn’t really work because the 1st and 2nd quartiles
can’t be distinguished as we don’t know if the values of 0 are actually
some number below 50,000 and both quartlies have a max of less than
50,000. So we will stick with our removal.</p>
</div>
<div id="national-taxonomy-of-exempt-entities-ntee-recoding"
class="section level2">
<h2>National Taxonomy of Exempt Entities (NTEE) recoding</h2>
<p>To provide more information to readers about what the nonprofits do,
we will convert the National Taxonomy of Exempt Entities (NTEE) codes
based on <a
href="https://urbaninstitute.github.io/nccs-legacy/ntee/ntee.html">this</a>
and <a href="https://www.irs.gov/pub/irs-tege/p4838.pdf">this (see page
15)</a>.</p>
<div class="sourceCode" id="cb27"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" tabindex="-1"></a>df_simplified <span class="ot"><-</span>df_simplified <span class="sc">%>%</span></span>
<span id="cb27-2"><a href="#cb27-2" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">NTEE_text =</span> <span class="fu">case_when</span>(</span>
<span id="cb27-3"><a href="#cb27-3" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"A"</span>)<span class="sc">~</span> <span class="st">"Arts"</span>, <span class="co"># if NTEE_CD starts with A make new variable value "Arts" etc.</span></span>
<span id="cb27-4"><a href="#cb27-4" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"B"</span>) <span class="sc">~</span> <span class="st">"Education"</span>,</span>
<span id="cb27-5"><a href="#cb27-5" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"C|D"</span>) <span class="sc">~</span> <span class="st">"Environment/Animals"</span>, <span class="co"># if NTEE_CD value starts with C or D make new variable value "Environment/Animals"</span></span>
<span id="cb27-6"><a href="#cb27-6" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"E|F|G|H"</span>) <span class="sc">~</span> <span class="st">"Health"</span>,</span>
<span id="cb27-7"><a href="#cb27-7" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"I|J|K|L|M|N|O|P"</span>) <span class="sc">~</span> <span class="st">"Human Services"</span>,</span>
<span id="cb27-8"><a href="#cb27-8" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"Q"</span>) <span class="sc">~</span> <span class="st">"International Affairs"</span>,</span>
<span id="cb27-9"><a href="#cb27-9" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"R|S|T|U|V|W"</span>) <span class="sc">~</span> <span class="st">"Societal Benefit"</span>,</span>
<span id="cb27-10"><a href="#cb27-10" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"X"</span>) <span class="sc">~</span> <span class="st">"Religious"</span>,</span>
<span id="cb27-11"><a href="#cb27-11" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> <span class="st">"NA"</span>)) <span class="co"># this line is redundant as this would happen automatically - but everything else will be NA</span></span></code></pre></div>
<p>Also for the quantile data:</p>
<div class="sourceCode" id="cb28"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" tabindex="-1"></a>df_simplified_no_zero <span class="ot"><-</span>df_simplified_no_zero <span class="sc">%>%</span></span>
<span id="cb28-2"><a href="#cb28-2" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">NTEE_text =</span> <span class="fu">case_when</span>(</span>
<span id="cb28-3"><a href="#cb28-3" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"A"</span>)<span class="sc">~</span> <span class="st">"Arts"</span>, <span class="co"># if NTEE_CD starts with A make new variable value "Arts" etc.</span></span>
<span id="cb28-4"><a href="#cb28-4" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"B"</span>) <span class="sc">~</span> <span class="st">"Education"</span>,</span>
<span id="cb28-5"><a href="#cb28-5" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"C|D"</span>) <span class="sc">~</span> <span class="st">"Environment/Animals"</span>, <span class="co"># if NTEE_CD value starts with C or D make new variable value "Environment/Animals"</span></span>
<span id="cb28-6"><a href="#cb28-6" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"E|F|G|H"</span>) <span class="sc">~</span> <span class="st">"Health"</span>,</span>
<span id="cb28-7"><a href="#cb28-7" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"I|J|K|L|M|N|O|P"</span>) <span class="sc">~</span> <span class="st">"Human Services"</span>,</span>
<span id="cb28-8"><a href="#cb28-8" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"Q"</span>) <span class="sc">~</span> <span class="st">"International Affairs"</span>,</span>
<span id="cb28-9"><a href="#cb28-9" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"R|S|T|U|V|W"</span>) <span class="sc">~</span> <span class="st">"Societal Benefit"</span>,</span>
<span id="cb28-10"><a href="#cb28-10" tabindex="-1"></a> <span class="fu">str_starts</span>(NTEE_CD, <span class="at">pattern =</span> <span class="st">"X"</span>) <span class="sc">~</span> <span class="st">"Religous"</span>,</span>
<span id="cb28-11"><a href="#cb28-11" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> <span class="st">"NA"</span>)) <span class="co"># this line is redundant as this would happen automatically - but everything else will be NA</span></span></code></pre></div>
</div>
</div>
<div id="visualizations-and-analysis" class="section level1">
<h1>Visualizations and Analysis</h1>
<div id="deeper-possible-visualizations" class="section level2">
<h2>Deeper possible visualizations</h2>
<p>First without log normalization figure:</p>
<div class="sourceCode" id="cb29"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" tabindex="-1"></a>df_simplified_no_zero <span class="sc">%>%</span> </span>
<span id="cb29-2"><a href="#cb29-2" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">y =</span> ASSET_AMT, <span class="at">x =</span> Percent_AA)) <span class="sc">+</span></span>
<span id="cb29-3"><a href="#cb29-3" tabindex="-1"></a> <span class="fu">geom_point</span>() <span class="sc">+</span> <span class="fu">geom_smooth</span>(<span class="at">method =</span> <span class="st">"loess"</span>)</span></code></pre></div>
<pre><code>## `geom_smooth()` using formula = 'y ~ x'</code></pre>
<p><img src="index_files/figure-html/unnamed-chunk-15-1.png" width="672" />
We can see that some of the dat points are much higher and this makes it
challenging to see the lower data values.</p>
<p>Now let’s look at normalized version.</p>
<p>Overall log Asset amount figure:</p>
<div class="sourceCode" id="cb31"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb31-1"><a href="#cb31-1" tabindex="-1"></a>df_simplified_no_zero <span class="sc">%>%</span> </span>
<span id="cb31-2"><a href="#cb31-2" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">y =</span> ASSET_AMT_log, <span class="at">x =</span> Percent_AA)) <span class="sc">+</span></span>
<span id="cb31-3"><a href="#cb31-3" tabindex="-1"></a> <span class="fu">geom_point</span>() <span class="sc">+</span> <span class="fu">geom_smooth</span>(<span class="at">method =</span> <span class="st">"loess"</span>)</span></code></pre></div>
<pre><code>## `geom_smooth()` using formula = 'y ~ x'</code></pre>
<p><img src="index_files/figure-html/unnamed-chunk-16-1.png" width="672" /></p>
</div>
<div id="quartile-plots" class="section level2">
<h2>Quartile plots</h2>
<p>Quartiles with log asset data:</p>
<div class="sourceCode" id="cb33"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb33-1"><a href="#cb33-1" tabindex="-1"></a>df_simplified_no_zero <span class="sc">%>%</span> </span>
<span id="cb33-2"><a href="#cb33-2" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">y =</span> ASSET_AMT_log, <span class="at">x =</span> Percent_AA)) <span class="sc">+</span></span>
<span id="cb33-3"><a href="#cb33-3" tabindex="-1"></a> <span class="fu">geom_point</span>() <span class="sc">+</span> <span class="fu">facet_wrap</span>(<span class="sc">~</span> ASSET_quartile_text, <span class="at">scales =</span> <span class="st">"free"</span>) <span class="sc">+</span><span class="fu">geom_smooth</span>()</span></code></pre></div>
<pre><code>## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'</code></pre>
<p><img src="index_files/figure-html/unnamed-chunk-17-1.png" width="672" /></p>
<p>Look at log asset data for each NTEE type- <strong>remember the
caveat that there are many organizations that are not included because
of NA or zero value ASSET_AMT</strong>. However, still we can see that
there is a trend towards lower amount of assets for most categories even
with this limited data.</p>
<div class="sourceCode" id="cb35"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb35-1"><a href="#cb35-1" tabindex="-1"></a>df_simplified_no_zero <span class="sc">%>%</span></span>
<span id="cb35-2"><a href="#cb35-2" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">y =</span> ASSET_AMT_log, <span class="at">x =</span> Neighborhood)) <span class="sc">+</span></span>
<span id="cb35-3"><a href="#cb35-3" tabindex="-1"></a> <span class="fu">geom_boxplot</span>()<span class="sc">+</span> <span class="fu">geom_jitter</span>(<span class="at">width =</span> .<span class="dv">08</span>) <span class="sc">+</span> </span>
<span id="cb35-4"><a href="#cb35-4" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span> NTEE_text, <span class="at">scales =</span> <span class="st">"free_y"</span>) <span class="sc">+</span> </span>
<span id="cb35-5"><a href="#cb35-5" tabindex="-1"></a> <span class="fu">geom_smooth</span>(<span class="at">method =</span> <span class="st">"lm"</span>, <span class="at">se=</span><span class="cn">TRUE</span>, <span class="fu">aes</span>(<span class="at">group=</span><span class="dv">1</span>))</span></code></pre></div>
<pre><code>## `geom_smooth()` using formula = 'y ~ x'</code></pre>
<p><img src="index_files/figure-html/unnamed-chunk-18-1.png" width="672" /></p>
<p>Compare all organizations by neighborhood AA status for log asset
data. <em>remember the caveat that there are many organizations that are
not included because of NA or zero value ASSET_AMT</em></p>
<div class="sourceCode" id="cb37"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb37-1"><a href="#cb37-1" tabindex="-1"></a>df_simplified_no_zero <span class="sc">%>%</span></span>
<span id="cb37-2"><a href="#cb37-2" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">y =</span> ASSET_AMT_log, <span class="at">x =</span> Neighborhood)) <span class="sc">+</span></span>
<span id="cb37-3"><a href="#cb37-3" tabindex="-1"></a> <span class="fu">geom_boxplot</span>()<span class="sc">+</span> <span class="fu">geom_jitter</span>(<span class="at">width =</span> .<span class="dv">08</span>) <span class="sc">+</span> <span class="fu">geom_smooth</span>(<span class="at">method =</span> <span class="st">"lm"</span>, <span class="at">se=</span><span class="cn">TRUE</span>, <span class="fu">aes</span>(<span class="at">group=</span><span class="dv">1</span>))</span></code></pre></div>
<pre><code>## `geom_smooth()` using formula = 'y ~ x'</code></pre>
<p><img src="index_files/figure-html/unnamed-chunk-19-1.png" width="672" /></p>
</div>
<div id="association-tests" class="section level2">
<h2>Association Tests</h2>
<div class="sourceCode" id="cb39"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb39-1"><a href="#cb39-1" tabindex="-1"></a><span class="fu">summary</span>(<span class="fu">glm</span>(<span class="at">data =</span> df_simplified_no_zero, ASSET_AMT <span class="sc">~</span>Percent_AA)) <span class="co"># for every increase in percent AA of the neighborhood there was a 266,249$ decrease in asset amount of the nonprofits in the neighborhood</span></span></code></pre></div>
<pre><code>##
## Call:
## glm(formula = ASSET_AMT ~ Percent_AA, data = df_simplified_no_zero)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 29664870 5349712 5.545 3.47e-08 ***
## Percent_AA -266249 107553 -2.476 0.0134 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 1.84704e+16)
##
## Null deviance: 2.7726e+19 on 1496 degrees of freedom
## Residual deviance: 2.7613e+19 on 1495 degrees of freedom
## AIC: 60322
##
## Number of Fisher Scoring iterations: 2</code></pre>
<div class="sourceCode" id="cb41"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb41-1"><a href="#cb41-1" tabindex="-1"></a><span class="co"># there is a less than 5% risk of concluding that an association exists between asset amount a percent AA of neighborhood when there is no actual association.</span></span>
<span id="cb41-2"><a href="#cb41-2" tabindex="-1"></a></span>
<span id="cb41-3"><a href="#cb41-3" tabindex="-1"></a></span>
<span id="cb41-4"><a href="#cb41-4" tabindex="-1"></a><span class="fu">hist</span>(df_simplified_no_zero<span class="sc">$</span>ASSET_AMT_log)</span></code></pre></div>
<p><img src="index_files/figure-html/unnamed-chunk-20-1.png" width="672" /></p>
<div class="sourceCode" id="cb42"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb42-1"><a href="#cb42-1" tabindex="-1"></a><span class="fu">summary</span>(<span class="fu">glm</span>(<span class="at">data =</span> df_simplified_no_zero, ASSET_AMT_log<span class="sc">~</span>Percent_AA)) <span class="co"># for every increase in percent AA of the neighborhood there was a 266,249$ decrease in asset amount of the nonprofits in the neighborhood</span></span></code></pre></div>
<pre><code>##
## Call:
## glm(formula = ASSET_AMT_log ~ Percent_AA, data = df_simplified_no_zero)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.632645 0.135946 100.280 < 2e-16 ***
## Percent_AA -0.018598 0.002733 -6.805 1.46e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 11.92755)
##
## Null deviance: 18384 on 1496 degrees of freedom
## Residual deviance: 17832 on 1495 degrees of freedom
## AIC: 7963.1
##
## Number of Fisher Scoring iterations: 2</code></pre>
<div class="sourceCode" id="cb44"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb44-1"><a href="#cb44-1" tabindex="-1"></a><span class="fu">glm</span>(<span class="at">data =</span> df_simplified_no_zero, ASSET_AMT_log <span class="sc">~</span> Percent_AA) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">which =</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>)</span></code></pre></div>
<p><img src="index_files/figure-html/unnamed-chunk-20-2.png" width="672" /><img src="index_files/figure-html/unnamed-chunk-20-3.png" width="672" /><img src="index_files/figure-html/unnamed-chunk-20-4.png" width="672" /></p>
<div class="sourceCode" id="cb45"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb45-1"><a href="#cb45-1" tabindex="-1"></a><span class="co">#nonparametric test - because the residiuals looked skewed in the above qqplot</span></span>
<span id="cb45-2"><a href="#cb45-2" tabindex="-1"></a><span class="fu">cor.test</span>(df_simplified_no_zero<span class="sc">$</span>ASSET_AMT, df_simplified_no_zero<span class="sc">$</span>Percent_AA, <span class="at">method =</span> <span class="st">"spearman"</span>, <span class="at">exact =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
<pre><code>##
## Spearman's rank correlation rho
##
## data: df_simplified_no_zero$ASSET_AMT and df_simplified_no_zero$Percent_AA
## S = 641433720, p-value = 1.055e-08
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.1471965</code></pre>
<p>Look at quartiles with log asset data: <em>remember the caveat that
there are many organizations that are not included because of NA or zero
value ASSET_AMT</em></p>
<div class="sourceCode" id="cb47"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb47-1"><a href="#cb47-1" tabindex="-1"></a>df_simplified_no_zero <span class="sc">%>%</span></span>
<span id="cb47-2"><a href="#cb47-2" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">y =</span> ASSET_AMT_log, <span class="at">x =</span> Neighborhood)) <span class="sc">+</span></span>
<span id="cb47-3"><a href="#cb47-3" tabindex="-1"></a> <span class="fu">geom_boxplot</span>()<span class="sc">+</span> <span class="fu">geom_jitter</span>(<span class="at">width =</span> .<span class="dv">08</span>) <span class="sc">+</span> <span class="fu">geom_smooth</span>(<span class="at">method =</span> <span class="st">"lm"</span>, <span class="at">se=</span><span class="cn">TRUE</span>, <span class="fu">aes</span>(<span class="at">group=</span><span class="dv">1</span>)) <span class="sc">+</span> <span class="fu">facet_wrap</span>(<span class="sc">~</span>ASSET_quartile_text, <span class="at">scales =</span> <span class="st">"free_y"</span>)</span></code></pre></div>
<pre><code>## `geom_smooth()` using formula = 'y ~ x'</code></pre>
<p><img src="index_files/figure-html/unnamed-chunk-21-1.png" width="672" /></p>
<p>First create data to make visualization easier <em>caveat for the
data: that there are many organizations that are not included because of
NA or zero value ASSET_AMT</em></p>
<div class="sourceCode" id="cb49"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb49-1"><a href="#cb49-1" tabindex="-1"></a>quartile_data <span class="ot"><-</span>df_simplified_no_zero <span class="sc">%>%</span> </span>
<span id="cb49-2"><a href="#cb49-2" tabindex="-1"></a> <span class="fu">group_by</span>(ASSET_quartile_text, Neighborhood) <span class="sc">%>%</span> </span>
<span id="cb49-3"><a href="#cb49-3" tabindex="-1"></a> <span class="fu">count</span>()</span>
<span id="cb49-4"><a href="#cb49-4" tabindex="-1"></a>quartile_data</span></code></pre></div>
<pre><code>## # A tibble: 8 × 3
## # Groups: ASSET_quartile_text, Neighborhood [8]
## ASSET_quartile_text Neighborhood n
## <chr> <fct> <int>
## 1 1st_Quartile "Majority\nNon-Black" 217
## 2 1st_Quartile "Majority\nBlack" 158
## 3 2nd_Quartile "Majority\nNon-Black" 235
## 4 2nd_Quartile "Majority\nBlack" 139
## 5 3rd_Quartile "Majority\nNon-Black" 263
## 6 3rd_Quartile "Majority\nBlack" 111
## 7 4th_Quartile "Majority\nNon-Black" 268
## 8 4th_Quartile "Majority\nBlack" 106</code></pre>
<p>Create percentage variable for each quantile</p>
<div class="sourceCode" id="cb51"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb51-1"><a href="#cb51-1" tabindex="-1"></a>quartile_data <span class="ot"><-</span> quartile_data <span class="sc">%>%</span></span>
<span id="cb51-2"><a href="#cb51-2" tabindex="-1"></a> <span class="fu">group_by</span>(ASSET_quartile_text) <span class="sc">%>%</span> </span>
<span id="cb51-3"><a href="#cb51-3" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Percent =</span> <span class="fu">round</span>(n<span class="sc">/</span><span class="fu">sum</span>(n)<span class="sc">*</span><span class="dv">100</span>)) </span>
<span id="cb51-4"><a href="#cb51-4" tabindex="-1"></a>quartile_data</span></code></pre></div>
<pre><code>## # A tibble: 8 × 4
## # Groups: ASSET_quartile_text [4]
## ASSET_quartile_text Neighborhood n Percent
## <chr> <fct> <int> <dbl>
## 1 1st_Quartile "Majority\nNon-Black" 217 58
## 2 1st_Quartile "Majority\nBlack" 158 42
## 3 2nd_Quartile "Majority\nNon-Black" 235 63
## 4 2nd_Quartile "Majority\nBlack" 139 37
## 5 3rd_Quartile "Majority\nNon-Black" 263 70
## 6 3rd_Quartile "Majority\nBlack" 111 30
## 7 4th_Quartile "Majority\nNon-Black" 268 72
## 8 4th_Quartile "Majority\nBlack" 106 28</code></pre>
<p>Visuals…of the above data:</p>
<div class="sourceCode" id="cb53"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb53-1"><a href="#cb53-1" tabindex="-1"></a>quart_plot <span class="ot"><-</span> quartile_data <span class="sc">%>%</span> </span>
<span id="cb53-2"><a href="#cb53-2" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x=</span> ASSET_quartile_text, <span class="at">y =</span> Percent, <span class="at">fill =</span> Neighborhood)) <span class="sc">+</span> </span>
<span id="cb53-3"><a href="#cb53-3" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="at">position =</span> <span class="fu">position_dodge</span>(<span class="at">width =</span> .<span class="dv">9</span>))<span class="sc">+</span></span>
<span id="cb53-4"><a href="#cb53-4" tabindex="-1"></a> <span class="fu">scale_y_continuous</span>(<span class="at">labels =</span> <span class="cf">function</span>(x) <span class="fu">paste0</span>(x, <span class="st">"%"</span>)) <span class="sc">+</span></span>
<span id="cb53-5"><a href="#cb53-5" tabindex="-1"></a> <span class="fu">ylim</span>(<span class="dv">0</span>,<span class="dv">100</span>) <span class="sc">+</span></span>
<span id="cb53-6"><a href="#cb53-6" tabindex="-1"></a> <span class="fu">scale_fill_grey</span>() <span class="sc">+</span></span>
<span id="cb53-7"><a href="#cb53-7" tabindex="-1"></a> <span class="fu">theme_linedraw</span>() <span class="sc">+</span></span>
<span id="cb53-8"><a href="#cb53-8" tabindex="-1"></a> <span class="fu">geom_text</span>(<span class="fu">aes</span>(<span class="at">label =</span> <span class="fu">paste0</span>(Percent, <span class="st">"%"</span>)), <span class="at">position =</span> <span class="fu">position_dodge</span>(<span class="at">width =</span> .<span class="dv">9</span>), <span class="at">vjust =</span> <span class="sc">-</span>.<span class="dv">5</span>) </span></code></pre></div>
<pre><code>## Scale for y is already present.
## Adding another scale for y, which will replace the existing scale.</code></pre>
<div class="sourceCode" id="cb55"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb55-1"><a href="#cb55-1" tabindex="-1"></a>quart_plot <span class="sc">+</span> <span class="fu">labs</span>(<span class="at">x =</span> <span class="st">"Quartile based on nonprofit asset amount"</span>, <span class="at">y =</span> <span class="st">"Percentage of nonprofits in the asset quartile"</span>)</span></code></pre></div>
<p><img src="index_files/figure-html/unnamed-chunk-24-1.png" width="672" /></p>
<p><strong>this does NOT include all 4,082 organizations</strong></p>
</div>
<div id="overall-percentage-plot" class="section level2">
<h2>Overall Percentage Plot</h2>
<p>First let’s get a count of each - <strong>NOTE we are keeping zero
values and NA as low asset</strong>! The NA neighborhood means there is
only one neighborhood that did not fit the categories or have
information. We can drop this neighborhood.</p>
<div class="sourceCode" id="cb56"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb56-1"><a href="#cb56-1" tabindex="-1"></a>df_simplified <span class="sc">%>%</span></span>
<span id="cb56-2"><a href="#cb56-2" tabindex="-1"></a> <span class="fu">count</span>(ASSET_High_text, Neighborhood)</span></code></pre></div>
<pre><code>## # A tibble: 5 × 3
## ASSET_High_text Neighborhood n
## <chr> <fct> <int>
## 1 High Asset "Majority\nNon-Black" 539
## 2 High Asset "Majority\nBlack" 222
## 3 Low Asset "Majority\nNon-Black" 1589
## 4 Low Asset "Majority\nBlack" 1732
## 5 Low Asset <NA> 1</code></pre>
<div class="sourceCode" id="cb58"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb58-1"><a href="#cb58-1" tabindex="-1"></a>df_simplified <span class="ot"><-</span>df_simplified <span class="sc">%>%</span></span>
<span id="cb58-2"><a href="#cb58-2" tabindex="-1"></a> <span class="fu">drop_na</span>(Neighborhood)</span>
<span id="cb58-3"><a href="#cb58-3" tabindex="-1"></a></span>
<span id="cb58-4"><a href="#cb58-4" tabindex="-1"></a>df_simplified <span class="sc">%>%</span></span>
<span id="cb58-5"><a href="#cb58-5" tabindex="-1"></a> <span class="fu">count</span>(ASSET_High_text, Neighborhood)</span></code></pre></div>
<pre><code>## # A tibble: 4 × 3
## ASSET_High_text Neighborhood n
## <chr> <fct> <int>
## 1 High Asset "Majority\nNon-Black" 539
## 2 High Asset "Majority\nBlack" 222
## 3 Low Asset "Majority\nNon-Black" 1589
## 4 Low Asset "Majority\nBlack" 1732</code></pre>
<div class="sourceCode" id="cb60"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb60-1"><a href="#cb60-1" tabindex="-1"></a>High_asset_data <span class="ot"><-</span>df_simplified <span class="sc">%>%</span> </span>
<span id="cb60-2"><a href="#cb60-2" tabindex="-1"></a> <span class="fu">group_by</span>(ASSET_High_text, Neighborhood) <span class="sc">%>%</span> </span>
<span id="cb60-3"><a href="#cb60-3" tabindex="-1"></a> <span class="fu">count</span>() </span>
<span id="cb60-4"><a href="#cb60-4" tabindex="-1"></a>High_asset_data</span></code></pre></div>
<pre><code>## # A tibble: 4 × 3
## # Groups: ASSET_High_text, Neighborhood [4]
## ASSET_High_text Neighborhood n
## <chr> <fct> <int>
## 1 High Asset "Majority\nNon-Black" 539
## 2 High Asset "Majority\nBlack" 222
## 3 Low Asset "Majority\nNon-Black" 1589
## 4 Low Asset "Majority\nBlack" 1732</code></pre>
<p>Create percentage variable for each category:</p>
<div class="sourceCode" id="cb62"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb62-1"><a href="#cb62-1" tabindex="-1"></a>High_asset_data <span class="ot"><-</span> High_asset_data <span class="sc">%>%</span></span>
<span id="cb62-2"><a href="#cb62-2" tabindex="-1"></a> <span class="fu">group_by</span>(Neighborhood) <span class="sc">%>%</span> </span>
<span id="cb62-3"><a href="#cb62-3" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Percent_AA_cat =</span> <span class="fu">round</span>(n<span class="sc">/</span><span class="fu">sum</span>(n)<span class="sc">*</span><span class="dv">100</span>)) </span>
<span id="cb62-4"><a href="#cb62-4" tabindex="-1"></a>High_asset_data</span></code></pre></div>
<pre><code>## # A tibble: 4 × 4
## # Groups: Neighborhood [2]
## ASSET_High_text Neighborhood n Percent_AA_cat
## <chr> <fct> <int> <dbl>
## 1 High Asset "Majority\nNon-Black" 539 25
## 2 High Asset "Majority\nBlack" 222 11
## 3 Low Asset "Majority\nNon-Black" 1589 75
## 4 Low Asset "Majority\nBlack" 1732 89</code></pre>
<p>Visuals…of the above data:</p>
<div class="sourceCode" id="cb64"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb64-1"><a href="#cb64-1" tabindex="-1"></a>High_asset_data <span class="sc">%>%</span> </span>
<span id="cb64-2"><a href="#cb64-2" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x=</span> Neighborhood, <span class="at">y =</span> Percent_AA_cat, <span class="at">fill =</span> ASSET_High_text)) <span class="sc">+</span> </span>
<span id="cb64-3"><a href="#cb64-3" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="at">position =</span> <span class="fu">position_dodge</span>(<span class="at">width =</span> .<span class="dv">9</span>))<span class="sc">+</span></span>
<span id="cb64-4"><a href="#cb64-4" tabindex="-1"></a> <span class="fu">scale_y_continuous</span>(<span class="at">labels =</span> <span class="cf">function</span>(x) <span class="fu">paste0</span>(x, <span class="st">"%"</span>)) <span class="sc">+</span></span>
<span id="cb64-5"><a href="#cb64-5" tabindex="-1"></a> <span class="fu">ylim</span>(<span class="dv">0</span>,<span class="dv">100</span>) <span class="sc">+</span></span>
<span id="cb64-6"><a href="#cb64-6" tabindex="-1"></a> <span class="fu">geom_text</span>(<span class="fu">aes</span>(<span class="at">label =</span> <span class="fu">paste0</span>(Percent_AA_cat, <span class="st">"%"</span>)), <span class="at">position =</span> <span class="fu">position_dodge</span>(<span class="at">width =</span> .<span class="dv">9</span>), <span class="at">vjust =</span> <span class="sc">-</span>.<span class="dv">5</span>) <span class="sc">+</span></span>
<span id="cb64-7"><a href="#cb64-7" tabindex="-1"></a> <span class="fu">ylab</span>(<span class="st">"Percent of Neighborhood Category"</span>) <span class="sc">+</span></span>
<span id="cb64-8"><a href="#cb64-8" tabindex="-1"></a> <span class="fu">theme_linedraw</span>() <span class="sc">+</span></span>
<span id="cb64-9"><a href="#cb64-9" tabindex="-1"></a> <span class="fu">scale_fill_grey</span>() <span class="sc">+</span></span>
<span id="cb64-10"><a href="#cb64-10" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">legend.title =</span> <span class="fu">element_blank</span>())</span></code></pre></div>
<pre><code>## Scale for y is already present.
## Adding another scale for y, which will replace the existing scale.</code></pre>
<p><img src="index_files/figure-html/unnamed-chunk-28-1.png" width="672" />
<strong>this includes all 4,082 organizations</strong></p>
</div>
<div id="high-vs-non-asset-by-category" class="section level2">
<h2>High vs non asset by category</h2>
<p>First create data to make visualization easier</p>
<div class="sourceCode" id="cb66"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb66-1"><a href="#cb66-1" tabindex="-1"></a>High_asset_data <span class="ot"><-</span>df_simplified <span class="sc">%>%</span></span>
<span id="cb66-2"><a href="#cb66-2" tabindex="-1"></a> <span class="fu">group_by</span>(ASSET_High_text, Neighborhood, NTEE_text) <span class="sc">%>%</span> </span>
<span id="cb66-3"><a href="#cb66-3" tabindex="-1"></a> <span class="fu">count</span>()</span>
<span id="cb66-4"><a href="#cb66-4" tabindex="-1"></a>High_asset_data</span></code></pre></div>
<pre><code>## # A tibble: 36 × 4
## # Groups: ASSET_High_text, Neighborhood, NTEE_text [36]
## ASSET_High_text Neighborhood NTEE_text n
## <chr> <fct> <chr> <int>
## 1 High Asset "Majority\nNon-Black" Arts 34
## 2 High Asset "Majority\nNon-Black" Education 54
## 3 High Asset "Majority\nNon-Black" Environment/Animals 9
## 4 High Asset "Majority\nNon-Black" Health 65
## 5 High Asset "Majority\nNon-Black" Human Services 75
## 6 High Asset "Majority\nNon-Black" International Affairs 4
## 7 High Asset "Majority\nNon-Black" NA 174
## 8 High Asset "Majority\nNon-Black" Religious 2
## 9 High Asset "Majority\nNon-Black" Societal Benefit 122
## 10 High Asset "Majority\nBlack" Arts 8
## # ℹ 26 more rows</code></pre>
<div class="sourceCode" id="cb68"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb68-1"><a href="#cb68-1" tabindex="-1"></a><span class="co">#Create percentage variable for each category</span></span>
<span id="cb68-2"><a href="#cb68-2" tabindex="-1"></a>High_asset_data <span class="ot"><-</span> High_asset_data <span class="sc">%>%</span></span>
<span id="cb68-3"><a href="#cb68-3" tabindex="-1"></a> <span class="fu">group_by</span>(NTEE_text) <span class="sc">%>%</span> </span>
<span id="cb68-4"><a href="#cb68-4" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Percent_ntee_cat =</span> <span class="fu">round</span>(n<span class="sc">/</span><span class="fu">sum</span>(n)<span class="sc">*</span><span class="dv">100</span>)) </span>
<span id="cb68-5"><a href="#cb68-5" tabindex="-1"></a>High_asset_data</span></code></pre></div>
<pre><code>## # A tibble: 36 × 5
## # Groups: NTEE_text [9]
## ASSET_High_text Neighborhood NTEE_text n Percent_ntee_cat
## <chr> <fct> <chr> <int> <dbl>
## 1 High Asset "Majority\nNon-Black" Arts 34 13
## 2 High Asset "Majority\nNon-Black" Education 54 18
## 3 High Asset "Majority\nNon-Black" Environment/Ani… 9 15
## 4 High Asset "Majority\nNon-Black" Health 65 25
## 5 High Asset "Majority\nNon-Black" Human Services 75 9
## 6 High Asset "Majority\nNon-Black" International A… 4 9
## 7 High Asset "Majority\nNon-Black" NA 174 13
## 8 High Asset "Majority\nNon-Black" Religious 2 0
## 9 High Asset "Majority\nNon-Black" Societal Benefit 122 23
## 10 High Asset "Majority\nBlack" Arts 8 3
## # ℹ 26 more rows</code></pre>
<p>Visuals…of the above data:</p>
<div class="sourceCode" id="cb70"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb70-1"><a href="#cb70-1" tabindex="-1"></a>High_asset_data <span class="sc">%>%</span> </span>
<span id="cb70-2"><a href="#cb70-2" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x=</span> Neighborhood, <span class="at">y =</span> Percent_ntee_cat, <span class="at">fill =</span> ASSET_High_text)) <span class="sc">+</span> </span>
<span id="cb70-3"><a href="#cb70-3" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="at">position =</span> <span class="fu">position_dodge</span>(<span class="at">width =</span> .<span class="dv">9</span>))<span class="sc">+</span></span>
<span id="cb70-4"><a href="#cb70-4" tabindex="-1"></a> <span class="fu">scale_y_continuous</span>(<span class="at">labels =</span> <span class="cf">function</span>(x) <span class="fu">paste0</span>(x, <span class="st">"%"</span>)) <span class="sc">+</span></span>
<span id="cb70-5"><a href="#cb70-5" tabindex="-1"></a> <span class="fu">ylim</span>(<span class="dv">0</span>, <span class="dv">100</span>) <span class="sc">+</span></span>
<span id="cb70-6"><a href="#cb70-6" tabindex="-1"></a> <span class="fu">geom_text</span>(<span class="fu">aes</span>(<span class="at">label =</span> <span class="fu">paste0</span>(Percent_ntee_cat, <span class="st">"%"</span>)), <span class="at">position =</span> <span class="fu">position_dodge</span>(<span class="at">width =</span> .<span class="dv">9</span>), <span class="at">vjust =</span> <span class="sc">-</span>.<span class="dv">5</span>) <span class="sc">+</span> <span class="fu">facet_wrap</span>(<span class="sc">~</span>NTEE_text) <span class="sc">+</span></span>
<span id="cb70-7"><a href="#cb70-7" tabindex="-1"></a> <span class="fu">theme_linedraw</span>() <span class="sc">+</span></span>
<span id="cb70-8"><a href="#cb70-8" tabindex="-1"></a> <span class="fu">scale_fill_grey</span>() <span class="sc">+</span></span>
<span id="cb70-9"><a href="#cb70-9" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">legend.title =</span> <span class="fu">element_blank</span>()) <span class="sc">+</span></span>
<span id="cb70-10"><a href="#cb70-10" tabindex="-1"></a> <span class="fu">ylab</span>(<span class="st">"Percentage for each category"</span>)</span></code></pre></div>
<p><strong>this includes all 4,082 organizations</strong></p>
</div>
<div id="count-plotstables" class="section level2">
<h2>Count plots/Tables</h2>
<div id="different-kinds-of-orgs" class="section level3">
<h3>Different kinds of orgs</h3>
<div class="sourceCode" id="cb71"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb71-1"><a href="#cb71-1" tabindex="-1"></a><span class="fu">library</span>(forcats)</span>
<span id="cb71-2"><a href="#cb71-2" tabindex="-1"></a>df_simplified <span class="sc">%>%</span> <span class="fu">group_by</span>(NTEE_text) <span class="sc">%>%</span><span class="fu">summarize</span>(<span class="at">count =</span> <span class="fu">n</span>()) <span class="sc">%>%</span> </span>
<span id="cb71-3"><a href="#cb71-3" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">NTEE_text =</span> <span class="fu">str_replace</span>(<span class="at">string =</span> NTEE_text, <span class="at">pattern =</span> <span class="st">"NA"</span>, <span class="at">replacement =</span> <span class="st">"Unclassified"</span>)) <span class="sc">%>%</span></span>
<span id="cb71-4"><a href="#cb71-4" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Percentage =</span> <span class="fu">round</span>(count<span class="sc">/</span><span class="fu">sum</span>(count)<span class="sc">*</span><span class="dv">100</span>, <span class="at">digits =</span> <span class="dv">2</span>)) <span class="sc">%>%</span></span>
<span id="cb71-5"><a href="#cb71-5" tabindex="-1"></a> <span class="fu">arrange</span>(NTEE_text)</span></code></pre></div>
<pre><code>## # A tibble: 9 × 3
## NTEE_text count Percentage
## <chr> <int> <dbl>
## 1 Arts 255 6.25
## 2 Education 305 7.47
## 3 Environment/Animals 59 1.45
## 4 Health 264 6.47
## 5 Human Services 814 19.9
## 6 International Affairs 43 1.05
## 7 Religious 469 11.5
## 8 Societal Benefit 540 13.2
## 9 Unclassified 1333 32.7</code></pre>
<div class="sourceCode" id="cb73"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb73-1"><a href="#cb73-1" tabindex="-1"></a>Total_NTEE <span class="ot"><-</span>df_simplified <span class="sc">%>%</span> <span class="fu">group_by</span>(NTEE_text) <span class="sc">%>%</span><span class="fu">summarize</span>(<span class="at">count =</span> <span class="fu">n</span>()) <span class="sc">%>%</span> </span>
<span id="cb73-2"><a href="#cb73-2" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">NTEE_text =</span> <span class="fu">str_replace</span>(<span class="at">string =</span> NTEE_text, <span class="at">pattern =</span> <span class="st">"NA"</span>, <span class="at">replacement =</span> <span class="st">"Unclassified"</span>)) <span class="sc">%>%</span></span>
<span id="cb73-3"><a href="#cb73-3" tabindex="-1"></a> <span class="fu">arrange</span>(NTEE_text)</span></code></pre></div>
<div class="sourceCode" id="cb74"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb74-1"><a href="#cb74-1" tabindex="-1"></a>df_simplified <span class="sc">%>%</span> </span>
<span id="cb74-2"><a href="#cb74-2" tabindex="-1"></a> <span class="fu">group_by</span>(NTEE_text, Neighborhood) <span class="sc">%>%</span></span>
<span id="cb74-3"><a href="#cb74-3" tabindex="-1"></a> <span class="fu">summarize</span>(<span class="at">count =</span> <span class="fu">n</span>()) <span class="sc">%>%</span> </span>
<span id="cb74-4"><a href="#cb74-4" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">NTEE_text =</span> <span class="fu">as_factor</span>(NTEE_text)) <span class="sc">%>%</span></span>
<span id="cb74-5"><a href="#cb74-5" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x =</span> <span class="fu">fct_reorder</span>(NTEE_text, count, min), <span class="at">y =</span> count , <span class="at">fill =</span> Neighborhood)) <span class="sc">+</span> </span>
<span id="cb74-6"><a href="#cb74-6" tabindex="-1"></a> <span class="fu">scale_fill_viridis_d</span>() <span class="sc">+</span></span>
<span id="cb74-7"><a href="#cb74-7" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="at">position =</span><span class="fu">position_dodge</span>(<span class="at">width =</span> .<span class="dv">9</span>)) <span class="sc">+</span> </span>
<span id="cb74-8"><a href="#cb74-8" tabindex="-1"></a> <span class="fu">ylab</span> (<span class="st">"Number of Organizations"</span>) <span class="sc">+</span></span>
<span id="cb74-9"><a href="#cb74-9" tabindex="-1"></a> <span class="fu">theme_linedraw</span>() <span class="sc">+</span></span>
<span id="cb74-10"><a href="#cb74-10" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.text.x =</span> <span class="fu">element_text</span>(<span class="at">angle =</span> <span class="dv">60</span>, <span class="at">vjust =</span> .<span class="dv">5</span>),</span>
<span id="cb74-11"><a href="#cb74-11" tabindex="-1"></a> <span class="at">axis.title.x =</span> <span class="fu">element_blank</span>()) <span class="sc">+</span></span>