Palestine Perception Study

Q1 survey frequencies - Awareness and perception of USAID

Author

MENA MELS

Q1 Exposure to donor logos

Overall

Code
#args(ov_tab)

q1a <- ov_tab(svyrdat, q1a, "q1a", "Seen logo") %>%
  mutate(Donor="UNRWA") %>%
  select(Item, Label, Donor, Disaggregation, Number, Percent:ci)

q1b <- ov_tab(svyrdat, q1b, "q1b", "Seen logo") %>%
  mutate(Donor="UNDP") %>%
  select(Item, Label, Donor, Disaggregation, Number, Percent:ci)

q1c <- ov_tab(svyrdat, q1c, "q1c", "Seen logo") %>%
  mutate(Donor="UNICEF") %>%
  select(Item, Label, Donor, Disaggregation, Number, Percent:ci)

q1d <- ov_tab(svyrdat, q1d, "q1d", "Seen logo") %>%
  mutate(Donor="Red Crescent") %>%
  select(Item, Label, Donor, Disaggregation, Number, Percent:ci)

q1e <- ov_tab(svyrdat, q1e, "q1e", "Seen logo") %>%
  mutate(Donor="WFP") %>%
  select(Item, Label, Donor, Disaggregation, Number, Percent:ci)

q1f <- ov_tab(svyrdat, q1f, "q1f", "Seen logo") %>%
  mutate(Donor="EU") %>%
  select(Item, Label, Donor, Disaggregation, Number, Percent:ci)

q1g <- ov_tab(svyrdat, q1g, "q1g", "Seen logo") %>%
  mutate(Donor="USAID") %>%
  select(Item, Label, Donor, Disaggregation, Number, Percent:ci)

q1h <- ov_tab(svyrdat, q1h, "q1h", "Seen logo") %>%
  mutate(Donor="ActionAid") %>%
  select(Item, Label, Donor, Disaggregation, Number, Percent:ci)

#q1h

q1 <- bind_rows(q1a, q1b, q1c, q1d, q1e, q1f, q1g, q1h) %>%
  arrange(desc(Percent))

write_csv(q1, here("output/tables/eval Q1/q1 logos.csv"))

q1_flx <- q1 %>%
  select(Donor, Number, Percent, `Confidence interval`=ci) %>%
  flextable() %>%
  colformat_double(j=2,
                   digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=4, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q1. Seen donor logo in past year")

save_as_docx(q1_flx, path=here("output/tables/eval Q1/q1 logos.docx"))

q1_flx

Donor

Number

Percent

Confidence interval

UNRWA

2,291

91.8%

90.2% - 93.4%

Red Crescent

2,009

80.5%

77.8% - 83.2%

UNICEF

1,909

76.5%

74% - 79%

EU

1,444

57.9%

55% - 60.7%

UNDP

993

39.8%

36.7% - 42.9%

WFP

957

38.4%

35.5% - 41.2%

USAID

816

32.7%

29.9% - 35.5%

ActionAid

164

6.6%

5.2% - 7.9%

Q1. Seen donor logo in past year

USAID logo, disaggregated

Code
q1g_ov <- ov_tab(svyrdat, q1g, 
                "q1g", "Seen USAID logo")

q1g_sex <- disag_tab(svyrdat, q1g, sex, sex_key, 
                    "q1g", "Seen USAID logo", "Sex")

q1g_age <- disag_tab(svyrdat, q1g, age_grp,age_grp_key,  
                    "q1g", "Seen USAID logo", "Age group")

q1g_ed <- disag_tab(svyrdat, q1g, educ_cat, educ_key,
                   "q1g", "Seen USAID logo", "Education")

q1g_mad <- disag_tab(svyrdat, q1g, madrassa,mad_key,
                   "q1g", "Seen USAID logo", "Madrassa education")

q1g_area <- disag_tab(svyrdat, q1g, area,area_key,
                     "q1g","Seen USAID logo","Area")

q1g_gov <- disag_tab(svyrdat, q1g, gov,gov_key,
                     "q1g","Seen USAID logo","Governorate")

q1g_subreg <- disag_tab(svyrdat, q1g, subregion,subreg_key,
                     "q1g","Seen USAID logo","Subregion")

q1g_reg <- disag_tab(svyrdat, q1g, region,reg_key,
                     "q1g","Seen USAID logo","Region")

q1g_disag <- bind_rows(q1g_ov,
                      q1g_reg,
                      q1g_subreg,
                      q1g_gov,
                      q1g_area,
                      q1g_sex,
                      q1g_age,
                      q1g_ed,
                      q1g_mad)

#q1g_disag

write_csv(q1g_disag, here("output/tables/eval Q1/q1g disag.csv"))

q1g_disag_flx <- q1g_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3,
                   digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q1. Seen USAID logo in past year") %>%
  border_inner_h()

save_as_docx(q1g_disag_flx, path=here("output/tables/eval Q1/q1g_disag.docx"))

q1g_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Seen USAID logo

816

32.7%

29.9% - 35.5%

Region

West Bank

495

33.8%

29.9% - 37.8%

Gaza

321

31.1%

27.3% - 34.9%

Subregion

Northern West Bank

214

37.6%

32.3% - 43%

Central West Bank

161

41.2%

31.4% - 51%

Southern West Bank

120

23.8%

18.2% - 29.4%

Gaza Strip

321

31.1%

27.3% - 34.9%

Governorate

Jenin

75

49.9%

37.7% - 62.2%

Tubas

14

40.7%

32.6% - 48.7%

Tulkarm

17

21.2%

9.2% - 33.2%

Nablus

71

33.1%

23.1% - 43.2%

Qalqiliya

21

40.9%

30.7% - 51.1%

Salfit

17

41.4%

30.6% - 52.1%

Ramallah

94

54.0%

38.2% - 69.7%

Jericho

9

42.6%

17.8% - 67.3%

Jerusalem

58

29.8%

17.4% - 42.2%

Bethlehem

30

24.9%

17.2% - 32.6%

Hebron

90

23.5%

16.5% - 30.4%

North Gaza

74

34.7%

26.4% - 42.9%

Gaza

125

33.6%

27.7% - 39.4%

Dier al-Balah

35

24.9%

13.3% - 36.6%

Khan Yunis

52

29.0%

19% - 39.1%

Rafah

35

27.7%

16.9% - 38.5%

Area

Urban

608

31.6%

28.4% - 34.8%

Village

151

41.0%

32.3% - 49.8%

Refugee camp

57

28.3%

21.7% - 34.9%

Sex

Male

457

36.8%

33.2% - 40.4%

Female

359

28.7%

25.5% - 31.8%

Age group

Youth (18-29)

333

31.8%

27.2% - 36.4%

Adult (30-54)

381

35.4%

32.1% - 38.7%

Mature (55+)

102

27.6%

23% - 32.2%

Education

Elementary school education

107

19.9%

15.9% - 23.9%

Secondary education

356

33.2%

28.9% - 37.6%

Post-secondary education

353

39.8%

36% - 43.7%

Madrassa education

No madrassa education

694

32.2%

29.1% - 35.3%

Madrassa education

123

35.8%

30.1% - 41.5%

Q1. Seen USAID logo in past year

Q2 Familiar with USAID

Overall

Code
q2 <- fac_tab(svyrdat, q2) %>%
  mutate(#item = "q2",
         #varlab="Familiar with USAID", 
         lab=fam_key$familiar_lab[1:4]) %>%
  select(Response=q2, Label=lab, Percent:Number, margin, Lower, Upper, ci) %>%
  mutate(Ind="Familiar with USAID")

#q2
q2 <- write_csv(q2, here("output/tables/eval Q1/q2 familiar.csv"))

q2_flx <- q2 %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3,
                   digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q2. Familiar with USAID")

save_as_docx(q2_flx, path=here("output/tables/eval Q1/q2 familiar.docx"))

q2_flx

Response

Label

Number

Percent

Confidence interval

0

Not at all familiar/unsure

1,493

58.6%

55.5% - 61.7%

1

Somewhat familiar

873

34.2%

31.4% - 37%

2

Very familiar

181

7.1%

5.7% - 8.5%

98

Refused

1

0.1%

0% - 0.1%

Q2. Familiar with USAID

Disaggregated

Code
q2_ov <- ov_tab(svyrdat, usaid_famil_bin, 
                "q2", "Familiar with USAID") # 3.1 margin, 2.6 deff

q2_sex <- disag_tab(svyrdat, usaid_famil_bin, sex, sex_key, 
                    "q2", "Familiar with USAID", "Sex")

q2_age <- disag_tab(svyrdat, usaid_famil_bin, age_grp,age_grp_key,  

                    "q2", "Familiar with USAID", "Age group")


q2_ed <- disag_tab(svyrdat, usaid_famil_bin, educ_cat, educ_key,
                   "q2", "Familiar with USAID", "Education")

q2_mad <- disag_tab(svyrdat, usaid_famil_bin, madrassa,mad_key,
                   "q2", "Familiar with USAID", "Madrassa education")

q2_area <- disag_tab(svyrdat, usaid_famil_bin, area,area_key,
                     "q2","Familiar with USAID","Area")

q2_subreg <- disag_tab(svyrdat, usaid_famil_bin, subregion,subreg_key,
                     "q2","Familiar with USAID","Subregion")

q2_gov <- disag_tab(svyrdat, usaid_famil_bin, gov,gov_key,
                     "q2","Seen USAID logo","Governorate")

q2_reg <- disag_tab(svyrdat, usaid_famil_bin, region,reg_key,
                     "q2","Familiar with USAID","Region") # 4.7 marg

q2_disag <- bind_rows(q2_ov,
                      q2_area,
                      q2_reg,
                      q2_subreg,
                      q2_gov,
                      q2_sex,
                      q2_age,
                      q2_ed,
                      q2_mad)

q2_disag_flx <- q2_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q2. Familiar with USAID") %>%
  border_inner_h()

save_as_docx(q2_disag_flx, path=here("output/tables/eval Q1/q2_disag.docx"))

q2_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Familiar with USAID

1,054

41.3%

38.3% - 44.4%

Area

Urban

837

42.5%

38.9% - 46%

Village

129

34.3%

26.8% - 41.8%

Refugee camp

88

43.6%

30.9% - 56.2%

Region

West Bank

543

36.4%

32.4% - 40.5%

Gaza

511

48.3%

43.5% - 53%

Subregion

Northern West Bank

244

42.0%

36.9% - 47.2%

Central West Bank

135

33.6%

24.7% - 42.5%

Southern West Bank

164

32.3%

24.8% - 39.8%

Gaza Strip

511

48.3%

43.5% - 53%

Governorate

Jenin

67

44.2%

33.1% - 55.3%

Tubas

17

50.6%

42.3% - 58.8%

Tulkarm

39

49.3%

35.1% - 63.6%

Nablus

78

35.6%

26.4% - 44.9%

Qalqiliya

27

48.4%

32.6% - 64.2%

Salfit

16

38.2%

25.7% - 50.6%

Ramallah

62

35.9%

21.4% - 50.4%

Jericho

7

32.5%

15.4% - 49.6%

Jerusalem

65

31.7%

19.5% - 44%

Bethlehem

50

40.9%

28.6% - 53.2%

Hebron

115

29.6%

20.5% - 38.7%

North Gaza

101

47.0%

38.8% - 55.2%

Gaza

234

61.7%

51.4% - 72.1%

Dier al-Balah

55

37.4%

26% - 48.8%

Khan Yunis

69

36.0%

27% - 44.9%

Rafah

52

41.4%

30.4% - 52.4%

Sex

Male

544

42.8%

39.1% - 46.6%

Female

509

39.9%

36.1% - 43.7%

Age group

Youth (18-29)

404

37.7%

32.8% - 42.7%

Adult (30-54)

514

46.7%

43% - 50.4%

Mature (55+)

136

36.0%

31.2% - 40.8%

Education

Elementary school education

149

27.6%

22.9% - 32.3%

Secondary education

439

39.9%

36% - 43.9%

Post-secondary education

466

51.3%

46.4% - 56.2%

Madrassa education

No madrassa education

852

38.7%

35.6% - 41.8%

Madrassa education

202

57.8%

48.8% - 66.9%

Q2. Familiar with USAID

Q3 USAID activities familiar with, ranked

Code
q3_1 <- ov_tab(svyrdat, q3_1, "q3_1", "Food security/nutrition") 

q3_2 <- ov_tab(svyrdat, q3_2, "q3_2", "Job training") 

q3_3 <- ov_tab(svyrdat, q3_3, "q3_3", "Support for community groups") 

q3_4 <- ov_tab(svyrdat, q3_4, "q3_4", "Economic growth / entrepreneurship") 

q3_5 <- ov_tab(svyrdat, q3_5, "q3_5", "Water/wastewater") 

q3_6 <- ov_tab(svyrdat, q3_6, "q3_6", "Roads/bridges") 

q3_7 <- ov_tab(svyrdat, q3_7, "q3_7", "Transportation") 

q3_8 <- ov_tab(svyrdat, q3_8, "q3_8", "Youth") 

q3_9 <- ov_tab(svyrdat, q3_9, "q3_9", "Education") 

q3_10 <- ov_tab(svyrdat, q3_10, "q3_10", "Health") 

q3_11 <- ov_tab(svyrdat, q3_11, "q3_11", "Peacebuilding") 

q3_12 <- ov_tab(svyrdat, q3_12, "q3_12", "Tourism") 

q3_13 <- ov_tab(svyrdat, q3_13, "q3_13", "Agriculture") 

q3 <- bind_rows(q3_1, q3_2, q3_3, q3_4, q3_5, q3_6, q3_7, q3_8, q3_9, q3_10, q3_11, q3_12, q3_13) %>%
  arrange(desc(Percent))

q3_flx <- q3 %>%
  select(Activity=Label, Number, Percent, `Confidence interval`=ci) %>%
  flextable() %>%
  colformat_double(j=2, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=4, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q3. USAID activities familiar with")

save_as_docx(q3_flx, path=here("output/tables/eval Q1/q3.docx"))

q3_flx

Activity

Number

Percent

Confidence interval

Food security/nutrition

716

68.0%

64.1% - 71.9%

Education

469

44.5%

40.5% - 48.6%

Water/wastewater

418

39.6%

35.8% - 43.4%

Health

376

35.7%

31.5% - 39.9%

Economic growth / entrepreneurship

318

30.2%

26.3% - 34.1%

Support for community groups

271

25.7%

22.3% - 29.1%

Job training

257

24.4%

20.8% - 28%

Roads/bridges

233

22.1%

19% - 25.2%

Youth

224

21.3%

17.8% - 24.7%

Agriculture

144

13.7%

11.1% - 16.2%

Tourism

125

11.8%

8.8% - 14.9%

Transportation

86

8.2%

5.8% - 10.5%

Peacebuilding

77

7.3%

5.1% - 9.5%

Q3. USAID activities familiar with

Dissaggregated

Code
q3_ov <- ov_tab(svyrdat, q3_1, 
                "q3_1", "Food security and nutritional support") 

q3_sex <- disag_tab(svyrdat, q3_1, sex, sex_key, 
                    "q3_1", "Familiar with USAID", "Sex")

q3_age <- disag_tab(svyrdat, q3_1, age_grp,age_grp_key,  

                    "q3_1", "Familiar with USAID", "Age group")


q3_ed <- disag_tab(svyrdat, q3_1, educ_cat, educ_key,
                   "q3_1", "Familiar with USAID", "Education")

q3_mad <- disag_tab(svyrdat, q3_1, madrassa,mad_key,
                   "q3_1", "Familiar with USAID", "Madrassa education")

q3_area <- disag_tab(svyrdat, q3_1, area,area_key,
                     "q3_1","Familiar with USAID","Area")

q3_gov <- disag_tab(svyrdat, q3_1, gov,gov_key,
                     "q3_1","Seen USAID logo","Governorate")

q3_subreg <- disag_tab(svyrdat, q3_1, subregion,subreg_key,
                     "q3_1","Familiar with USAID","Subregion")


q3_reg <- disag_tab(svyrdat, q3_1, region,reg_key,
                     "q3_1","Familiar with USAID","Region") # 4.7 marg

q3_disag <- bind_rows(q3_ov,
                      q3_area,
                      q3_reg,
                      q3_subreg,
                      q3_gov,
                      q3_sex,
                      q3_age,
                      q3_ed,
                      q3_mad)

q3_disag_flx <- q3_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q3. Food security and nutritional support") %>%
  border_inner_h

save_as_docx(q3_disag_flx, path=here("output/tables/eval Q1/q3_disag.docx"))

q3_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Food security and nutritional support

716

68.0%

64.1% - 71.9%

Area

Urban

568

67.8%

63.4% - 72.3%

Village

89

69.1%

58.1% - 80%

Refugee camp

59

67.7%

55.5% - 80%

Region

West Bank

347

63.9%

58.5% - 69.3%

Gaza

370

72.3%

66.6% - 78%

Subregion

Northern West Bank

155

63.7%

56% - 71.3%

Central West Bank

90

66.3%

56.2% - 76.5%

Southern West Bank

102

62.3%

51.3% - 73.2%

Gaza Strip

370

72.3%

66.6% - 78%

Governorate

Jenin

39

57.8%

40.8% - 74.7%

Tubas

7

38.0%

12.1% - 63.8%

Tulkarm

30

76.2%

64.7% - 87.6%

Nablus

63

80.9%

70.2% - 91.7%

Qalqiliya

7

27.5%

8.5% - 46.4%

Salfit

10

61.7%

30.6% - 92.9%

Ramallah

39

63.0%

53% - 73%

Jericho

5

67.5%

44.8% - 90.2%

Jerusalem

45

69.4%

51.8% - 87%

Bethlehem

22

45.2%

29.1% - 61.3%

Hebron

80

69.7%

55.5% - 83.8%

North Gaza

64

63.8%

51.1% - 76.5%

Gaza

182

77.8%

70.5% - 85.1%

Dier al-Balah

40

72.0%

55.6% - 88.3%

Khan Yunis

46

67.4%

48.8% - 86%

Rafah

37

70.9%

48.6% - 93.3%

Sex

Male

346

63.5%

58.3% - 68.6%

Female

371

72.8%

67.6% - 78%

Age group

Youth (18-29)

277

68.6%

61.7% - 75.5%

Adult (30-54)

345

67.2%

62.7% - 71.6%

Mature (55+)

95

69.3%

62.3% - 76.4%

Education

Elementary school education

112

75.1%

67.5% - 82.6%

Secondary education

313

71.4%

66.1% - 76.7%

Post-secondary education

291

62.5%

57.2% - 67.8%

Madrassa education

No madrassa education

572

67.1%

62.8% - 71.3%

Madrassa education

145

71.8%

63.8% - 79.7%

Q3. Food security and nutritional support

Ranked by region

Code
# q3_1reg <- disag_tab(svyrdat, q3_1, region,reg_key, "q3_1", "Food security/nutrition","Region") 
# 
# q3_2reg <- disag_tab(svyrdat, q3_2, region,reg_key, " q3_2", "Job training","Region") 
# 
# q3_3reg <- disag_tab(svyrdat, q3_3, region,reg_key, " q3_3", "Support for community groups","Region") 
# 
# q3_4reg <- disag_tab(svyrdat, q3_4, region,reg_key, " q3_4", " Economic growth / entrepreneurship","Region") 
# 
# q3_5reg <- disag_tab(svyrdat, q3_5, region,reg_key, " q3_5", " Water/wastewater","Region") 
# 
# q3_6reg <- disag_tab(svyrdat, q3_6, region,reg_key, " q3_6", "Roads/bridges","Region") 
# 
# q3_7reg <- disag_tab(svyrdat, q3_7, region,reg_key, " q3_7", "Transportation","Region") 
# 
# q3_8reg <- disag_tab(svyrdat, q3_8, region,reg_key, " q3_8", "Youth","Region") 
# 
# q3_9reg <- disag_tab(svyrdat, q3_9, region,reg_key, " q3_9", "Education","Region") 
# 
# q3_10reg <- disag_tab(svyrdat, q3_10, region,reg_key, " q3_10", "Health","Region") 
# 
# q3_11reg <- disag_tab(svyrdat, q3_11, region,reg_key, " q3_11", "Peacebuilding","Region") 
# 
# q3_12reg <- disag_tab(svyrdat, q3_12, region,reg_key, " q3_12", "Tourism","Region") 
# q3_13reg <- disag_tab(svyrdat, q3_13, region,reg_key, " q3_13", "Agriculture","Region")
Code
# q3_reg <- bind_rows(q3_1reg, q3_13reg, q3_12reg, q3_11reg, q3_10reg, q3_9reg, q3_8reg, q3_7reg, q3_6reg, q3_5reg, q3_4reg, q3_3reg, q3_2reg ) 
# 
# q3_reg <- q3_reg %>%
#   group_by(`Disaggregation type`) %>%
#   mutate(region_rank = rank(-Percent)) %>% 
#   arrange(`Disaggregation type`, desc(Percent)) 

#q3_reg
Code
q3_reg_flx <-q3_reg  %>%
  select( Activity=Label, Number, Percent, `Confidence interval`=ci) %>%
  flextable() %>%
  colformat_double(j=2, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=4, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q3.Familiar with USAID activities across region")


q3_1reg <- disag_tab(svyrdat, q3_1, region,reg_key, "q3_1", "Food security/nutrition","Region")
q3_2reg <- disag_tab(svyrdat, q3_2, region,reg_key, " q3_2", "Job training","Region")
q3_3reg <- disag_tab(svyrdat, q3_3, region,reg_key, " q3_3", "Support for community groups","Region") 
q3_4reg <- disag_tab(svyrdat, q3_4, region,reg_key, " q3_4", " Economic growth / entrepreneurship","Region")
q3_5reg <- disag_tab(svyrdat, q3_5, region,reg_key, " q3_5", " Water/wastewater","Region")
q3_6reg <- disag_tab(svyrdat, q3_6, region,reg_key, " q3_6", "Roads/bridges","Region") 
q3_7reg <- disag_tab(svyrdat, q3_7, region,reg_key, " q3_7", "Transportation","Region")
q3_8reg <- disag_tab(svyrdat, q3_8, region,reg_key, " q3_8", "Youth","Region")

q3_9reg <- disag_tab(svyrdat, q3_9, region,reg_key, " q3_9", "Education","Region") 
q3_10reg <- disag_tab(svyrdat, q3_10, region,reg_key, " q3_10", "Health","Region") 
q3_11reg <- disag_tab(svyrdat, q3_11, region,reg_key, " q3_11", "Peacebuilding","Region")
q3_12reg <- disag_tab(svyrdat, q3_12, region,reg_key, " q3_12", "Tourism","Region")
q3_13reg <- disag_tab(svyrdat, q3_13, region,reg_key, " q3_13", "Agriculture","Region")

q3_reg <- bind_rows(q3_1reg, q3_13reg, q3_12reg, q3_11reg, q3_10reg, q3_9reg, q3_8reg, q3_7reg, q3_6reg, q3_5reg, q3_4reg, q3_3reg, q3_2reg ) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent))%>% 
arrange(`Disaggregation type`, desc(Percent))

q3_reg_flx <- q3_reg %>% select(`USAID activities`=Label, Number, Percent, `Confidence interval`=ci) %>%
 flextable() %>% set_formatter(Percent=function(x) sprintf("%.1f%%", x*100))%>%
  align(j=4, align="center") %>% 
  colformat_double(j=3, digits=0)%>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q3. Familiar with USAID activities across region")

q3_reg_flx

Disaggregation type

USAID activities

Number

Percent

Confidence interval

Gaza

Food security/nutrition

370

72.3%

66.6% - 78%

Gaza

Education

207

40.5%

34% - 47%

Gaza

Economic growth / entrepreneurship

192

37.6%

31.8% - 43.5%

Gaza

Water/wastewater

187

36.5%

30.6% - 42.4%

Gaza

Job training

176

34.4%

28.1% - 40.6%

Gaza

Health

168

32.9%

27% - 38.9%

Gaza

Support for community groups

162

31.7%

26.3% - 37.1%

Gaza

Youth

134

26.2%

21.1% - 31.3%

Gaza

Roads/bridges

111

21.7%

17% - 26.4%

Gaza

Tourism

102

20.0%

14.9% - 25.2%

Gaza

Agriculture

68

13.2%

9.5% - 17%

Gaza

Peacebuilding

66

12.9%

9% - 16.8%

Gaza

Transportation

57

11.2%

7.1% - 15.4%

West Bank

Food security/nutrition

347

63.9%

58.5% - 69.3%

West Bank

Education

262

48.3%

43.3% - 53.3%

West Bank

Water/wastewater

231

42.6%

37.8% - 47.3%

West Bank

Health

208

38.3%

32.4% - 44.2%

West Bank

Economic growth / entrepreneurship

126

23.2%

18.4% - 28%

West Bank

Roads/bridges

122

22.5%

18.4% - 26.5%

West Bank

Support for community groups

109

20.1%

15.8% - 24.3%

West Bank

Youth

90

16.6%

12% - 21.3%

West Bank

Job training

81

14.9%

11.5% - 18.3%

West Bank

Agriculture

76

14.1%

10.6% - 17.6%

West Bank

Transportation

28

5.2%

2.9% - 7.6%

West Bank

Tourism

22

4.1%

1.1% - 7.1%

West Bank

Peacebuilding

11

2.1%

0.1% - 4%

Q3. Familiar with USAID activities across region

Code
save_as_docx(q3_reg_flx, path=here("output/tables/eval Q1/q3 ranked by region.docx"))

Ranked by subregion

Code
q3_1subreg <- disag_tab(svyrdat, q3_1, subregion,subreg_key, "q3_1", "Food security/nutrition"," Sub Region")
q3_2subreg <- disag_tab(svyrdat, q3_2, subregion,subreg_key, " q3_2", "Job training"," Sub Region")
q3_3subreg <- disag_tab(svyrdat, q3_3, subregion,subreg_key, " q3_3", "Support for community groups"," Sub Region")
q3_4subreg <- disag_tab(svyrdat, q3_4, subregion,subreg_key, " q3_4", " Economic growth / entrepreneurship"," Sub Region")
q3_5subreg <- disag_tab(svyrdat, q3_5, subregion,subreg_key, " q3_5", " Water/wastewater"," Sub Region")
q3_6subreg <- disag_tab(svyrdat, q3_6, subregion,subreg_key, " q3_6", "Roads/bridges"," Sub Region")
q3_7subreg <- disag_tab(svyrdat, q3_7, subregion,subreg_key, " q3_7", "Transportation"," Sub Region")
q3_8subreg <- disag_tab(svyrdat, q3_8, subregion,subreg_key, " q3_8", "Youth"," Sub Region")
q3_9subreg <- disag_tab(svyrdat, q3_9, subregion,subreg_key, " q3_9", "Education"," Sub Region")
q3_10subreg <- disag_tab(svyrdat, q3_10, subregion,subreg_key, " q3_10", "Health"," Sub Region")
q3_11subreg <- disag_tab(svyrdat, q3_11, subregion,subreg_key, " q3_11", "Peacebuilding"," Sub Region")
q3_12subreg <- disag_tab(svyrdat, q3_12, subregion,subreg_key, " q3_12", "Tourism"," Sub Region")
q3_13subreg <- disag_tab(svyrdat, q3_13, subregion,subreg_key, " q3_13", "Agriculture"," Sub Region")

q3_subreg <- bind_rows(q3_1subreg, q3_13subreg, q3_12subreg, q3_11subreg, q3_10subreg, q3_9subreg, q3_8subreg, q3_7subreg, q3_6subreg, q3_5subreg, q3_4subreg, q3_3subreg, q3_2subreg ) %>% 
group_by(`Disaggregation type`) %>%
mutate(region_rank = rank(-Percent)) %>%
arrange(`Disaggregation type`, desc(Percent))

q3sub_flx <- q3_subreg %>%
  select(`USAID activities`=Label, Number, Percent, `Confidence interval`=ci) %>% flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100))%>% 
align(j=4, align="center") %>%
  colformat_double(j=3, digits=0)%>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q3. Familiar with USAID activities across sub region")

q3sub_flx

Disaggregation type

USAID activities

Number

Percent

Confidence interval

Central West Bank

Food security/nutrition

90

66.3%

56.2% - 76.5%

Central West Bank

Education

79

58.5%

49.8% - 67.1%

Central West Bank

Health

66

48.9%

37.4% - 60.5%

Central West Bank

Water/wastewater

59

43.9%

33.9% - 53.8%

Central West Bank

Youth

33

24.3%

11.8% - 36.8%

Central West Bank

Support for community groups

26

19.4%

11.5% - 27.2%

Central West Bank

Roads/bridges

20

14.8%

9.3% - 20.4%

Central West Bank

Economic growth / entrepreneurship

17

12.9%

4.8% - 21%

Central West Bank

Job training

14

10.3%

5.8% - 14.7%

Central West Bank

Agriculture

8

6.0%

1.5% - 10.6%

Central West Bank

Tourism

3

2.1%

0.3% - 4%

Central West Bank

Transportation

3

2.0%

-0.1% - 4.1%

Central West Bank

Peacebuilding

1

0.7%

-0.6% - 2%

Gaza Strip

Food security/nutrition

370

72.3%

66.6% - 78%

Gaza Strip

Education

207

40.5%

34% - 47%

Gaza Strip

Economic growth / entrepreneurship

192

37.6%

31.8% - 43.5%

Gaza Strip

Water/wastewater

187

36.5%

30.6% - 42.4%

Gaza Strip

Job training

176

34.4%

28.1% - 40.6%

Gaza Strip

Health

168

32.9%

27% - 38.9%

Gaza Strip

Support for community groups

162

31.7%

26.3% - 37.1%

Gaza Strip

Youth

134

26.2%

21.1% - 31.3%

Gaza Strip

Roads/bridges

111

21.7%

17% - 26.4%

Gaza Strip

Tourism

102

20.0%

14.9% - 25.2%

Gaza Strip

Agriculture

68

13.2%

9.5% - 17%

Gaza Strip

Peacebuilding

66

12.9%

9% - 16.8%

Gaza Strip

Transportation

57

11.2%

7.1% - 15.4%

Northern West Bank

Food security/nutrition

155

63.7%

56% - 71.3%

Northern West Bank

Education

113

46.4%

39.7% - 53.1%

Northern West Bank

Water/wastewater

95

38.8%

32.7% - 44.9%

Northern West Bank

Health

79

32.5%

24.6% - 40.4%

Northern West Bank

Roads/bridges

62

25.5%

18.7% - 32.3%

Northern West Bank

Economic growth / entrepreneurship

62

25.4%

19% - 31.7%

Northern West Bank

Agriculture

43

17.6%

11.8% - 23.4%

Northern West Bank

Job training

40

16.5%

11.1% - 21.9%

Northern West Bank

Support for community groups

36

14.8%

9.8% - 19.9%

Northern West Bank

Youth

29

11.7%

6.1% - 17.3%

Northern West Bank

Tourism

16

6.4%

0% - 12.8%

Northern West Bank

Transportation

12

5.0%

2.1% - 8%

Northern West Bank

Peacebuilding

9

3.7%

-0.5% - 7.8%

Southern West Bank

Food security/nutrition

102

62.3%

51.3% - 73.2%

Southern West Bank

Water/wastewater

77

47.1%

37.2% - 57%

Southern West Bank

Education

70

42.7%

32.2% - 53.2%

Southern West Bank

Health

63

38.2%

27% - 49.4%

Southern West Bank

Economic growth / entrepreneurship

47

28.5%

18.2% - 38.8%

Southern West Bank

Support for community groups

47

28.4%

18.3% - 38.5%

Southern West Bank

Roads/bridges

40

24.3%

17.2% - 31.4%

Southern West Bank

Youth

29

17.5%

10.2% - 24.8%

Southern West Bank

Job training

27

16.4%

9.5% - 23.3%

Southern West Bank

Agriculture

25

15.4%

9.4% - 21.4%

Southern West Bank

Transportation

14

8.3%

2.3% - 14.2%

Southern West Bank

Tourism

4

2.3%

0.3% - 4.3%

Southern West Bank

Peacebuilding

1

0.8%

-0.5% - 2.1%

Q3. Familiar with USAID activities across sub region

Code
save_as_docx(q3_reg_flx, path=here("output/tables/eval Q1/q3 ranked by region.docx"))

Familiar with food security, disaggregated

Code
q3_1_ov <- ov_tab(svyrdat, q3_1, 
                "q3_1", "Familiar with food security activity") # 3.1 margin, 2.6 deff

q3_1_sex <- disag_tab(svyrdat, q3_1, sex, sex_key, 
                    "q3_1", "Familiar with food security activity", "Sex")

q3_1_age <- disag_tab(svyrdat, q3_1, age_grp,age_grp_key,  

                    "q3_1", "Familiar with food security activity", "Age group")


q3_1_ed <- disag_tab(svyrdat, q3_1, educ_cat, educ_key,
                   "q3_1", "Familiar with food security activity", "Education")

q3_1_mad <- disag_tab(svyrdat, q3_1, madrassa,mad_key,
                   "q3_1", "Familiar with food security activity", "Madrassa education")

q3_1_area <- disag_tab(svyrdat, q3_1, area,area_key, 
                       "q3_1","Familiar with food security activity","Area")

q3_1_gov <- disag_tab(svyrdat, q3_1, gov,gov_key,
                     "q3_1","Familiar with food security activity","Governorate")

q3_1_subreg <- disag_tab(svyrdat, q3_1, subregion,subreg_key,
                     "q3_1","Familiar with food security activity","Subregion")


q3_1_reg <- disag_tab(svyrdat, q3_1, region,reg_key,
                     "q3_1","Familiar with food security activity","Region") # 4.7 marg

q3_1_disag <- bind_rows(q3_1_ov,
                        q3_1_area,
                      q3_1_reg,
                      q3_1_subreg,
                      q3_1_gov,
                      q3_1_sex,
                      q3_1_age,
                      q3_1_ed,
                      q3_1_mad)

q3_1_disag_flx <- q3_1_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  #fix_border_issues() %>%
  #hline(i=c(1,4,7,10,12,15,18), border=smlbrdr) %>%
  border_inner_h() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q3_1. Familiar with food security activity")

save_as_docx(q3_1_disag_flx, path=here("output/tables/eval Q1/q3_1_disag.docx"))
Error in print.rdocx(z, target = path): C:/Users/dan.killian/Documents/Palestinian Perception Study/output/tables/eval Q1/q3_1_disag.docx is already edited. You must close the document in order to be able to write the file.
Code
q3_1_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Familiar with food security activity

716

68.0%

64.1% - 71.9%

Area

Urban

568

67.8%

63.4% - 72.3%

Village

89

69.1%

58.1% - 80%

Refugee camp

59

67.7%

55.5% - 80%

Region

West Bank

347

63.9%

58.5% - 69.3%

Gaza

370

72.3%

66.6% - 78%

Subregion

Northern West Bank

155

63.7%

56% - 71.3%

Central West Bank

90

66.3%

56.2% - 76.5%

Southern West Bank

102

62.3%

51.3% - 73.2%

Gaza Strip

370

72.3%

66.6% - 78%

Governorate

Jenin

39

57.8%

40.8% - 74.7%

Tubas

7

38.0%

12.1% - 63.8%

Tulkarm

30

76.2%

64.7% - 87.6%

Nablus

63

80.9%

70.2% - 91.7%

Qalqiliya

7

27.5%

8.5% - 46.4%

Salfit

10

61.7%

30.6% - 92.9%

Ramallah

39

63.0%

53% - 73%

Jericho

5

67.5%

44.8% - 90.2%

Jerusalem

45

69.4%

51.8% - 87%

Bethlehem

22

45.2%

29.1% - 61.3%

Hebron

80

69.7%

55.5% - 83.8%

North Gaza

64

63.8%

51.1% - 76.5%

Gaza

182

77.8%

70.5% - 85.1%

Dier al-Balah

40

72.0%

55.6% - 88.3%

Khan Yunis

46

67.4%

48.8% - 86%

Rafah

37

70.9%

48.6% - 93.3%

Sex

Male

346

63.5%

58.3% - 68.6%

Female

371

72.8%

67.6% - 78%

Age group

Youth (18-29)

277

68.6%

61.7% - 75.5%

Adult (30-54)

345

67.2%

62.7% - 71.6%

Mature (55+)

95

69.3%

62.3% - 76.4%

Education

Elementary school education

112

75.1%

67.5% - 82.6%

Secondary education

313

71.4%

66.1% - 76.7%

Post-secondary education

291

62.5%

57.2% - 67.8%

Madrassa education

No madrassa education

572

67.1%

62.8% - 71.3%

Madrassa education

145

71.8%

63.8% - 79.7%

Q3_1. Familiar with food security activity

Q4 Perception of USAID

Overall

Code
q4_tot <- svytotal(~factor(q4),
         na.rm=T,
         design=svydat) %>%
  as.data.frame()

q4 <- svymean(~factor(q4),
        na.rm=T,
        deff="replace",
        design=svydat) %>%
  as.data.frame() %>%
  rownames_to_column() %>%
  mutate(#item="q4",
         Ind="Positive perception of USAID",
         Response = str_sub(rowname, 11, nchar(rowname)),
         Label=percept_key$perception_lab,
         Number=q4_tot$total,
          margin = 1.96*SE,
           Lower=mean - margin,
           Upper=mean + margin,
         ci=paste(round(Lower*100,1), "%", " - ", round(Upper*100,1), "%", sep="")) %>%
  select(Response, Label, Number, Percent=mean, SE, deff, margin:ci)

write_csv(q4, here("output/tables/eval Q1/q4.csv"))
#q4

q4_flx <- q4 %>%
  select(1:4,`Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q4. Perception of USAID")

save_as_docx(q4_flx, path=here("output/tables/eval Q1/q4.docx"))

q4_flx

Response

Label

Number

Percent

Confidence interval

1

Very negative

41

3.8%

2.8% - 4.9%

2

Somewhat negative

77

7.3%

5.7% - 9%

3

Neither negative nor positive

269

25.6%

22.4% - 28.7%

4

Somewhat positive

492

46.7%

43% - 50.3%

5

Very positive

154

14.6%

11.6% - 17.6%

98

Refused

0

0.0%

0% - 0.1%

99

Don't know

20

1.9%

1.2% - 2.7%

Q4. Perception of USAID

Disaggregated

Code
percep_ov <- ov_tab(svyrdat, usaid_percep_bin, "q4", "Positive perception of USAID") 

percep_sex <- disag_tab(svyrdat, usaid_percep_bin, sex, sex_key, 
                    "q4", "Positive perception of USAID", "Sex")

percep_age <- disag_tab(svyrdat, usaid_percep_bin, age_grp, age_grp_key, 
                    "q4", "Perception of USAID", "Age group")

percep_ed <- disag_tab(svyrdat, usaid_percep_bin, educ_cat, educ_key, 
                    "q4", "Positive perception of USAID", "Education")

percep_mad <- disag_tab(svyrdat, usaid_percep_bin, madrassa, mad_key, 
                    "q4", "Positive perception of USAID", "Madrassa education")

percep_area <- disag_tab(svyrdat, usaid_percep_bin, area, area_key, 
                    "q4", "Positive perception of USAID", "Area")

percep_gov <- disag_tab(svyrdat, usaid_percep_bin, gov,gov_key,
                     "q4","Positive perception of USAID", "Governorate")

percep_subreg <- disag_tab(svyrdat, usaid_percep_bin, subregion, subreg_key, 
                    "q4", "Positive perception of USAID", "Subregion")

percep_reg <- disag_tab(svyrdat, usaid_percep_bin, region, reg_key, 
                    "q4", "Positive perception of USAID", "Region") # 5.6 margin

percep_disag <- bind_rows(percep_ov,
                          percep_area,
                      percep_reg,
                      percep_subreg,
                      percep_gov,
                      percep_sex,
                      percep_age,
                      percep_ed,
                      percep_mad)

percep_disag_flx <- percep_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q4. Positive perception of USAID") %>%
  border_inner_h()

save_as_docx(percep_disag_flx, path=here("output/tables/eval Q1/q4 percep_disag.docx"))

percep_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Positive perception of USAID

646

61.3%

57.6% - 64.9%

Area

Urban

503

60.0%

55.9% - 64.2%

Village

84

65.3%

55.3% - 75.2%

Refugee camp

59

67.2%

56.4% - 77.9%

Region

West Bank

311

57.4%

52.5% - 62.3%

Gaza

334

65.4%

59.8% - 71%

Subregion

Northern West Bank

141

57.7%

49.9% - 65.5%

Central West Bank

67

49.7%

39.8% - 59.6%

Southern West Bank

104

63.2%

55% - 71.4%

Gaza Strip

334

65.4%

59.8% - 71%

Governorate

Jenin

39

57.6%

38.6% - 76.6%

Tubas

13

76.5%

60.2% - 92.9%

Tulkarm

18

46.0%

31.1% - 61%

Nablus

48

61.5%

47.9% - 75.2%

Qalqiliya

14

52.7%

38% - 67.5%

Salfit

9

56.7%

39.1% - 74.4%

Ramallah

31

48.8%

33.3% - 64.4%

Jericho

4

56.5%

43.2% - 69.9%

Jerusalem

33

49.8%

35.6% - 63.9%

Bethlehem

29

58.3%

41% - 75.6%

Hebron

75

65.3%

56.1% - 74.6%

North Gaza

82

81.2%

67.5% - 94.8%

Gaza

137

58.5%

50.9% - 66.1%

Dier al-Balah

30

54.6%

28.9% - 80.2%

Khan Yunis

43

62.7%

47.9% - 77.5%

Rafah

42

80.8%

74.2% - 87.4%

Sex

Male

319

58.6%

54% - 63.2%

Female

327

64.1%

59% - 69.3%

Age group

Youth (18-29)

269

66.7%

60.2% - 73.1%

Adult (30-54)

300

58.4%

54.4% - 62.3%

Mature (55+)

76

56.1%

48.9% - 63.2%

Education

Elementary school education

83

55.9%

46.3% - 65.4%

Secondary education

266

60.7%

55% - 66.4%

Post-secondary education

296

63.6%

58.9% - 68.2%

Madrassa education

No madrassa education

518

60.8%

56.9% - 64.8%

Madrassa education

127

63.0%

55.1% - 70.9%

Q4. Positive perception of USAID

Q5 Negative impressions, ranked

Code
q5a <- ov_tab(svyrdat, q5a_bin, " q5a", " I haven’t seen any projects in my community") 
q5b <- ov_tab(svyrdat, q5b_bin, " q5b ", " I haven’t seen any results in my community ") 
q5c <- ov_tab(svyrdat, q5c_bin, " q5c ", " The US doesn’t support Palestinians ") 
q5d <- ov_tab(svyrdat, q5d_bin, " q5d ", " Foreign interference is always bad ") 
q5e <- ov_tab(svyrdat, q5e_bin, " q5e ", " The projects are not relevant ") 
q5f <- ov_tab(svyrdat, q5f_bin, " q5f ", " The projects are harmful to my community ") 
q5g <- ov_tab(svyrdat, q5g_bin, " q5g ", " The projects are unfair in who gets to participate") 
q5 <- bind_rows(q5a, q5b, q5c, q5d, q5e, q5f, q5g) %>%
      arrange(desc(Percent))

#q5
write_csv(q5, here("output/tables/eval Q1/q5.csv"))

q5_flx <- q5 %>% select(`Negative Impression`=Label, Number, Percent, `Confidence interval`=ci) %>% 
flextable() %>%
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
align(j=4, align="center") %>% 
colformat_double(j=2, digits=0) %>%
set_table_properties(layout="autofit") %>%
 add_footer_lines(values="Q5. Negative Impression  Ranked")
q5_flx

Negative Impression

Number

Percent

Confidence interval

I haven’t seen any projects in my community

51

43.4%

34.7% - 52.1%

I haven’t seen any results in my community

51

43.2%

33.2% - 53.1%

The projects are unfair in who gets to participate

48

40.6%

31.3% - 50%

The US doesn’t support Palestinians

48

40.4%

31.1% - 49.8%

Foreign interference is always bad

39

32.7%

24.2% - 41.2%

The projects are not relevant

29

24.5%

16.7% - 32.3%

The projects are harmful to my community

22

18.4%

10.3% - 26.5%

Q5. Negative Impression Ranked

Code
save_as_docx(q5_flx, path=here("output/tables/eval Q1/q5 percep_disag.docx"))

Ranked by region

Code
q5a_reg <- disag_tab(svyrdat, q5a_bin, region,reg_key, "q5a", " I haven’t seen any projects in my community","Region")
q5b_reg <- disag_tab(svyrdat, q5b_bin, region,reg_key, "q5b", " I haven’t seen any results in my community ","Region")
q5c_reg <- disag_tab(svyrdat, q5c_bin, region,reg_key, "q5c", " The US doesn’t support Palestinians ","Region")
q5d_reg <- disag_tab(svyrdat, q5d_bin, region,reg_key, "q5d", " Foreign interference is always bad ","Region")
q5e_reg <- disag_tab(svyrdat, q5e_bin, region,reg_key, "q5e", " The projects are not relevant ","Region")
q5f_reg <- disag_tab(svyrdat, q5f_bin, region,reg_key, "q5f", " The projects are harmful to my community ","Region")
q5g_reg <- disag_tab(svyrdat, q5g_bin, region,reg_key, "q5g", " The projects are unfair in who gets to participate ","Region")

q5_reg <- bind_rows(q5a_reg, q5b_reg, q5c_reg,
                     q5d_reg,
                     q5e_reg,
                     q5f_reg,
                     q5g_reg,
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))
#q5_reg
write_csv(q5_reg, here("output/tables/eval Q1/q5_reg.csv"))

q5_flx <- q5_reg %>% select(`Negative Impression By Region`=Label, Number, Percent, `Confidence interval`=ci) %>%
  flextable() %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
  align(j=5, align="center") %>%
  colformat_double(j=3, digits=0) %>%
  set_table_properties(layout="autofit") %>% 
  hline(i=c(7), border=smlbrdr) %>%

  add_footer_lines(values="Q5. Negative Impression Ranked by Region")
q5_flx

Disaggregation type

Negative Impression By Region

Number

Percent

Confidence interval

Gaza

I haven’t seen any results in my community

26

58.1%

42.8% - 73.5%

Gaza

I haven’t seen any projects in my community

24

52.4%

38.3% - 66.5%

Gaza

The US doesn’t support Palestinians

22

48.6%

34.6% - 62.5%

Gaza

The projects are unfair in who gets to participate

18

39.5%

24.1% - 54.9%

Gaza

Foreign interference is always bad

14

31.9%

15.8% - 47.9%

Gaza

The projects are not relevant

13

29.3%

16.3% - 42.2%

Gaza

The projects are harmful to my community

13

28.4%

11.6% - 45.2%

West Bank

The projects are unfair in who gets to participate

30

41.4%

29.6% - 53.1%

West Bank

I haven’t seen any projects in my community

27

37.8%

27% - 48.6%

West Bank

The US doesn’t support Palestinians

26

35.4%

23% - 47.7%

West Bank

I haven’t seen any results in my community

25

33.8%

21.3% - 46.4%

West Bank

Foreign interference is always bad

24

33.2%

23.7% - 42.7%

West Bank

The projects are not relevant

16

21.5%

11.8% - 31.2%

West Bank

The projects are harmful to my community

9

12.2%

5.2% - 19.1%

Q5. Negative Impression Ranked by Region

Code
save_as_docx(q5_flx, path=here("output/tables/eval Q1/q5_percep_disag_region.docx"))

Ranked by subregion

Code
q5a_subreg <- disag_tab(svyrdat, q5a_bin, subregion,subreg_key, "q5a", " I haven’t seen any projects in my community "," Sub region ")
q5b_subreg <- disag_tab(svyrdat, q5b_bin, subregion,subreg_key, "q5b", " I haven’t seen any results in my community "," Sub region ")
q5c_subreg <- disag_tab(svyrdat, q5c_bin, subregion,subreg_key, "q5c", " The US doesn’t support Palestinians "," Sub region ")
q5d_subreg <- disag_tab(svyrdat, q5d_bin, subregion,subreg_key, "q5d", " Foreign interference is always bad "," Sub region ")
q5e_subreg <- disag_tab(svyrdat, q5e_bin, subregion,subreg_key, "q5e", " The projects are not relevant "," Sub region ")
q5f_subreg <- disag_tab(svyrdat, q5f_bin, subregion,subreg_key, "q5f", " The projects are harmful to my community "," Sub region ")
q5g_subreg <- disag_tab(svyrdat, q5g_bin, subregion,subreg_key, "q5g", " The projects are unfair in who gets to participate"," Sub region ")
q5_subreg <- bind_rows(q5a_subreg, q5b_subreg, q5c_subreg,
                     q5d_subreg,
                     q5e_subreg,
                     q5f_subreg,
                     q5g_subreg,
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))
write_csv(q5_subreg, here("output/tables/eval Q1/q5_subreg.csv"))

q5sub_flx <- q5_subreg %>%
select(`Negative Impression By Sub Region`=Label, Number, Percent, `Confidence interval`=ci) %>% 
  flextable() %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=4, align="center") %>%
  colformat_double(j=3, digits=0) %>%
    hline(i=c(7,14,21), border=smlbrdr) %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q5. Negative Impression Ranked Subregion")

q5sub_flx

Disaggregation type

Negative Impression By Sub Region

Number

Percent

Confidence interval

Central West Bank

The US doesn’t support Palestinians

13

58.0%

38.6% - 77.3%

Central West Bank

Foreign interference is always bad

9

39.7%

23.1% - 56.2%

Central West Bank

I haven’t seen any results in my community

8

36.0%

12.8% - 59.3%

Central West Bank

The projects are unfair in who gets to participate

7

30.7%

13.1% - 48.4%

Central West Bank

The projects are harmful to my community

6

29.2%

9.5% - 48.8%

Central West Bank

I haven’t seen any projects in my community

6

25.2%

11.9% - 38.5%

Central West Bank

The projects are not relevant

3

15.3%

5.3% - 25.3%

Gaza Strip

I haven’t seen any results in my community

26

58.1%

42.8% - 73.5%

Gaza Strip

I haven’t seen any projects in my community

24

52.4%

38.3% - 66.5%

Gaza Strip

The US doesn’t support Palestinians

22

48.6%

34.6% - 62.5%

Gaza Strip

The projects are unfair in who gets to participate

18

39.5%

24.1% - 54.9%

Gaza Strip

Foreign interference is always bad

14

31.9%

15.8% - 47.9%

Gaza Strip

The projects are not relevant

13

29.3%

16.3% - 42.2%

Gaza Strip

The projects are harmful to my community

13

28.4%

11.6% - 45.2%

Northern West Bank

The projects are unfair in who gets to participate

17

48.0%

29.7% - 66.3%

Northern West Bank

I haven’t seen any projects in my community

17

47.4%

29.9% - 64.9%

Northern West Bank

I haven’t seen any results in my community

12

33.8%

16.7% - 50.9%

Northern West Bank

Foreign interference is always bad

10

27.9%

13.2% - 42.6%

Northern West Bank

The US doesn’t support Palestinians

9

26.5%

10.6% - 42.4%

Northern West Bank

The projects are not relevant

7

18.4%

5.2% - 31.6%

Northern West Bank

The projects are harmful to my community

1

4.1%

-1% - 9.1%

Southern West Bank

The projects are unfair in who gets to participate

6

41.4%

17.3% - 65.5%

Southern West Bank

The projects are not relevant

6

38.1%

8.8% - 67.3%

Southern West Bank

Foreign interference is always bad

5

36.1%

17.3% - 54.9%

Southern West Bank

I haven’t seen any projects in my community

5

33.6%

9.4% - 57.8%

Southern West Bank

I haven’t seen any results in my community

5

30.8%

2.3% - 59.3%

Southern West Bank

The US doesn’t support Palestinians

3

23.0%

-5.3% - 51.2%

Southern West Bank

The projects are harmful to my community

1

6.3%

-2% - 14.6%

Q5. Negative Impression Ranked Subregion

Code
save_as_docx(q5sub_flx, path=here("output/tables/eval Q1/q5_percep_disag_subregion.docx"))

Q6 Positive impressions, ranked

Code
q6a <- ov_tab(svyrdat, q6a_bin, " q6a", " They help the needy/poor/vulnerable") 
q6b <- ov_tab(svyrdat, q6b_bin, " q6b ", " They build infrastructure") 
q6c <- ov_tab(svyrdat, q6c_bin, " q6c ", " They provide hope") 
q6d <- ov_tab(svyrdat, q6d_bin, " q6d ", " Because of what I’ve seen or read") 
q6e <- ov_tab(svyrdat, q6e_bin, " q6e ", " Because they are from the US") 
q6f <- ov_tab(svyrdat, q6f_bin, " q6f ", " The projects are fair") 
q6g <- ov_tab(svyrdat, q6g_bin, " q6g ", " They care about Palestinians") 

q6  <- bind_rows(q6a, q6b, q6c, q6d, q6e, q6f, q6g) %>%
      arrange(desc(Percent))
write_csv(q6, here("output/tables/eval Q1/q6.csv"))

#q6 
q6_flx <- q6 %>% 
select(`Postive Impression`=Label, Number, Percent, `Confidence interval`=ci) %>% flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
align(j=4, align="center") %>% 
colformat_double(j=2, digits=0) %>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q6. Postive Impression  Ranked")

q6_flx

Postive Impression

Number

Percent

Confidence interval

They help the needy/poor/vulnerable

555

85.9%

82.1% - 89.7%

They care about Palestinians

378

58.6%

53.9% - 63.3%

They build infrastructure

306

47.4%

42.3% - 52.5%

The projects are fair

124

19.2%

15.4% - 23.1%

Because of what I’ve seen or read

111

17.1%

12.9% - 21.4%

They provide hope

109

16.9%

12.8% - 21.1%

Because they are from the US

72

11.1%

7.7% - 14.5%

Q6. Postive Impression Ranked

Code
save_as_docx(q6_flx, path=here("output/tables/eval Q1/q6_percep_disag.docx"))

Ranked by region

Code
q6a_reg <- disag_tab(svyrdat, q6a_bin, region,reg_key, "q6a", " They help the needy/poor/vulnerable ","Region")
q6b_reg <- disag_tab(svyrdat, q6b_bin, region,reg_key, "q6b", " They build infrastructure ","Region")
q6c_reg <- disag_tab(svyrdat, q6c_bin, region,reg_key, "q6c", " They provide hope ","Region")
q6d_reg <- disag_tab(svyrdat, q6d_bin, region,reg_key, "q6d", " Because of what I’ve seen or read ","Region")
q6e_reg <- disag_tab(svyrdat, q6e_bin, region,reg_key, "q6e", " Because they are from the US ","Region")
q6f_reg <- disag_tab(svyrdat, q6f_bin, region,reg_key, "q6f", " The projects are fair ","Region")
q6g_reg <- disag_tab(svyrdat, q6g_bin, region,reg_key, "q6g", " They care about Palestinians ","Region")

q6_reg <- bind_rows(q6a_reg, q6b_reg, q6c_reg,
                     q6d_reg,
                     q6e_reg,
                     q6f_reg,
                     q6g_reg,
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))
#q6_reg
q6_flx <- q6_reg %>% select(`Postive Impression By Region`=Label, Number, Percent, `Confidence interval`=ci) %>% 
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
align(j=4, align="center") %>%
colformat_double(j=3, digits=0) %>%
   hline(i=c(7), border=smlbrdr) %>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q6. Postive Impression Ranked")
q6_flx

Disaggregation type

Postive Impression By Region

Number

Percent

Confidence interval

Gaza

They help the needy/poor/vulnerable

297

88.8%

83.4% - 94.1%

Gaza

They care about Palestinians

204

61.2%

54.2% - 68.1%

Gaza

They build infrastructure

135

40.4%

33.7% - 47.2%

Gaza

They provide hope

80

23.9%

17.1% - 30.6%

Gaza

Because of what I’ve seen or read

78

23.3%

16.5% - 30.1%

Gaza

The projects are fair

68

20.4%

15.1% - 25.7%

Gaza

Because they are from the US

64

19.3%

13.3% - 25.2%

West Bank

They help the needy/poor/vulnerable

258

82.9%

77.4% - 88.4%

West Bank

They care about Palestinians

174

55.9%

49.6% - 62.2%

West Bank

They build infrastructure

171

54.9%

47.4% - 62.4%

West Bank

The projects are fair

56

18.0%

12.4% - 23.6%

West Bank

Because of what I’ve seen or read

33

10.5%

6.2% - 14.9%

West Bank

They provide hope

30

9.5%

5.3% - 13.7%

West Bank

Because they are from the US

7

2.4%

0.6% - 4.1%

Q6. Postive Impression Ranked

Code
save_as_docx(q6_flx, path=here("output/tables/eval Q1/q6_percep_region.docx"))

Ranked by subregion

Code
q6a_subreg <- disag_tab(svyrdat, q6a_bin, subregion,subreg_key, "q6a", " They help the needy/poor/vulnerable "," Sub region ")
q6b_subreg <- disag_tab(svyrdat, q6b_bin, subregion,subreg_key, "q6b", " They build infrastructure "," Sub region ")
q6c_subreg <- disag_tab(svyrdat, q6c_bin, subregion,subreg_key, "q6c", " They provide hope "," Sub region ")
q6d_subreg <- disag_tab(svyrdat, q6d_bin, subregion,subreg_key, "q6d", " Because of what I’ve seen or read "," Sub region ")
q6e_subreg <- disag_tab(svyrdat, q6e_bin, subregion,subreg_key, "q6e", " Because they are from the US "," Sub region ")
q6f_subreg <- disag_tab(svyrdat, q6f_bin, subregion,subreg_key, "q6f", " The projects are fair "," Sub region ")
q6g_subreg <- disag_tab(svyrdat, q6g_bin, subregion,subreg_key, "q6g", " They care about Palestinians "," Sub region ")
q6_subreg <- bind_rows(q6a_subreg, q6b_subreg, q6c_subreg,
                     q6d_subreg,
                     q6e_subreg,
                     q6f_subreg,
                     q6g_subreg,
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))

q6sub_flx <- q6_subreg %>%
select(`Postive Impression By Sub Region`=Label, Number, Percent, `Confidence interval`=ci) %>% flextable() %>% set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
align(j=4, align="center") %>%
hline(i=c(7,14,21), border=smlbrdr) %>%
colformat_double(j=3, digits=0) %>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q6. Postive Impression Ranked")

q6sub_flx

Disaggregation type

Postive Impression By Sub Region

Number

Percent

Confidence interval

Central West Bank

They help the needy/poor/vulnerable

64

95.2%

90.8% - 99.6%

Central West Bank

They care about Palestinians

42

62.1%

50.4% - 73.8%

Central West Bank

They build infrastructure

28

41.0%

25.4% - 56.6%

Central West Bank

The projects are fair

13

19.7%

4.8% - 34.7%

Central West Bank

They provide hope

8

11.2%

1.9% - 20.5%

Central West Bank

Because of what I’ve seen or read

3

5.0%

0.8% - 9.2%

Central West Bank

Because they are from the US

0

0.2%

-0.2% - 0.7%

Gaza Strip

They help the needy/poor/vulnerable

297

88.8%

83.4% - 94.1%

Gaza Strip

They care about Palestinians

204

61.2%

54.2% - 68.1%

Gaza Strip

They build infrastructure

135

40.4%

33.7% - 47.2%

Gaza Strip

They provide hope

80

23.9%

17.1% - 30.6%

Gaza Strip

Because of what I’ve seen or read

78

23.3%

16.5% - 30.1%

Gaza Strip

The projects are fair

68

20.4%

15.1% - 25.7%

Gaza Strip

Because they are from the US

64

19.3%

13.3% - 25.2%

Northern West Bank

They help the needy/poor/vulnerable

105

74.7%

65% - 84.5%

Northern West Bank

They build infrastructure

85

60.3%

50.5% - 70%

Northern West Bank

They care about Palestinians

83

58.8%

50% - 67.6%

Northern West Bank

Because of what I’ve seen or read

23

16.6%

8.1% - 25%

Northern West Bank

The projects are fair

20

14.1%

7% - 21.1%

Northern West Bank

They provide hope

14

10.2%

4.3% - 16%

Northern West Bank

Because they are from the US

6

4.6%

1% - 8.3%

Southern West Bank

They help the needy/poor/vulnerable

89

85.9%

78.1% - 93.7%

Southern West Bank

They build infrastructure

59

56.6%

42.6% - 70.6%

Southern West Bank

They care about Palestinians

50

48.0%

36.3% - 59.6%

Southern West Bank

The projects are fair

23

22.3%

12.5% - 32.1%

Southern West Bank

They provide hope

8

7.4%

-0.2% - 15.1%

Southern West Bank

Because of what I’ve seen or read

6

5.9%

1.6% - 10.2%

Southern West Bank

Because they are from the US

1

0.7%

-0.7% - 2%

Q6. Postive Impression Ranked

Code
save_as_docx(q6sub_flx, path=here("output/tables/eval Q1/q6_percep_subregion.docx"))

Q7 Perception of USG

Overall

Code
#frq(dat$q7)

q7 <- fac_tab(svyrdat, q7) %>%
  mutate(lab=percept_key$perception_lab) %>%
  select(Label=q7, Response=lab, Percent:Number, margin, Lower, Upper, ci) %>%
  mutate(Ind="Positive perception of United States Government")

write_csv(q7, here("output/tables/eval Q1/q7.csv"))
#q7

q7_flx <- q7 %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q7. Perception of USG")

save_as_docx(q7_flx, path=here("output/tables/eval Q1/q7.docx"))

q7_flx

Label

Response

Number

Percent

Confidence interval

1

Very negative

833

32.7%

29.8% - 35.6%

2

Somewhat negative

474

18.6%

16.6% - 20.6%

3

Neither negative nor positive

520

20.4%

18.1% - 22.7%

4

Somewhat positive

474

18.6%

16.4% - 20.8%

5

Very positive

104

4.1%

2.9% - 5.2%

98

Refused

11

0.4%

0.1% - 0.8%

99

Don't know

132

5.2%

4% - 6.4%

Q7. Perception of USG

Disaggregated

Code
usg_ov <- ov_tab(svyrdat, usg_percep_bin, "q7", "Positive perception of USG") 

usg_sex <- disag_tab(svyrdat, usg_percep_bin, sex, sex_key, 
                    "q7", "Positive perception of USG", "Sex")

usg_age <- disag_tab(svyrdat, usg_percep_bin, age_grp, age_grp_key, 
                    "q7", "Positive perception of USG", "Age group")

usg_ed <- disag_tab(svyrdat, usg_percep_bin, educ_cat, educ_key, 
                    "q7", "Positive perception of USG", "Education")

usg_mad <- disag_tab(svyrdat, usg_percep_bin, madrassa, mad_key, 
                    "q7", "Positive perception of USG", "Madrassa education")

usg_area <- disag_tab(svyrdat, usg_percep_bin, area, area_key, 
                    "q7", "Positive perception of USG", "Area")

usg_gov <- disag_tab(svyrdat, usg_percep_bin, gov,gov_key,
                     "q7","Positive perception of USG", "Governorate")

usg_subreg <- disag_tab(svyrdat, usg_percep_bin, subregion, subreg_key, 
                    "q7", "Positive perception of USG", "Subregion")

usg_reg <- disag_tab(svyrdat, usg_percep_bin, region, reg_key, 
                    "q7", "Positive perception of USG", "Region")

usg_disag <- bind_rows(usg_ov,
                       usg_area,
                      usg_reg,
                      usg_subreg,
                      usg_gov,
                      usg_sex,
                      usg_age,
                      usg_ed,
                      usg_mad)

write_csv(usg_disag, here("output/tables/eval Q1/q7 usg disag.csv"))

usg_disag_flx <- usg_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  #hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  border_inner_h() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q7. Positive perception of USG")

save_as_docx(usg_disag_flx, path=here("output/tables/eval Q1/q7 usg disag.docx"))

usg_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Positive perception of USG

578

22.7%

20.3% - 25.1%

Area

Urban

473

24.0%

21.2% - 26.8%

Village

68

18.2%

11.2% - 25.1%

Refugee camp

37

18.3%

10.5% - 26%

Region

West Bank

233

15.7%

12.8% - 18.5%

Gaza

345

32.6%

28.3% - 36.8%

Subregion

Northern West Bank

89

15.3%

10.9% - 19.7%

Central West Bank

60

15.0%

10.1% - 19.9%

Southern West Bank

84

16.6%

11.2% - 22%

Gaza Strip

345

32.6%

28.3% - 36.8%

Governorate

Jenin

22

14.6%

5.3% - 24%

Tubas

5

14.5%

7.3% - 21.8%

Tulkarm

14

17.0%

5.6% - 28.4%

Nablus

41

18.7%

10.5% - 27%

Qalqiliya

0

0.5%

-0.6% - 1.5%

Salfit

7

17.5%

12.1% - 23%

Ramallah

32

18.5%

10.5% - 26.6%

Jericho

4

18.0%

7.4% - 28.5%

Jerusalem

24

11.7%

5.2% - 18.2%

Bethlehem

27

22.1%

11% - 33.3%

Hebron

57

14.8%

8.8% - 20.9%

North Gaza

62

29.0%

19.5% - 38.6%

Gaza

156

41.3%

33.9% - 48.6%

Dier al-Balah

19

12.8%

3.3% - 22.4%

Khan Yunis

50

26.3%

17.4% - 35.2%

Rafah

57

45.2%

29.7% - 60.7%

Sex

Male

266

20.9%

17.9% - 23.9%

Female

312

24.4%

21.1% - 27.8%

Age group

Youth (18-29)

283

26.5%

22.5% - 30.5%

Adult (30-54)

246

22.3%

19.4% - 25.3%

Mature (55+)

49

12.9%

9.5% - 16.3%

Education

Elementary school education

98

18.0%

13.5% - 22.6%

Secondary education

277

25.2%

21.4% - 29%

Post-secondary education

204

22.4%

19.2% - 25.6%

Madrassa education

No madrassa education

456

20.7%

18.2% - 23.3%

Madrassa education

122

35.0%

29.5% - 40.5%

Q7. Positive perception of USG

Q7a Perception of US people

Overall

Code
#frq(dat$q7a)

q7a <- fac_tab(svyrdat, q7a) %>%
  mutate(lab=percept_key$perception_lab) %>%
  select(Label=q7a, Response=lab, Percent:Number, margin, Lower, Upper, ci) %>%
  mutate(Ind="Positive perception of United States people")

write_csv(q7a, here("output/tables/eval Q1/q7a.csv"))
#q7a

q7a_flx <- q7a %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q7a. Perception of United States people")

save_as_docx(q7a_flx, path=here("output/tables/eval Q1/q7a.docx"))

q7a_flx

Label

Response

Number

Percent

Confidence interval

1

Very negative

371

14.6%

12.6% - 16.5%

2

Somewhat negative

429

16.8%

14.9% - 18.8%

3

Neither negative nor positive

386

15.1%

13.3% - 17%

4

Somewhat positive

899

35.3%

32.8% - 37.7%

5

Very positive

267

10.5%

8.7% - 12.2%

98

Refused

11

0.4%

0.1% - 0.7%

99

Don't know

186

7.3%

6% - 8.6%

Q7a. Perception of United States people

Disaggregated

Code
usp_ov <- ov_tab(svyrdat, usp_bin, "q7a", "Positive perception of American people") 

usp_sex <- disag_tab(svyrdat, usp_bin, sex, sex_key, 
                    "q7a", "Positive perception of American people", "Sex")

usp_age <- disag_tab(svyrdat, usp_bin, age_grp, age_grp_key, 
                    "q7a", "Positive perception of American people", "Age group")

usp_ed <- disag_tab(svyrdat, usp_bin, educ_cat, educ_key, 
                    "q7a", "Positive perception of American people", "Education")

usp_mad <- disag_tab(svyrdat, usp_bin, madrassa, mad_key, 
                    "q7a", "Positive perception of American people", "Madrassa")

usp_area <- disag_tab(svyrdat, usp_bin, area, area_key, 
                    "q7a", "Positive perception of American people", "Area")

usp_gov <- disag_tab(svyrdat, usp_bin, gov,gov_key,
                     "q7a","Positive perception of American people", "Governorate")

usp_subreg <- disag_tab(svyrdat, usp_bin, subregion, subreg_key, 
                    "q7a", "Positive perception of American people", "Subregion")

usp_reg <- disag_tab(svyrdat, usp_bin, region, reg_key, 
                    "q7a", "Positive perception of American people", "Region")

usp_disag <- bind_rows(usp_ov,
                       usp_area,
                      usp_reg,
                      usp_subreg,
                      usp_gov,
                      usp_sex,
                      usp_age,
                      usp_ed,
                      usp_mad)

write_csv(usp_disag, here("output/tables/eval Q1/q7a usp disag.csv"))

usp_disag_flx <- usp_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q7a. Positive perception of United States people") %>%
  border_inner_h()

save_as_docx(usp_disag_flx, path=here("output/tables/eval Q1/q7a usp disag.docx"))

usp_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Positive perception of American people

1,166

45.7%

43% - 48.5%

Area

Urban

893

45.3%

42.1% - 48.5%

Village

191

50.7%

45% - 56.4%

Refugee camp

82

40.6%

28.8% - 52.4%

Region

West Bank

751

50.4%

47% - 53.8%

Gaza

415

39.2%

34.7% - 43.6%

Subregion

Northern West Bank

272

47.0%

41.8% - 52.1%

Central West Bank

200

49.8%

43.9% - 55.7%

Southern West Bank

279

54.8%

48.1% - 61.5%

Gaza Strip

415

39.2%

34.7% - 43.6%

Governorate

Jenin

62

41.1%

34% - 48.1%

Tubas

15

43.6%

33.9% - 53.3%

Tulkarm

35

44.2%

26.4% - 62%

Nablus

113

51.7%

42.4% - 60.9%

Qalqiliya

24

44.4%

22.9% - 65.9%

Salfit

23

55.7%

45.4% - 66%

Ramallah

88

50.6%

40.6% - 60.6%

Jericho

9

41.9%

26.9% - 56.9%

Jerusalem

103

49.9%

42.3% - 57.5%

Bethlehem

66

54.1%

42.9% - 65.3%

Hebron

213

55.0%

47% - 63.1%

North Gaza

131

60.8%

52.1% - 69.5%

Gaza

81

21.5%

15.6% - 27.3%

Dier al-Balah

66

44.6%

28.6% - 60.6%

Khan Yunis

73

38.2%

27.5% - 49%

Rafah

63

50.6%

36.4% - 64.8%

Sex

Male

587

46.2%

42.7% - 49.7%

Female

578

45.3%

41.7% - 48.8%

Age group

Youth (18-29)

481

45.0%

40.9% - 49.1%

Adult (30-54)

527

47.9%

44.3% - 51.5%

Mature (55+)

157

41.4%

36.5% - 46.3%

Education

Elementary school education

230

42.4%

37% - 47.8%

Secondary education

526

47.9%

44.2% - 51.5%

Post-secondary education

410

45.1%

40.9% - 49.4%

Madrassa

No madrassa education

1,049

47.7%

44.8% - 50.6%

Madrassa education

117

33.4%

27.1% - 39.7%

Q7a. Positive perception of United States people

Q8 USAID performance

Overall

Code
#frq(dat$q8)

q8 <- fac_tab(svyrdat, q8) %>%
  mutate(lab=percept_key$perception_lab) %>%
  select(Label=q8, Response=lab, Percent:Number, margin, Lower, Upper, ci) %>%
  mutate(Ind="Positive perception of USAID performance")

write_csv(q8, here("output/tables/eval Q1/q8.csv"))
#q8

q8_flx <- q8 %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q8. Perception of USAID performance")

save_as_docx(q8_flx, path=here("output/tables/eval Q1/q8.docx"))

q8_flx

Label

Response

Number

Percent

Confidence interval

1

Very negative

162

6.4%

5.1% - 7.7%

2

Somewhat negative

271

10.6%

8.9% - 12.3%

3

Neither negative nor positive

523

20.5%

18.2% - 22.8%

4

Somewhat positive

1,009

39.6%

36.8% - 42.4%

5

Very positive

410

16.1%

13.7% - 18.5%

98

Refused

8

0.3%

0% - 0.6%

99

Don't know

165

6.5%

5.1% - 7.9%

Q8. Perception of USAID performance

Disaggregated

Code
#frq(dat$usaid_perf_bin)

perf_ov <- ov_tab(svyrdat, usaid_perf_bin, "q8", "Positive perception of USAID performance") 
# 3 margin, 2.5 deff

perf_sex <- disag_tab(svyrdat, usaid_perf_bin, sex, sex_key, 
                    "q8", "Positive perception of USAID performance", "Sex")

perf_age <- disag_tab(svyrdat, usaid_perf_bin, age_grp, age_grp_key, 
                    "q8", "Positive perception of USAID performance", "Age group")

perf_ed <- disag_tab(svyrdat, usaid_perf_bin, educ_cat, educ_key, 
                    "q8", "Positive perception of USAID performance", "Education")

perf_mad <- disag_tab(svyrdat, usaid_perf_bin, madrassa, mad_key, 
                    "q8", "Positive perception of USAID performance", "Madrassa education")

perf_area <- disag_tab(svyrdat, usaid_perf_bin, area, area_key, 
                    "q8", "Positive perception of USAID performance", "Area")

perf_gov <- disag_tab(svyrdat, usaid_perf_bin, gov,gov_key,
                     "q8","Positive perception of USAID performance", "Governorate")

perf_subreg <- disag_tab(svyrdat, usaid_perf_bin, subregion, subreg_key, 
                    "q8", "Positive perception of USAID performance", "Subregion")

perf_reg <- disag_tab(svyrdat, usaid_perf_bin, region, reg_key, 
                    "q8", "Positive perception of USAID performance", "Region") # 5.3 margin

perf_disag <- bind_rows(perf_ov,
                        perf_area,
                      perf_reg,
                      perf_subreg,
                      perf_gov,
                      perf_sex,
                      perf_age,
                      perf_ed,
                      perf_mad)

write_csv(perf_disag, here("output/tables/eval Q1/q8 perf disag.csv"))

perf_disag_flx <- perf_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  #hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q8. Positive perception of USAID performance") %>%
  border_inner_h()

save_as_docx(perf_disag_flx, path=here("output/tables/eval Q1/q8 perf disag.docx"))

perf_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Positive perception of USAID performance

1,419

55.7%

52.6% - 58.7%

Area

Urban

1,072

54.4%

50.9% - 57.8%

Village

239

63.5%

55.8% - 71.2%

Refugee camp

109

54.0%

42.8% - 65.3%

Region

West Bank

824

55.3%

51.8% - 58.9%

Gaza

595

56.2%

50.8% - 61.5%

Subregion

Northern West Bank

313

54.0%

47.6% - 60.4%

Central West Bank

217

54.0%

48.8% - 59.2%

Southern West Bank

294

57.8%

51.5% - 64.1%

Gaza Strip

595

56.2%

50.8% - 61.5%

Governorate

Jenin

84

55.1%

43.3% - 67%

Tubas

22

65.6%

42.8% - 88.5%

Tulkarm

26

32.6%

19.3% - 45.9%

Nablus

124

56.7%

45.4% - 68.1%

Qalqiliya

35

64.1%

46.6% - 81.7%

Salfit

22

54.5%

31.8% - 77.1%

Ramallah

99

56.7%

49.2% - 64.2%

Jericho

13

60.1%

44.7% - 75.6%

Jerusalem

105

51.1%

43.7% - 58.6%

Bethlehem

62

50.9%

37.9% - 63.8%

Hebron

232

60.0%

52.7% - 67.3%

North Gaza

155

72.3%

63.5% - 81%

Gaza

204

54.0%

47% - 61%

Dier al-Balah

58

39.2%

19.9% - 58.6%

Khan Yunis

104

54.3%

41.5% - 67.2%

Rafah

73

58.0%

38.1% - 77.9%

Sex

Male

702

55.2%

51.3% - 59.1%

Female

717

56.1%

52.3% - 60%

Age group

Youth (18-29)

617

57.7%

53.2% - 62.1%

Adult (30-54)

635

57.7%

54.3% - 61.2%

Mature (55+)

167

44.1%

39.2% - 49.1%

Education

Elementary school education

272

50.2%

44.6% - 55.8%

Secondary education

609

55.4%

51.3% - 59.5%

Post-secondary education

539

59.3%

55% - 63.6%

Madrassa education

No madrassa education

1,212

55.1%

51.9% - 58.3%

Madrassa education

207

59.4%

52.7% - 66.1%

Q8. Positive perception of USAID performance

Q9 USAID activities

Overall

Code
#frq(dat$q8)

q9 <- fac_tab(svyrdat, q9) %>%
  #mutate(lab=percept_key$perception_lab) %>%
  left_join(yes_key,
            by=c("q9"="yes_no")) %>%
  select(Label=q9, Response=yes_no_lab, Percent:Number, margin, Lower, Upper, ci)

write_csv(q9, here("output/tables/eval Q1/q9.csv"))
#q9

q9_flx <- q9 %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q9. Noticed USAID activities")

save_as_docx(q9_flx, path=here("output/tables/eval Q1/q9.docx"))

q9_flx

Label

Response

Number

Percent

Confidence interval

0

No

1,850

72.6%

70% - 75.2%

1

Yes

616

24.2%

21.8% - 26.6%

98

Refused

27

1.1%

0.5% - 1.6%

99

Don't know

56

2.2%

1.4% - 3%

Q9. Noticed USAID activities

Disaggregated

Code
q9_ov <- ov_tab(svyrdat, us_act_exposure, "q9", "Exposed to USAID activity") 

q9_sex <- disag_tab(svyrdat, us_act_exposure, sex, sex_key, 
                    "q9", "Exposed to USAID activity", "Sex")

q9_age <- disag_tab(svyrdat, us_act_exposure, age_grp, age_grp_key, 
                    "q9", "Exposed to USAID activity", "Age group")

q9_ed <- disag_tab(svyrdat, us_act_exposure, educ_cat, educ_key, 
                    "q9", "Exposed to USAID activity", "Education")

q9_mad <- disag_tab(svyrdat, us_act_exposure, madrassa, mad_key, 
                    "q9", "Exposed to USAID activity", "Madrassa education")

q9_area <- disag_tab(svyrdat, us_act_exposure, area, area_key, 
                    "q9", "Exposed to USAID activity", "Area")

q9_gov <- disag_tab(svyrdat, us_act_exposure, gov,gov_key,
                     "q9","Exposed to USAID activity", "Governorate")

q9_subreg <- disag_tab(svyrdat, us_act_exposure, subregion, subreg_key, 
                    "q9", "Exposed to USAID activity", "Subregion")

q9_reg <- disag_tab(svyrdat, us_act_exposure, region, reg_key, 
                    "q9", "Exposed to USAID activity", "Region")

q9_disag <- bind_rows(q9_ov,
                      q9_reg,
                      q9_subreg,
                      q9_area,
                      q9_sex,
                      q9_age,
                      q9_ed,
                      q9_mad)

q9_disag_flx <- q9_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q9. Noticed implementation of USAID activities") %>%
  border_inner_h()

save_as_docx(q9_disag_flx, path=here("output/tables/eval Q1/q9 usaid acts disag.docx"))

q9_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Exposed to USAID activity

616

24.2%

21.8% - 26.6%

Region

West Bank

349

23.4%

20.5% - 26.3%

Gaza

267

25.3%

21.1% - 29.4%

Subregion

Northern West Bank

150

25.8%

21.9% - 29.7%

Central West Bank

84

21.0%

16.3% - 25.6%

Southern West Bank

115

22.5%

16.3% - 28.8%

Gaza Strip

267

25.3%

21.1% - 29.4%

Area

Urban

456

23.1%

20.3% - 26%

Village

108

28.7%

23.7% - 33.7%

Refugee camp

52

25.8%

18.4% - 33.2%

Sex

Male

351

27.6%

24.3% - 30.9%

Female

265

20.8%

17.8% - 23.7%

Age group

Youth (18-29)

262

24.5%

20.5% - 28.6%

Adult (30-54)

280

25.4%

22.5% - 28.4%

Mature (55+)

74

19.4%

15.8% - 23.1%

Education

Elementary school education

91

16.7%

13.2% - 20.3%

Secondary education

247

22.5%

19.1% - 26%

Post-secondary education

278

30.6%

26.8% - 34.4%

Madrassa education

No madrassa education

499

22.7%

20.2% - 25.2%

Madrassa education

117

33.6%

27.4% - 39.8%

Q9. Noticed implementation of USAID activities

Q10 USAID activities implemented, ranked

Code
q10a <- ov_tab(svyrdat, q10a_bin, " q10a", " Food security and nutritional support") 
q10b <- ov_tab(svyrdat, q10b_bin, " q10b ", " Job training and support") 
q10c <- ov_tab(svyrdat, q10c_bin, " q10c ", " Support for local community groups") 
q10d <- ov_tab(svyrdat, q10d_bin, " q10d ", " Economic growth activities for small businesses") 
q10e <- ov_tab(svyrdat, q10e_bin, " q10e ", " Water and wastewater activities") 
q10f <- ov_tab(svyrdat, q10f_bin, " q10f ", " Transportation activities") 
q10g <- ov_tab(svyrdat, q10g_bin, " q10g ", " Youth focused activities") 
q10h <- ov_tab(svyrdat, q10g_bin, " q10h ", " Health activities") 
q10i <- ov_tab(svyrdat, q10g_bin, " q10i ", " Cross border peacebuilding") 
q10j <- ov_tab(svyrdat, q10g_bin, " q10j ", " Tourism") 
q10ja <- ov_tab(svyrdat, q10ja_bin, " q10j_a", " Educational and school activities") 

q10k <- ov_tab(svyrdat, q10g_bin, " q10k ", " Agriculture") 


q10  <- bind_rows(q10a, q10b, q10c, q10d, q10e, q10f, q10g, q10h, q10i, q10j, q10ja ,q10k) %>%
     arrange(desc(Percent))

#q10 
write_csv(q10, here("output/tables/eval Q1/q10.csv"))

q10_flx <- q10 %>%
select(`Activity`=Label, Number, Percent, `Confidence interval`=ci) %>% 
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
align(j=4, align="center") %>%
colformat_double(j=2, digits=0) %>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q10. Part of USAID Actvitiy Ranked")
q10_flx

Activity

Number

Percent

Confidence interval

Food security and nutritional support

330

53.5%

48.1% - 58.9%

Educational and school activities

257

41.8%

36.5% - 47.1%

Water and wastewater activities

241

39.2%

33.4% - 44.9%

Support for local community groups

159

25.8%

21.4% - 30.2%

Economic growth activities for small businesses

139

22.5%

17.7% - 27.3%

Youth focused activities

119

19.3%

15% - 23.6%

Health activities

119

19.3%

15% - 23.6%

Cross border peacebuilding

119

19.3%

15% - 23.6%

Tourism

119

19.3%

15% - 23.6%

Agriculture

119

19.3%

15% - 23.6%

Job training and support

105

17.0%

13.2% - 20.8%

Transportation activities

59

9.6%

6.7% - 12.4%

Q10. Part of USAID Actvitiy Ranked

Code
save_as_docx(q10_flx, path=here("output/tables/eval Q1/q10.docx"))


Ranked by region

Code
q10a_reg <- disag_tab(svyrdat, q10a_bin, region,reg_key, "q10a", " Food security and nutritional support ","Region")
q10b_reg <- disag_tab(svyrdat, q10b_bin, region,reg_key, "q10b", " Job training and support ","Region")
q10c_reg <- disag_tab(svyrdat, q10c_bin, region,reg_key, "q10c", " Support for local community groups ","Region")
q10d_reg <- disag_tab(svyrdat, q10d_bin, region,reg_key, "q10d", " Economic growth activities for small businesses ","Region")
q10e_reg <- disag_tab(svyrdat, q10e_bin, region,reg_key, "q10e", " Water and wastewater activities ","Region")
q10f_reg <- disag_tab(svyrdat, q10f_bin, region,reg_key, "q10f", " Transportation activities ","Region")
q10g_reg <- disag_tab(svyrdat, q10g_bin, region,reg_key, "q10g", " Youth focused activities ","Region")
q10h_reg <- disag_tab(svyrdat, q10h_bin, region,reg_key, "q10h", " Health activities ","Region")
q10i_reg <- disag_tab(svyrdat, q10i_bin, region,reg_key, "q10i", " Cross border peacebuilding","Region")
q10j_reg <- disag_tab(svyrdat, q10j_bin, region,reg_key, "q10j", " Tourism","Region")
q10ja_reg <- disag_tab(svyrdat, q10ja_bin, region,reg_key, " q10j_a", " Educational and school activities ","Region")

q10k_reg <- disag_tab(svyrdat, q10k_bin, region,reg_key, "q10k", " Agriculture","Region")


q10_reg <- bind_rows(q10a_reg, q10b_reg, q10c_reg,
                     q10d_reg,
                     q10e_reg,
                     q10f_reg,
                     q10g_reg, q10h_reg, q10i_reg ,q10j_reg, q10k_reg, q10ja_reg
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))

#q10_reg
write_csv(q10_reg, here("output/tables/eval Q1/q10reg.csv"))

q10_flx <- q10_reg %>% select(`Activity By Region `=Label, Number, Percent, `Confidence interval`=ci) %>%
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
align(j=4, align="center") %>%
colformat_double(j=3, digits=0) %>%
hline(i=c(12), border=smlbrdr) %>%
set_table_properties(layout="autofit") %>% 
add_footer_lines(values="Q10. Part of USAID Actvitiy By Region")
q10_flx

Disaggregation type

Activity By Region

Number

Percent

Confidence interval

Gaza

Food security and nutritional support

189

70.5%

63% - 78.1%

Gaza

Educational and school activities

100

37.3%

28.8% - 45.9%

Gaza

Economic growth activities for small businesses

96

36.1%

28.9% - 43.2%

Gaza

Health activities

91

33.9%

27.3% - 40.4%

Gaza

Water and wastewater activities

83

30.9%

22.5% - 39.2%

Gaza

Support for local community groups

73

27.4%

21.3% - 33.6%

Gaza

Youth focused activities

70

26.2%

18.3% - 34%

Gaza

Job training and support

67

24.9%

18% - 31.7%

Gaza

Agriculture

33

12.5%

7.6% - 17.4%

Gaza

Cross border peacebuilding

31

11.6%

6.3% - 16.8%

Gaza

Transportation activities

18

6.7%

2.9% - 10.5%

Gaza

Tourism

14

5.2%

2% - 8.4%

West Bank

Water and wastewater activities

159

45.5%

37.8% - 53.2%

West Bank

Educational and school activities

158

45.2%

38.7% - 51.7%

West Bank

Food security and nutritional support

141

40.5%

33.2% - 47.7%

West Bank

Health activities

133

38.1%

31.1% - 45.1%

West Bank

Support for local community groups

86

24.6%

18.3% - 30.9%

West Bank

Agriculture

50

14.2%

9.7% - 18.8%

West Bank

Youth focused activities

49

14.0%

9.4% - 18.7%

West Bank

Economic growth activities for small businesses

42

12.1%

6.4% - 17.8%

West Bank

Transportation activities

41

11.7%

7.6% - 15.9%

West Bank

Job training and support

38

10.9%

6.8% - 15.1%

West Bank

Cross border peacebuilding

7

2.0%

0.1% - 3.9%

West Bank

Tourism

5

1.4%

-0.2% - 3.1%

Q10. Part of USAID Actvitiy By Region

Code
save_as_docx(q10_flx, path=here("output/tables/eval Q1/q10region.docx"))

Ranked by subregion

Code
q10a_subreg <- disag_tab(svyrdat, q10a_bin, subregion,subreg_key, "q10a", " Food security and nutritional support "," Sub region ")
q10b_subreg <- disag_tab(svyrdat, q10b_bin, subregion,subreg_key, "q10b", " Job training and support "," Sub region ")
q10c_subreg <- disag_tab(svyrdat, q10c_bin, subregion,subreg_key, "q10c", " Support for local community groups "," Sub region ")
q10d_subreg <- disag_tab(svyrdat, q10d_bin, subregion,subreg_key, "q10d", " Economic growth activities for small businesses "," Sub region ")
q10e_subreg <- disag_tab(svyrdat, q10e_bin, subregion,subreg_key, "q10e", " Water and wastewater activities "," Sub region ")
q10f_subreg <- disag_tab(svyrdat, q10f_bin, subregion,subreg_key, "q10f", " Transportation activities "," Sub region ")
q10g_subreg <- disag_tab(svyrdat, q10g_bin, subregion,subreg_key, "q10g", " Youth focused activities "," Sub region ")
q10h_subreg <- disag_tab(svyrdat, q10h_bin, subregion,subreg_key, "q10h", " Health activities "," Sub region ")
q10i_subreg <- disag_tab(svyrdat, q10i_bin, subregion,subreg_key, "q10i", " Cross border peacebuilding "," Sub region ")
q10j_subreg <- disag_tab(svyrdat, q10j_bin, subregion,subreg_key, "q10j", " Tourism "," Sub region ")
q10ja_subreg <- disag_tab(svyrdat, q10ja_bin, subregion,subreg_key, " q10j_a", " Educational and school activities "," Sub region ")

q10k_subreg <- disag_tab(svyrdat, q10k_bin, subregion,subreg_key, "q10k", " Agriculture "," Sub region ")


q10_subreg <- bind_rows(q10a_subreg, q10b_subreg, q10c_subreg,
                     q10d_subreg,
                     q10e_subreg,
                     q10f_subreg,
                     q10g_subreg, q10h_subreg, q10i_subreg, q10j_subreg, q10k_subreg, q10ja_subreg
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))


#q10_subreg

write_csv(q10_subreg, here("output/tables/eval Q1/q10subreg.csv"))


q10sub_flx <- q10_subreg %>% select(`Part of USAID Actvitiy By SubRegion`=Label, Number, Percent, `Confidence interval`=ci) %>%
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
align(j=4, align="center") %>%
colformat_double(j=3, digits=0) %>%
set_table_properties(layout="autofit") %>% 
hline(i=c(12,24,36), border=smlbrdr) %>%
add_footer_lines(values="Q10. Part of USAID Actvitiy By SubRegion")

q10sub_flx 

Disaggregation type

Part of USAID Actvitiy By SubRegion

Number

Percent

Confidence interval

Central West Bank

Educational and school activities

46

54.2%

40.1% - 68.2%

Central West Bank

Health activities

35

41.5%

27.3% - 55.8%

Central West Bank

Water and wastewater activities

31

37.2%

22.7% - 51.6%

Central West Bank

Food security and nutritional support

28

33.6%

18.7% - 48.5%

Central West Bank

Support for local community groups

11

13.3%

5.5% - 21%

Central West Bank

Youth focused activities

11

12.6%

3.7% - 21.4%

Central West Bank

Economic growth activities for small businesses

8

9.7%

-1% - 20.3%

Central West Bank

Agriculture

8

9.1%

0.1% - 18.1%

Central West Bank

Transportation activities

8

9.0%

1% - 17.1%

Central West Bank

Job training and support

6

7.5%

2.2% - 12.7%

Central West Bank

Cross border peacebuilding

0

0.0%

0% - 0%

Central West Bank

Tourism

0

0.0%

0% - 0%

Gaza Strip

Food security and nutritional support

189

70.5%

63% - 78.1%

Gaza Strip

Educational and school activities

100

37.3%

28.8% - 45.9%

Gaza Strip

Economic growth activities for small businesses

96

36.1%

28.9% - 43.2%

Gaza Strip

Health activities

91

33.9%

27.3% - 40.4%

Gaza Strip

Water and wastewater activities

83

30.9%

22.5% - 39.2%

Gaza Strip

Support for local community groups

73

27.4%

21.3% - 33.6%

Gaza Strip

Youth focused activities

70

26.2%

18.3% - 34%

Gaza Strip

Job training and support

67

24.9%

18% - 31.7%

Gaza Strip

Agriculture

33

12.5%

7.6% - 17.4%

Gaza Strip

Cross border peacebuilding

31

11.6%

6.3% - 16.8%

Gaza Strip

Transportation activities

18

6.7%

2.9% - 10.5%

Gaza Strip

Tourism

14

5.2%

2% - 8.4%

Northern West Bank

Water and wastewater activities

75

49.9%

38.3% - 61.6%

Northern West Bank

Educational and school activities

70

46.8%

37.7% - 55.8%

Northern West Bank

Food security and nutritional support

58

38.5%

29.7% - 47.3%

Northern West Bank

Health activities

49

32.5%

23.7% - 41.3%

Northern West Bank

Support for local community groups

39

25.8%

17.1% - 34.4%

Northern West Bank

Transportation activities

23

15.4%

8.8% - 22%

Northern West Bank

Agriculture

22

14.7%

8.3% - 21.1%

Northern West Bank

Economic growth activities for small businesses

15

10.2%

4.7% - 15.7%

Northern West Bank

Job training and support

14

9.5%

3.9% - 15.1%

Northern West Bank

Youth focused activities

12

7.8%

2.9% - 12.7%

Northern West Bank

Tourism

5

3.4%

-0.6% - 7.3%

Northern West Bank

Cross border peacebuilding

4

2.5%

-0.6% - 5.7%

Southern West Bank

Food security and nutritional support

55

48.1%

33.4% - 62.8%

Southern West Bank

Water and wastewater activities

53

45.9%

31.8% - 59.9%

Southern West Bank

Health activities

49

42.8%

28% - 57.6%

Southern West Bank

Educational and school activities

42

36.6%

24.4% - 48.8%

Southern West Bank

Support for local community groups

36

31.4%

17.5% - 45.2%

Southern West Bank

Youth focused activities

27

23.2%

13.5% - 32.9%

Southern West Bank

Agriculture

20

17.3%

8.8% - 25.8%

Southern West Bank

Economic growth activities for small businesses

19

16.4%

3% - 29.8%

Southern West Bank

Job training and support

18

15.4%

6.3% - 24.5%

Southern West Bank

Transportation activities

10

8.9%

2.2% - 15.6%

Southern West Bank

Cross border peacebuilding

3

2.8%

-1.1% - 6.7%

Southern West Bank

Tourism

0

0.0%

0% - 0%

Q10. Part of USAID Actvitiy By SubRegion

Code
save_as_docx(q10sub_flx, path=here("output/tables/eval Q1/q10subreg.docx"))

Q11 Participation in USAID activity

Overall

Code
q11 <- fac_tab(svyrdat, q11) %>%
  #mutate(lab=percept_key$perception_lab) %>%
  left_join(yes_key,
            by=c("q11"="yes_no")) %>%
  select(Label=q11, Response =yes_no_lab, Percent:Number, margin, Lower, Upper, ci)
write_csv(q11, here("output/tables/eval Q1/q11.csv"))
#q11

q11_flx <- q11 %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q11. Participated in USAID activity")

save_as_docx(q11_flx, path=here("output/tables/eval Q1/q11.docx"))

q11_flx

Label

Response

Number

Percent

Confidence interval

0

No

2,396

94.0%

92.8% - 95.3%

1

Yes

129

5.1%

4% - 6.2%

98

Refused

12

0.5%

0.1% - 0.8%

99

Don't know

11

0.4%

0.1% - 0.7%

Q11. Participated in USAID activity

Disaggregated

Code
q11_ov <- ov_tab(svyrdat, usaid_training, "q11", "Participated in USAID activity") 

q11_sex <- disag_tab(svyrdat, usaid_training, sex, sex_key, 
                    "q11", "Participated in USAID activity", "Sex")

q11_age <- disag_tab(svyrdat, usaid_training, age_grp, age_grp_key, 
                    "q11", "Participated in USAID activity", "Age group")

q11_ed <- disag_tab(svyrdat, usaid_training, educ_cat, educ_key, 
                    "q11", "Participated in USAID activity", "Education")

q11_mad <- disag_tab(svyrdat, usaid_training, madrassa, mad_key, 
                    "q11", "Participated in USAID activity", "Madrassa education")

q11_area <- disag_tab(svyrdat, usaid_training, area, area_key, 
                    "q11", "Participated in USAID activity", "Area")

q11_gov <- disag_tab(svyrdat, usaid_training, gov,gov_key,
                     "q11","Participated in USAID activity", "Governorate")

q11_subreg <- disag_tab(svyrdat, usaid_training, subregion, subreg_key, 
                    "q11", "Participated in USAID activity", "Subregion")

q11_reg <- disag_tab(svyrdat, usaid_training, region, reg_key, 
                    "q11", "Participated in USAID activity", "Region")


q11_disag <- bind_rows(q11_ov,
                       q11_area,
                      q11_reg,
                      q11_subreg,
                      q11_gov,
                      q11_sex,
                      q11_age,
                      q11_ed,
                      q11_mad)

write_csv(q11_disag, here("output/tables/eval Q1/q11 usaid participation disag.csv"))

q11_disag_flx <- q11_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q11. Participated in USAID USAID activity") %>%
  border_inner_h()

save_as_docx(q11_disag_flx, path=here("output/tables/eval Q1/q11 usaid acts disag.docx"))

q11_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Participated in USAID activity

129

5.1%

4% - 6.2%

Area

Urban

109

5.5%

4.1% - 6.9%

Village

5

1.5%

0.4% - 2.5%

Refugee camp

15

7.4%

3.1% - 11.6%

Region

West Bank

31

2.1%

1.1% - 3.1%

Gaza

98

9.3%

6.9% - 11.6%

Subregion

Northern West Bank

10

1.8%

0.4% - 3.1%

Central West Bank

9

2.1%

0.9% - 3.4%

Southern West Bank

12

2.4%

0.2% - 4.7%

Gaza Strip

98

9.3%

6.9% - 11.6%

Governorate

Jenin

5

3.2%

-0.3% - 6.7%

Tubas

0

0.8%

-1% - 2.6%

Tulkarm

1

1.0%

-1% - 3.1%

Nablus

2

1.0%

-1% - 3%

Qalqiliya

0

0.8%

-0.8% - 2.4%

Salfit

2

4.0%

-1.9% - 9.8%

Ramallah

6

3.2%

0.8% - 5.6%

Jericho

0

1.3%

-0.3% - 3%

Jerusalem

3

1.3%

0.1% - 2.5%

Bethlehem

3

2.1%

-0.1% - 4.4%

Hebron

10

2.5%

-0.3% - 5.4%

North Gaza

24

11.2%

6.6% - 15.8%

Gaza

48

12.6%

7.7% - 17.6%

Dier al-Balah

2

1.3%

-1.3% - 4%

Khan Yunis

14

7.3%

2% - 12.6%

Rafah

10

8.2%

1.9% - 14.6%

Sex

Male

68

5.4%

4% - 6.8%

Female

61

4.8%

3.3% - 6.3%

Age group

Youth (18-29)

51

4.7%

2.9% - 6.6%

Adult (30-54)

70

6.3%

4.8% - 7.9%

Mature (55+)

9

2.3%

1.1% - 3.6%

Education

Elementary school education

15

2.8%

1.3% - 4.3%

Secondary education

55

5.0%

3.4% - 6.7%

Post-secondary education

59

6.5%

4.5% - 8.4%

Madrassa education

No madrassa education

91

4.2%

3.1% - 5.2%

Madrassa education

38

10.9%

7% - 14.8%

Q11. Participated in USAID USAID activity

Q12 USAID activities participated in, ranked

Code
q12a <- ov_tab(svyrdat, q12a_bin, " q12a", " Food security and nutritional support") 
q12b <- ov_tab(svyrdat, q12b_bin, " q12b ", " Job training and support") 
q12d <- ov_tab(svyrdat, q12d_bin, " q12d ", " Support for local community groups") 
q12h <- ov_tab(svyrdat, q12h_bin, " q12h ", " Economic growth activities for small businesses") 
q12i <- ov_tab(svyrdat, q12i_bin, " q12i ", " Water and wastewater activities") 
q12c <- ov_tab(svyrdat, q12c_bin, " q12c ", " Youth focused activities") 
q12e <- ov_tab(svyrdat, q12e_bin, " q12e ", " Health activities") 
q12j <- ov_tab(svyrdat, q12j_bin, " q12j ", " Cross border peacebuilding") 
q12k <- ov_tab(svyrdat, q12k_bin, " q12k ", " Tourism") 
q12f <- ov_tab(svyrdat, q12f_bin, " q12f", " Educational and school activities")
q12g <- ov_tab(svyrdat, q12g_bin, " q12g ", " Agriculture") 

q12  <- bind_rows(q12a, q12b, q12c, q12d, q12e, q12f, q12g, q12h, q12i, q12j, q12k) %>%
      arrange(desc(Percent))

#q12 
write_csv(q12, here("output/tables/eval Q1/q12.csv"))

q12_flx <- q12 %>% select(` USAID activities implemented  `=Label, Number, Percent, `Confidence interval`=ci) %>%
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
align(j=4, align="center") %>%
colformat_double(j=2, digits=0) %>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q12. USAID activities implemented anked")


q12_flx

USAID activities implemented

Number

Percent

Confidence interval

Food security and nutritional support

74

57.3%

46% - 68.7%

Health activities

59

45.6%

35.3% - 55.9%

Educational and school activities

48

36.8%

28.1% - 45.6%

Youth focused activities

47

36.2%

26.6% - 45.7%

Job training and support

41

31.7%

22.5% - 40.8%

Support for local community groups

36

27.7%

18% - 37.5%

Agriculture

30

23.2%

13.1% - 33.3%

Water and wastewater activities

28

22.0%

14% - 30%

Tourism

21

16.4%

9.4% - 23.4%

Cross border peacebuilding

20

15.4%

8.2% - 22.6%

Economic growth activities for small businesses

18

14.1%

7.7% - 20.6%

Q12. USAID activities implemented anked

Code
save_as_docx(q12_flx, path=here("output/tables/eval Q1/q12.docx"))

Disaggregated

Code
q12_ov <- ov_tab(svyrdat, q12a_bin, 
                "q12a_bin", "Food security and nutritional support") # 3.1 margin, 2.6 deff

q12_sex <- disag_tab(svyrdat, q12a_bin, sex, sex_key, 
                    "q12a_bin", "Familiar with USAID", "Sex")

q12_age <- disag_tab(svyrdat, q12a_bin, age_grp,age_grp_key,  

                    "q12a_bin", "Familiar with USAID", "Age group")


q12_ed <- disag_tab(svyrdat, q12a_bin, educ_cat, educ_key,
                   " q12a_bin", "Familiar with USAID", "Education")

q12_mad <- disag_tab(svyrdat, q12a_bin, madrassa,mad_key,
                   "q12a_bin", "Familiar with USAID", "Madrassa education")

q12_area <- disag_tab(svyrdat, q12a_bin, area,area_key,
                     "q12a_bin","Familiar with USAID","Area")

q12_gov <- disag_tab(svyrdat, q12a_bin, gov,gov_key,
                     "q12a_bin","Familiar with USAID", "Governorate")

q12_subreg <- disag_tab(svyrdat, q12a_bin, subregion,subreg_key,
                     "q12a_bin","Familiar with USAID","Subregion")


q12_reg <- disag_tab(svyrdat, q12a_bin, region,reg_key,
                     "q12a_bin","Familiar with USAID","Region") # 4.7 marg

q12_disag <- bind_rows(q12_ov,
                       q12_area,
                      q12_reg,
                      q12_subreg,
                      q12_gov,
                      q12_sex,
                      q12_age,
                      q12_ed,
                      q12_mad)

q12_disag_flx <- q12_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
#hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q12.Food security and nutritional support") %>%
  border_inner_h()

save_as_docx(q12_disag_flx, path=here("output/tables/eval Q1/q12_disag.docx"))

q12_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Food security and nutritional support

74

57.3%

46% - 68.7%

Area

Urban

66

60.9%

48.7% - 73.1%

Village

0

0.0%

0% - 0%

Refugee camp

8

52.6%

17.4% - 87.7%

Region

West Bank

9

30.4%

3.5% - 57.3%

Gaza

65

65.9%

53.4% - 78.4%

Subregion

Northern West Bank

3

29.3%

-7.2% - 65.8%

Central West Bank

1

17.2%

-5.2% - 39.6%

Southern West Bank

5

40.4%

-12.5% - 93.4%

Gaza Strip

65

65.9%

53.4% - 78.4%

Governorate

Jenin

0

0.0%

0% - 0%

Tubas

0

0.0%

0% - 0%

Tulkarm

1

100.0%

100% - 100%

Nablus

2

100.0%

100% - 100%

Qalqiliya

0

0.0%

0% - 0%

Salfit

0

0.0%

0% - 0%

Ramallah

0

7.0%

-7.6% - 21.5%

Jericho

0

50.0%

-24.8% - 124.8%

Jerusalem

1

34.9%

-16.8% - 86.6%

Bethlehem

0

0.0%

0% - 0%

Hebron

5

51.2%

-8.5% - 110.9%

North Gaza

15

64.5%

40.6% - 88.4%

Gaza

35

73.4%

57.2% - 89.7%

Dier al-Balah

1

28.3%

28.3% - 28.3%

Khan Yunis

5

38.5%

-6.8% - 83.8%

Rafah

8

78.9%

39.9% - 117.9%

Sex

Male

31

45.8%

31.4% - 60.1%

Female

43

70.2%

55.7% - 84.8%

Age group

Youth (18-29)

26

50.8%

29.3% - 72.3%

Adult (30-54)

45

65.0%

54.5% - 75.6%

Mature (55+)

3

34.3%

11% - 57.7%

Education

Elementary school education

7

46.9%

17.8% - 75.9%

Secondary education

31

55.7%

39.3% - 72.1%

Post-secondary education

36

61.6%

46.4% - 76.8%

Madrassa education

No madrassa education

45

49.1%

36.2% - 62%

Madrassa education

29

77.2%

59.8% - 94.5%

Q12.Food security and nutritional support

Ranked by region

Code
q12a_reg <- disag_tab(svyrdat, q12a_bin, region,reg_key, "q12a", " Food security and nutritional support ","Region")
q12b_reg <- disag_tab(svyrdat, q12b_bin, region,reg_key, "q12b", " Job training and support ","Region")
q12c_reg <- disag_tab(svyrdat, q12c_bin, region,reg_key, "q12c", "Youth focused activities ","Region")
q12d_reg <- disag_tab(svyrdat, q12d_bin, region,reg_key, "q12d", " Support for local community groups ","Region")
q12e_reg <- disag_tab(svyrdat, q12e_bin, region,reg_key, "q12e",  " Health activities ","Region")
q12f_reg <- disag_tab(svyrdat, q12f_bin, region,reg_key, "q12f", " Educational and school activities ","Region")
q12g_reg <- disag_tab(svyrdat, q12g_bin, region,reg_key, "q12g", " Agriculture ","Region")
q12h_reg <- disag_tab(svyrdat, q12h_bin, region,reg_key, "q12h", " Economic growth activities for small businesses ","Region")
q12i_reg <- disag_tab(svyrdat, q12i_bin, region,reg_key, "q12i", " Cross border peacebuilding","Region")
q12j_reg <- disag_tab(svyrdat, q12j_bin, region,reg_key, "q12j", " Water and wastewater activities ","Region")
q12k_reg <- disag_tab(svyrdat, q12k_bin, region,reg_key, "q12k", " Tourism ","Region")


q12_reg <- bind_rows(q12a_reg, q12b_reg, q12c_reg,
                     q12d_reg,
                     q12e_reg,
                     q12f_reg,
                     q12g_reg, q12h_reg, q12i_reg ,q12j_reg, q12k_reg
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))


#q12_reg
write_csv(q12_reg, here("output/tables/eval Q1/q12reg.csv"))

q12_flx <- q12_reg %>%
select(` USAID activities participated by Region`=Label, Number, Percent, `Confidence interval`=ci) %>% 
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
align(j=4, align="center") %>% 
hline(i=c(11), border=smlbrdr) %>%
colformat_double(j=3, digits=0) %>%
set_table_properties(layout="autofit") %>% 
add_footer_lines(values="Q12. USAID activities participated by Region Ranked")

q12_flx

Disaggregation type

USAID activities participated by Region

Number

Percent

Confidence interval

Gaza

Food security and nutritional support

65

65.9%

53.4% - 78.4%

Gaza

Health activities

44

44.7%

33.7% - 55.7%

Gaza

Educational and school activities

41

41.7%

31.4% - 51.9%

Gaza

Youth focused activities

40

40.5%

29% - 52%

Gaza

Job training and support

29

29.2%

18.5% - 39.9%

Gaza

Agriculture

27

27.3%

14.8% - 39.8%

Gaza

Support for local community groups

26

26.3%

15.1% - 37.4%

Gaza

Cross border peacebuilding

22

22.1%

12.4% - 31.7%

Gaza

Tourism

21

21.6%

12.9% - 30.3%

Gaza

Water and wastewater activities

19

19.3%

10.3% - 28.3%

Gaza

Economic growth activities for small businesses

16

16.0%

8.4% - 23.6%

West Bank

Health activities

15

48.4%

23.6% - 73.1%

West Bank

Job training and support

12

39.4%

22.7% - 56.2%

West Bank

Support for local community groups

10

32.4%

13.2% - 51.6%

West Bank

Food security and nutritional support

9

30.4%

3.5% - 57.3%

West Bank

Youth focused activities

7

22.7%

7.5% - 37.9%

West Bank

Educational and school activities

7

21.7%

6.9% - 36.5%

West Bank

Cross border peacebuilding

7

21.7%

8% - 35.3%

West Bank

Agriculture

3

10.4%

0.7% - 20%

West Bank

Economic growth activities for small businesses

3

8.2%

-2.6% - 19%

West Bank

Water and wastewater activities

1

3.2%

-3.1% - 9.5%

West Bank

Tourism

0

0.0%

0% - 0%

Q12. USAID activities participated by Region Ranked

Code
save_as_docx(q12_flx, path=here("output/tables/eval Q1/q12reg.docx"))

Ranked by subregion

Code
q12a_subreg <- disag_tab(svyrdat, q12a_bin, subregion,subreg_key, "q12a", " Food security and nutritional support "," Sub region ")
q12b_subreg <- disag_tab(svyrdat, q12b_bin, subregion,subreg_key, "q12b", " Job training and support "," Sub region ")
q12c_subreg <- disag_tab(svyrdat, q12c_bin, subregion,subreg_key, "q12c", " Youth focused activities "," Sub region ")
q12d_subreg <- disag_tab(svyrdat, q12d_bin, subregion,subreg_key, "q12d", " Support for local community groups "," Sub region ")
q12e_subreg <- disag_tab(svyrdat, q12e_bin, subregion,subreg_key, "q12e", " Health activities "," Sub region ")
q12f_subreg <- disag_tab(svyrdat, q12f_bin, subregion,subreg_key, "q12f", " Educational and school activities "," Sub region ")
q12g_subreg <- disag_tab(svyrdat, q12g_bin, subregion,subreg_key, "q12g", " Agriculture "," Sub region ")
q12h_subreg <- disag_tab(svyrdat, q12h_bin, subregion,subreg_key, "q12h", " Economic growth activities for small businesses "," Sub region ")
q12i_subreg <- disag_tab(svyrdat, q12i_bin, subregion,subreg_key, "q12i", " Cross border peacebuilding "," Sub region ")
q12j_subreg <- disag_tab(svyrdat, q12j_bin, subregion,subreg_key, "q12j", " Water and wastewater activities "," Sub region ")

q12k_subreg <- disag_tab(svyrdat, q12k_bin, subregion,subreg_key, "q12k", " Tourism "," Sub region ")
q12_subreg <- bind_rows(q12a_subreg, q12b_subreg, q12c_subreg,
                     q12d_subreg,
                     q12e_subreg,
                     q12f_subreg,
                     q12g_subreg, q12h_subreg, q12i_subreg, q12j_subreg, q12k_subreg
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))

#q12_subreg
write_csv(q12_subreg, here("output/tables/eval Q1/q12subreg.csv"))

q12sub_flx <- q12_subreg %>%
select(` USAID activities participated  by SubRegion`=Label, Number, Percent, `Confidence interval`=ci) %>%
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
align(j=4, align="center") %>%
colformat_double(j=3, digits=0) %>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q12. USAID activities participated by SubRegion Ranked")

q12sub_flx 

Disaggregation type

USAID activities participated by SubRegion

Number

Percent

Confidence interval

Central West Bank

Job training and support

3

39.4%

6.2% - 72.6%

Central West Bank

Health activities

3

36.8%

2.6% - 71%

Central West Bank

Educational and school activities

2

26.0%

0.6% - 51.4%

Central West Bank

Youth focused activities

2

25.0%

-2.4% - 52.4%

Central West Bank

Support for local community groups

2

22.5%

-11.7% - 56.6%

Central West Bank

Cross border peacebuilding

2

22.1%

-1.3% - 45.5%

Central West Bank

Food security and nutritional support

1

17.2%

-5.2% - 39.6%

Central West Bank

Economic growth activities for small businesses

1

17.1%

-13.1% - 47.3%

Central West Bank

Agriculture

0

5.4%

-5.3% - 16.1%

Central West Bank

Water and wastewater activities

0

0.0%

0% - 0%

Central West Bank

Tourism

0

0.0%

0% - 0%

Gaza Strip

Food security and nutritional support

65

65.9%

53.4% - 78.4%

Gaza Strip

Health activities

44

44.7%

33.7% - 55.7%

Gaza Strip

Educational and school activities

41

41.7%

31.4% - 51.9%

Gaza Strip

Youth focused activities

40

40.5%

29% - 52%

Gaza Strip

Job training and support

29

29.2%

18.5% - 39.9%

Gaza Strip

Agriculture

27

27.3%

14.8% - 39.8%

Gaza Strip

Support for local community groups

26

26.3%

15.1% - 37.4%

Gaza Strip

Cross border peacebuilding

22

22.1%

12.4% - 31.7%

Gaza Strip

Tourism

21

21.6%

12.9% - 30.3%

Gaza Strip

Water and wastewater activities

19

19.3%

10.3% - 28.3%

Gaza Strip

Economic growth activities for small businesses

16

16.0%

8.4% - 23.6%

Northern West Bank

Health activities

5

46.7%

11.2% - 82.1%

Northern West Bank

Food security and nutritional support

3

29.3%

-7.2% - 65.8%

Northern West Bank

Job training and support

2

23.3%

-3.9% - 50.4%

Northern West Bank

Educational and school activities

2

20.0%

-4.6% - 44.6%

Northern West Bank

Support for local community groups

2

17.9%

-5.5% - 41.3%

Northern West Bank

Agriculture

1

13.4%

-5.4% - 32.2%

Northern West Bank

Water and wastewater activities

1

9.8%

-9.5% - 29%

Northern West Bank

Cross border peacebuilding

1

8.1%

-7.7% - 24%

Northern West Bank

Youth focused activities

1

5.4%

-3% - 13.7%

Northern West Bank

Economic growth activities for small businesses

0

0.0%

0% - 0%

Northern West Bank

Tourism

0

0.0%

0% - 0%

Southern West Bank

Health activities

7

57.8%

11.5% - 104%

Southern West Bank

Job training and support

7

52.8%

36.8% - 68.8%

Southern West Bank

Support for local community groups

6

51.3%

23.1% - 79.5%

Southern West Bank

Food security and nutritional support

5

40.4%

-12.5% - 93.4%

Southern West Bank

Youth focused activities

4

35.5%

15.1% - 55.9%

Southern West Bank

Cross border peacebuilding

4

32.6%

14.7% - 50.6%

Southern West Bank

Educational and school activities

3

20.2%

-6.3% - 46.7%

Southern West Bank

Agriculture

1

11.3%

-6.5% - 29.1%

Southern West Bank

Economic growth activities for small businesses

1

8.7%

-6.4% - 23.9%

Southern West Bank

Water and wastewater activities

0

0.0%

0% - 0%

Southern West Bank

Tourism

0

0.0%

0% - 0%

Q12. USAID activities participated by SubRegion Ranked

Code
save_as_docx(q12sub_flx, path=here("output/tables/eval Q1/q12subreg.docx"))

Q13 Familiar with other donors

Overall

Code
q13 <- fac_tab(svyrdat, q13) %>%
  #mutate(lab=percept_key$perception_lab) %>%
  left_join(fam_key,
            by=c("q13"="familiar")) %>%
  select(Label=q13, Response =familiar_lab, Percent:Number, margin, Lower, Upper, ci)

#q13
write_csv(q13, here("output/tables/eval Q1/q13.csv"))


q13_flx <- q13 %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q13. Familiarity with other donors")

q13_flx

Label

Response

Number

Percent

Confidence interval

0

Not at all familiar/unsure

1,069

42.0%

38.8% - 45.1%

1

Somewhat familiar

1,169

45.9%

43% - 48.7%

2

Very familiar

295

11.6%

9.3% - 13.8%

98

Refused

15

0.6%

0.2% - 1%

Q13. Familiarity with other donors

Code
save_as_docx(q13_flx, path=here("output/tables/eval Q1/q13.docx"))

Disaggregated

Code
q13_ov <- ov_tab(svyrdat, donor_famil_bin, "q13", "Familiar with other donors") 

q13_sex <- disag_tab(svyrdat, donor_famil_bin, sex, sex_key, 
                    "q13", "Familiar with other donors", "Sex")

q13_age <- disag_tab(svyrdat, donor_famil_bin, age_grp,age_grp_key, 
                    "q13", "Familiar with other donors", "Sex")

q13_ed <- disag_tab(svyrdat, donor_famil_bin, educ_cat, educ_key, 
                    "q13", "Familiar with other donors", "Education")

q13_mad <- disag_tab(svyrdat, donor_famil_bin, madrassa, mad_key, 
                    "q13", "Familiar with other donors", "Madrassa education")

q13_area <- disag_tab(svyrdat, donor_famil_bin, area, area_key, 
                    "q13", "Familiar with other donors", "Area")

q13_gov <- disag_tab(svyrdat, donor_famil_bin, gov,gov_key,
                     "q13","Familiar with other donors", "Governorate")

q13_subreg <- disag_tab(svyrdat, donor_famil_bin, subregion, subreg_key, 
                    "q13", "Familiar with other donors", "Subregion")

q13_reg <- disag_tab(svyrdat, donor_famil_bin, region, reg_key, 
                    "q13", "Familiar with other donors", "Region")


q13_disag <- bind_rows(q13_ov,
                       q13_area,
                      q13_reg,
                      q13_subreg,
                      q13_gov,
                      q13_sex,
                      q13_age,
                      q13_ed,
                      q13_mad)

write_csv(q13_disag, here("output/tables/eval Q1/q13 familiar other donors disag.csv"))
#q13_disag

q13_disag_flx <- q13_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  #hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q13. Familiar with other donors") %>%
  border_inner_h()

save_as_docx(q13_disag_flx, path=here("output/tables/eval Q1/q13 familiar other donors disag.docx"))

q13_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Familiar with other donors

1,464

57.4%

54.3% - 60.6%

Area

Urban

1,143

58.0%

54.4% - 61.6%

Village

196

52.0%

43% - 61.1%

Refugee camp

125

62.1%

48.3% - 75.9%

Region

West Bank

758

50.9%

47.1% - 54.7%

Gaza

706

66.7%

61.3% - 72.1%

Subregion

Northern West Bank

325

56.0%

50.4% - 61.7%

Central West Bank

148

36.8%

30.4% - 43.2%

Southern West Bank

285

56.1%

48.7% - 63.5%

Gaza Strip

706

66.7%

61.3% - 72.1%

Governorate

Jenin

75

49.2%

37.4% - 61.1%

Tubas

13

37.2%

19.7% - 54.7%

Tulkarm

36

45.5%

32.2% - 58.9%

Nablus

137

63.0%

53.5% - 72.6%

Qalqiliya

38

68.6%

57.8% - 79.4%

Salfit

26

63.1%

49.8% - 76.5%

Ramallah

71

40.8%

27.7% - 53.8%

Jericho

9

42.6%

28.2% - 57.1%

Jerusalem

68

32.8%

27% - 38.5%

Bethlehem

60

49.4%

33.8% - 65.1%

Hebron

225

58.2%

49.7% - 66.8%

North Gaza

174

80.8%

73% - 88.7%

Gaza

270

71.4%

62.5% - 80.3%

Dier al-Balah

82

55.3%

37% - 73.7%

Khan Yunis

115

59.9%

48.1% - 71.7%

Rafah

65

52.0%

34.8% - 69.3%

Sex

Male

770

60.6%

56.6% - 64.6%

Female

694

54.3%

50.2% - 58.5%

Youth (18-29)

612

57.2%

52.5% - 62%

Adult (30-54)

668

60.7%

57.1% - 64.3%

Mature (55+)

184

48.5%

43.5% - 53.5%

Education

Elementary school education

241

44.5%

39% - 50%

Secondary education

642

58.4%

54.3% - 62.5%

Post-secondary education

581

64.0%

59.8% - 68.3%

Madrassa education

No madrassa education

1,218

55.4%

52.1% - 58.7%

Madrassa education

246

70.5%

63.3% - 77.7%

Q13. Familiar with other donors

Q14 Donors familiar with, ranked

Code
q14a <- ov_tab(svyrdat, q14a_bin, " q14a", " United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)") 
q14b <- ov_tab(svyrdat, q14b_bin, " q14b ", " United Nations Development Programme (UNDP)") 
q14c <- ov_tab(svyrdat, q14c_bin, " q14c ", " United Nations Children’s Fund (UNICEF)") 
q14d <- ov_tab(svyrdat, q14d_bin, " q14d ", " Red Crescent/Red Cross") 
q14e <- ov_tab(svyrdat, q14e_bin, " q14e ", " German Society for International Cooperation (GIZ)") 
q14f <- ov_tab(svyrdat, q14f_bin, " q14f", " UKAid/Foreign, Commonwealth & Development Office (FCDO)") 
q14g <- ov_tab(svyrdat, q14g_bin, " q14g ", " Norwegian Refugee Council (NRC)") 
q14h <- ov_tab(svyrdat, q14h_bin, " q14h ", " Japan International Cooperation Agency (JICA)") 
q14i <- ov_tab(svyrdat, q14i_bin, " q14i ", " Belgium Development Agency (ENABEL)") 
q14j <- ov_tab(svyrdat, q14j_bin, " q14j ", " Sweden International Development Agency (Sida)") 
q14k <- ov_tab(svyrdat, q14k_bin, " q14k ", " Turkish Cooperation and Coordination Agency (TiKA)") 
q14l <- ov_tab(svyrdat, q14l_bin, " q14l ", " European Union (EU)") 
q14m <- ov_tab(svyrdat, q14m_bin, " q14m ", " World Food Programme (WFP)") 
q14n <- ov_tab(svyrdat, q14n_bin, " q14n ", " World Bank") 

q14  <- bind_rows(q14a, q14b, q14c, q14d, q14e, q14f, q14g, q14h, q14i, q14j, q14k, q14l, q14m, q14n) %>%
      arrange(desc(Percent))

#q14 
write_csv(q14, here("output/tables/eval Q1/q14.csv"))


q14_flx <- q14 %>% 
select(`Familiar with foreign donors  `=Label, Number, Percent, `Confidence interval`=ci) %>% 
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
align(j=4, align="center") %>%
colformat_double(j=2, digits=0) %>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q14. Familiar with foreign donors Ranked")

q14_flx

Familiar with foreign donors

Number

Percent

Confidence interval

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

1,207

82.5%

79.5% - 85.5%

Red Crescent/Red Cross

1,066

72.8%

69.1% - 76.6%

United Nations Children’s Fund (UNICEF)

997

68.1%

64.3% - 71.9%

European Union (EU)

641

43.8%

40% - 47.6%

United Nations Development Programme (UNDP)

455

31.0%

27.3% - 34.8%

World Food Programme (WFP)

346

23.6%

20.4% - 26.9%

World Bank

260

17.7%

14.3% - 21.2%

Norwegian Refugee Council (NRC)

231

15.8%

13.1% - 18.5%

Japan International Cooperation Agency (JICA)

226

15.4%

12.8% - 18%

German Society for International Cooperation (GIZ)

175

11.9%

9.7% - 14.2%

Belgium Development Agency (ENABEL)

146

10.0%

7.9% - 12.1%

Turkish Cooperation and Coordination Agency (TiKA)

132

9.0%

7% - 11.1%

Sweden International Development Agency (Sida)

101

6.9%

5.1% - 8.7%

UKAid/Foreign, Commonwealth & Development Office (FCDO)

97

6.7%

4.8% - 8.6%

Q14. Familiar with foreign donors Ranked

Code
save_as_docx(q14_flx, path=here("output/tables/eval Q1/q14.docx"))

Disaggregated q14a

Code
q14_ov <- ov_tab(svyrdat, q14a_bin, 
                " q14a_bin ", " United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA) ") 

q14_sex <- disag_tab(svyrdat, q14a_bin, sex, sex_key, 
                    " q14a_bin ", "Familiar with USAID", "Sex")

q14_age <- disag_tab(svyrdat, q14a_bin, age_grp,age_grp_key,  

                    " q14a_bin ", "Familiar with USAID", "Age group")


q14_ed <- disag_tab(svyrdat, q14a_bin, educ_cat, educ_key,
                   " q14a_bin ", "Familiar with USAID", "Education")

q14_mad <- disag_tab(svyrdat, q14a_bin, madrassa,mad_key,
                   " q14a_bin ", "Familiar with USAID", "Madrassa education")

q14_area <- disag_tab(svyrdat, q14a_bin, area,area_key,
                     " q14a_bin ","Familiar with USAID","Area")

q14_gov <- disag_tab(svyrdat, q14a_bin, gov,gov_key,
                     "q14a_bin","Familiar with USAID", "Governorate")

q14_subreg <- disag_tab(svyrdat, q14a_bin, subregion,subreg_key,
                     " q14a_bin ","Familiar with USAID","Subregion")


q14_reg <- disag_tab(svyrdat, q14a_bin, region,reg_key,
                     " q14a_bin ","Familiar with USAID","Region") # 4.7 marg

q14_disag <- bind_rows(q14_ov,
                       q14_area,
                      q14_reg,
                      q14_subreg,
                      q14_gov,
                      q14_sex,
                      q14_age,
                      q14_ed,
                      q14_mad)

q14_disag_flx <- q14_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
#hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q14a. Familiar with UNRWA") %>%
  border_inner_h()

save_as_docx(q14_disag_flx, path=here("output/tables/eval Q1/q14a_disag.docx"))

q14_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

1,207

82.5%

79.5% - 85.5%

Area

Urban

946

82.8%

79.2% - 86.3%

Village

149

76.0%

67.4% - 84.6%

Refugee camp

112

89.7%

83.7% - 95.7%

Region

West Bank

578

76.3%

72.2% - 80.3%

Gaza

629

89.1%

84.8% - 93.4%

Subregion

Northern West Bank

273

84.0%

79.7% - 88.4%

Central West Bank

84

56.6%

47.6% - 65.7%

Southern West Bank

221

77.6%

69.6% - 85.6%

Gaza Strip

629

89.1%

84.8% - 93.4%

Governorate

Jenin

72

96.4%

92.8% - 99.9%

Tubas

12

91.8%

82.7% - 100.9%

Tulkarm

24

66.8%

51.4% - 82.3%

Nablus

110

79.9%

71.5% - 88.2%

Qalqiliya

35

93.7%

87.1% - 100.3%

Salfit

20

76.8%

66.5% - 87.1%

Ramallah

36

50.7%

40.2% - 61.1%

Jericho

4

47.3%

21.1% - 73.5%

Jerusalem

43

64.1%

48.2% - 80%

Bethlehem

39

65.4%

42.7% - 88.1%

Hebron

182

80.8%

72.8% - 88.9%

North Gaza

149

85.7%

73.1% - 98.2%

Gaza

245

90.8%

86.5% - 95%

Dier al-Balah

78

94.6%

88.9% - 100.3%

Khan Yunis

100

87.4%

75.1% - 99.7%

Rafah

57

87.7%

73.1% - 102.2%

Sex

Male

630

81.9%

77.8% - 86%

Female

577

83.1%

79.3% - 86.9%

Age group

Youth (18-29)

500

81.6%

76.6% - 86.6%

Adult (30-54)

567

84.9%

81.8% - 88%

Mature (55+)

141

76.5%

70% - 83%

Education

Elementary school education

200

82.9%

77.1% - 88.8%

Secondary education

532

82.9%

78.8% - 87%

Post-secondary education

476

81.8%

77.8% - 85.9%

Madrassa education

No madrassa education

991

81.4%

78.1% - 84.7%

Madrassa education

216

87.8%

82.2% - 93.4%

Q14a. Familiar with UNRWA

Disaggregated 14d

Code
q14d_ov <- ov_tab(svyrdat, q14d_bin, 
                "q14d_bin", " Red Crescent/Red Cross ") 

q14d_sex <- disag_tab(svyrdat, q14d_bin, sex, sex_key, 
                    "q14d_bin", "Familiar with USAID", "Sex")

q14d_age <- disag_tab(svyrdat, q14d_bin, age_grp,age_grp_key,  
                    "q14d_bin", "Familiar with USAID", "Age group")


q14d_ed <- disag_tab(svyrdat, q14d_bin, educ_cat, educ_key,
                   "q14d_bin", "Familiar with USAID", "Education")

q14d_mad <- disag_tab(svyrdat, q14d_bin, madrassa,mad_key,
                   "q14d_bin", "Familiar with USAID", "Madrassa education")

q14d_area <- disag_tab(svyrdat, q14d_bin, area,area_key,
                     "q14d_bin","Familiar with USAID","Area")

q14d_gov <- disag_tab(svyrdat, q14d_bin, gov,gov_key,
                     "q14d_bin","Familiar with USAID", "Governorate")

q14d_subreg <- disag_tab(svyrdat, q14d_bin, subregion,subreg_key,
                     "q14d_bin","Familiar with USAID","Subregion")


q14d_reg <- disag_tab(svyrdat, q14d_bin, region,reg_key,
                     "q14d_bin","Familiar with USAID","Region") # 4.7 marg

q14d_disag <- bind_rows(q14d_ov,
                        q14d_area,
                      q14d_reg,
                      q14d_subreg,
                      q14d_gov,
                      q14d_sex,
                      q14d_age,
                      q14d_ed,
                      q14d_mad)

q14d_disag_flx <- q14d_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
#hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q14d. Familiar with Red Crescent/Red Cross") %>%
  border_inner_h()

save_as_docx(q14_disag_flx_d, path=here("output/tables/eval Q1/q14d_disag.docx"))
Error in save_as_docx(q14_disag_flx_d, path = here("output/tables/eval Q1/q14d_disag.docx")): object 'q14_disag_flx_d' not found
Code
q14d_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Red Crescent/Red Cross

1,066

72.8%

69.1% - 76.6%

Area

Urban

842

73.6%

69.2% - 78%

Village

126

64.3%

54.9% - 73.8%

Refugee camp

99

79.0%

70.6% - 87.4%

Region

West Bank

505

66.6%

61.2% - 72%

Gaza

562

79.5%

74.5% - 84.6%

Subregion

Northern West Bank

229

70.7%

62.9% - 78.4%

Central West Bank

86

58.1%

46.4% - 69.8%

Southern West Bank

189

66.3%

56.5% - 76.2%

Gaza Strip

562

79.5%

74.5% - 84.6%

Governorate

Jenin

57

75.5%

58.9% - 92.2%

Tubas

12

94.3%

86.6% - 102%

Tulkarm

26

71.9%

55.2% - 88.5%

Nablus

99

72.1%

60.7% - 83.5%

Qalqiliya

20

53.0%

29.8% - 76.3%

Salfit

16

61.6%

38.8% - 84.4%

Ramallah

38

54.1%

35.1% - 73.1%

Jericho

2

19.1%

7.2% - 30.9%

Jerusalem

46

67.7%

51.4% - 84%

Bethlehem

33

55.6%

29.3% - 82%

Hebron

156

69.2%

58.4% - 80%

North Gaza

146

84.1%

71.1% - 97%

Gaza

206

76.2%

69.1% - 83.2%

Dier al-Balah

68

83.2%

74.5% - 91.8%

Khan Yunis

93

81.1%

68.9% - 93.3%

Rafah

48

74.0%

54.5% - 93.6%

Sex

Male

574

74.6%

70% - 79.1%

Female

492

70.9%

65.8% - 76.1%

Age group

Youth (18-29)

451

73.7%

68.2% - 79.2%

Adult (30-54)

494

74.0%

69.8% - 78.1%

Mature (55+)

121

65.9%

59% - 72.8%

Education

Elementary school education

169

70.3%

62.6% - 78.1%

Secondary education

468

72.9%

68% - 77.9%

Post-secondary education

429

73.8%

69.3% - 78.2%

Madrassa education

No madrassa education

872

71.6%

67.4% - 75.8%

Madrassa education

194

79.0%

73.4% - 84.5%

Q14d. Familiar with Red Crescent/Red Cross

Ranked by region

Code
q14a_reg <- disag_tab(svyrdat, q14a_bin, region,reg_key, "q14a", " United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA) ","Region")
q14b_reg <- disag_tab(svyrdat, q14b_bin, region,reg_key, "q14b", " United Nations Development Programme (UNDP)","Region")
q14c_reg <- disag_tab(svyrdat, q14c_bin, region,reg_key, "q14c", "United Nations Children’s Fund (UNICEF)","Region")
q14d_reg <- disag_tab(svyrdat, q14d_bin, region,reg_key, "q14d", " Red Crescent/Red Cross","Region")
q14e_reg <- disag_tab(svyrdat, q14e_bin, region,reg_key, "q14e",  " German Society for International Cooperation (GIZ)","Region")
q14f_reg <- disag_tab(svyrdat, q14f_bin, region,reg_key, "q14f", " UKAid/Foreign, Commonwealth & Development Office (FCDO) ","Region")
q14g_reg <- disag_tab(svyrdat, q14g_bin, region,reg_key, "q14g", " Norwegian Refugee Council (NRC) ","Region")
q14h_reg <- disag_tab(svyrdat, q14h_bin, region,reg_key, "q14h", " Japan International Cooperation Agency (JICA)","Region")
q14i_reg <- disag_tab(svyrdat, q14i_bin, region,reg_key, "q14i", " Belgium Development Agency (ENABEL)","Region")
q14j_reg <- disag_tab(svyrdat, q14j_bin, region,reg_key, "q14j", " Sweden International Development Agency (Sida) ","Region")
q14k_reg <- disag_tab(svyrdat, q14k_bin, region,reg_key, "q14k", " Turkish Cooperation and Coordination Agency (TiKA)","Region")
q14l_reg <- disag_tab(svyrdat, q14k_bin, region,reg_key, "q14k", " European Union (EU)","Region")
q14m_reg <- disag_tab(svyrdat, q14m_bin, region,reg_key, "q14m", " World Food Programme (WFP)","Region")
q14n_reg <- disag_tab(svyrdat, q14n_bin, region,reg_key, "q14n", " World Bank","Region")
q14_reg <- bind_rows(q14a_reg, q14b_reg, q14c_reg,
                     q14d_reg,
                     q14e_reg,
                     q14f_reg,
                     q14g_reg, q14h_reg, q14i_reg ,q14j_reg, q14k_reg, q14l_reg, q14m_reg, q14n_reg
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))

#q14_reg
write_csv(q14_reg, here("output/tables/eval Q1/q14reg.csv"))

q14_flx <- q14_reg %>%
select(`Familiar with foreign donors by Region`=Label, Number, Percent, `Confidence interval`=ci) %>% 
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
align(j=4, align="center") %>%
colformat_double(j=3, digits=0) %>%
hline(i=c(14), border=smlbrdr) %>%
set_table_properties(layout="autofit") %>% 
add_footer_lines(values="Q14. Familiar with foreign donors by Region Ranked")

q14_flx

Disaggregation type

Familiar with foreign donors by Region

Number

Percent

Confidence interval

Gaza

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

629

89.1%

84.8% - 93.4%

Gaza

Red Crescent/Red Cross

562

79.5%

74.5% - 84.6%

Gaza

United Nations Children’s Fund (UNICEF)

553

78.3%

72.9% - 83.7%

Gaza

United Nations Development Programme (UNDP)

264

37.4%

31.5% - 43.3%

Gaza

World Food Programme (WFP)

181

25.7%

20.8% - 30.6%

Gaza

Norwegian Refugee Council (NRC)

165

23.3%

18.5% - 28.1%

Gaza

World Bank

139

19.7%

14% - 25.3%

Gaza

Japan International Cooperation Agency (JICA)

128

18.1%

14.1% - 22.2%

Gaza

Belgium Development Agency (ENABEL)

114

16.1%

12.1% - 20.1%

Gaza

Turkish Cooperation and Coordination Agency (TiKA)

99

14.0%

10.2% - 17.9%

Gaza

European Union (EU)

99

14.0%

10.2% - 17.9%

Gaza

German Society for International Cooperation (GIZ)

95

13.4%

10.1% - 16.7%

Gaza

UKAid/Foreign, Commonwealth & Development Office (FCDO)

77

10.9%

7.3% - 14.4%

Gaza

Sweden International Development Agency (Sida)

57

8.0%

5.3% - 10.8%

West Bank

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

578

76.3%

72.2% - 80.3%

West Bank

Red Crescent/Red Cross

505

66.6%

61.2% - 72%

West Bank

United Nations Children’s Fund (UNICEF)

444

58.6%

53.4% - 63.8%

West Bank

United Nations Development Programme (UNDP)

190

25.1%

20.6% - 29.7%

West Bank

World Food Programme (WFP)

164

21.7%

17.4% - 26%

West Bank

World Bank

120

15.9%

11.8% - 20%

West Bank

Japan International Cooperation Agency (JICA)

98

12.9%

9.6% - 16.2%

West Bank

German Society for International Cooperation (GIZ)

80

10.6%

7.6% - 13.6%

West Bank

Norwegian Refugee Council (NRC)

67

8.8%

6.1% - 11.5%

West Bank

Sweden International Development Agency (Sida)

45

5.9%

3.5% - 8.3%

West Bank

Turkish Cooperation and Coordination Agency (TiKA)

33

4.3%

2.6% - 6.1%

West Bank

European Union (EU)

33

4.3%

2.6% - 6.1%

West Bank

Belgium Development Agency (ENABEL)

33

4.3%

2.8% - 5.8%

West Bank

UKAid/Foreign, Commonwealth & Development Office (FCDO)

21

2.8%

1.1% - 4.4%

Q14. Familiar with foreign donors by Region Ranked

Code
save_as_docx(q14_flx, path=here("output/tables/eval Q1/q14reg.docx"))

Ranked by subregion

Code
q14a_subreg <- disag_tab(svyrdat, q14a_bin, subregion,subreg_key, "q14a", " United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA) "," Sub region ")
q14b_subreg <- disag_tab(svyrdat, q14b_bin, subregion,subreg_key, "q14b", " United Nations Development Programme (UNDP)"," Sub region ")
q14c_subreg <- disag_tab(svyrdat, q14c_bin, subregion,subreg_key, "q14c", " United Nations Children’s Fund (UNICEF)"," Sub region ")
q14d_subreg <- disag_tab(svyrdat, q14d_bin, subregion,subreg_key, "q14d", " Red Crescent/Red Cross"," Sub region ")
q14e_subreg <- disag_tab(svyrdat, q14e_bin, subregion,subreg_key, "q14e", " German Society for International Cooperation (GIZ)"," Sub region ")
q14f_subreg <- disag_tab(svyrdat, q14f_bin, subregion,subreg_key, "q14f", " UKAid/Foreign, Commonwealth & Development Office (FCDO) "," Sub region ")
q14g_subreg <- disag_tab(svyrdat, q14g_bin, subregion,subreg_key, "q14g", " Norwegian Refugee Council (NRC) "," Sub region ")
q14h_subreg <- disag_tab(svyrdat, q14h_bin, subregion,subreg_key, "q14h", " Japan International Cooperation Agency (JICA)"," Sub region ")
q14i_subreg <- disag_tab(svyrdat, q14i_bin, subregion,subreg_key, "q14i", " Belgium Development Agency (ENABEL) "," Sub region ")
q14j_subreg <- disag_tab(svyrdat, q14j_bin, subregion,subreg_key, "q14j", " Sweden International Development Agency (Sida) "," Sub region ")

q14k_subreg <- disag_tab(svyrdat, q14k_bin, subregion,subreg_key, "q14k", " Turkish Cooperation and Coordination Agency (TiKA)"," Sub region ")
q14l_subreg <- disag_tab(svyrdat, q14l_bin, subregion,subreg_key, "q14l", " European Union (EU)"," Sub region ")
q14m_subreg <- disag_tab(svyrdat, q14m_bin, subregion,subreg_key, "q14m", " World Food Programme (WFP)"," Sub region ")
q14n_subreg <- disag_tab(svyrdat, q14n_bin, subregion,subreg_key, "q14n", " World Bank"," Sub region ")
q14_subreg <- bind_rows(q14a_subreg, q14b_subreg, q14c_subreg,
                     q14d_subreg,
                     q14e_subreg,
                     q14f_subreg,
                     q14g_subreg, q14h_subreg, q14i_subreg, q14j_subreg, q14k_subreg, q14l_subreg, q14m_subreg, q14n_subreg
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))

#q14_subreg
write_csv(q14_subreg, here("output/tables/eval Q1/q14subreg.csv"))

q14sub_flx <- q14_subreg %>% 
select(`Familiar with foreign donors by SubRegion`=Label, Number, Percent, `Confidence interval`=ci) %>%
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
align(j=4, align="center") %>% 
colformat_double(j=3, digits=0) %>%
hline(i=c(14,28,42), border=smlbrdr) %>%
set_table_properties(layout="autofit") %>% 
add_footer_lines(values="Q14. Familiar with foreign donors by SubRegion Ranked")

q14sub_flx 

Disaggregation type

Familiar with foreign donors by SubRegion

Number

Percent

Confidence interval

Central West Bank

Red Crescent/Red Cross

86

58.1%

46.4% - 69.8%

Central West Bank

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

84

56.6%

47.6% - 65.7%

Central West Bank

European Union (EU)

73

49.4%

38.6% - 60.2%

Central West Bank

United Nations Children’s Fund (UNICEF)

61

41.3%

31.8% - 50.8%

Central West Bank

United Nations Development Programme (UNDP)

55

37.3%

27.6% - 47%

Central West Bank

World Food Programme (WFP)

28

19.0%

10.5% - 27.5%

Central West Bank

Japan International Cooperation Agency (JICA)

27

18.6%

11.2% - 26%

Central West Bank

World Bank

25

16.7%

8.3% - 25.1%

Central West Bank

Norwegian Refugee Council (NRC)

22

15.0%

9.1% - 20.9%

Central West Bank

German Society for International Cooperation (GIZ)

17

11.7%

5.3% - 18.1%

Central West Bank

Sweden International Development Agency (Sida)

13

8.6%

1% - 16.1%

Central West Bank

Belgium Development Agency (ENABEL)

12

8.4%

2.7% - 14%

Central West Bank

Turkish Cooperation and Coordination Agency (TiKA)

10

6.7%

2.5% - 10.9%

Central West Bank

UKAid/Foreign, Commonwealth & Development Office (FCDO)

5

3.5%

0% - 7.1%

Gaza Strip

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

629

89.1%

84.8% - 93.4%

Gaza Strip

Red Crescent/Red Cross

562

79.5%

74.5% - 84.6%

Gaza Strip

United Nations Children’s Fund (UNICEF)

553

78.3%

72.9% - 83.7%

Gaza Strip

European Union (EU)

317

45.0%

39% - 50.9%

Gaza Strip

United Nations Development Programme (UNDP)

264

37.4%

31.5% - 43.3%

Gaza Strip

World Food Programme (WFP)

181

25.7%

20.8% - 30.6%

Gaza Strip

Norwegian Refugee Council (NRC)

165

23.3%

18.5% - 28.1%

Gaza Strip

World Bank

139

19.7%

14% - 25.3%

Gaza Strip

Japan International Cooperation Agency (JICA)

128

18.1%

14.1% - 22.2%

Gaza Strip

Belgium Development Agency (ENABEL)

114

16.1%

12.1% - 20.1%

Gaza Strip

Turkish Cooperation and Coordination Agency (TiKA)

99

14.0%

10.2% - 17.9%

Gaza Strip

German Society for International Cooperation (GIZ)

95

13.4%

10.1% - 16.7%

Gaza Strip

UKAid/Foreign, Commonwealth & Development Office (FCDO)

77

10.9%

7.3% - 14.4%

Gaza Strip

Sweden International Development Agency (Sida)

57

8.0%

5.3% - 10.8%

Northern West Bank

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

273

84.0%

79.7% - 88.4%

Northern West Bank

Red Crescent/Red Cross

229

70.7%

62.9% - 78.4%

Northern West Bank

United Nations Children’s Fund (UNICEF)

217

66.9%

59.4% - 74.4%

Northern West Bank

European Union (EU)

157

48.2%

41.7% - 54.8%

Northern West Bank

World Food Programme (WFP)

77

23.8%

18% - 29.6%

Northern West Bank

United Nations Development Programme (UNDP)

71

21.9%

15.3% - 28.6%

Northern West Bank

Japan International Cooperation Agency (JICA)

62

19.0%

12.8% - 25.3%

Northern West Bank

World Bank

57

17.6%

12.3% - 22.9%

Northern West Bank

German Society for International Cooperation (GIZ)

47

14.6%

9.3% - 20%

Northern West Bank

Norwegian Refugee Council (NRC)

33

10.2%

5.2% - 15.2%

Northern West Bank

Sweden International Development Agency (Sida)

24

7.5%

4% - 11.1%

Northern West Bank

Turkish Cooperation and Coordination Agency (TiKA)

18

5.7%

2.2% - 9.1%

Northern West Bank

UKAid/Foreign, Commonwealth & Development Office (FCDO)

13

3.9%

0.7% - 7%

Northern West Bank

Belgium Development Agency (ENABEL)

10

3.0%

1.4% - 4.7%

Southern West Bank

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

221

77.6%

69.6% - 85.6%

Southern West Bank

Red Crescent/Red Cross

189

66.3%

56.5% - 76.2%

Southern West Bank

United Nations Children’s Fund (UNICEF)

166

58.2%

49.3% - 67%

Southern West Bank

European Union (EU)

94

33.0%

24% - 42.1%

Southern West Bank

United Nations Development Programme (UNDP)

64

22.5%

14.8% - 30.2%

Southern West Bank

World Food Programme (WFP)

59

20.7%

12.3% - 29%

Southern West Bank

World Bank

39

13.5%

5.4% - 21.6%

Southern West Bank

German Society for International Cooperation (GIZ)

15

5.4%

1.7% - 9.2%

Southern West Bank

Norwegian Refugee Council (NRC)

11

4.0%

1.4% - 6.5%

Southern West Bank

Belgium Development Agency (ENABEL)

10

3.7%

1.8% - 5.6%

Southern West Bank

Japan International Cooperation Agency (JICA)

9

3.0%

0% - 6%

Southern West Bank

Sweden International Development Agency (Sida)

8

2.7%

-0.2% - 5.5%

Southern West Bank

Turkish Cooperation and Coordination Agency (TiKA)

5

1.6%

0.2% - 3%

Southern West Bank

UKAid/Foreign, Commonwealth & Development Office (FCDO)

3

1.1%

-0.7% - 2.8%

Q14. Familiar with foreign donors by SubRegion Ranked

Code
save_as_docx(q14sub_flx, path=here("output/tables/eval Q1/q14subreg.docx"))

Q15 Participated in other donor activity

Overall

Code
#frq(dat$q15)

q15 <- fac_tab(svyrdat, q15) %>%
  #mutate(lab=percept_key$perception_lab) %>%
  left_join(yes_key,
            by=c("q15"="yes_no")) %>%
  select(Label=q15, Response =yes_no_lab, Percent:Number, margin, Lower, Upper, ci)
write_csv(q15, here("output/tables/eval Q1/q15.csv"))
#q15

q15_flx <- q15 %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q15. Participated in other donor activity")

save_as_docx(q15_flx, path=here("output/tables/eval Q1/q15.docx"))

q15_flx

Label

Response

Number

Percent

Confidence interval

0

No

2,292

89.9%

87.9% - 91.9%

1

Yes

236

9.3%

7.3% - 11.2%

98

Refused

14

0.6%

0.2% - 0.9%

99

Don't know

6

0.2%

0.1% - 0.4%

Q15. Participated in other donor activity

Disaggregated

Code
#frq(dat$dnr_act_exposure)

q15_ov <- ov_tab(svyrdat, dnr_act_exposure, "q15", "Participated in other donor activity") 

q15_sex <- disag_tab(svyrdat, dnr_act_exposure, sex, sex_key, 
                    "q15", "Participated in other donor activity", "Sex")

q15_age <- disag_tab(svyrdat, dnr_act_exposure, age_grp, age_grp_key, 
                    "q15", "Participated in other donor activity", "Age group")


q15_ed <- disag_tab(svyrdat, dnr_act_exposure, educ_cat, educ_key, 
                    "q15", "Participated in other donor activity", "Education")


q15_mad <- disag_tab(svyrdat, dnr_act_exposure, madrassa, mad_key, 
                    "q15", "Participated in other donor activity", "Madrassa education")


q15_area <- disag_tab(svyrdat, dnr_act_exposure, area, area_key, 
                    "q15", "Participated in other donor activity", "Area")

q15_gov <- disag_tab(svyrdat, dnr_act_exposure, gov,gov_key,
                     "q15","Participated in other donor activity", "Governorate")

q15_subreg <- disag_tab(svyrdat, dnr_act_exposure, subregion, subreg_key, 
                    "q15", "Participated in other donor activity", "Subregion")


q15_reg <- disag_tab(svyrdat, dnr_act_exposure, region, reg_key, 
                    "q15", "Participated in other donor activity", "Region")

q15_disag <- bind_rows(q15_ov,
                       q15_area,
                      q15_reg,
                      q15_subreg,
                      q15_gov,
                      q15_sex,
                      q15_age,
                      q15_ed,
                      q15_mad)

write_csv(q15_disag, here("output/tables/eval Q1/q15 participated other donor disag.csv"))

#q15_disag

q15_disag_flx <- q15_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q15. Participated in other donor activity") %>%
  border_inner_h()

save_as_docx(q15_disag_flx, path=here("output/tables/eval Q1/q15 participated other donor disag.docx"))

q15_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Participated in other donor activity

236

9.3%

7.3% - 11.2%

Area

Urban

185

9.4%

7.2% - 11.5%

Village

15

4.0%

2% - 6.1%

Refugee camp

37

18.1%

5.5% - 30.7%

Region

West Bank

65

4.4%

3.1% - 5.7%

Gaza

171

16.1%

11.9% - 20.4%

Subregion

Northern West Bank

15

2.6%

1.1% - 4.1%

Central West Bank

22

5.4%

3.2% - 7.6%

Southern West Bank

29

5.6%

2.8% - 8.5%

Gaza Strip

171

16.1%

11.9% - 20.4%

Governorate

Jenin

3

1.8%

0.2% - 3.4%

Tubas

0

0.0%

0% - 0%

Tulkarm

1

1.3%

-0.2% - 2.8%

Nablus

9

4.1%

0.5% - 7.8%

Qalqiliya

1

1.7%

-0.8% - 4.3%

Salfit

1

3.0%

-1.4% - 7.4%

Ramallah

8

4.3%

1.6% - 7.1%

Jericho

1

6.2%

0.4% - 12%

Jerusalem

13

6.2%

2.6% - 9.8%

Bethlehem

9

7.2%

1.8% - 12.5%

Hebron

20

5.2%

1.8% - 8.6%

North Gaza

53

24.5%

14.5% - 34.5%

Gaza

67

17.7%

11.8% - 23.7%

Dier al-Balah

35

23.3%

2.3% - 44.4%

Khan Yunis

10

5.4%

1.3% - 9.4%

Rafah

6

5.0%

1.1% - 8.9%

Sex

Male

133

10.5%

7.7% - 13.2%

Female

103

8.1%

6% - 10.2%

Age group

Youth (18-29)

106

10.0%

6.8% - 13.1%

Adult (30-54)

110

10.0%

7.8% - 12.1%

Mature (55+)

20

5.3%

3.2% - 7.5%

Education

Elementary school education

30

5.6%

2.8% - 8.5%

Secondary education

102

9.3%

6.7% - 11.8%

Post-secondary education

104

11.4%

8.6% - 14.3%

Madrassa education

No madrassa education

173

7.9%

5.9% - 9.8%

Madrassa education

63

18.0%

13% - 23%

Q15. Participated in other donor activity

Q16 Donor activities participated in, ranked

Code
q16a <- ov_tab(svyrdat, q16a_bin, " q16a", " United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)") 
q16b <- ov_tab(svyrdat, q16b_bin, " q16b ", " United Nations Development Programme (UNDP)") 
q16c <- ov_tab(svyrdat, q16c_bin, " q16c ", " United Nations Children’s Fund (UNICEF)") 
q16d <- ov_tab(svyrdat, q16d_bin, " q16d ", " Red Crescent/Red Cross") 
q16e <- ov_tab(svyrdat, q16e_bin, " q16e ", " German Society for International Cooperation (GIZ)") 
q16f <- ov_tab(svyrdat, q16f_bin, " q16f", " UKAid/Foreign, Commonwealth & Development Office (FCDO)") 
q16g <- ov_tab(svyrdat, q16g_bin, " q16g ", " Norwegian Refugee Council (NRC)") 
q16h <- ov_tab(svyrdat, q16h_bin, " q16h ", " Japan International Cooperation Agency (JICA)") 
q16i <- ov_tab(svyrdat, q16i_bin, " q16i ", " Belgium Development Agency (ENABEL)") 
q16j <- ov_tab(svyrdat, q16j_bin, " q16j ", " Sweden International Development Agency (Sida)") 
q16k <- ov_tab(svyrdat, q16k_bin, " q16k ", " Turkish Cooperation and Coordination Agency (TiKA)") 
q16l <- ov_tab(svyrdat, q16l_bin, " q16l ", " European Union (EU)") 
q16m <- ov_tab(svyrdat, q16m_bin, " q16m ", " World Food Programme (WFP)") 
q16n <- ov_tab(svyrdat, q16n_bin, " q16n ", " World Bank") 
q16  <- bind_rows(q16a, q16b, q16c, q16d, q16e, q16f, q16g, q16h, q16i, q16j, q16k, q16l, q16m, q16n) %>%
      arrange(desc(Percent))

#q16 
write_csv(q16, here("output/tables/eval Q1/q16.csv"))

q16_flx <- q16 %>% select(`Donor activities participated in  `=Label, Number, Percent, `Confidence interval`=ci) %>%
flextable() %>%
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% 
align(j=4, align="center") %>% 
colformat_double(j=2, digits=0) %>%
set_table_properties(layout="autofit") %>% add_footer_lines(values="Q16. Donor activities Participated in Ranked")

q16_flx

Donor activities participated in

Number

Percent

Confidence interval

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

149

62.9%

53.5% - 72.2%

Red Crescent/Red Cross

109

46.0%

36.4% - 55.5%

United Nations Children’s Fund (UNICEF)

103

43.7%

33.7% - 53.7%

United Nations Development Programme (UNDP)

65

27.7%

18.8% - 36.6%

European Union (EU)

63

26.8%

18.8% - 34.9%

World Food Programme (WFP)

46

19.6%

13.9% - 25.3%

World Bank

39

16.6%

10.6% - 22.6%

German Society for International Cooperation (GIZ)

39

16.4%

10.4% - 22.4%

Norwegian Refugee Council (NRC)

30

12.7%

6.7% - 18.7%

Sweden International Development Agency (Sida)

23

9.8%

4.4% - 15.3%

Turkish Cooperation and Coordination Agency (TiKA)

23

9.7%

4.7% - 14.7%

Belgium Development Agency (ENABEL)

22

9.5%

4% - 15%

UKAid/Foreign, Commonwealth & Development Office (FCDO)

17

7.3%

2.7% - 11.9%

Japan International Cooperation Agency (JICA)

13

5.4%

2% - 8.8%

Q16. Donor activities Participated in Ranked

Code
save_as_docx(q16_flx, path=here("output/tables/eval Q1/q16.docx"))

Ranked by region

Code
q16a_reg <- disag_tab(svyrdat, q16a_bin, region,reg_key, "q16a", " United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA) ","Region")
q16b_reg <- disag_tab(svyrdat, q16b_bin, region,reg_key, "q16b", " United Nations Development Programme (UNDP)","Region")
q16c_reg <- disag_tab(svyrdat, q16c_bin, region,reg_key, "q16c", "United Nations Children’s Fund (UNICEF)","Region")
q16d_reg <- disag_tab(svyrdat, q16d_bin, region,reg_key, "q16d", " Red Crescent/Red Cross","Region")
q16e_reg <- disag_tab(svyrdat, q16e_bin, region,reg_key, "q16e",  " German Society for International Cooperation (GIZ)","Region")
q16f_reg <- disag_tab(svyrdat, q16f_bin, region,reg_key, "q16f", " UKAid/Foreign, Commonwealth & Development Office (FCDO) ","Region")
q16g_reg <- disag_tab(svyrdat, q16g_bin, region,reg_key, "q16g", " Norwegian Refugee Council (NRC) ","Region")
q16h_reg <- disag_tab(svyrdat, q16h_bin, region,reg_key, "q16h", " Japan International Cooperation Agency (JICA)","Region")
q16i_reg <- disag_tab(svyrdat, q16i_bin, region,reg_key, "q16i", " Belgium Development Agency (ENABEL)","Region")
q16j_reg <- disag_tab(svyrdat, q16j_bin, region,reg_key, "q16j", " Sweden International Development Agency (Sida) ","Region")
q16k_reg <- disag_tab(svyrdat, q16k_bin, region,reg_key, "q16k", " Turkish Cooperation and Coordination Agency (TiKA)","Region")
q16l_reg <- disag_tab(svyrdat, q16k_bin, region,reg_key, "q16k", " European Union (EU)","Region")
q16m_reg <- disag_tab(svyrdat, q16m_bin, region,reg_key, "q16m", " World Food Programme (WFP)","Region")
q16n_reg <- disag_tab(svyrdat, q16n_bin, region,reg_key, "q16n", " World Bank","Region")
q16_reg <- bind_rows(q16a_reg, q16b_reg, q16c_reg,
                     q16d_reg,
                     q16e_reg,
                     q16f_reg,
                     q16g_reg, q16h_reg, q16i_reg ,q16j_reg, q16k_reg, q16l_reg, q16m_reg, q16n_reg
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))

#q16_reg

write_csv(q16_reg, here("output/tables/eval Q1/q16reg.csv"))

q16_flx <- q16_reg %>% 
select(`Donor activities participated in,by Region`=Label, Number, Percent, `Confidence interval`=ci) %>% 
flextable() %>% set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>% align(j=4, align="center") %>%
colformat_double(j=3, digits=0) %>%
set_table_properties(layout="autofit") %>%
add_footer_lines(values="Q16. Donor activities participated in by Region ")

q16_flx

Disaggregation type

Donor activities participated in,by Region

Number

Percent

Confidence interval

Gaza

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

126

73.8%

63.9% - 83.8%

Gaza

United Nations Children’s Fund (UNICEF)

85

49.5%

36.5% - 62.5%

Gaza

Red Crescent/Red Cross

81

47.3%

35.3% - 59.4%

Gaza

United Nations Development Programme (UNDP)

55

32.2%

20.5% - 43.9%

Gaza

World Food Programme (WFP)

41

23.7%

16.4% - 31.1%

Gaza

World Bank

35

20.6%

12.5% - 28.7%

Gaza

Norwegian Refugee Council (NRC)

29

17.2%

9% - 25.5%

Gaza

German Society for International Cooperation (GIZ)

29

17.0%

9.7% - 24.3%

Gaza

Turkish Cooperation and Coordination Agency (TiKA)

22

13.1%

6.2% - 20.1%

Gaza

European Union (EU)

22

13.1%

6.2% - 20.1%

Gaza

Belgium Development Agency (ENABEL)

22

13.1%

5.4% - 20.8%

Gaza

Sweden International Development Agency (Sida)

18

10.2%

3.6% - 16.9%

Gaza

UKAid/Foreign, Commonwealth & Development Office (FCDO)

17

10.1%

3.7% - 16.4%

Gaza

Japan International Cooperation Agency (JICA)

8

4.8%

1% - 8.6%

West Bank

Red Crescent/Red Cross

28

42.3%

27.9% - 56.8%

West Bank

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

22

34.1%

19.3% - 48.9%

West Bank

United Nations Children’s Fund (UNICEF)

19

28.5%

13.7% - 43.3%

West Bank

United Nations Development Programme (UNDP)

10

16.0%

6% - 26%

West Bank

German Society for International Cooperation (GIZ)

10

14.8%

4.3% - 25.3%

West Bank

Sweden International Development Agency (Sida)

6

8.8%

-0.1% - 17.7%

West Bank

World Food Programme (WFP)

6

8.6%

0.9% - 16.4%

West Bank

Japan International Cooperation Agency (JICA)

5

6.9%

0.1% - 13.8%

West Bank

World Bank

4

6.2%

-1.7% - 14.1%

West Bank

Norwegian Refugee Council (NRC)

0

0.7%

-0.7% - 2.2%

West Bank

Turkish Cooperation and Coordination Agency (TiKA)

0

0.7%

-0.6% - 2.1%

West Bank

European Union (EU)

0

0.7%

-0.6% - 2.1%

West Bank

UKAid/Foreign, Commonwealth & Development Office (FCDO)

0

0.0%

0% - 0%

West Bank

Belgium Development Agency (ENABEL)

0

0.0%

0% - 0%

Q16. Donor activities participated in by Region

Code
save_as_docx(q16_flx, path=here("output/tables/eval Q1/q16reg.docx"))

Ranked by subregion

Code
q16a_subreg <- disag_tab(svyrdat, q16a_bin, subregion,subreg_key, "q16a", " United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA) "," Sub region ")
q16b_subreg <- disag_tab(svyrdat, q16b_bin, subregion,subreg_key, "q16b", " United Nations Development Programme (UNDP)"," Sub region ")
q16c_subreg <- disag_tab(svyrdat, q16c_bin, subregion,subreg_key, "q16c", " United Nations Children’s Fund (UNICEF)"," Sub region ")
q16d_subreg <- disag_tab(svyrdat, q16d_bin, subregion,subreg_key, "q16d", " Red Crescent/Red Cross"," Sub region ")
q16e_subreg <- disag_tab(svyrdat, q16e_bin, subregion,subreg_key, "q16e", " German Society for International Cooperation (GIZ)"," Sub region ")
q16f_subreg <- disag_tab(svyrdat, q16f_bin, subregion,subreg_key, "q16f", " UKAid/Foreign, Commonwealth & Development Office (FCDO) "," Sub region ")
q16g_subreg <- disag_tab(svyrdat, q16g_bin, subregion,subreg_key, "q16g", " Norwegian Refugee Council (NRC) "," Sub region ")
q16h_subreg <- disag_tab(svyrdat, q16h_bin, subregion,subreg_key, "q16h", " Japan International Cooperation Agency (JICA)"," Sub region ")
q16i_subreg <- disag_tab(svyrdat, q16i_bin, subregion,subreg_key, "q16i", " Belgium Development Agency (ENABEL) "," Sub region ")
q16j_subreg <- disag_tab(svyrdat, q16j_bin, subregion,subreg_key, "q16j", " Sweden International Development Agency (Sida) "," Sub region ")

q16k_subreg <- disag_tab(svyrdat, q16k_bin, subregion,subreg_key, "q16k", " Turkish Cooperation and Coordination Agency (TiKA)"," Sub region ")
q16l_subreg <- disag_tab(svyrdat, q16l_bin, subregion,subreg_key, "q16l", " European Union (EU)"," Sub region ")
q16m_subreg <- disag_tab(svyrdat, q16m_bin, subregion,subreg_key, "q16m", " World Food Programme (WFP)"," Sub region ")
q16n_subreg <- disag_tab(svyrdat, q16n_bin, subregion,subreg_key, "q16n", " World Bank"," Sub region ")
q16_subreg <- bind_rows(q16a_subreg, q16b_subreg, q16c_subreg,
                     q16d_subreg,
                     q16e_subreg,
                     q16f_subreg,
                     q16g_subreg, q16h_subreg, q16i_subreg, q16j_subreg, q16k_subreg, q16l_subreg, q16m_subreg, q16n_subreg
) %>%
  group_by(`Disaggregation type`) %>%
  mutate(region_rank = rank(-Percent)) %>%
  arrange(`Disaggregation type`, desc(Percent))

#q16_subreg
write_csv(q16_subreg, here("output/tables/eval Q1/q16subreg.csv"))


q16sub_flx <- q16_subreg %>% 
select(`Donor activities participated in,by SubRegion`=Label, Number, Percent, `Confidence interval`=ci) %>%
flextable() %>% 
set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
align(j=4, align="center") %>% 
colformat_double(j=3, digits=0) %>%
set_table_properties(layout="autofit") %>% 
add_footer_lines(values="Q16. Donor activities participated in,by SubRegion  Ranked")

q16sub_flx 

Disaggregation type

Donor activities participated in,by SubRegion

Number

Percent

Confidence interval

Central West Bank

Red Crescent/Red Cross

14

64.2%

40.7% - 87.7%

Central West Bank

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

7

33.6%

9.3% - 58%

Central West Bank

United Nations Children’s Fund (UNICEF)

5

24.8%

1.3% - 48.3%

Central West Bank

European Union (EU)

3

15.4%

1.6% - 29.2%

Central West Bank

Japan International Cooperation Agency (JICA)

3

14.9%

-3.7% - 33.6%

Central West Bank

German Society for International Cooperation (GIZ)

2

11.3%

0% - 22.6%

Central West Bank

Sweden International Development Agency (Sida)

2

8.5%

-7.4% - 24.4%

Central West Bank

United Nations Development Programme (UNDP)

2

7.5%

-2.9% - 17.9%

Central West Bank

World Food Programme (WFP)

1

5.3%

-2.3% - 12.8%

Central West Bank

Norwegian Refugee Council (NRC)

0

2.3%

-2.3% - 6.8%

Central West Bank

UKAid/Foreign, Commonwealth & Development Office (FCDO)

0

0.0%

0% - 0%

Central West Bank

Belgium Development Agency (ENABEL)

0

0.0%

0% - 0%

Central West Bank

Turkish Cooperation and Coordination Agency (TiKA)

0

0.0%

0% - 0%

Central West Bank

World Bank

0

0.0%

0% - 0%

Gaza Strip

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

126

73.8%

63.9% - 83.8%

Gaza Strip

United Nations Children’s Fund (UNICEF)

85

49.5%

36.5% - 62.5%

Gaza Strip

Red Crescent/Red Cross

81

47.3%

35.3% - 59.4%

Gaza Strip

United Nations Development Programme (UNDP)

55

32.2%

20.5% - 43.9%

Gaza Strip

European Union (EU)

45

26.6%

16.6% - 36.6%

Gaza Strip

World Food Programme (WFP)

41

23.7%

16.4% - 31.1%

Gaza Strip

World Bank

35

20.6%

12.5% - 28.7%

Gaza Strip

Norwegian Refugee Council (NRC)

29

17.2%

9% - 25.5%

Gaza Strip

German Society for International Cooperation (GIZ)

29

17.0%

9.7% - 24.3%

Gaza Strip

Turkish Cooperation and Coordination Agency (TiKA)

22

13.1%

6.2% - 20.1%

Gaza Strip

Belgium Development Agency (ENABEL)

22

13.1%

5.4% - 20.8%

Gaza Strip

Sweden International Development Agency (Sida)

18

10.2%

3.6% - 16.9%

Gaza Strip

UKAid/Foreign, Commonwealth & Development Office (FCDO)

17

10.1%

3.7% - 16.4%

Gaza Strip

Japan International Cooperation Agency (JICA)

8

4.8%

1% - 8.6%

Northern West Bank

European Union (EU)

7

44.2%

13.3% - 75.1%

Northern West Bank

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

5

31.6%

4% - 59.2%

Northern West Bank

German Society for International Cooperation (GIZ)

2

15.1%

-11.9% - 42.2%

Northern West Bank

United Nations Development Programme (UNDP)

2

10.9%

-3.1% - 24.9%

Northern West Bank

Japan International Cooperation Agency (JICA)

1

8.6%

-0.2% - 17.5%

Northern West Bank

World Food Programme (WFP)

1

7.5%

-1.3% - 16.3%

Northern West Bank

Red Crescent/Red Cross

1

6.9%

-1.6% - 15.5%

Northern West Bank

Turkish Cooperation and Coordination Agency (TiKA)

0

3.1%

-2.1% - 8.3%

Northern West Bank

World Bank

0

2.0%

-2% - 6%

Northern West Bank

United Nations Children’s Fund (UNICEF)

0

0.0%

0% - 0%

Northern West Bank

UKAid/Foreign, Commonwealth & Development Office (FCDO)

0

0.0%

0% - 0%

Northern West Bank

Norwegian Refugee Council (NRC)

0

0.0%

0% - 0%

Northern West Bank

Belgium Development Agency (ENABEL)

0

0.0%

0% - 0%

Northern West Bank

Sweden International Development Agency (Sida)

0

0.0%

0% - 0%

Southern West Bank

United Nations Children’s Fund (UNICEF)

13

46.1%

21.8% - 70.4%

Southern West Bank

Red Crescent/Red Cross

13

44.3%

21.7% - 66.9%

Southern West Bank

United Nations Relief and Works Agency for Palestine Refugees in the Near East (UNRWA)

10

35.8%

11.4% - 60.1%

Southern West Bank

European Union (EU)

8

27.9%

8.4% - 47.4%

Southern West Bank

United Nations Development Programme (UNDP)

7

25.1%

6% - 44.2%

Southern West Bank

German Society for International Cooperation (GIZ)

5

17.3%

0.6% - 33.9%

Southern West Bank

Sweden International Development Agency (Sida)

4

13.6%

-1.8% - 29%

Southern West Bank

World Bank

4

13.1%

-3.4% - 29.6%

Southern West Bank

World Food Programme (WFP)

3

11.8%

-3.4% - 27%

Southern West Bank

UKAid/Foreign, Commonwealth & Development Office (FCDO)

0

0.0%

0% - 0%

Southern West Bank

Norwegian Refugee Council (NRC)

0

0.0%

0% - 0%

Southern West Bank

Japan International Cooperation Agency (JICA)

0

0.0%

0% - 0%

Southern West Bank

Belgium Development Agency (ENABEL)

0

0.0%

0% - 0%

Southern West Bank

Turkish Cooperation and Coordination Agency (TiKA)

0

0.0%

0% - 0%

Q16. Donor activities participated in,by SubRegion Ranked

Code
save_as_docx(q16sub_flx, path=here("output/tables/eval Q1/q16subreg.docx"))

Q17 Other donor performance

Overall

Code
#frq(dat$q17)

q17 <- fac_tab(svyrdat, q17) %>%
  #mutate(lab=percept_key$perception_lab) %>%
  left_join(percept_key,
            by=c("q17"="perception")) %>%
  select(Label=q17, Response =perception_lab, Percent:Number, margin, Lower, Upper, ci) %>%
mutate(Ind="Positive perception of all donors")

write_csv(q17, here("output/tables/eval Q1/q17.csv"))
#q17

q17_flx <- q17 %>%
  select(1, 2, 6, 3, `Confidence interval`=10) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q17. Performance of other donors")

save_as_docx(q17_flx, path=here("output/tables/eval Q1/q17.docx"))

q17_flx

Label

Response

Number

Percent

Confidence interval

1

Very negative

113

4.4%

3.2% - 5.7%

2

Somewhat negative

221

8.7%

7% - 10.3%

3

Neither negative nor positive

511

20.0%

17.7% - 22.3%

4

Somewhat positive

1,087

42.6%

39.7% - 45.6%

5

Very positive

533

20.9%

18.2% - 23.7%

98

Refused

7

0.3%

0% - 0.5%

99

Don't know

78

3.1%

2.2% - 3.9%

Q17. Performance of other donors

Disaggregated

Code
#frq(dat$donor_perf_bin)

q17_ov <- ov_tab(svyrdat, donor_perf_bin, "q17", "Performance of other donors") 

q17_sex <- disag_tab(svyrdat, donor_perf_bin, sex, sex_key, 
                    "q17", "Performance of other donors", "Sex")

q17_age <- disag_tab(svyrdat, donor_perf_bin, age_grp, age_grp_key, 
                    "q17", "Performance of other donors", "Age group")

q17_ed <- disag_tab(svyrdat, donor_perf_bin, educ_cat, educ_key, 
                    "q17", "Performance of other donors", "Education")

q17_mad <- disag_tab(svyrdat, donor_perf_bin, madrassa, mad_key, 
                    "q17", "Performance of other donors", "Madrassa education")

q17_area <- disag_tab(svyrdat, donor_perf_bin, area, area_key, 
                    "q17", "Performance of other donors", "Area")

q17_gov <- disag_tab(svyrdat, donor_perf_bin, gov,gov_key,
                     "q17","Performance of other donors", "Governorate")

q17_subreg <- disag_tab(svyrdat, donor_perf_bin, subregion, subreg_key, 
                    "q17", "Performance of other donors", "Subregion")

q17_reg <- disag_tab(svyrdat, donor_perf_bin, region, reg_key, 
                    "q17", "Performance of other donors", "Region")

q17_disag <- bind_rows(q17_ov,
                       q17_area,
                      q17_reg,
                      q17_subreg,
                      q17_gov,
                      q17_sex,
                      q17_age,
                      q17_ed,
                      q17_mad)

write_csv(q17_disag, here("output/tables/eval Q1/q17 other donor performance disag.csv"))

#q17_disag

q17_disag_flx <- q17_disag %>% 
  select(3,5:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=3, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=5, align="center") %>%
  merge_v(j="Disaggregation") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Q17. Other donor performance") %>%
  border_inner_h()

save_as_docx(q17_disag_flx, path=here("output/tables/eval Q1/q17 other donor performance disag.docx"))

q17_disag_flx

Disaggregation

Disaggregation type

Number

Percent

Confidence interval

Overall

Performance of other donors

1,620

63.6%

60.5% - 66.7%

Area

Urban

1,215

61.6%

58.1% - 65.2%

Village

281

74.7%

67.8% - 81.6%

Refugee camp

124

61.6%

51.1% - 72.1%

Region

West Bank

993

66.6%

62.9% - 70.3%

Gaza

627

59.3%

54% - 64.6%

Subregion

Northern West Bank

364

62.8%

56.8% - 68.8%

Central West Bank

253

63.0%

56.8% - 69.2%

Southern West Bank

376

73.9%

67.3% - 80.6%

Gaza Strip

627

59.3%

54% - 64.6%

Governorate

Jenin

103

67.7%

58.9% - 76.5%

Tubas

22

64.6%

50.8% - 78.4%

Tulkarm

28

35.0%

22% - 48%

Nablus

141

64.7%

52.8% - 76.6%

Qalqiliya

42

76.1%

57.7% - 94.6%

Salfit

28

69.4%

52.2% - 86.5%

Ramallah

110

63.3%

52.8% - 73.8%

Jericho

14

65.3%

43.5% - 87.2%

Jerusalem

129

62.4%

54.5% - 70.4%

Bethlehem

89

73.4%

60.5% - 86.2%

Hebron

287

74.1%

66.3% - 81.8%

North Gaza

160

74.5%

61.1% - 87.9%

Gaza

197

52.0%

44.2% - 59.9%

Dier al-Balah

87

58.5%

42% - 75.1%

Khan Yunis

107

55.6%

43.5% - 67.7%

Rafah

77

61.5%

47.1% - 75.9%

Sex

Male

800

63.0%

59.2% - 66.8%

Female

820

64.2%

60.4% - 67.9%

Age group

Youth (18-29)

691

64.6%

60.1% - 69.1%

Adult (30-54)

728

66.2%

62.6% - 69.7%

Mature (55+)

201

53.1%

48.1% - 58.2%

Education

Elementary school education

320

59.0%

53.1% - 65%

Secondary education

700

63.7%

59.7% - 67.8%

Post-secondary education

600

66.1%

61.9% - 70.2%

Madrassa education

No madrassa education

1,427

64.9%

61.6% - 68.2%

Madrassa education

193

55.2%

48.4% - 62%

Q17. Other donor performance

Key indicator table

Overall

Code
q1_key_ov <- bind_rows(q2_ov, q1g_ov, percep_ov, perf_ov, usg_ov, usp_ov, q9_ov, q11_ov, q13_ov, q15_ov, q17_ov)

#q1_key
write_csv(q1_key_ov, here("output/tables/eval Q1/Eval Q1 Key Indicator Table - overall.csv"))

q1_key_ov_flx <- q1_key_ov %>%
  select(Indicator=Label, 6:7, `Confidence interval`=13) %>%
  flextable() %>%
  colformat_double(j=2, digits=0) %>%
  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(j=4, align="center") %>%
  fix_border_issues() %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Eval Q1 Key Indicator Table")

save_as_docx(q1_key_ov_flx, path=here("output/tables/eval Q1/Eval Q1 Key Indicator Table - overall.docx"))

q1_key_ov_flx

Indicator

Number

Percent

Confidence interval

Familiar with USAID

1,054

41.3%

38.3% - 44.4%

Seen USAID logo

816

32.7%

29.9% - 35.5%

Positive perception of USAID

646

61.3%

57.6% - 64.9%

Positive perception of USAID performance

1,419

55.7%

52.6% - 58.7%

Positive perception of USG

578

22.7%

20.3% - 25.1%

Positive perception of American people

1,166

45.7%

43% - 48.5%

Exposed to USAID activity

616

24.2%

21.8% - 26.6%

Participated in USAID activity

129

5.1%

4% - 6.2%

Familiar with other donors

1,464

57.4%

54.3% - 60.6%

Participated in other donor activity

236

9.3%

7.3% - 11.2%

Performance of other donors

1,620

63.6%

60.5% - 66.7%

Eval Q1 Key Indicator Table

Region

Code
q1_key_reg <- bind_rows(q2_reg, 
                        q1g_reg, 
                        percep_reg, 
                        perf_reg, 
                        usg_reg, 
                        usp_reg,
                        q9_reg,
                        q11_reg,
                        q13_reg,
                        q15_reg,
                        q17_reg) %>% 
  bind_rows(q1_key_ov) %>%
  mutate(disag=ifelse(`Disaggregation type`==Label, "Overall", `Disaggregation type`))

sum(names(q1_key_ov)!=names(q1_key_reg))
[1] 1
Code
q1_key_regW <- q1_key_reg %>%
  select(Indicator=Label, disag, Percent) %>%
  pivot_wider(values_from = Percent,
              names_from=disag) %>%
  mutate(`West Bank`=`West Bank`*100,
         Gaza = Gaza*100,
         Overall=Overall*100,
         Category=c(rep("Familiarity with USAID", 2), 
                    rep("Perception of USAID", 4),
                    rep("Exposure to USAID",2),
                    rep("Familiarity with other donors", 3))) %>%
  select(Category, everything())

#q1_key_regW

write_csv(q1_key_regW, here("output/tables/eval Q1/Eval Q1 Key Indicator Table - region.csv"))

q1_key_regW_flx <- q1_key_regW %>%
  #select(1,5:7) %>%
  flextable() %>%
  #height(height=15) %>%
  line_spacing(space=1, part="all") %>%
  colformat_double(j=3:5, digits=1, suffix = "%") %>%
#  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(part="header", align="center") %>%
  fix_border_issues() %>%
#  hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Eval Q1 Key Indicator Table, with region") %>%
  merge_v(1) %>%
  fix_border_issues(part="all") %>%
  hline(i=c(2, 6, 8))
  #border_inner_h()

save_as_docx(q1_key_regW_flx, path=here("output/tables/eval Q1/Eval Q1 Key Indicator Table - region.docx"))

q1_key_regW_flx

Category

Indicator

West Bank

Gaza

Overall

Familiarity with USAID

Familiar with USAID

36.4%

48.3%

41.3%

Seen USAID logo

33.8%

31.1%

32.7%

Perception of USAID

Positive perception of USAID

57.4%

65.4%

61.3%

Positive perception of USAID performance

55.3%

56.2%

55.7%

Positive perception of USG

15.7%

32.6%

22.7%

Positive perception of American people

50.4%

39.2%

45.7%

Exposure to USAID

Exposed to USAID activity

23.4%

25.3%

24.2%

Participated in USAID activity

2.1%

9.3%

5.1%

Familiarity with other donors

Familiar with other donors

50.9%

66.7%

57.4%

Participated in other donor activity

4.4%

16.1%

9.3%

Performance of other donors

66.6%

59.3%

63.6%

Eval Q1 Key Indicator Table, with region

Subregion

Code
q1_key_subreg <- bind_rows(q2_subreg, 
                        q1g_subreg, 
                        percep_subreg, 
                        perf_subreg, 
                        usg_subreg, 
                        usp_subreg,
                        q9_subreg,
                        q11_subreg,
                        q13_subreg,
                        q15_subreg,
                        q17_subreg) %>% 
  bind_rows(q1_key_ov) %>%
  mutate(disag=ifelse(`Disaggregation type`==Label, "Overall", `Disaggregation type`))

sum(names(q1_key_ov)!=names(q1_key_reg))
[1] 1
Code
q1_key_subregW <- q1_key_subreg %>%
  select(Indicator=Label, disag, Percent) %>%
  pivot_wider(values_from = Percent,
              names_from=disag) %>%
  mutate(`Northern West Bank`=`Northern West Bank`*100,
         `Central West Bank`=`Central West Bank`*100,
         `Southern West Bank`=`Southern West Bank`*100,
         `Gaza Strip`=`Gaza Strip`*100,
         Overall=Overall*100,
         Category=c(rep("Familiarity with USAID", 2), 
                    rep("Perception of USAID", 4),
                    rep("Exposure to USAID",2),
                    rep("Familiarity with other donors", 3))) %>%
  select(Category, everything())

#q1_key_subregW

write_csv(q1_key_subregW, here("output/tables/eval Q1/Eval Q1 Key Indicator Table - subregion.csv"))

q1_key_subregW_flx <- q1_key_subregW %>%
  #select(1,5:7) %>%
  flextable() %>%
  #height(height=15) %>%
  line_spacing(space=1, part="all") %>%
  colformat_double(j=3:7, digits=1, suffix = "%") %>%
#  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
  align(part="header", align="center") %>%
  fix_border_issues() %>%
#  hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
  set_table_properties(layout="autofit") %>%
  add_footer_lines(values="Eval Q1 Key Indicator Table, with region") %>%
  merge_v(1) %>%
  fix_border_issues(part="all") %>%
  hline(i=c(2, 6, 8))
  #border_inner_h()

save_as_docx(q1_key_subregW_flx, path=here("output/tables/eval Q1/Eval Q1 Key Indicator Table - subregion.docx"))

q1_key_subregW_flx

Category

Indicator

Northern West Bank

Central West Bank

Southern West Bank

Gaza Strip

Overall

Familiarity with USAID

Familiar with USAID

42.0%

33.6%

32.3%

48.3%

41.3%

Seen USAID logo

37.6%

41.2%

23.8%

31.1%

32.7%

Perception of USAID

Positive perception of USAID

57.7%

49.7%

63.2%

65.4%

61.3%

Positive perception of USAID performance

54.0%

54.0%

57.8%

56.2%

55.7%

Positive perception of USG

15.3%

15.0%

16.6%

32.6%

22.7%

Positive perception of American people

47.0%

49.8%

54.8%

39.2%

45.7%

Exposure to USAID

Exposed to USAID activity

25.8%

21.0%

22.5%

25.3%

24.2%

Participated in USAID activity

1.8%

2.1%

2.4%

9.3%

5.1%

Familiarity with other donors

Familiar with other donors

56.0%

36.8%

56.1%

66.7%

57.4%

Participated in other donor activity

2.6%

5.4%

5.6%

16.1%

9.3%

Performance of other donors

62.8%

63.0%

73.9%

59.3%

63.6%

Eval Q1 Key Indicator Table, with region

Code
# q1_key_gov <- bind_rows(q2_gov,
#                         q1g_gov,
#                         percep_gov,
#                         perf_gov,
#                         usg_gov,
#                         usp_gov,
#                         q9_gov,
#                         q11_gov,
#                         q13_gov,
#                         q15_gov,
#                         q17_gov) %>%
#   #bind_rows(q1_key_gov) %>%
#   mutate(disag=ifelse(`Disaggregation type`==Label, "Overall", `Disaggregation type`))
# 
# sum(names(q1_key_ov)!=names(q1_key_reg))
# 
# q1_key_govW <- q1_key_gov %>%
#   select(Indicator=Label, disag, Percent) %>%
#   pivot_wider(values_from = Percent,
#               names_from=disag)
# %>%
#   mutate(`West Bank`=`West Bank`*100,
#          Gaza = Gaza*100,
#          Overall=Overall*100,
#          Category=c(rep("Familiarity with USAID", 2),
#                     rep("Perception of USAID", 4),
#                     rep("Exposure to USAID",2),
#                     rep("Familiarity with other donors", 3))) %>%
#   select(Category, everything())
# 
# q1_key_regW
# 
# write_csv(q1_key_regW, here("output/tables/eval Q1/Eval Q1 Key Indicator Table - region.csv"))
# 
# q1_key_regW_flx <- q1_key_regW %>%
#   #select(1,5:7) %>%
#   flextable() %>%
#   #height(height=15) %>%
#   line_spacing(space=1, part="all") %>%
#   colformat_double(j=3:5, digits=1, suffix = "%") %>%
# #  set_formatter(Percent=function(x) sprintf("%.1f%%", x*100)) %>%
#   align(part="header", align="center") %>%
#   fix_border_issues() %>%
# #  hline(i=c(1,3,7,10,12,15,18), border=smlbrdr) %>%
#   set_table_properties(layout="autofit") %>%
#   add_footer_lines(values="Eval Q1 Key Indicator Table, with region") %>%
#   merge_v(1) %>%
#   fix_border_issues(part="all") %>%
#   hline(i=c(2, 6, 8))
#   #border_inner_h()
# 
# save_as_docx(q1_key_regW_flx, path=here("output/tables/eval Q1/Eval Q1 Key Indicator Table - region.docx"))
# 
# q1_key_regW_flx

Key indicators - ordinal

Code
q4_tot <- svytotal(~factor(q4),
         na.rm=T,
         design=svydat) %>%
  as.data.frame()

usaid_percep_ord <- svymean(~factor(usaid_percep_ord3),
        na.rm=T,
        deff="replace",
        design=svydat) %>%
  as.data.frame() %>%
  mutate(Indicator="USAID",
         Response=c(-1,0,1),
         Label=c("Negative","No opinion","Positive"),
         Percent=round(mean*100,0),
         lab_pos = cumsum(Percent) - .1*Percent) %>%
  select(Indicator, Response, Label, Percent, lab_pos) 


#write_csv(q4, here("output/tables/eval Q1/q4.csv"))
#q4

usaid_percep_ord_flx <- usaid_percep_ord %>%
  select(-2, -5) %>%
  pivot_wider(values_from=Percent,
              names_from=Label) %>%
  flextable() %>%
  set_table_properties(layout="autofit") %>%
  colformat_double(j=2:4, digits=0, suffix="%")

#usaid_percep_ord_flx

save_as_docx(usaid_percep_ord_flx, path=here("output/tables/eval Q1/usaid percep ord.docx"))
Code
#args(ov_tab)

perford <- fac_tab(svyrdat, usaid_perf_ord3) %>%
  mutate(Indicator="Positive perception of USAID performance",
         Label=c("Negative","No opinion","Positive"),
         Percent=round(Percent*100,0),
         lab_pos = cumsum(Percent) - .1*Percent) %>%
  select(Indicator, Response=1, Label, Percent, lab_pos) 

#str(perford)

# ggplot(perford, aes(x=Indicator, y=reorder(Percent, Response), fill=Label)) + 
#   geom_col(width=.2) +
# #  geom_text(aes(label=paste(Percent, "%", sep=""), group=Label)) +
# #  geom_text(aes(label=paste(round(Percent*100,3), "%", sep=""))) +
# #  coord_flip() +
#   scale_fill_viridis_d() +
#   theme(legend.position="none",
#         axis.title.y=element_blank(),
#         axis.text.y=element_blank(),
#         axis.ticks.y=element_blank())
Code
#perford

perford_flx <- perford %>%
  select(-2, -5) %>%
  pivot_wider(values_from=Percent,
              names_from=Label) %>%
  flextable() %>%
  set_table_properties(layout="autofit") %>%
  colformat_double(j=2:4, digits=0, suffix="%")

#labs$perception2

#perford
#perford_flx

save_as_docx(perford_flx, path=here("output/tables/eval Q1/usaid perf ord.docx"))


#ggplot(perford, aes())
Code
usg_ord <- fac_tab(svyrdat, usg_percep_ord3) %>%
  mutate(Indicator="Positive perception of United States Government",
         Label=c("Negative","No opinion","Positive"),
         Percent=round(Percent*100,0),
         lab_pos = cumsum(Percent) - .1*Percent) %>%
  select(Indicator, Response=1, Label, Percent, lab_pos) 

#usg_ord

usg_ord_flx <- usg_ord %>%
  select(Indicator, Label, Percent) %>%
  pivot_wider(values_from=Percent,
              names_from=Label) %>%
  flextable() %>%
  set_table_properties(layout="autofit") %>%
  colformat_double(j=2:4, digits=0, suffix="%")

#usg_ord_flx

save_as_docx(usg_ord_flx, path=here("output/tables/eval Q1/usg percep ord.docx"))
Code
usp_ord <- fac_tab(svyrdat, usp_ord3) %>%
  mutate(Indicator="United States people",
         Label=c("Negative","No opinion","Positive"),
         Percent=round(Percent*100,0),
         lab_pos = cumsum(Percent) - .1*Percent) %>%
  select(Indicator, Response=1, Label, Percent, lab_pos) 

#usp_ord

usp_ord_flx <- usp_ord %>%
  select(Indicator, Label, Percent) %>%
  pivot_wider(values_from=Percent,
              names_from=Label) %>%
  flextable() %>%
  set_table_properties(layout="autofit") %>%
  colformat_double(j=2:4, digits=0, suffix="%")

#usp_ord_flx

save_as_docx(usg_ord_flx, path=here("output/tables/eval Q1/usp percep ord.docx"))
Code
donor_perf_ord <- fac_tab(svyrdat, donor_perf_ord3) %>%
  mutate(Indicator="All donors",
         Label=c("Negative","No opinion","Positive"),
         Percent=round(Percent*100,0),
         lab_pos = cumsum(Percent) - .1*Percent) %>%
  select(Indicator, Response=1, Label, Percent, lab_pos) 

#donor_perf_ord

donor_perf_ord_flx <- donor_perf_ord %>%
  select(Indicator, Label, Percent) %>%
  pivot_wider(values_from=Percent,
              names_from=Label) %>%
  flextable() %>%
  set_table_properties(layout="autofit") %>%
  colformat_double(j=2:4, digits=0, suffix="%")

#donor_perf_ord_flx

save_as_docx(donor_perf_ord_flx, path=here("output/tables/eval Q1/donor percep ord.docx"))
Code
q1ord <- bind_rows(usaid_percep_ord,
                   perford,
                   usg_ord,
                   usp_ord,
                   donor_perf_ord) 

q1ord <- q1ord %>%
  `rownames<-` (NULL) %>%
  mutate(ind2=rep(c("USAID",
                    "USAID performance",
                    "United States Government",
                    "United States people",
                    "All donors in Palestine"), each=3),
         num=rep(1:5, each=3)) 


q1ord <- q1ord %>%
  group_by(ind2) %>%
  mutate(lab_pos2=cumsum(Percent-.2*Percent)) %>%
  ungroup()

#str(q1ord)
#q1ord

write_csv(q1ord, here("output/tables/eval Q1/q1 ord.csv"))
                 
q1ordL <- q1ord %>%
  select(Indicator, Label, Percent) %>%
  pivot_wider(values_from=Percent,
              names_from=Label) 

#q1ordL


q1ord_flx <- q1ord %>%
  select(Indicator, Label, Percent) %>%
  pivot_wider(values_from=Percent,
              names_from=Label) %>%
  flextable() %>%
  set_table_properties(layout="autofit") %>%
  colformat_double(j=2:4, digits=0, suffix="%")

save_as_docx(q1ord_flx, path=here("output/tables/eval Q1/q1 ord.docx"))

q1ord_flx

Indicator

Negative

No opinion

Positive

USAID

11%

28%

61%

Positive perception of USAID performance

17%

27%

56%

Positive perception of United States Government

51%

26%

23%

United States people

31%

23%

46%

All donors

13%

23%

64%