Libraries

Data

gaza_geno <- read.csv("D:/R_Gaza/gaza/data/killed-in-gaza.csv")
class(gaza_geno)
## [1] "data.frame"

First data exploration

gaza_geno <- as_tibble(gaza_geno)
class(gaza_geno)
## [1] "tbl_df"     "tbl"        "data.frame"
gaza_geno
## # A tibble: 34,344 × 7
##    id          name                       en_name         age dob   sex   source
##    <chr>       <chr>                      <chr>         <int> <chr> <chr> <chr> 
##  1 طفللللللل   بنت اسيا نزار محمد ابووردة Bint Asaia N…     0 2024… f     h     
##  2 طفللللل     ابن ولاء     الدوواسة      Abn Wlaa Ald…     0 2024… m     h     
##  3 طفل رضيع66  أمل محمد جمعة أبو صويص     Amal Muhamma…     0 2023… f     c     
##  4 طفل رضيع6   ياسر صلاح ياسر الدلو       Yasr Salah Y…     0 2023… m     h     
##  5 طفل رضيع55  كارمل علاء وليد حمدان      Karml Alaaa …     0 2023… f     c     
##  6 طفل رضيع5   ميساء ديب محمود السكافى    Maisaa Diab …     0 2023… f     c     
##  7 طفل رضيع4   محمد نعيم نصر عياد         Muhammad Nai…     0 2023… m     c     
##  8 طفل رضيع3   كنان شادي هاشم مشتهى       Knan Shadi H…     0 2023… m     c     
##  9 طفل رضيع226 ابن/ انوار احمد محمد درويش Abn/ Anwar A…     0 2023… m     h     
## 10 طفل رضيع225 بنت/زينب محمد العبد نواس   Daughter of …     0 2023… f     h     
## # ℹ 34,334 more rows
death_by_age <- 
  gaza_geno %>% 
  group_by(age = as.integer(age)) %>% 
  summarise(Death = n())

peak_10_ages <- death_by_age %>% 
  top_n(n = 10, Death) %>% 
  pull(age)

age_quantiles <- quantile(gaza_geno$age)
age_quantiles <- as.matrix(age_quantiles)
age_quantiles_rownames <- rownames(age_quantiles)
age_quantiles <- as.tibble(cbind(age_quantiles, age_quantiles_rownames))
colnames(age_quantiles)
## [1] "V1"                     "age_quantiles_rownames"
colnames(age_quantiles)<- c("Age", "Quantile")

age_quantiles %>% kbl(caption = "Age quantiles of murdered palestinians") %>% kable_classic() %>% kable_styling(full_width = FALSE)
Age quantiles of murdered palestinians
Age Quantile
0 0%
14 25%
26 50%
39 75%
101 100%
peak_10_ages
##  [1]  0 16 17 23 28 29 30 31 32 33
death_by_sex_age <- 
  gaza_geno %>% 
  mutate(sex = factor(sex, levels = c("f", "m"), 
                      labels = c("Female", "Male"))) %>% 
  group_by(age, sex, .groups = TRUE) %>% 
  summarise(Death = n())

death_by_sex_age <- death_by_sex_age[-3]

tbl_by_sex_age <- gaza_geno %>% 
  select(sex, age) %>% 
  mutate(sex = factor(sex, levels = c("f", "m"), labels = c("Female", "Male"))) %>% 
  tbl_summary(label = list(sex = "Sex", age = "Age")) 

tbl_by_sex_age
Characteristic N = 34,3441
Sex
    Female 12,370 (36%)
    Male 21,974 (64%)
Age 26 (14, 39)
1 n (%); Median (Q1, Q3)

Plots

theme_set(theme_bw())

A <-   gaza_geno %>% 
  ggplot(aes(x = age))+
  geom_histogram(fill = "#4D5052", colour = "black", bins = 20, binwidth = 2)+
  scale_x_continuous(breaks = seq(0, 100, 20))+
  labs(title = "Gaza genocide - Death by Age", x = "Age", y = "Frequency of Deaths")+
  theme(plot.title = element_text(face = "bold"))

B <-   death_by_age %>% 
  ggplot(aes(x = age, y = Death))+
  geom_line()+
  geom_segment(x = 14, xend= 14, y = 0, yend = 659, linetype = "dashed")+
  geom_segment(x = 26, xend= 26, y = 0, yend = 652, linetype = "dashed")+
  geom_segment(x = 39, xend= 39, y = 0, yend = 469, linetype = "dashed")+
  scale_x_continuous(breaks = seq(0, 100, 20))+
  labs(title = "Gaza genocide - Death by Age", x = "Age", y = "Number of Deaths", 
       caption = "The frequency and number of murdered palestinians by age (murdered by the Israelis)")+
  theme(plot.title = element_text(face = "bold"), 
        plot.caption = element_text(face = "italic", colour = "#4D5052"), 
        plot.caption.position = "plot")

hist_linechart_geno <-  A + B 



pal_hist_linechart <- plotTag({
  hist_linechart_geno
}, "Gaza genocide - Death by Age", width = 700, height = 400)

pal_hist_linechart
Gaza genocide - Death by Age
save_html(html = pal_hist_linechart, file = "pal_hist_linechart.html")

Maps

Setting the data

# Get palestinian cities, convert it to sf dataframe, assign projection to the coordinates and save it

data(world.cities)
palestine_cities <- world.cities %>% filter(country.etc == "Palestine")
class(palestine_cities)
## [1] "data.frame"
palestine_cities <- as_tibble(palestine_cities)
write_excel_csv(palestine_cities, 
                file = "D:/R_Gaza/IRachailovich.github.io/data/palestinians_cities.csv")

names(palestine_cities)    #get the names for the coordinate variables
## [1] "name"        "country.etc" "pop"         "lat"         "long"       
## [6] "capital"
palestine_cities_sf <- st_as_sf(palestine_cities, coords = c("lat", "long")) #convert to sf df tibble
class(palestine_cities_sf) #check if class has changed to sf dataframe tibble
## [1] "sf"         "tbl_df"     "tbl"        "data.frame"
st_crs(palestine_cities_sf) #check for geographic projections
## Coordinate Reference System: NA
st_crs(palestine_cities_sf) <- 4326  #assign geographic projection (4326, i.e., longlat WGS84)
st_crs(palestine_cities_sf)$proj4string #check if the geographic projection was assigned
## [1] "+proj=longlat +datum=WGS84 +no_defs"
names(palestine_cities_sf) #check if "lat" and "long" variables were changed to "geometry" variable.
## [1] "name"        "country.etc" "pop"         "capital"     "geometry"
st_write(palestine_cities_sf, "D:/R_Gaza/IRachailovich.github.io/data/palestinian_cities", 
         driver = "ESRI Shapefile", delete_layer = TRUE)  # save the sf data frame as shapefile
## Writing layer `palestinian_cities' to data source 
##   `D:/R_Gaza/IRachailovich.github.io/data/palestinian_cities' using driver `ESRI Shapefile'
## Writing 244 features with 4 fields and geometry type Point.
unzip(zipfile =  "D:/R_Gaza/gaza/data/localities_palestine_sf.zip" , exdir ="data/localities_palestine")
localities_palestine_sf <- st_read("data/localities_palestine")
## Reading layer `%D8%AA%D8%AC%D9%85%D8%B9%D8%A7%D8%AA_%D9%81%D9%84%D8%B3%D8%B7%D9%8A%D9%86___Localities_Palestine' from data source `D:\R_Gaza\IRachailovich.github.io\data\localities_palestine' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 619 features and 10 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 3809204 ymin: 3661924 xmax: 3960023 ymax: 3836009
## Projected CRS: WGS 84 / Pseudo-Mercator
localities_palestine_sf %>% head()
## Simple feature collection with 6 features and 10 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 3822272 ymin: 3669405 xmax: 3844607 ymax: 3707141
## Projected CRS: WGS 84 / Pseudo-Mercator
##   OBJECTID REGIONCODE DISTCODE GOVCODE  LOCCODE                    NAMEAR
## 1        1          2       24    2470 24703430             عبسان الجديدة
## 2        2          2       24    2470 24703470                     خزاعة
## 3        3          2       24    2465 24653200            مخيم دير البلح
## 4        4          2       24    2465 24653275               وادي السلقا
## 5        5          2       24    2455 24552681 أم النصر (القرية البدوية)
## 6        6          2       24    2465 24653065             مخيم النصيرات
##                                 NAMEEN NOTES Shape__Are Shape__Len
## 1                    'Abasan al Jadida  <NA>  4919436.7  11010.191
## 2                              Khuza'a  <NA>  9193057.5  14360.481
## 3                   Deir al Balah Camp  <NA>   337604.1   3122.714
## 4                        Wadi as Salqa  <NA>  8752155.1  12611.773
## 5 Um Al-Nnaser (Al Qaraya al Badawiya)  <NA>  4306257.9   9547.706
## 6                     An Nuseirat Camp  <NA>  1099596.7  10312.221
##                         geometry
## 1 MULTIPOLYGON (((3824072 367...
## 2 MULTIPOLYGON (((3826180 367...
## 3 MULTIPOLYGON (((3823061 368...
## 4 MULTIPOLYGON (((3827289 368...
## 5 MULTIPOLYGON (((3844490 370...
## 6 MULTIPOLYGON (((3827522 369...
class(localities_palestine_sf)
## [1] "sf"         "data.frame"
st_crs(localities_palestine_sf)$proj4string
## [1] "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"
localities_palestine_WGS84 <- st_transform(localities_palestine_sf, crs = 4326)
st_crs(localities_palestine_WGS84)$proj4string
## [1] "+proj=longlat +datum=WGS84 +no_defs"
st_write(localities_palestine_WGS84, "D:/R_Gaza/IRachailovich.github.io/data/localities_palestine", 
         driver = "ESRI Shapefile", delete_layer = TRUE)
## Deleting layer `localities_palestine' failed
## Writing layer `localities_palestine' to data source 
##   `D:/R_Gaza/IRachailovich.github.io/data/localities_palestine' using driver `ESRI Shapefile'
## Writing 619 features with 10 fields and geometry type Multi Polygon.
st_crs(localities_palestine_WGS84)$proj4string
## [1] "+proj=longlat +datum=WGS84 +no_defs"
st_crs(palestine_cities_sf)$proj4string
## [1] "+proj=longlat +datum=WGS84 +no_defs"

Creating maps

simple_polygons <- plotTag({
  ggplot(localities_palestine_WGS84)+
  geom_sf(colour = "black")
}, "simple_polygons", width = 700, height = 400)

simple_polygons
simple_polygons
save_html(html = simple_polygons, file = "simple_polygons.html")

col_fun <- colorFactor(c("#337bd7", "#c8143b"), domain = NULL)
itamar <- st_point(c(34.82375, 31.89530))
itamarpopup <- c("Where I.J.R was born")   
pal_popup <- paste0("<strong>City Name:</strong>", palestine_cities$name)


palestine_map <- leaflet(localities_palestine_WGS84) %>% 
  addPolygons(stroke = TRUE, weight = 0.7, color = "black", 
              fillColor = ~col_fun(REGIONCODE), 
              group = "Regions", fillOpacity = 0.8) %>% 
  addCircleMarkers(lng = 34.82375 , lat = 31.89530, group = "Where I Live",
                   popup = itamarpopup) %>% 
  addCircleMarkers(data = palestine_cities, group = "Cities", popup = pal_popup, 
                   radius = 0.01, color = "#2c120c") %>% 
  addTiles(group = "OSM") %>% 
  addProviderTiles(provider = "CartoDB", group = "CartoDB") %>% 
  addProviderTiles(provider = "CartoDB.Voyager", group = "CartoDB.Voyager") %>% 
  addProviderTiles(provider = "Esri", group = "Esri") %>% 
  addLayersControl(baseGroups = c("OSM", "CartoDB", "CartoDB.Voyager", "Esri"), 
                   overlayGroups = c("Regions", "Where I Live", "Cities"))
palestine_map
saveWidget(widget = palestine_map, file = "palestine_map.html", selfcontained = TRUE)