Soc-Ace: POLECAT Data Analysis

Author

Gagan Atreya

Published

October 20, 2024

Section 1. POLECAT Events By Country: 2020 - 2023

1.1 Breakdown of Events by Country

Display code
## Gagan Atreya
## POLECAT Analysis

rm(list = ls())

pacman::p_load(data.table, tidyverse, lubridate, 
               vtable, stringi, stringr, ggcharts, plyr, 
               gridExtra, RgoogleMaps, ggmap, mapproj)

df_2020 <- as.data.table(read.delim("~/Desktop/soc_ace_2024/data/polecat/ngecEvents.DV.2020.txt"))
df_2021 <- as.data.table(read.delim("~/Desktop/soc_ace_2024/data/polecat/ngecEvents.DV.2021.txt"))
df_2022 <- as.data.table(read.delim("~/Desktop/soc_ace_2024/data/polecat/ngecEvents.DV.2022.txt"))
df_2023 <- as.data.table(read.delim("~/Desktop/soc_ace_2024/data/polecat/ngecEvents.DV.2023.txt"))

df <- rbindlist(list(df_2020, df_2021, df_2022, df_2023))

country_list <- c("ARM", "BLR", "GEO", "HUN", 
                  "KAZ", "KGZ", "MDA", "POL", 
                  "ROU", "RUS", "SVK", "UKR")

df01 <- df[df$Country %in% country_list, ]
df <- df01
rm(list = setdiff(ls(), c("df")))

table(df$Country)

  ARM   BLR   GEO   HUN   KAZ   KGZ   MDA   POL   ROU   RUS   SVK   UKR 
 4185  9068  4162  1380  3272  1623  2002  3910  1938 28725  2162 52712 
Display code
df_agg <- df[, .(value = .N), by = Country]  

ggplot(df_agg, 
       aes(x = reorder(Country, value), y = value)) +
  geom_segment(aes(xend = Country, yend = 0), color = "grey") +  # Line segment
  geom_point(size = 3, color = "blue") +  # Lollipop
  coord_flip() +  # Flip coordinates for better readability
  labs(title = "Country Events in POLECAT",
       x = "Country",
       y = "Value") +
  theme_minimal()

1.2 Breakdown of Events by Contexts

We are interested in events with the following “contexts”:

  • Crime

  • Corruption

  • Illegal Drugs

  • Trafficking

However, the data show that there are no events that align with the above contexts, except a few for “illegal drugs”.

Display code
#### Contexts #####

context_list <- c("crime", "corruption", "illegal drugs", "trafficking")

df[, crime := as.integer(str_detect(Contexts, 
                                    "crime"))]
# table(df$crime)

df[, corruption := as.integer(str_detect(Contexts, 
                                         "corruption"))]
# table(df$corruption)

df[, trafficking := as.integer(str_detect(Contexts, 
                                          "trafficking"))]
# table(df$trafficking)

df[, drugs := as.integer(str_detect(Contexts, 
                                    "illegal_drugs"))]
table(df$drugs)

     0      1 
114767    372 
Display code
df_drugs <- df[df$drugs==1,]
Display code
df_agg_drugs <- df_drugs[, .(value = .N), by = Country]  

ggplot(df_agg_drugs, 
       aes(x = reorder(Country, value), y = value)) +
  geom_segment(aes(xend = Country, yend = 0), color = "grey") +  # Line segment
  geom_point(size = 3, color = "blue") +  # Lollipop
  coord_flip() +  # Flip coordinates for better readability
  labs(title = "Events related to \"illegal drugs\"",
       x = "Country",
       y = "Value") +
  theme_minimal()

Since there were no events recorded for “crime” “corruption”, and “trafficking”, we can look at other ‘context’ categories which might be relevant to us. For example - “Economic”, and “Legal” (See page 28 of the PLOVER manual).

Again, there are no events that fall under ‘economic’, but there are a few events recorded as ‘legal’:

Display code
df[, economic := as.integer(str_detect(Contexts, 
                                          "economic"))]
# table(df$economic)

df[, legal := as.integer(str_detect(Contexts, 
                                          "legal"))]
table(df$legal)

     0      1 
114767    372 
Display code
df_legal<- df[df$legal==1,]

df_agg_legal <- df_legal[, .(value = .N), by = Country]  

ggplot(df_agg_legal, 
       aes(x = reorder(Country, value), y = value)) +
  geom_segment(aes(xend = Country, yend = 0), color = "grey") +  # Line segment
  geom_point(size = 3, color = "blue") +  # Lollipop
  coord_flip() +  # Flip coordinates for better readability
  labs(title = "Events related to \"legal\"",
       x = "Country",
       y = "Value") +
  theme_minimal()

Seems like these are the exact same events. That is, any event tagged as ‘illegal drugs’ is also tagged as ‘legal’.

1.3. Other potential variables

We can look at other potential variables to make our categories.

One potential category is “Event type”

Display code
table(df$Event.Type)

   ACCUSE       AID   ASSAULT    COERCE   CONCEDE   CONSULT COOPERATE  MOBILIZE 
    21030     16655     33086      8381      1817       209       163      1069 
  PROTEST    REJECT   REQUEST   RETREAT  SANCTION  THREATEN 
     4214        34      8173      7900      6089      6319 

Another potential category is “Event mode”

Display code
table(df$Event.Mode)

        access         arrest         assist           beat        boycott 
           210           4215              1            325             46 
     ceasefire         censor        convict           demo         disarm 
            90            363            815           2724             10 
         expel misinformation           None          phone         police 
           712            353          82233              8             78 
     primitive        release         resign       restrict           riot 
          1019            406            292            204            140 
        sexual         strike       targeted      territory        torture 
           130            101            445            546            437 
        troops       withdraw       withhold 
           468            130              3 
Display code
## Visualise for "arrest"

1.4. “Arrest” across countries and years

Arrest vs countries

Occurence of event mode: “arrest” across countries:

Display code
df[, arrest := as.integer(str_detect(Event.Mode, 
                                          "arrest"))]

df_arrest<- df[df$arrest==1,]

df_agg_arrest <- df_arrest[, .(value = .N), by = Country]  

ggplot(df_agg_arrest, 
       aes(x = reorder(Country, value), y = value)) +
  geom_segment(aes(xend = Country, yend = 0), color = "grey") +  # Line segment
  geom_point(size = 3, color = "blue") +  # Lollipop
  coord_flip() +  # Flip coordinates for better readability
  labs(title = "Event Mode described as \"arrest\"",
       x = "Country",
       y = "Value") +
  theme_minimal()

Arrest vs years

Occurence of event mode: “arrest” across years:

Display code
df$year <- year(df$Event.Date)
df <- df[df$year > 2019, ]
df[, arrest := as.integer(str_detect(Event.Mode, 
                                          "arrest"))]

df_arrest <- df[df$arrest==1,]

table(df_arrest$year)

2020 2021 2022 2023 
 892 1431  922  964 
Display code
df_agg_arrest <- df_arrest[, .(value = .N), by = year]  

# Create a lollipop chart
ggplot(df_agg_arrest, 
       aes(x = factor(year), 
           y = value)) +
  geom_segment(aes(x = factor(year), 
                   xend = factor(year), 
                   y = 0, yend = value),
               color = "gray") +
  geom_point(size = 4, color = "blue") +
  labs(title = "Event mode: \"arrest\" across years",
       x = "Year", 
       y = "Count") +
  coord_flip()+
  theme_minimal()

Arrest vs country vs years

Occurence of event mode: “arrest” across countries across years:

Display code
df11 <- df_arrest[, .(year, Country)]

df11_agg <- df11[, .N, by = .(Country, year)]  # .N counts occurrences of each country per year

# Create a lollipop chart facetted by year
ggplot(df11_agg, aes(x = Country, y = N)) +
  geom_segment(aes(x = Country, xend = Country, y = 0, yend = N), color = "gray") +
  geom_point(size = 2, color = "blue") +
  labs(title = "Arrest across countries by year",
       x = "Country", y = "Count") +
  theme_minimal() +
  coord_flip()+
  facet_wrap(~ year)

Arrest vs country vs date

Occurence of event mode: “arrest” across countries across date:

Display code
df12 <- df_arrest[, .(Event.Date, Country)]
df12$Event.Date <- ymd(df12$Event.Date)
df12[, Year := year(Event.Date)]

df12a <- df12[df12$Country %in% c("ARM", "BLR", "GEO", 
                                  "HUN", "KAZ", "KGZ")]


df12b <- df12[df12$Country %in% c("MDA", "POL", "ROU",
                                  "RUS", "SVK", "UKR")]

# Plot the data
ggplot(df12a, aes(x = Event.Date)) +
  geom_bar(position = "stack", color = "black", fill = "blue") +  # Default fill for better readability
  scale_x_date(date_labels = "%Y", date_breaks = "12 months") +  # Show every 12 months on x-axis
  labs(title = "Country Occurrences for \"arrest\" Over Time",
       x = "Date",
       y = "Count") +
  facet_wrap(~Country, ncol = 2) +  # Facet by country with 4 columns
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis l

Display code
# Plot the data
ggplot(df12b, aes(x = Event.Date)) +
  geom_bar(position = "stack", color = "black", fill = "blue") +  # Default fill for better readability
  scale_x_date(date_labels = "%Y", date_breaks = "12 months") +  # Show every 12 months on x-axis
  labs(title = "Country Occurrences for \"arrest\" Over Time",
       x = "Date",
       y = "Count") +
  facet_wrap(~Country, ncol = 2) +  # Facet by country with 4 columns
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis l

Section 2. Maps: Armenia

Display code
ggmap::register_stadiamaps(key = "ecb62ab3-c884-4be1-9e19-4a49f5f8bed0")

2.1. Armenia: arrests

Display code
dfarm <- df[df$Country == "ARM", ]

dfarm$Latitude <- as.numeric(dfarm$Latitude)
dfarm$Longitude <- as.numeric(dfarm$Longitude)

# summary(dfarm$Latitude)
# summary(dfarm$Longitude)

mapoutline <- get_map(location = c(left = 44.05, # lon min
                                   bottom = 39.00, # lat min
                                   right = 46.75, # lon max
                                   top = 40.75), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfarm <- dfarm[dfarm$Event.Mode == "arrest", ]

dfarm$Event_count <- 1

df01 <- ddply(dfarm, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Armenia, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

2.2. Armenia: illegal drugs

Display code
dfarm$drugs <- ifelse(str_detect(dfarm$Contexts, "illegal_drugs") == T, 1, 0)

dfarm <- dfarm[dfarm$drugs == 1, ]

dfarm$Event_count <- 1

df01 <- ddply(dfarm, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfarm$Longitude <- as.numeric(dfarm$Longitude)
dfarm$Latitude <- as.numeric(dfarm$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Armenia, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 3. Maps: Belarus

3.1. Belarus: arrests

Display code
dfblr <- df[df$Country == "BLR", ]

dfblr$Latitude <- as.numeric(dfblr$Latitude)
dfblr$Longitude <- as.numeric(dfblr$Longitude)

 #summary(dfblr$Longitude)
 #summary(dfblr$Latitude)

mapoutline <- get_map(location = c(left = 23.00, # lon min
                                   bottom = 51.00, # lat min
                                   right = 32.75, # lon max
                                   top = 56.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfblr <- dfblr[dfblr$Event.Mode == "arrest", ]

dfblr$Event_count <- 1

df01 <- ddply(dfblr, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Belarus, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

3.2. Belarus: illegal drugs

Display code
dfblr$drugs <- ifelse(str_detect(dfblr$Contexts, "illegal_drugs") == T, 1, 0)

dfblr <- dfblr[dfblr$drugs == 1, ]

dfblr$Event_count <- 1

df01 <- ddply(dfblr, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfblr$Longitude <- as.numeric(dfblr$Longitude)
dfblr$Latitude <- as.numeric(dfblr$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Belarus, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 4. Maps: Georgia

4.1. Georgia: arrests

Display code
dfgeo <- df[df$Country == "GEO", ]

dfgeo$Latitude <- as.numeric(dfgeo$Latitude)
dfgeo$Longitude <- as.numeric(dfgeo$Longitude)

# summary(dfgeo$Longitude)
# summary(dfgeo$Latitude)


mapoutline <- get_map(location = c(left = 40.00, # lon min
                                   bottom = 41.00, # lat min
                                   right = 46.50, # lon max
                                   top = 43.50), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfgeo <- dfgeo[dfgeo$Event.Mode == "arrest", ]

dfgeo$Event_count <- 1

df01 <- ddply(dfgeo, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Georgia, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

4.2. Georgia: illegal drugs

Display code
dfgeo$drugs <- ifelse(str_detect(dfgeo$Contexts, "illegal_drugs") == T, 1, 0)

dfgeo <- dfgeo[dfgeo$drugs == 1, ]

dfgeo$Event_count <- 1

df01 <- ddply(dfgeo, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfgeo$Longitude <- as.numeric(dfgeo$Longitude)
dfgeo$Latitude <- as.numeric(dfgeo$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Georgia, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 5. Maps: Hungary

5.1. Hungary: arrests

Display code
dfhun <- df[df$Country == "HUN", ]

dfhun$Latitude <- as.numeric(dfhun$Latitude)
dfhun$Longitude <- as.numeric(dfhun$Longitude)

# summary(dfhun$Longitude)
# summary(dfhun$Latitude)

mapoutline <- get_map(location = c(left = 15.50, # lon min
                                   bottom = 45.55, # lat min
                                   right = 22.50, # lon max
                                   top = 49.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfhun <- dfhun[dfhun$Event.Mode == "arrest", ]

dfhun$Event_count <- 1

df01 <- ddply(dfhun, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Hungary, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

5.2. Hungary: illegal drugs

Display code
dfhun$drugs <- ifelse(str_detect(dfhun$Contexts, "illegal_drugs") == T, 1, 0)

dfhun <- dfhun[dfhun$drugs == 1, ]

dfhun$Event_count <- 1

df01 <- ddply(dfhun, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfhun$Longitude <- as.numeric(dfhun$Longitude)
dfhun$Latitude <- as.numeric(dfhun$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Hungary, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 6. Maps: Kazakhstan

6.1. Kazakhstan: arrests

Display code
dfkaz <- df[df$Country == "KAZ", ]

dfkaz$Latitude <- as.numeric(dfkaz$Latitude)
dfkaz$Longitude <- as.numeric(dfkaz$Longitude)

# summary(dfkaz$Longitude)
# summary(dfkaz$Latitude)

mapoutline <- get_map(location = c(left = 47.00, # lon min
                                   bottom = 40.00, # lat min
                                   right = 85.350, # lon max
                                   top = 55.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfkaz <- dfkaz[dfkaz$Event.Mode == "arrest", ]

dfkaz$Event_count <- 1

df01 <- ddply(dfkaz, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Kazakhstan, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

6.2. Kazakhstan: illegal drugs

Display code
dfkaz$drugs <- ifelse(str_detect(dfkaz$Contexts, "illegal_drugs") == T, 1, 0)

dfkaz <- dfkaz[dfkaz$drugs == 1, ]

dfkaz$Event_count <- 1

df01 <- ddply(dfkaz, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfkaz$Longitude <- as.numeric(dfkaz$Longitude)
dfkaz$Latitude <- as.numeric(dfkaz$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Kazakhstan, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 7. Maps: Kyrgyzstan

7.1. Kyrgyzstan: arrests

Display code
dfkgz <- df[df$Country == "KGZ", ]

dfkgz$Latitude <- as.numeric(dfkgz$Latitude)
dfkgz$Longitude <- as.numeric(dfkgz$Longitude)

# summary(dfkgz$Longitude)
# summary(dfkgz$Latitude)

mapoutline <- get_map(location = c(left = 69.00, # lon min
                                   bottom = 39.00, # lat min
                                   right = 79.50, # lon max
                                   top = 44.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfkgz <- dfkgz[dfkgz$Event.Mode == "arrest", ]

dfkgz$Event_count <- 1

df01 <- ddply(dfkgz, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Kyrgyzstan, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

7.2. Kyrgyzstan: illegal drugs

Display code
dfkgz$drugs <- ifelse(str_detect(dfkgz$Contexts, "illegal_drugs") == T, 1, 0)

dfkgz <- dfkgz[dfkgz$drugs == 1, ]

dfkgz$Event_count <- 1

df01 <- ddply(dfkgz, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfkgz$Longitude <- as.numeric(dfkgz$Longitude)
dfkgz$Latitude <- as.numeric(dfkgz$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Kyrgyzstan, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 8. Maps: Moldova

8.1. Moldova: arrests

Display code
dfmda <- df[df$Country == "MDA", ]

dfmda$Latitude <- as.numeric(dfmda$Latitude)
dfmda$Longitude <- as.numeric(dfmda$Longitude)

# summary(dfmda$Longitude)
# summary(dfmda$Latitude)

mapoutline <- get_map(location = c(left = 26.00, # lon min
                                   bottom = 45.00, # lat min
                                   right = 31.00, # lon max
                                   top = 49.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfmda <- dfmda[dfmda$Event.Mode == "arrest", ]

dfmda$Event_count <- 1

df01 <- ddply(dfmda, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Moldova, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

8.2. Moldova: illegal drugs

Display code
dfmda$drugs <- ifelse(str_detect(dfmda$Contexts, "illegal_drugs") == T, 1, 0)

dfmda <- dfmda[dfmda$drugs == 1, ]

dfmda$Event_count <- 1

df01 <- ddply(dfmda, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfmda$Longitude <- as.numeric(dfmda$Longitude)
dfmda$Latitude <- as.numeric(dfmda$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Moldova, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 9. Maps: Poland

9.1. Poland: arrests

Display code
dfpol <- df[df$Country == "POL", ]

dfpol$Latitude <- as.numeric(dfpol$Latitude)
dfpol$Longitude <- as.numeric(dfpol$Longitude)

# summary(dfpol$Longitude)
# summary(dfpol$Latitude)

mapoutline <- get_map(location = c(left = 13.50, # lon min
                                   bottom = 48.50, # lat min
                                   right = 24.75, # lon max
                                   top = 55.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfpol <- dfpol[dfpol$Event.Mode == "arrest", ]

dfpol$Event_count <- 1

df01 <- ddply(dfpol, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Poland, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

9.2. Poland: illegal drugs

Display code
dfpol$drugs <- ifelse(str_detect(dfpol$Contexts, "illegal_drugs") == T, 1, 0)

dfpol <- dfpol[dfpol$drugs == 1, ]

dfpol$Event_count <- 1

df01 <- ddply(dfpol, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfpol$Longitude <- as.numeric(dfpol$Longitude)
dfpol$Latitude <- as.numeric(dfpol$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Poland, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 10. Maps: Romania

10.1. Romania: arrests

Display code
dfrou <- df[df$Country == "ROU", ]

dfrou$Latitude <- as.numeric(dfrou$Latitude)
dfrou$Longitude <- as.numeric(dfrou$Longitude)

# summary(dfrou$Longitude)
# summary(dfrou$Latitude)

mapoutline <- get_map(location = c(left = 20.00, # lon min
                                   bottom = 43.00, # lat min
                                   right = 31.00, # lon max
                                   top = 49.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfrou <- dfrou[dfrou$Event.Mode == "arrest", ]

dfrou$Event_count <- 1

df01 <- ddply(dfrou, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Romania, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

10.2. Romania: illegal drugs

Display code
dfrou$drugs <- ifelse(str_detect(dfrou$Contexts, "illegal_drugs") == T, 1, 0)

dfrou <- dfrou[dfrou$drugs == 1, ]

dfrou$Event_count <- 1

df01 <- ddply(dfrou, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfrou$Longitude <- as.numeric(dfrou$Longitude)
dfrou$Latitude <- as.numeric(dfrou$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Romania, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 11. Maps: Russia

11.1. Russia: arrests

Display code
dfrus <- df[df$Country == "RUS", ]

dfrus$Latitude <- as.numeric(dfrus$Latitude)
dfrus$Longitude <- as.numeric(dfrus$Longitude)

# summary(dfrus$Longitude)
# summary(dfrus$Latitude)

mapoutline <- get_map(location = c(left = 20.00, # lon min
                                   bottom = 42.00, # lat min
                                   right = 160.00, # lon max
                                   top = 78.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")

# ggmap(mapoutline)
Display code
dfrus <- dfrus[dfrus$Event.Mode == "arrest", ]

dfrus$Event_count <- 1

df01 <- ddply(dfrus, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Russia, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

11.2. Russia: illegal drugs

Display code
dfrus$drugs <- ifelse(str_detect(dfrus$Contexts, "illegal_drugs") == T, 1, 0)

dfrus <- dfrus[dfrus$drugs == 1, ]

dfrus$Event_count <- 1

df01 <- ddply(dfrus, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfrus$Longitude <- as.numeric(dfrus$Longitude)
dfrus$Latitude <- as.numeric(dfrus$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Russia, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 12. Maps: Slovakia

12.1. Slovakia: arrests

Display code
dfsvk <- df[df$Country == "SVK", ]

dfsvk$Latitude <- as.numeric(dfsvk$Latitude)
dfsvk$Longitude <- as.numeric(dfsvk$Longitude)

# summary(dfsvk$Longitude)
# summary(dfsvk$Latitude)

mapoutline <- get_map(location = c(left = 16.00, # lon min
                                   bottom = 47.00, # lat min
                                   right = 23.00, # lon max
                                   top = 51.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfsvk <- dfsvk[dfsvk$Event.Mode == "arrest", ]

dfsvk$Event_count <- 1

df01 <- ddply(dfsvk, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Slovakia, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

12.2. Slovakia: illegal drugs

Display code
dfsvk$drugs <- ifelse(str_detect(dfsvk$Contexts, "illegal_drugs") == T, 1, 0)

dfsvk <- dfsvk[dfsvk$drugs == 1, ]

dfsvk$Event_count <- 1

df01 <- ddply(dfsvk, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfsvk$Longitude <- as.numeric(dfsvk$Longitude)
dfsvk$Latitude <- as.numeric(dfsvk$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Slovakia, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

Section 13. Maps: Ukraine

13.1. Ukraine: arrests

Display code
dfukr <- df[df$Country == "UKR", ]

dfukr$Latitude <- as.numeric(dfukr$Latitude)
dfukr$Longitude <- as.numeric(dfukr$Longitude)

# summary(dfukr$Longitude)
# summary(dfukr$Latitude)

mapoutline <- get_map(location = c(left = 21.00, # lon min
                                   bottom = 43.00, # lat min
                                   right = 41.00, # lon max
                                   top = 54.00), # lat max
                      maptype = "outdoors", 
                      source = "stadia",
                      color="bw")


# ggmap(mapoutline)
Display code
dfukr <- dfukr[dfukr$Event.Mode == "arrest", ]

dfukr$Event_count <- 1

df01 <- ddply(dfukr, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event mode tagged as arrests in Ukraine, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

13.2. Ukraine: illegal drugs

Display code
dfukr$drugs <- ifelse(str_detect(dfukr$Contexts, "illegal_drugs") == T, 1, 0)

dfukr <- dfukr[dfukr$drugs == 1, ]

dfukr$Event_count <- 1

df01 <- ddply(dfukr, 
            .(Latitude, Longitude), 
             summarize, 
             Event_count = sum(Event_count))

dfukr$Longitude <- as.numeric(dfukr$Longitude)
dfukr$Latitude <- as.numeric(dfukr$Latitude)

## Fill up the map with our data:
map01 <- print(ggmap(mapoutline) + 
                 geom_point(data = df01,
                            aes(x = Longitude, 
                                y = Latitude,
                                size = Event_count), 
                            alpha = 0.5, 
                            colour="black")+
                 ggtitle("Event contexts tagged as illegal_drugs in Ukraine, 2020 - 2023"))+
  theme_bw()+
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())