-
Notifications
You must be signed in to change notification settings - Fork 0
/
Preliminary_Delimitation_and_Conflict_Data_Analysis.R
executable file
·1487 lines (1140 loc) · 112 KB
/
Preliminary_Delimitation_and_Conflict_Data_Analysis.R
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
#This section is to help make the code work "out of the box" from Github
#set the working directory to where the files are stored - !CHANGE THIS TO YOUR OWN DIRECTORY!
#setwd("/home/aiddata/Desktop/Github/kfw2_amazon_conflict")
setwd("C:/Users/jflak/OneDrive/GitHub/kfw2_amazon_conflict")
#Naming Guide for the following code (up until the violence data manipulation section)
#
#The stages are, in order, identificada, delimitada, declarada, homologada, and regularizada. The names of values and variables
#are regularized based on these base names for the stages, which always come at the beginning of a value or variable name.
#The variable "Reg.SPU" in the 2011 dataset is renamed to "reg_extra2011" because it is "extra", it does not have a
#counterpart in the 2016 dataset, unlike the other variables.
#Every value and variable that corresponds to the 2011 Bonn Researchers dataset ends in "2011" while every value and variable
#that corresponds to the 2016 MLG dataset ends in "2016".
##########################################Start of Code#############################
#clear variables and values
rm(list = ls())
#reads the data from the files
data2011 <- read.csv(file = "Raw_and_Orginal_Data/DemStages_FUNAI2011_BonnResearchers.csv", header=TRUE, sep = ',')
data2016 <- read.csv(file = "Raw_and_Orginal_Data/DemStages_FUNAI_2016_fromMLG.csv", header=TRUE, sep = ',')
print("START OF TABLES")
#renames terrai_codigo to id_733 so the the id names match
names(data2016)[names(data2016)=="terrai_codigo"] <- "id_733"
#rename all of the demarcation stages from the 2016 dataset for clarity and ease of manipulation
names(data2016)[names(data2016)=="data_em_estudo"] <- "identificada2016"
names(data2016)[names(data2016)=="data_delimitada"] <- "delimitada2016"
names(data2016)[names(data2016)=="data_declarada"] <- "declarada2016"
names(data2016)[names(data2016)=="data_homologada"] <- "homologada2016"
names(data2016)[names(data2016)=="data_regularizada"] <- "regularizada2016"
#rename all of the demarcation stages from the 2011 dataset for clarity and ease of manipulation
names(data2011)[names(data2011)=="Identificada"] <- "identificada2011"
names(data2011)[names(data2011)=="Delimitada"] <- "delimitada2011"
names(data2011)[names(data2011)=="Declarada_Demarcada"] <- "declarada2011"
names(data2011)[names(data2011)=="Holologada_Homologado"] <- "homologada2011"
names(data2011)[names(data2011)=="Reg..CRI"] <- "regularizada2011"
names(data2011)[names(data2011)=="Reg..SPU"] <- "reg_extra2011"
#merges the two data frames by id_733 (the id variable that they have in common)
data_merged <- merge(data2011, data2016, by="id_733")
#changes the demarcation stage variables to date variables
data_merged$identificada2011 <- as.Date(data_merged$identificada2011, format= "%m/%d/%Y")
data_merged$identificada2016 <- as.Date(data_merged$identificada2016, format= "%m/%d/%Y")
data_merged$delimitada2011 <- as.Date(data_merged$delimitada2011, format= "%m/%d/%Y")
data_merged$delimitada2016 <- as.Date(data_merged$delimitada2016, format= "%m/%d/%Y")
data_merged$declarada2011 <- as.Date(data_merged$declarada2011, format= "%m/%d/%Y")
data_merged$declarada2016 <- as.Date(data_merged$declarada2016, format= "%m/%d/%Y")
data_merged$homologada2011 <- as.Date(data_merged$homologada2011, format= "%m/%d/%Y")
data_merged$homologada2016 <- as.Date(data_merged$homologada2016, format= "%m/%d/%Y")
data_merged$regularizada2011 <- as.Date(data_merged$regularizada2011, format= "%m/%d/%Y")
data_merged$regularizada2016 <- as.Date(data_merged$regularizada2016, format= "%m/%d/%Y")
data_merged$reg_extra2011 <- as.Date(data_merged$reg_extra2011, format= "%m/%d/%Y")
#counts number of non-blank observations and stores it in new value for each stage
identificada_count2011 <- length(data_merged$identificada2011) - sum(is.na(data_merged$identificada2011))
identificada_count2016 <- length(data_merged$identificada2016) - sum(is.na(data_merged$identificada2016))
delimitada_count2011 <- length(data_merged$delimitada2011) - sum(is.na(data_merged$delimitada2011))
delimitada_count2016 <- length(data_merged$delimitada2016) - sum(is.na(data_merged$delimitada2016))
declarada_count2011 <- length(data_merged$declarada2011) - sum(is.na(data_merged$declarada2011))
declarada_count2016 <- length(data_merged$declarada2016) - sum(is.na(data_merged$declarada2016))
homologada_count2011 <- length(data_merged$homologada2011) - sum(is.na(data_merged$homologada2011))
homologada_count2016 <- length(data_merged$homologada2016) - sum(is.na(data_merged$homologada2016))
regularizada_count2011 <- length(data_merged$regularizada2011) - sum(is.na(data_merged$regularizada2011))
regularizada_count2016 <- length(data_merged$regularizada2016) - sum(is.na(data_merged$regularizada2016))
reg_extra_count2011 <- length(data_merged$reg_extra2011) - sum(is.na(data_merged$reg_extra2011))
#counts number of non-blank observations for each stage (in either dataset)
identificada_count_any <- length(data_merged$identificada2011) - sum(is.na(data_merged$identificada2011) & is.na(data_merged$identificada2016))
delimitada_count_any <- length(data_merged$delimitada2011) - sum(is.na(data_merged$delimitada2011) & is.na(data_merged$delimitada2016))
declarada_count_any <- length(data_merged$declarada2011) - sum(is.na(data_merged$declarada2011) & is.na(data_merged$declarada2016))
homologada_count_any <- length(data_merged$homologada2011) - sum(is.na(data_merged$homologada2011) & is.na(data_merged$homologada2016))
regularizada_count_any <- length(data_merged$regularizada2011) - sum(is.na(data_merged$regularizada2011) & is.na(data_merged$regularizada2016))
#finds percentage of non-blank observations and stores it in new value for each stage
identificada_ratio2011 <- 100*(length(data_merged$identificada2011) - sum(is.na(data_merged$identificada2011))) / length(data_merged$identificada2011)
identificada_ratio2016 <- 100*(length(data_merged$identificada2016) - sum(is.na(data_merged$identificada2016))) / length(data_merged$identificada2016)
delimitada_ratio2011 <- 100*(length(data_merged$delimitada2011) - sum(is.na(data_merged$delimitada2011))) / length(data_merged$delimitada2011)
delimitada_ratio2016 <- 100*(length(data_merged$delimitada2016) - sum(is.na(data_merged$delimitada2016))) / length(data_merged$delimitada2016)
declarada_ratio2011 <- 100*(length(data_merged$declarada2011) - sum(is.na(data_merged$declarada2011))) / length(data_merged$declarada2011)
declarada_ratio2016 <- 100*(length(data_merged$declarada2016) - sum(is.na(data_merged$declarada2016))) / length(data_merged$declarada2016)
homologada_ratio2011 <- 100*(length(data_merged$homologada2011) - sum(is.na(data_merged$homologada2011))) / length(data_merged$homologada2011)
homologada_ratio2016 <- 100*(length(data_merged$homologada2016) - sum(is.na(data_merged$homologada2016))) / length(data_merged$homologada2016)
regularizada_ratio2011 <- 100*(length(data_merged$regularizada2011) - sum(is.na(data_merged$regularizada2011))) / length(data_merged$regularizada2011)
regularizada_ratio2016 <- 100*(length(data_merged$regularizada2016) - sum(is.na(data_merged$regularizada2016))) / length(data_merged$regularizada2016)
reg_extra_ratio2011 <- 100*(length(data_merged$reg_extra2011) - sum(is.na(data_merged$reg_extra2011))) / length(data_merged$reg_extra2011)
#checks whether the observations in each variable are the same, makes an indicator variable TRUE if different, FALSE if the same
data_merged$identificada_diff <- data_merged$identificada2016!=data_merged$identificada2011
data_merged$delimitada_diff <- data_merged$delimitada2016!=data_merged$delimitada2011
data_merged$declarada_diff <- data_merged$declarada2016!=data_merged$declarada2011
data_merged$homologada_diff <- data_merged$homologada2016!=data_merged$homologada2011
data_merged$regularizada_diff <- data_merged$regularizada2016!=data_merged$regularizada2011
#counts and stores in new values the number of differences between the two datasets for each stage
identificada_diff_val <- length(which(data_merged$identificada_diff))
delimitada_diff_val <- length(which(data_merged$delimitada_diff))
declarada_diff_val <- length(which(data_merged$declarada_diff))
homologada_diff_val <- length(which(data_merged$homologada_diff))
regularizada_diff_val <- length(which(data_merged$regularizada_diff))
#counts and stores in new values the agreement between the two datasets for each stage
identificada_same_val <- length(which(!data_merged$identificada_diff))
delimitada_same_val <- length(which(!data_merged$delimitada_diff))
declarada_same_val <- length(which(!data_merged$declarada_diff))
homologada_same_val <- length(which(!data_merged$homologada_diff))
regularizada_same_val <- length(which(!data_merged$regularizada_diff))
#counts number of non-blank observations that have map data for each stage
identificada_map_count2011 <- length(data_merged$id_587) - sum(is.na(data_merged$identificada2011) | is.na(data_merged$id_587))
identificada_map_count2016 <- length(data_merged$id_587) - sum(is.na(data_merged$identificada2016) | is.na(data_merged$id_587))
delimitada_map_count2011 <- length(data_merged$id_587) - sum(is.na(data_merged$delimitada2011) | is.na(data_merged$id_587))
delimitada_map_count2016 <- length(data_merged$id_587) - sum(is.na(data_merged$delimitada2016) | is.na(data_merged$id_587))
declarada_map_count2011 <- length(data_merged$id_587) - sum(is.na(data_merged$declarada2011) | is.na(data_merged$id_587))
declarada_map_count2016 <- length(data_merged$id_587) - sum(is.na(data_merged$declarada2016) | is.na(data_merged$id_587))
homologada_map_count2011 <- length(data_merged$id_587) - sum(is.na(data_merged$homologada2011) | is.na(data_merged$id_587))
homologada_map_count2016 <- length(data_merged$id_587) - sum(is.na(data_merged$homologada2016) | is.na(data_merged$id_587))
regularizada_map_count2011 <- length(data_merged$id_587) - sum(is.na(data_merged$regularizada2011) | is.na(data_merged$id_587))
regularizada_map_count2016 <- length(data_merged$id_587) - sum(is.na(data_merged$regularizada2016) | is.na(data_merged$id_587))
reg_extra_map_count2011 <- length(data_merged$id_587) - sum(is.na(data_merged$reg_extra2011) | is.na(data_merged$id_587))
#counts number of non-blank mapped observations for each stage (in either dataset)
identificada_count_any_map <- length(data_merged$identificada2011) - sum((is.na(data_merged$identificada2011) | is.na(data_merged$id_587)) & (is.na(data_merged$identificada2016) | is.na(data_merged$id_587)))
delimitada_count_any_map <- length(data_merged$delimitada2011) - sum((is.na(data_merged$delimitada2011) | is.na(data_merged$id_587)) & (is.na(data_merged$delimitada2016) | is.na(data_merged$id_587)))
declarada_count_any_map <- length(data_merged$declarada2011) - sum((is.na(data_merged$declarada2011) | is.na(data_merged$id_587)) & (is.na(data_merged$declarada2016) | is.na(data_merged$id_587)))
homologada_count_any_map <- length(data_merged$homologada2011) - sum((is.na(data_merged$homologada2011) | is.na(data_merged$id_587)) & (is.na(data_merged$homologada2016) | is.na(data_merged$id_587)))
regularizada_count_any_map <- length(data_merged$regularizada2011) - sum((is.na(data_merged$regularizada2011) | is.na(data_merged$id_587)) & (is.na(data_merged$regularizada2016) | is.na(data_merged$id_587)))
#Concept note table 1####
print("Concept Note Table 1")
table_conceptnote1 <- matrix(c(identificada_count_any, identificada_count_any_map,
delimitada_count_any, delimitada_count_any_map,
declarada_count_any, declarada_count_any_map,
homologada_count_any, homologada_count_any_map,
regularizada_count_any, regularizada_count_any_map),
ncol = 2, byrow = TRUE)
colnames(table_conceptnote1) <- c("Counts of Communities with Demarcation Information", "Counts of Communities with Demarcation Information and Map Information")
rownames(table_conceptnote1) <- c("Identificada", "Delimitada", "Declarada", "Homologada", "Regularizada")
table_conceptnote1 <- as.table(table_conceptnote1)
print(table_conceptnote1)
print("------------------------------------------------------------------------------------------")
#counts number of observations that are the same and have map data
identificada_same_map <- length(which(!data_merged$identificada_diff & !is.na(data_merged$id_587)))
delimitada_same_map <- length(which(!data_merged$delimitada_diff & !is.na(data_merged$id_587)))
declarada_same_map <- length(which(!data_merged$declarada_diff & !is.na(data_merged$id_587)))
homologada_same_map <- length(which(!data_merged$homologada_diff & !is.na(data_merged$id_587)))
regularizada_same_map <- length(which(!data_merged$regularizada_diff & !is.na(data_merged$id_587)))
#counts number of observations that are different and have map data
identificada_diff_map <- length(which((data_merged$identificada_diff) & is.na(data_merged$id_587)))
delimitada_diff_map <- length(which((data_merged$delimitada_diff) & is.na(data_merged$id_587)))
declarada_diff_map <- length(which((data_merged$declarada_diff) & is.na(data_merged$id_587)))
homologada_diff_map <- length(which((data_merged$homologada_diff) & is.na(data_merged$id_587)))
regularizada_diff_map <- length(which((data_merged$regularizada_diff) & is.na(data_merged$id_587)))
#changes the indicator variables from TRUE/FALSE to 1/0
data_merged$identificada_diff <- as.numeric(data_merged$identificada_diff)
data_merged$delimitada_diff <- as.numeric(data_merged$delimitada_diff)
data_merged$declarada_diff <- as.numeric(data_merged$declarada_diff)
data_merged$homologada_diff <- as.numeric(data_merged$homologada_diff)
data_merged$regularizada_diff <- as.numeric(data_merged$regularizada_diff)
#seperates the data into day, month, year columns for each stage
data_merged$identificada_day2016 <- as.numeric(format(data_merged$identificada2016, format = "%d"))
data_merged$identificada_month2016 <- as.numeric(format(data_merged$identificada2016, format = "%m"))
data_merged$identificada_year2016 <- as.numeric(format(data_merged$identificada2016, format = "%Y"))
data_merged$identificada_day2011 <- as.numeric(format(data_merged$identificada2011, format = "%d"))
data_merged$identificada_month2011 <- as.numeric(format(data_merged$identificada2011, format = "%m"))
data_merged$identificada_year2011 <- as.numeric(format(data_merged$identificada2011, format = "%Y"))
data_merged$delimitada_day2016 <- as.numeric(format(data_merged$delimitada2016, format = "%d"))
data_merged$delimitada_month2016 <- as.numeric(format(data_merged$delimitada2016, format = "%m"))
data_merged$delimitada_year2016 <- as.numeric(format(data_merged$delimitada2016, format = "%Y"))
data_merged$delimitada_day2011 <- as.numeric(format(data_merged$delimitada2011, format = "%d"))
data_merged$delimitada_month2011 <- as.numeric(format(data_merged$delimitada2011, format = "%m"))
data_merged$delimitada_year2011 <- as.numeric(format(data_merged$delimitada2011, format = "%Y"))
data_merged$declarada_day2016 <- as.numeric(format(data_merged$declarada2016, format = "%d"))
data_merged$declarada_month2016 <- as.numeric(format(data_merged$declarada2016, format = "%m"))
data_merged$declarada_year2016 <- as.numeric(format(data_merged$declarada2016, format = "%Y"))
data_merged$declarada_day2011 <- as.numeric(format(data_merged$declarada2011, format = "%d"))
data_merged$declarada_month2011 <- as.numeric(format(data_merged$declarada2011, format = "%m"))
data_merged$declarada_year2011 <- as.numeric(format(data_merged$declarada2011, format = "%Y"))
data_merged$homologada_day2016 <- as.numeric(format(data_merged$homologada2016, format = "%d"))
data_merged$homologada_month2016 <- as.numeric(format(data_merged$homologada2016, format = "%m"))
data_merged$homologada_year2016 <- as.numeric(format(data_merged$homologada2016, format = "%Y"))
data_merged$homologada_day2011 <- as.numeric(format(data_merged$homologada2011, format = "%d"))
data_merged$homologada_month2011 <- as.numeric(format(data_merged$homologada2011, format = "%m"))
data_merged$homologada_year2011 <- as.numeric(format(data_merged$homologada2011, format = "%Y"))
data_merged$regularizada_day2016 <- as.numeric(format(data_merged$regularizada2016, format = "%d"))
data_merged$regularizada_month2016 <- as.numeric(format(data_merged$regularizada2016, format = "%m"))
data_merged$regularizada_year2016 <- as.numeric(format(data_merged$regularizada2016, format = "%Y"))
data_merged$regularizada_day2011 <- as.numeric(format(data_merged$regularizada2011, format = "%d"))
data_merged$regularizada_month2011 <- as.numeric(format(data_merged$regularizada2011, format = "%m"))
data_merged$regularizada_year2011 <- as.numeric(format(data_merged$regularizada2011, format = "%Y"))
data_merged$reg_extra_day2011 <- as.numeric(format(data_merged$reg_extra2011, format = "%d"))
data_merged$reg_extra_month2011 <- as.numeric(format(data_merged$reg_extra2011, format = "%m"))
data_merged$reg_extra_year2011 <- as.numeric(format(data_merged$reg_extra2011, format = "%Y"))
#creates a table comparing 2011 and 2016 data####
print("Comparison of 2011 and 2016 data, with Agreement:")
table_one <- matrix(c(identificada_count2011, identificada_map_count2011, identificada_count2016, identificada_map_count2016, identificada_same_val, identificada_diff_val, identificada_same_map, identificada_diff_map,
delimitada_count2011, delimitada_map_count2011, delimitada_count2016, delimitada_map_count2016, delimitada_same_val, delimitada_diff_val, delimitada_same_map, delimitada_diff_map,
declarada_count2011, declarada_map_count2011, declarada_count2016, declarada_map_count2016, declarada_same_val, declarada_diff_val, declarada_same_map, declarada_diff_map,
homologada_count2011, homologada_map_count2011, homologada_count2016, homologada_map_count2016, homologada_same_val, homologada_diff_val, homologada_same_map, homologada_diff_map,
regularizada_count2011, regularizada_map_count2011, regularizada_count2016, regularizada_map_count2016, regularizada_same_val, regularizada_diff_val, regularizada_same_map, regularizada_diff_map),
ncol = 8, byrow = TRUE)
colnames(table_one) <- c("~2011", "~2011 Mapped", "~2016", "~2016 Mapped", "~Agreement", "~Disagreement", "~Mapped Agreement", "~Mapped Disagreement")
rownames(table_one) <- c("Identificada", "Delimitada", "Declarada", "Homologada", "Regularizada")
table_one <- as.table(table_one)
print(table_one)
#==================================================================================================
####################################################Start of PPTAL Manipulation###################################
#reads in PPTAL data
dataPPTAL <- read.csv(file = "Raw_and_Orginal_Data/PPTAL_151lands_demdates.csv", header=TRUE, sep = ',')
#renames id to id_587 in the PPTAL data so the id names match
names(dataPPTAL)[names(dataPPTAL)=="id"] <- "id_587"
#merges data_merged with PPTAL data by id_587
data_merged <- merge(data_merged, dataPPTAL, by = "id_587")
#counts number of non-blank observations for each stage in PPTAL data
id_count <- length(data_merged$idstart_m) - sum(is.na(data_merged$idstart_m))
del_count <- length(data_merged$delplan_m) - sum(is.na(data_merged$delplan_m))
dem_count <- length(data_merged$demplan_m) - sum(is.na(data_merged$demplan_m))
appr_count <- length(data_merged$apprend_m) - sum(is.na(data_merged$apprend_m))
reg_count <- length(data_merged$regplan_m) - sum(is.na(data_merged$regplan_m))
#checks whether the observations in PPTAL and 2011 data are the same, makes an indicator variable TRUE if different, FALSE if the same
data_merged$id_diff_2011 <- data_merged$identificada_month2011!=data_merged$idstart_m | data_merged$identificada_year2011!=data_merged$idstart_y
data_merged$del_diff_2011 <- data_merged$delimitada_month2011!=data_merged$delplan_m | data_merged$delimitada_year2011!=data_merged$delplan_y
data_merged$dem_diff_2011 <- data_merged$declarada_month2011!=data_merged$demplan_m | data_merged$declarada_year2011!=data_merged$demplan_y
data_merged$appr_diff_2011 <- data_merged$homologada_month2011!=data_merged$apprend_m | data_merged$homologada_year2011!=data_merged$apprend_y
data_merged$reg_diff_2011 <- data_merged$regularizada_month2011!=data_merged$regplan_m | data_merged$regularizada_year2011!=data_merged$regplan_y
#checks whether the observations in PPTAL and 2016 data are the same, makes an indicator variable TRUE if different, FALSE if the same
data_merged$id_diff_2016 <- data_merged$identificada_month2016!=data_merged$idstart_m | data_merged$identificada_year2016!=data_merged$idstart_y
data_merged$del_diff_2016 <- data_merged$delimitada_month2016!=data_merged$delplan_m | data_merged$delimitada_year2016!=data_merged$delplan_y
data_merged$dem_diff_2016 <- data_merged$declarada_month2016!=data_merged$demplan_m | data_merged$declarada_year2016!=data_merged$demplan_y
data_merged$appr_diff_2016 <- data_merged$homologada_month2016!=data_merged$apprend_m | data_merged$homologada_year2016!=data_merged$apprend_y
data_merged$reg_diff_2016 <- data_merged$regularizada_month2016!=data_merged$regplan_m | data_merged$regularizada_year2016!=data_merged$regplan_y
#counts and stores in new values the number of differences between the two datasets for each stage
id_diff_val_2011 <- length(which(data_merged$id_diff_2011))
del_diff_val_2011 <- length(which(data_merged$del_diff_2011))
dem_diff_val_2011 <- length(which(data_merged$dem_diff_2011))
appr_diff_val_2011 <- length(which(data_merged$appr_diff_2011))
reg_diff_val_2011 <- length(which(data_merged$reg_diff_2011))
id_diff_val_2016 <- length(which(data_merged$id_diff_2016))
del_diff_val_2016 <- length(which(data_merged$del_diff_2016))
dem_diff_val_2016 <- length(which(data_merged$dem_diff_2016))
appr_diff_val_2016 <- length(which(data_merged$appr_diff_2016))
reg_diff_val_2016 <- length(which(data_merged$reg_diff_2016))
#counts and stores in new values the number of observations that agree between the two datasets for each stage
id_same_val_2011 <- length(which(!data_merged$id_diff_2011))
del_same_val_2011 <- length(which(!data_merged$del_diff_2011))
dem_same_val_2011 <- length(which(!data_merged$dem_diff_2011))
appr_same_val_2011 <- length(which(!data_merged$appr_diff_2011))
reg_same_val_2011 <- length(which(!data_merged$reg_diff_2011))
id_same_val_2016 <- length(which(!data_merged$id_diff_2016))
del_same_val_2016 <- length(which(!data_merged$del_diff_2016))
dem_same_val_2016 <- length(which(!data_merged$dem_diff_2016))
appr_same_val_2016 <- length(which(!data_merged$appr_diff_2016))
reg_same_val_2016 <- length(which(!data_merged$reg_diff_2016))
#-----------------------------------------------------------------------------
#checks whether the month observations in PPTAL and 2011 data are the same, makes an indicator variable TRUE if different, FALSE if the same
data_merged$id_diff_m2011 <- data_merged$identificada_month2011!=data_merged$idstart_m
data_merged$del_diff_m2011 <- data_merged$delimitada_month2011!=data_merged$delplan_m
data_merged$dem_diff_m2011 <- data_merged$declarada_month2011!=data_merged$demplan_m
data_merged$appr_diff_m2011 <- data_merged$homologada_month2011!=data_merged$apprend_m
data_merged$reg_diff_m2011 <- data_merged$regularizada_month2011!=data_merged$regplan_m
#checks whether the month observations in PPTAL and 2016 data are the same, makes an indicator variable TRUE if different, FALSE if the same
data_merged$id_diff_m2016 <- data_merged$identificada_month2016!=data_merged$idstart_m
data_merged$del_diff_m2016 <- data_merged$delimitada_month2016!=data_merged$delplan_m
data_merged$dem_diff_m2016 <- data_merged$declarada_month2016!=data_merged$demplan_m
data_merged$appr_diff_m2016 <- data_merged$homologada_month2016!=data_merged$apprend_m
data_merged$reg_diff_m2016 <- data_merged$regularizada_month2016!=data_merged$regplan_m
#counts and stores in new values the number of month differences between the two datasets for each stage
id_diff_val_m2011 <- length(which(data_merged$id_diff_m2011))
del_diff_val_m2011 <- length(which(data_merged$del_diff_m2011))
dem_diff_val_m2011 <- length(which(data_merged$dem_diff_m2011))
appr_diff_val_m2011 <- length(which(data_merged$appr_diff_m2011))
reg_diff_val_m2011 <- length(which(data_merged$reg_diff_m2011))
id_diff_val_m2016 <- length(which(data_merged$id_diff_m2016))
del_diff_val_m2016 <- length(which(data_merged$del_diff_m2016))
dem_diff_val_m2016 <- length(which(data_merged$dem_diff_m2016))
appr_diff_val_m2016 <- length(which(data_merged$appr_diff_m2016))
reg_diff_val_m2016 <- length(which(data_merged$reg_diff_m2016))
#counts and stores in new values the number of month observations that agree between the two datasets for each stage
id_same_val_m2011 <- length(which(!data_merged$id_diff_m2011))
del_same_val_m2011 <- length(which(!data_merged$del_diff_m2011))
dem_same_val_m2011 <- length(which(!data_merged$dem_diff_m2011))
appr_same_val_m2011 <- length(which(!data_merged$appr_diff_m2011))
reg_same_val_m2011 <- length(which(!data_merged$reg_diff_m2011))
id_same_val_m2016 <- length(which(!data_merged$id_diff_m2016))
del_same_val_m2016 <- length(which(!data_merged$del_diff_m2016))
dem_same_val_m2016 <- length(which(!data_merged$dem_diff_m2016))
appr_same_val_m2016 <- length(which(!data_merged$appr_diff_m2016))
reg_same_val_m2016 <- length(which(!data_merged$reg_diff_m2016))
#-----------------------------------------------------------------------------
#checks whether the year observations in PPTAL and 2011 data are the same, makes an indicator variable TRUE if different, FALSE if the same
data_merged$id_diff_y2011 <- data_merged$identificada_year2011!=data_merged$idstart_y
data_merged$del_diff_y2011 <- data_merged$delimitada_year2011!=data_merged$delplan_y
data_merged$dem_diff_y2011 <- data_merged$declarada_year2011!=data_merged$demplan_y
data_merged$appr_diff_y2011 <- data_merged$homologada_year2011!=data_merged$apprend_y
data_merged$reg_diff_y2011 <- data_merged$regularizada_year2011!=data_merged$regplan_y
#checks whether the year observations in PPTAL and 2016 data are the same, makes an indicator variable TRUE if different, FALSE if the same
data_merged$id_diff_y2016 <- data_merged$identificada_year2016!=data_merged$idstart_y
data_merged$del_diff_y2016 <- data_merged$delimitada_year2016!=data_merged$delplan_y
data_merged$dem_diff_y2016 <- data_merged$declarada_year2016!=data_merged$demplan_y
data_merged$appr_diff_y2016 <- data_merged$homologada_year2016!=data_merged$apprend_y
data_merged$reg_diff_y2016 <- data_merged$regularizada_year2016!=data_merged$regplan_y
#counts and stores in new values the number of year differences between the two datasets for each stage
id_diff_val_y2011 <- length(which(data_merged$id_diff_y2011))
del_diff_val_y2011 <- length(which(data_merged$del_diff_y2011))
dem_diff_val_y2011 <- length(which(data_merged$dem_diff_y2011))
appr_diff_val_y2011 <- length(which(data_merged$appr_diff_y2011))
reg_diff_val_y2011 <- length(which(data_merged$reg_diff_y2011))
id_diff_val_y2016 <- length(which(data_merged$id_diff_y2016))
del_diff_val_y2016 <- length(which(data_merged$del_diff_y2016))
dem_diff_val_y2016 <- length(which(data_merged$dem_diff_y2016))
appr_diff_val_y2016 <- length(which(data_merged$appr_diff_y2016))
reg_diff_val_y2016 <- length(which(data_merged$reg_diff_y2016))
#counts and stores in new values the number of year observations that agree between the two datasets for each stage
id_same_val_y2011 <- length(which(!data_merged$id_diff_y2011))
del_same_val_y2011 <- length(which(!data_merged$del_diff_y2011))
dem_same_val_y2011 <- length(which(!data_merged$dem_diff_y2011))
appr_same_val_y2011 <- length(which(!data_merged$appr_diff_y2011))
reg_same_val_y2011 <- length(which(!data_merged$reg_diff_y2011))
id_same_val_y2016 <- length(which(!data_merged$id_diff_y2016))
del_same_val_y2016 <- length(which(!data_merged$del_diff_y2016))
dem_same_val_y2016 <- length(which(!data_merged$dem_diff_y2016))
appr_same_val_y2016 <- length(which(!data_merged$appr_diff_y2016))
reg_same_val_y2016 <- length(which(!data_merged$reg_diff_y2016))
#-----------------------------------------------------------------------------
#counts the number of observations that are not blank in BOTH the datasets
id_present_2011 <- length(data_merged$idstart_m) - sum(is.na(data_merged$idstart_m) | is.na(data_merged$identificada2011))
del_present_2011 <- length(data_merged$delplan_m) - sum(is.na(data_merged$delplan_m) | is.na(data_merged$delimitada2011))
dem_present_2011 <- length(data_merged$demplan_m) - sum(is.na(data_merged$demplan_m) | is.na(data_merged$declarada2011))
appr_present_2011 <- length(data_merged$apprend_m) - sum(is.na(data_merged$apprend_m) | is.na(data_merged$homologada2011))
reg_present_2011 <- length(data_merged$regplan_m) - sum(is.na(data_merged$regplan_m) | is.na(data_merged$regularizada2011))
id_present_2016 <- length(data_merged$idstart_m) - sum(is.na(data_merged$idstart_m) | is.na(data_merged$identificada2016))
del_present_2016 <- length(data_merged$delplan_m) - sum(is.na(data_merged$delplan_m) | is.na(data_merged$delimitada2016))
dem_present_2016 <- length(data_merged$demplan_m) - sum(is.na(data_merged$demplan_m) | is.na(data_merged$declarada2016))
appr_present_2016 <- length(data_merged$apprend_m) - sum(is.na(data_merged$apprend_m) | is.na(data_merged$homologada2016))
reg_present_2016 <- length(data_merged$regplan_m) - sum(is.na(data_merged$regplan_m) | is.na(data_merged$regularizada2016))
#counts the number of observations that are present in 2011 or 2016 but NOT PPTAL
id_present_only_2011 <- length(data_merged$idstart_m) - sum(!is.na(data_merged$idstart_m) | is.na(data_merged$identificada2011))
del_present_only_2011 <- length(data_merged$delplan_m) - sum(!is.na(data_merged$delplan_m) | is.na(data_merged$delimitada2011))
dem_present_only_2011 <- length(data_merged$demplan_m) - sum(!is.na(data_merged$demplan_m) | is.na(data_merged$declarada2011))
appr_present_only_2011 <- length(data_merged$apprend_m) - sum(!is.na(data_merged$apprend_m) | is.na(data_merged$homologada2011))
reg_present_only_2011 <- length(data_merged$regplan_m) - sum(!is.na(data_merged$regplan_m) | is.na(data_merged$regularizada2011))
id_present_only_2016 <- length(data_merged$idstart_m) - sum(!is.na(data_merged$idstart_m) | is.na(data_merged$identificada2016))
del_present_only_2016 <- length(data_merged$delplan_m) - sum(!is.na(data_merged$delplan_m) | is.na(data_merged$delimitada2016))
dem_present_only_2016 <- length(data_merged$demplan_m) - sum(!is.na(data_merged$demplan_m) | is.na(data_merged$declarada2016))
appr_present_only_2016 <- length(data_merged$apprend_m) - sum(!is.na(data_merged$apprend_m) | is.na(data_merged$homologada2016))
reg_present_only_2016 <- length(data_merged$regplan_m) - sum(!is.na(data_merged$regplan_m) | is.na(data_merged$regularizada2016))
#creates a table comparing agreement of PPTAL, 2011 and 2016 data####
print("------------------------------------------------------------------------------------------")
print("Comparison of PPTAL, 2011, and 2016 data, with Agreement, and Agreement of Month and Year:")
table_two <- matrix(c(id_count, id_same_val_2011, id_diff_val_2011, id_same_val_m2011, id_diff_val_m2011,id_same_val_y2011, id_diff_val_y2011, id_present_2011, id_present_only_2011, id_same_val_2016, id_diff_val_2016, id_same_val_m2016, id_diff_val_m2016, id_same_val_y2016, id_diff_val_y2016, id_present_2016, id_present_only_2016,
del_count, del_same_val_2011, del_diff_val_2011, del_same_val_m2011, del_diff_val_m2011, del_same_val_y2011, del_diff_val_y2011, del_present_2011, del_present_only_2011, del_same_val_2016, del_diff_val_2016, del_same_val_m2016, del_diff_val_m2016, del_same_val_y2016, del_diff_val_y2016, del_present_2016, del_present_only_2016,
dem_count, dem_same_val_2011, dem_diff_val_2011, dem_same_val_m2011, dem_diff_val_m2011, dem_same_val_y2011, dem_diff_val_y2011, dem_present_2011, dem_present_only_2011, dem_same_val_2016, dem_diff_val_2016, dem_same_val_m2016, dem_diff_val_m2016, dem_same_val_y2016, dem_diff_val_y2016, dem_present_2016, dem_present_only_2016,
appr_count, appr_same_val_2011, appr_diff_val_2011, appr_same_val_m2011, appr_diff_val_m2011, appr_same_val_y2011, appr_diff_val_y2011, appr_present_2011, appr_present_only_2011, appr_same_val_2016, appr_diff_val_2016, appr_same_val_m2016, appr_diff_val_m2016, appr_same_val_y2016, appr_diff_val_y2016, appr_present_2016, appr_present_only_2016,
reg_count, reg_same_val_2011, reg_diff_val_2011, reg_same_val_m2011, reg_diff_val_m2011, reg_same_val_y2011, reg_diff_val_y2011, reg_present_2011, reg_present_only_2011, reg_same_val_2016, reg_diff_val_2016, reg_same_val_m2016, reg_diff_val_m2016, reg_same_val_y2016, reg_diff_val_y2016, reg_present_2016, reg_present_only_2016),
ncol = 17, byrow = TRUE)
colnames(table_two) <- c("~PPTAL", "~PPTAL 2011 Agree", "~PPTAL 2011 Disagree", "~PPTAL 2011 M Agree", "~PPTAL 2011 M Disagree", "~PPTAL 2011 Y Agree", "~PPTAL 2011 Y Disagree", "~Present PPTAL 2011", "~Present 2011, not PPTAL",
"~PPTAL 2016 Agree", "~PPTAL 2016 Disagree", "~PPTAL 2016 M Agree", "~PPTAL 2016 M Disagree", "~PPTAL 2016 Y Agree", "~PPTAL 2016 Y Disagree", "~Present PPTAL 2016", "~Present 2016, not PPTAL")
rownames(table_two) <- c("Identificada", "Delimitada", "Declarada", "Homologada", "Regularizada")
table_two <- as.table(table_two)
print(table_two)
#creates a table comparing PPTAL, 2011 and 2016 data (# of Observations)####
print("------------------------------------------------------------------------------------------")
print("Comparison of PPTAL, 2011 and 2016 data (# of Observations):")
table_three <- matrix(c(id_count, identificada_count2011, identificada_map_count2011, identificada_count2016, identificada_map_count2016,
del_count, delimitada_count2011, delimitada_map_count2011, delimitada_count2016, delimitada_map_count2016,
dem_count, declarada_count2011, declarada_map_count2011, declarada_count2016, declarada_map_count2016,
appr_count, homologada_count2011, homologada_map_count2011, homologada_count2016, homologada_map_count2016,
reg_count, regularizada_count2011, regularizada_map_count2011, regularizada_count2016, regularizada_map_count2016),
ncol = 5, byrow = TRUE)
colnames(table_three) <- c("~PPTAL Observations", "~2011 Observations", "~2011 Mapped Observations", "~2016 Observations",
"~2016 Mapped Observations")
rownames(table_three) <- c("Identificada", "Delimitada", "Declarada", "Homologada", "Regularizada")
table_three <- as.table(table_three)
print(table_three)
print("======================================================================================")
#############################################Start of Violence Data Manipulation###############################
#reads the violence data from the files
data_iviolence <- read.csv(file = "Raw_and_Orginal_Data/Final_IndividualViolence_CIMI (1).csv", header=TRUE, sep = ',')
data_lviolence <- read.csv(file = "Raw_and_Orginal_Data/Final_LandViolence_CIMI_new (2).csv", header=TRUE, sep = ',')
#drops rows with missing ad_id
data_iviolence$ad_id <- as.numeric(as.character(data_iviolence$ad_id))
data_lviolence$ad_id <- as.numeric(as.character(data_lviolence$ad_id))
data_iviolence <- data_iviolence[!(is.na(data_iviolence$ad_id)),]
data_lviolence <- data_lviolence[!(is.na(data_lviolence$ad_id)),]
#creates new vectors of unique ad_ids from both violence datasets
iviolence_uniqueid <- sort(unique(data_iviolence$ad_id))
lviolence_uniqueid <- sort(unique(data_lviolence$ad_id))
#gets number of unique areas affected by violence
iviolence_uniqueid_val <- length(iviolence_uniqueid)
lviolence_uniqueid_val <- length(lviolence_uniqueid)
#creates new dataframes for finding violence overlap with other datasets
iviolence_overlap <- as.data.frame(iviolence_uniqueid)
lviolence_overlap <- as.data.frame(lviolence_uniqueid)
#prints vectors of unique ad_ids
#print(iviolence_uniqueid)
#print(lviolence_uniqueid)
#renames iviolence_uniqueid to ad_id so the the id names match
names(iviolence_overlap)[names(iviolence_overlap)=="iviolence_uniqueid"] <- "id_ad"
#renames lviolence_uniqueid to ad_id so the the id names match
names(lviolence_overlap)[names(lviolence_overlap)=="lviolence_uniqueid"] <- "id_ad"
#changes the demarcation stage variables in 2011 dataset to date variables
data2011$identificada2011 <- as.Date(data2011$identificada2011, format= "%m/%d/%Y")
data2011$delimitada2011 <- as.Date(data2011$delimitada2011, format= "%m/%d/%Y")
data2011$declarada2011 <- as.Date(data2011$declarada2011, format= "%m/%d/%Y")
data2011$homologada2011 <- as.Date(data2011$homologada2011, format= "%m/%d/%Y")
data2011$regularizada2011 <- as.Date(data2011$regularizada2011, format= "%m/%d/%Y")
data2011$reg_extra2011 <- as.Date(data2011$reg_extra2011, format= "%m/%d/%Y")
#merges violence data and 2011 data (dropping rows that have no corresponding id_ad)
iviolence_overlap_11 <- merge(iviolence_overlap, data2011, by = "id_ad")
lviolence_overlap_11 <- merge(lviolence_overlap, data2011, by = "id_ad")
#merges 2011/2016 data (dropping rows that have no corresponding id_733)
data_merged_11_16 <- merge(data2011, data2016, by="id_733")
#changes the demarcation stage variables in 2011/2016 merged dataset to date variables
data_merged_11_16$identificada2011 <- as.Date(data_merged_11_16$identificada2011, format= "%m/%d/%Y")
data_merged_11_16$identificada2016 <- as.Date(data_merged_11_16$identificada2016, format= "%m/%d/%Y")
data_merged_11_16$delimitada2011 <- as.Date(data_merged_11_16$delimitada2011, format= "%m/%d/%Y")
data_merged_11_16$delimitada2016 <- as.Date(data_merged_11_16$delimitada2016, format= "%m/%d/%Y")
data_merged_11_16$declarada2011 <- as.Date(data_merged_11_16$declarada2011, format= "%m/%d/%Y")
data_merged_11_16$declarada2016 <- as.Date(data_merged_11_16$declarada2016, format= "%m/%d/%Y")
data_merged_11_16$homologada2011 <- as.Date(data_merged_11_16$homologada2011, format= "%m/%d/%Y")
data_merged_11_16$homologada2016 <- as.Date(data_merged_11_16$homologada2016, format= "%m/%d/%Y")
data_merged_11_16$regularizada2011 <- as.Date(data_merged_11_16$regularizada2011, format= "%m/%d/%Y")
data_merged_11_16$regularizada2016 <- as.Date(data_merged_11_16$regularizada2016, format= "%m/%d/%Y")
data_merged_11_16$reg_extra2011 <- as.Date(data_merged_11_16$reg_extra2011, format= "%m/%d/%Y")
#merges violence data and 2011/2016 merged data (dropping rows that have no corresponding id_ad)
iviolence_overlap_16 <- merge(iviolence_overlap, data_merged_11_16, by = "id_ad")
lviolence_overlap_16 <- merge(lviolence_overlap, data_merged_11_16, by = "id_ad")
#merges violence data and PPTAL data (dropping rows that have no corresponding id_ad)
iviolence_overlap_PPTAL <- merge(iviolence_overlap, data_merged, by = "id_ad")
lviolence_overlap_PPTAL <- merge(lviolence_overlap, data_merged, by = "id_ad")
#finds overlap of violence data and mapped data
iviolence_overlap_11_map <- iviolence_overlap_11[(!is.na(iviolence_overlap_11$id_587)),]
lviolence_overlap_11_map <- lviolence_overlap_11[(!is.na(lviolence_overlap_11$id_587)),]
iviolence_overlap_16_map <- iviolence_overlap_16[(!is.na(iviolence_overlap_16$id_587)),]
lviolence_overlap_16_map <- lviolence_overlap_16[(!is.na(lviolence_overlap_16$id_587)),]
#fills in values for whether there is overlap for each dataset into columns in iviolence_overlap
iviolence_overlap$overlap_11 <- iviolence_overlap$id_ad %in% iviolence_overlap_11$id_ad
iviolence_overlap$overlap_16 <- iviolence_overlap$id_ad %in% iviolence_overlap_16$id_ad
iviolence_overlap$overlap_PPTAL <- iviolence_overlap$id_ad %in% iviolence_overlap_PPTAL$id_ad
iviolence_overlap$overlap_any <- (iviolence_overlap$id_ad %in% iviolence_overlap_11$id_ad) | (iviolence_overlap$id_ad %in% iviolence_overlap_16$id_ad) | (iviolence_overlap$id_ad %in% iviolence_overlap_PPTAL$id_ad)
iviolence_overlap$overlap_11_map <- iviolence_overlap$id_ad %in% iviolence_overlap_11_map$id_ad
iviolence_overlap$overlap_16_map <- iviolence_overlap$id_ad %in% iviolence_overlap_16_map$id_ad
iviolence_overlap$overlap_any_map <- (iviolence_overlap$id_ad %in% iviolence_overlap_11_map$id_ad) | (iviolence_overlap$id_ad %in% iviolence_overlap_16_map$id_ad) | (iviolence_overlap$id_ad %in% iviolence_overlap_PPTAL$id_ad)
#fills in values for whether there is overlap for each dataset into columns in lviolence_overlap
lviolence_overlap$overlap_11 <- lviolence_overlap$id_ad %in% lviolence_overlap_11$id_ad
lviolence_overlap$overlap_16 <- lviolence_overlap$id_ad %in% lviolence_overlap_16$id_ad
lviolence_overlap$overlap_PPTAL <- lviolence_overlap$id_ad %in% lviolence_overlap_PPTAL$id_ad
lviolence_overlap$overlap_any <- (lviolence_overlap$id_ad %in% lviolence_overlap_11$id_ad) | (lviolence_overlap$id_ad %in% lviolence_overlap_16$id_ad) | (lviolence_overlap$id_ad %in% lviolence_overlap_PPTAL$id_ad)
lviolence_overlap$overlap_11_map <- lviolence_overlap$id_ad %in% lviolence_overlap_11_map$id_ad
lviolence_overlap$overlap_16_map <- lviolence_overlap$id_ad %in% lviolence_overlap_16_map$id_ad
lviolence_overlap$overlap_any_map <- (lviolence_overlap$id_ad %in% lviolence_overlap_11_map$id_ad) | (lviolence_overlap$id_ad %in% lviolence_overlap_16_map$id_ad) | (lviolence_overlap$id_ad %in% lviolence_overlap_PPTAL$id_ad)
########################Start of Finding Individual Stage Overlap###############################
#finding identificada overlap for violence data and each other dataset
iviolence_overlap$overlap_11_id <- !is.na(iviolence_overlap_11$identificada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)])
iviolence_overlap$overlap_16_id <- !is.na(iviolence_overlap_16$identificada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)])
iviolence_overlap$overlap_PPTAL_id <- !is.na(iviolence_overlap_PPTAL$idstart_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_id <- !is.na(iviolence_overlap_11$identificada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)]) | !is.na(iviolence_overlap_16$identificada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)]) | !is.na(iviolence_overlap_PPTAL$idstart_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding identificada overlap for violence data and each other mapped dataset
iviolence_overlap$overlap_11_id_map <- !is.na(iviolence_overlap_11_map$identificada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)])
iviolence_overlap$overlap_16_id_map <- !is.na(iviolence_overlap_16_map$identificada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)])
iviolence_overlap$overlap_PPTAL_id_map <- !is.na(iviolence_overlap_PPTAL$idstart_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_id_map <- !is.na(iviolence_overlap_11_map$identificada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)]) | !is.na(iviolence_overlap_16_map$identificada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)]) | !is.na(iviolence_overlap_PPTAL$idstart_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding delimitada overlap for violence data and each other dataset
iviolence_overlap$overlap_11_del <- !is.na(iviolence_overlap_11$delimitada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)])
iviolence_overlap$overlap_16_del <- !is.na(iviolence_overlap_16$delimitada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)])
iviolence_overlap$overlap_PPTAL_del <- !is.na(iviolence_overlap_PPTAL$delplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_del <- !is.na(iviolence_overlap_11$delimitada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)]) | !is.na(iviolence_overlap_16$delimitada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)]) | !is.na(iviolence_overlap_PPTAL$delplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding delimitada overlap for violence data and each other mapped dataset
iviolence_overlap$overlap_11_del_map <- !is.na(iviolence_overlap_11_map$delimitada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)])
iviolence_overlap$overlap_16_del_map <- !is.na(iviolence_overlap_16_map$delimitada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)])
iviolence_overlap$overlap_PPTAL_del_map <- !is.na(iviolence_overlap_PPTAL$delplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_del_map <- !is.na(iviolence_overlap_11_map$delimitada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)]) | !is.na(iviolence_overlap_16_map$delimitada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)]) | !is.na(iviolence_overlap_PPTAL$delplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding declarada overlap for violence data and each other dataset
iviolence_overlap$overlap_11_dem <- !is.na(iviolence_overlap_11$declarada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)])
iviolence_overlap$overlap_16_dem <- !is.na(iviolence_overlap_16$declarada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)])
iviolence_overlap$overlap_PPTAL_dem <- !is.na(iviolence_overlap_PPTAL$demplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_dem <- !is.na(iviolence_overlap_11$declarada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)]) | !is.na(iviolence_overlap_16$declarada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)]) | !is.na(iviolence_overlap_PPTAL$demplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding declarada overlap for violence data and each other mapped dataset
iviolence_overlap$overlap_11_dem_map <- !is.na(iviolence_overlap_11_map$declarada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)])
iviolence_overlap$overlap_16_dem_map <- !is.na(iviolence_overlap_16_map$declarada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)])
iviolence_overlap$overlap_PPTAL_dem_map <- !is.na(iviolence_overlap_PPTAL$demplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_dem_map <- !is.na(iviolence_overlap_11_map$declarada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)]) | !is.na(iviolence_overlap_16_map$declarada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)]) | !is.na(iviolence_overlap_PPTAL$demplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding homologada overlap for violence data and each other dataset
iviolence_overlap$overlap_11_appr <- !is.na(iviolence_overlap_11$homologada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)])
iviolence_overlap$overlap_16_appr <- !is.na(iviolence_overlap_16$homologada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)])
iviolence_overlap$overlap_PPTAL_appr <- !is.na(iviolence_overlap_PPTAL$apprend_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_appr <- !is.na(iviolence_overlap_11$homologada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)]) | !is.na(iviolence_overlap_16$homologada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)]) | !is.na(iviolence_overlap_PPTAL$apprend_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding homologada overlap for violence data and each other mapped dataset
iviolence_overlap$overlap_11_appr_map <- !is.na(iviolence_overlap_11_map$homologada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)])
iviolence_overlap$overlap_16_appr_map <- !is.na(iviolence_overlap_16_map$homologada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)])
iviolence_overlap$overlap_PPTAL_appr_map <- !is.na(iviolence_overlap_PPTAL$apprend_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_appr_map <- !is.na(iviolence_overlap_11_map$homologada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)]) | !is.na(iviolence_overlap_16_map$homologada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)]) | !is.na(iviolence_overlap_PPTAL$apprend_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding regularizada overlap for violence data and each other dataset
iviolence_overlap$overlap_11_reg <- !is.na(iviolence_overlap_11$regularizada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)])
iviolence_overlap$overlap_16_reg <- !is.na(iviolence_overlap_16$regularizada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)])
iviolence_overlap$overlap_PPTAL_reg <- !is.na(iviolence_overlap_PPTAL$regplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_reg <- !is.na(iviolence_overlap_11$regularizada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11$id_ad)]) | !is.na(iviolence_overlap_16$regularizada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16$id_ad)]) | !is.na(iviolence_overlap_PPTAL$regplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
#finding regularizada overlap for violence data and each other mapped dataset
iviolence_overlap$overlap_11_reg_map <- !is.na(iviolence_overlap_11_map$regularizada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)])
iviolence_overlap$overlap_16_reg_map <- !is.na(iviolence_overlap_16_map$regularizada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)])
iviolence_overlap$overlap_PPTAL_reg_map <- !is.na(iviolence_overlap_PPTAL$regplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
iviolence_overlap$overlap_any_reg_map <- !is.na(iviolence_overlap_11_map$regularizada2011[match(iviolence_overlap$id_ad, iviolence_overlap_11_map$id_ad)]) | !is.na(iviolence_overlap_16_map$regularizada2016[match(iviolence_overlap$id_ad, iviolence_overlap_16_map$id_ad)]) | !is.na(iviolence_overlap_PPTAL$regplan_m[match(iviolence_overlap$id_ad, iviolence_overlap_PPTAL$id_ad)])
##################Counting the Overlap for each stage for individual violence###########
ioverlap_11_id_val <- length(which(iviolence_overlap$overlap_11_id))
ioverlap_16_id_val <- length(which(iviolence_overlap$overlap_16_id))
ioverlap_PPTAL_id_val <- length(which(iviolence_overlap$overlap_PPTAL_id))
ioverlap_11_id_map_val <- length(which(iviolence_overlap$overlap_11_id_map))
ioverlap_16_id_map_val <- length(which(iviolence_overlap$overlap_16_id_map))
ioverlap_any_id_val <- length(which(iviolence_overlap$overlap_any_id))
ioverlap_any_id_map_val <- length(which(iviolence_overlap$overlap_any_id_map))
ioverlap_11_del_val <- length(which(iviolence_overlap$overlap_11_del))
ioverlap_16_del_val <- length(which(iviolence_overlap$overlap_16_del))
ioverlap_PPTAL_del_val <- length(which(iviolence_overlap$overlap_PPTAL_del))
ioverlap_11_del_map_val <- length(which(iviolence_overlap$overlap_11_del_map))
ioverlap_16_del_map_val <- length(which(iviolence_overlap$overlap_16_del_map))
ioverlap_any_del_val <- length(which(iviolence_overlap$overlap_any_del))
ioverlap_any_del_map_val <- length(which(iviolence_overlap$overlap_any_del_map))
ioverlap_11_dem_val <- length(which(iviolence_overlap$overlap_11_dem))
ioverlap_16_dem_val <- length(which(iviolence_overlap$overlap_16_dem))
ioverlap_PPTAL_dem_val <- length(which(iviolence_overlap$overlap_PPTAL_dem))
ioverlap_11_dem_map_val <- length(which(iviolence_overlap$overlap_11_dem_map))
ioverlap_16_dem_map_val <- length(which(iviolence_overlap$overlap_16_dem_map))
ioverlap_any_dem_val <- length(which(iviolence_overlap$overlap_any_dem))
ioverlap_any_dem_map_val <- length(which(iviolence_overlap$overlap_any_dem_map))
ioverlap_11_appr_val <- length(which(iviolence_overlap$overlap_11_appr))
ioverlap_16_appr_val <- length(which(iviolence_overlap$overlap_16_appr))
ioverlap_PPTAL_appr_val <- length(which(iviolence_overlap$overlap_PPTAL_appr))
ioverlap_11_appr_map_val <- length(which(iviolence_overlap$overlap_11_appr_map))
ioverlap_16_appr_map_val <- length(which(iviolence_overlap$overlap_16_appr_map))
ioverlap_any_appr_val <- length(which(iviolence_overlap$overlap_any_appr))
ioverlap_any_appr_map_val <- length(which(iviolence_overlap$overlap_any_appr_map))
ioverlap_11_reg_val <- length(which(iviolence_overlap$overlap_11_reg))
ioverlap_16_reg_val <- length(which(iviolence_overlap$overlap_16_reg))
ioverlap_PPTAL_reg_val <- length(which(iviolence_overlap$overlap_PPTAL_reg))
ioverlap_11_reg_map_val <- length(which(iviolence_overlap$overlap_11_reg_map))
ioverlap_16_reg_map_val <- length(which(iviolence_overlap$overlap_16_reg_map))
ioverlap_any_reg_val <- length(which(iviolence_overlap$overlap_any_reg))
ioverlap_any_reg_map_val <- length(which(iviolence_overlap$overlap_any_reg_map))
ioverlap_any_any_val <- length(which(iviolence_overlap$overlap_any))
ioverlap_any_any_val_map <- length(which(iviolence_overlap$overlap_any_map))
#finding identificada overlap for violence data and each other dataset
lviolence_overlap$overlap_11_id <- !is.na(lviolence_overlap_11$identificada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)])
lviolence_overlap$overlap_16_id <- !is.na(lviolence_overlap_16$identificada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)])
lviolence_overlap$overlap_PPTAL_id <- !is.na(lviolence_overlap_PPTAL$idstart_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_id <- !is.na(lviolence_overlap_11$identificada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)]) | !is.na(lviolence_overlap_16$identificada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)]) | !is.na(lviolence_overlap_PPTAL$idstart_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding identificada overlap for violence data and each other mapped dataset
lviolence_overlap$overlap_11_id_map <- !is.na(lviolence_overlap_11_map$identificada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)])
lviolence_overlap$overlap_16_id_map <- !is.na(lviolence_overlap_16_map$identificada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)])
lviolence_overlap$overlap_PPTAL_id_map <- !is.na(lviolence_overlap_PPTAL$idstart_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_id_map <- !is.na(lviolence_overlap_11_map$identificada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)]) | !is.na(lviolence_overlap_16_map$identificada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)]) | !is.na(lviolence_overlap_PPTAL$idstart_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding delimitada overlap for violence data and each other dataset
lviolence_overlap$overlap_11_del <- !is.na(lviolence_overlap_11$delimitada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)])
lviolence_overlap$overlap_16_del <- !is.na(lviolence_overlap_16$delimitada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)])
lviolence_overlap$overlap_PPTAL_del <- !is.na(lviolence_overlap_PPTAL$delplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_del <- !is.na(lviolence_overlap_11$delimitada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)]) | !is.na(lviolence_overlap_16$delimitada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)]) | !is.na(lviolence_overlap_PPTAL$delplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding delimitada overlap for violence data and each other mapped dataset
lviolence_overlap$overlap_11_del_map <- !is.na(lviolence_overlap_11_map$delimitada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)])
lviolence_overlap$overlap_16_del_map <- !is.na(lviolence_overlap_16_map$delimitada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)])
lviolence_overlap$overlap_PPTAL_del_map <- !is.na(lviolence_overlap_PPTAL$delplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_del_map <- !is.na(lviolence_overlap_11_map$delimitada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)]) | !is.na(lviolence_overlap_16_map$delimitada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)]) | !is.na(lviolence_overlap_PPTAL$delplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding declarada overlap for violence data and each other dataset
lviolence_overlap$overlap_11_dem <- !is.na(lviolence_overlap_11$declarada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)])
lviolence_overlap$overlap_16_dem <- !is.na(lviolence_overlap_16$declarada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)])
lviolence_overlap$overlap_PPTAL_dem <- !is.na(lviolence_overlap_PPTAL$demplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_dem <- !is.na(lviolence_overlap_11$declarada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)]) | !is.na(lviolence_overlap_16$declarada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)]) | !is.na(lviolence_overlap_PPTAL$demplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding declarada overlap for violence data and each other mapped dataset
lviolence_overlap$overlap_11_dem_map <- !is.na(lviolence_overlap_11_map$declarada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)])
lviolence_overlap$overlap_16_dem_map <- !is.na(lviolence_overlap_16_map$declarada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)])
lviolence_overlap$overlap_PPTAL_dem_map <- !is.na(lviolence_overlap_PPTAL$demplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_dem_map <- !is.na(lviolence_overlap_11_map$declarada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)]) | !is.na(lviolence_overlap_16_map$declarada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)]) | !is.na(lviolence_overlap_PPTAL$demplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding homologada overlap for violence data and each other dataset
lviolence_overlap$overlap_11_appr <- !is.na(lviolence_overlap_11$homologada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)])
lviolence_overlap$overlap_16_appr <- !is.na(lviolence_overlap_16$homologada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)])
lviolence_overlap$overlap_PPTAL_appr <- !is.na(lviolence_overlap_PPTAL$apprend_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_appr <- !is.na(lviolence_overlap_11$homologada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)]) | !is.na(lviolence_overlap_16$homologada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)]) | !is.na(lviolence_overlap_PPTAL$apprend_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding homologada overlap for violence data and each other mapped dataset
lviolence_overlap$overlap_11_appr_map <- !is.na(lviolence_overlap_11_map$homologada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)])
lviolence_overlap$overlap_16_appr_map <- !is.na(lviolence_overlap_16_map$homologada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)])
lviolence_overlap$overlap_PPTAL_appr_map <- !is.na(lviolence_overlap_PPTAL$apprend_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_appr_map <- !is.na(lviolence_overlap_11_map$homologada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)]) | !is.na(lviolence_overlap_16_map$homologada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)]) | !is.na(lviolence_overlap_PPTAL$apprend_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding regularizada overlap for violence data and each other dataset
lviolence_overlap$overlap_11_reg <- !is.na(lviolence_overlap_11$regularizada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)])
lviolence_overlap$overlap_16_reg <- !is.na(lviolence_overlap_16$regularizada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)])
lviolence_overlap$overlap_PPTAL_reg <- !is.na(lviolence_overlap_PPTAL$regplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_reg <- !is.na(lviolence_overlap_11$regularizada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11$id_ad)]) | !is.na(lviolence_overlap_16$regularizada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16$id_ad)]) | !is.na(lviolence_overlap_PPTAL$regplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
#finding regularizada overlap for violence data and each other mapped dataset
lviolence_overlap$overlap_11_reg_map <- !is.na(lviolence_overlap_11_map$regularizada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)])
lviolence_overlap$overlap_16_reg_map <- !is.na(lviolence_overlap_16_map$regularizada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)])
lviolence_overlap$overlap_PPTAL_reg_map <- !is.na(lviolence_overlap_PPTAL$regplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
lviolence_overlap$overlap_any_reg_map <- !is.na(lviolence_overlap_11_map$regularizada2011[match(lviolence_overlap$id_ad, lviolence_overlap_11_map$id_ad)]) | !is.na(lviolence_overlap_16_map$regularizada2016[match(lviolence_overlap$id_ad, lviolence_overlap_16_map$id_ad)]) | !is.na(lviolence_overlap_PPTAL$regplan_m[match(lviolence_overlap$id_ad, lviolence_overlap_PPTAL$id_ad)])
##################Counting the Overlap for each stage for land violence###########
loverlap_11_id_val <- length(which(lviolence_overlap$overlap_11_id))
loverlap_16_id_val <- length(which(lviolence_overlap$overlap_16_id))
loverlap_PPTAL_id_val <- length(which(lviolence_overlap$overlap_PPTAL_id))
loverlap_11_id_map_val <- length(which(lviolence_overlap$overlap_11_id_map))
loverlap_16_id_map_val <- length(which(lviolence_overlap$overlap_16_id_map))
loverlap_any_id_val <- length(which(lviolence_overlap$overlap_any_id))
loverlap_any_id_map_val <- length(which(lviolence_overlap$overlap_any_id_map))
loverlap_11_del_val <- length(which(lviolence_overlap$overlap_11_del))
loverlap_16_del_val <- length(which(lviolence_overlap$overlap_16_del))
loverlap_PPTAL_del_val <- length(which(lviolence_overlap$overlap_PPTAL_del))
loverlap_11_del_map_val <- length(which(lviolence_overlap$overlap_11_del_map))
loverlap_16_del_map_val <- length(which(lviolence_overlap$overlap_16_del_map))
loverlap_any_del_val <- length(which(lviolence_overlap$overlap_any_del))
loverlap_any_del_map_val <- length(which(lviolence_overlap$overlap_any_del_map))
loverlap_11_dem_val <- length(which(lviolence_overlap$overlap_11_dem))
loverlap_16_dem_val <- length(which(lviolence_overlap$overlap_16_dem))
loverlap_PPTAL_dem_val <- length(which(lviolence_overlap$overlap_PPTAL_dem))
loverlap_11_dem_map_val <- length(which(lviolence_overlap$overlap_11_dem_map))
loverlap_16_dem_map_val <- length(which(lviolence_overlap$overlap_16_dem_map))
loverlap_any_dem_val <- length(which(lviolence_overlap$overlap_any_dem))
loverlap_any_dem_map_val <- length(which(lviolence_overlap$overlap_any_dem_map))
loverlap_11_appr_val <- length(which(lviolence_overlap$overlap_11_appr))
loverlap_16_appr_val <- length(which(lviolence_overlap$overlap_16_appr))
loverlap_PPTAL_appr_val <- length(which(lviolence_overlap$overlap_PPTAL_appr))
loverlap_11_appr_map_val <- length(which(lviolence_overlap$overlap_11_appr_map))
loverlap_16_appr_map_val <- length(which(lviolence_overlap$overlap_16_appr_map))
loverlap_any_appr_val <- length(which(lviolence_overlap$overlap_any_appr))
loverlap_any_appr_map_val <- length(which(lviolence_overlap$overlap_any_appr_map))
loverlap_11_reg_val <- length(which(lviolence_overlap$overlap_11_reg))
loverlap_16_reg_val <- length(which(lviolence_overlap$overlap_16_reg))
loverlap_PPTAL_reg_val <- length(which(lviolence_overlap$overlap_PPTAL_reg))
loverlap_11_reg_map_val <- length(which(lviolence_overlap$overlap_11_reg_map))
loverlap_16_reg_map_val <- length(which(lviolence_overlap$overlap_16_reg_map))
loverlap_any_reg_val <- length(which(lviolence_overlap$overlap_any_reg))
loverlap_any_reg_map_val <- length(which(lviolence_overlap$overlap_any_reg_map))
loverlap_any_any_val <- length(which(lviolence_overlap$overlap_any))
loverlap_any_any_val_map <- length(which(lviolence_overlap$overlap_any_map))
#creates a table of individual violence overlap with stage data####
print("Individual Violence Overlap with Stage Data:")
table_four <- matrix(c(ioverlap_11_id_val, ioverlap_16_id_val, ioverlap_PPTAL_id_val, ioverlap_11_id_map_val, ioverlap_16_id_map_val, ioverlap_any_id_val, ioverlap_any_id_map_val,
ioverlap_11_del_val, ioverlap_16_del_val, ioverlap_PPTAL_del_val, ioverlap_11_del_map_val, ioverlap_16_del_map_val, ioverlap_any_del_val, ioverlap_any_del_map_val,
ioverlap_11_dem_val, ioverlap_16_dem_val, ioverlap_PPTAL_dem_val, ioverlap_11_dem_map_val, ioverlap_16_dem_map_val, ioverlap_any_dem_val, ioverlap_any_dem_map_val,
ioverlap_11_appr_val, ioverlap_16_appr_val, ioverlap_PPTAL_appr_val, ioverlap_11_appr_map_val, ioverlap_16_appr_map_val, ioverlap_any_appr_val, ioverlap_any_appr_map_val,
ioverlap_11_reg_val, ioverlap_16_reg_val, ioverlap_PPTAL_reg_val, ioverlap_11_reg_map_val, ioverlap_16_reg_map_val, ioverlap_any_reg_val, ioverlap_any_reg_map_val),
ncol = 7, byrow = TRUE)
colnames(table_four) <- c("~2011", "~2016", "~PPTAL", "~2011 Mapped", "~2016 Mapped", "~Any", "~Any Mapped")
rownames(table_four) <- c("Identificada", "Delimitada", "Declarada", "Homologada", "Regularizada")
table_four <- as.table(table_four)
print(table_four)
print("---------------------------------------------------------------------------------------------------------------")
#creates a table of land violence overlap with stage data####
print("Land Violence Overlap with Stage Data:")
table_five <- matrix(c(loverlap_11_id_val, loverlap_16_id_val, loverlap_PPTAL_id_val, loverlap_11_id_map_val, loverlap_16_id_map_val, loverlap_any_id_val, loverlap_any_id_map_val,
loverlap_11_del_val, loverlap_16_del_val, loverlap_PPTAL_del_val, loverlap_11_del_map_val, loverlap_16_del_map_val, loverlap_any_del_val, loverlap_any_del_map_val,
loverlap_11_dem_val, loverlap_16_dem_val, loverlap_PPTAL_dem_val, loverlap_11_dem_map_val, loverlap_16_dem_map_val, loverlap_any_dem_val, loverlap_any_dem_map_val,
loverlap_11_appr_val, loverlap_16_appr_val, loverlap_PPTAL_appr_val, loverlap_11_appr_map_val, loverlap_16_appr_map_val, loverlap_any_appr_val, loverlap_any_appr_map_val,
loverlap_11_reg_val, loverlap_16_reg_val, loverlap_PPTAL_reg_val, loverlap_11_reg_map_val, loverlap_16_reg_map_val, loverlap_any_reg_val, loverlap_any_reg_map_val),
ncol = 7, byrow = TRUE)
colnames(table_five) <- c("~2011", "~2016", "~PPTAL", "~2011 Mapped", "~2016 Mapped", "~Any", "~Any Mapped")
rownames(table_five) <- c("Identificada", "Delimitada", "Declarada", "Homologada", "Regularizada")
table_five <- as.table(table_five)
print(table_five)
print("---------------------------------------------------------------------------------------------------------------")
#counts frequency of each ad_id in the data (number of incidences of violence per unit)
iviolence_overlap$freq <- table(data_iviolence$ad_id)
lviolence_overlap$freq <- table(data_lviolence$ad_id)
#counts number of ad_ids with 1-5+ incidences of violence for mapped id (individual)####
ifreq_11_id_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_id_map == TRUE] == 1))
ifreq_16_id_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_id_map == TRUE] == 1))
ifreq_PPTAL_id_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_id_map == TRUE] == 1))
ifreq_11_id_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_id_map == TRUE] == 2))
ifreq_16_id_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_id_map == TRUE] == 2))
ifreq_PPTAL_id_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_id_map == TRUE] == 2))
ifreq_11_id_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_id_map == TRUE] == 3))
ifreq_16_id_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_id_map == TRUE] == 3))
ifreq_PPTAL_id_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_id_map == TRUE] == 3))
ifreq_11_id_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_id_map == TRUE] == 4))
ifreq_16_id_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_id_map == TRUE] == 4))
ifreq_PPTAL_id_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_id_map == TRUE] == 4))
ifreq_11_id_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_id_map == TRUE] >= 5))
ifreq_16_id_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_id_map == TRUE] >= 5))
ifreq_PPTAL_id_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_id_map == TRUE] >= 5))
#counts number of ad_ids with 1-5+ incidences of violence for mapped del
ifreq_11_del_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_del_map == TRUE] == 1))
ifreq_16_del_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_del_map == TRUE] == 1))
ifreq_PPTAL_del_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_del_map == TRUE] == 1))
ifreq_11_del_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_del_map == TRUE] == 2))
ifreq_16_del_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_del_map == TRUE] == 2))
ifreq_PPTAL_del_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_del_map == TRUE] == 2))
ifreq_11_del_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_del_map == TRUE] == 3))
ifreq_16_del_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_del_map == TRUE] == 3))
ifreq_PPTAL_del_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_del_map == TRUE] == 3))
ifreq_11_del_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_del_map == TRUE] == 4))
ifreq_16_del_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_del_map == TRUE] == 4))
ifreq_PPTAL_del_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_del_map == TRUE] == 4))
ifreq_11_del_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_del_map == TRUE] >= 5))
ifreq_16_del_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_del_map == TRUE] >= 5))
ifreq_PPTAL_del_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_del_map == TRUE] >= 5))
#counts number of ad_ids with 1-5+ incidences of violence for mapped dem
ifreq_11_dem_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_dem_map == TRUE] == 1))
ifreq_16_dem_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_dem_map == TRUE] == 1))
ifreq_PPTAL_dem_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_dem_map == TRUE] == 1))
ifreq_11_dem_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_dem_map == TRUE] == 2))
ifreq_16_dem_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_dem_map == TRUE] == 2))
ifreq_PPTAL_dem_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_dem_map == TRUE] == 2))
ifreq_11_dem_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_dem_map == TRUE] == 3))
ifreq_16_dem_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_dem_map == TRUE] == 3))
ifreq_PPTAL_dem_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_dem_map == TRUE] == 3))
ifreq_11_dem_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_dem_map == TRUE] == 4))
ifreq_16_dem_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_dem_map == TRUE] == 4))
ifreq_PPTAL_dem_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_dem_map == TRUE] == 4))
ifreq_11_dem_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_dem_map == TRUE] >= 5))
ifreq_16_dem_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_dem_map == TRUE] >= 5))
ifreq_PPTAL_dem_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_dem_map == TRUE] >= 5))
#counts number of ad_ids with 1-5+ incidences of violence for mapped appr
ifreq_11_appr_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_appr_map == TRUE] == 1))
ifreq_16_appr_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_appr_map == TRUE] == 1))
ifreq_PPTAL_appr_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_appr_map == TRUE] == 1))
ifreq_11_appr_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_appr_map == TRUE] == 2))
ifreq_16_appr_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_appr_map == TRUE] == 2))
ifreq_PPTAL_appr_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_appr_map == TRUE] == 2))
ifreq_11_appr_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_appr_map == TRUE] == 3))
ifreq_16_appr_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_appr_map == TRUE] == 3))
ifreq_PPTAL_appr_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_appr_map == TRUE] == 3))
ifreq_11_appr_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_appr_map == TRUE] == 4))
ifreq_16_appr_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_appr_map == TRUE] == 4))
ifreq_PPTAL_appr_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_appr_map == TRUE] == 4))
ifreq_11_appr_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_appr_map == TRUE] >= 5))
ifreq_16_appr_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_appr_map == TRUE] >= 5))
ifreq_PPTAL_appr_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_appr_map == TRUE] >= 5))
#counts number of ad_ids with 1-5+ incidences of violence for mapped reg
ifreq_11_reg_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_reg_map == TRUE] == 1))
ifreq_16_reg_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_reg_map == TRUE] == 1))
ifreq_PPTAL_reg_map1 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_reg_map == TRUE] == 1))
ifreq_11_reg_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_reg_map == TRUE] == 2))
ifreq_16_reg_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_reg_map == TRUE] == 2))
ifreq_PPTAL_reg_map2 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_reg_map == TRUE] == 2))
ifreq_11_reg_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_reg_map == TRUE] == 3))
ifreq_16_reg_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_reg_map == TRUE] == 3))
ifreq_PPTAL_reg_map3 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_reg_map == TRUE] == 3))
ifreq_11_reg_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_reg_map == TRUE] == 4))
ifreq_16_reg_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_reg_map == TRUE] == 4))
ifreq_PPTAL_reg_map4 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_reg_map == TRUE] == 4))
ifreq_11_reg_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_11_reg_map == TRUE] >= 5))
ifreq_16_reg_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_16_reg_map == TRUE] >= 5))
ifreq_PPTAL_reg_map5 <- length(which(iviolence_overlap$freq[iviolence_overlap$overlap_PPTAL_reg_map == TRUE] >= 5))
#counts number of ad_ids with 1-5+ incidences of violence for mapped id (land)####
lfreq_11_id_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_id_map == TRUE] == 1))
lfreq_16_id_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_id_map == TRUE] == 1))
lfreq_PPTAL_id_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_id_map == TRUE] == 1))
lfreq_11_id_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_id_map == TRUE] == 2))
lfreq_16_id_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_id_map == TRUE] == 2))
lfreq_PPTAL_id_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_id_map == TRUE] == 2))
lfreq_11_id_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_id_map == TRUE] == 3))
lfreq_16_id_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_id_map == TRUE] == 3))
lfreq_PPTAL_id_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_id_map == TRUE] == 3))
lfreq_11_id_map4 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_id_map == TRUE] == 4))
lfreq_16_id_map4 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_id_map == TRUE] == 4))
lfreq_PPTAL_id_map4 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_id_map == TRUE] == 4))
lfreq_11_id_map5 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_id_map == TRUE] >= 5))
lfreq_16_id_map5 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_id_map == TRUE] >= 5))
lfreq_PPTAL_id_map5 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_id_map == TRUE] >= 5))
#counts number of ad_ids with 1-5+ incidences of violence for mapped del
lfreq_11_del_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_del_map == TRUE] == 1))
lfreq_16_del_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_del_map == TRUE] == 1))
lfreq_PPTAL_del_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_del_map == TRUE] == 1))
lfreq_11_del_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_del_map == TRUE] == 2))
lfreq_16_del_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_del_map == TRUE] == 2))
lfreq_PPTAL_del_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_del_map == TRUE] == 2))
lfreq_11_del_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_del_map == TRUE] == 3))
lfreq_16_del_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_del_map == TRUE] == 3))
lfreq_PPTAL_del_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_del_map == TRUE] == 3))
lfreq_11_del_map4 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_del_map == TRUE] == 4))
lfreq_16_del_map4 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_del_map == TRUE] == 4))
lfreq_PPTAL_del_map4 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_del_map == TRUE] == 4))
lfreq_11_del_map5 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_del_map == TRUE] >= 5))
lfreq_16_del_map5 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_del_map == TRUE] >= 5))
lfreq_PPTAL_del_map5 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_del_map == TRUE] >= 5))
#counts number of ad_ids with 1-5+ incidences of violence for mapped dem
lfreq_11_dem_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_dem_map == TRUE] == 1))
lfreq_16_dem_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_dem_map == TRUE] == 1))
lfreq_PPTAL_dem_map1 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_dem_map == TRUE] == 1))
lfreq_11_dem_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_dem_map == TRUE] == 2))
lfreq_16_dem_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_dem_map == TRUE] == 2))
lfreq_PPTAL_dem_map2 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_dem_map == TRUE] == 2))
lfreq_11_dem_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_11_dem_map == TRUE] == 3))
lfreq_16_dem_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_16_dem_map == TRUE] == 3))
lfreq_PPTAL_dem_map3 <- length(which(lviolence_overlap$freq[lviolence_overlap$overlap_PPTAL_dem_map == TRUE] == 3))