協作閣

開源協作部落格

Cyber Tracker Sponsors

car

Freya / 2019-04-25 /


library(dplyr)
library(lubridate)
library(ggplot2)
library(ggthemes)
library(dplyr)
library(ggplot2)
library(readr)
library(tidyr)
library(DT)
#install.packages('anytime')
library(anytime)
#install.packages('gghighlight')
library(gghighlight)
#install.packages('sf')
library(sf)
#install.packages('rnaturalearth')
library(rnaturalearth)
#install.packages('leaflet')
library(leaflet)

Cyber Operations Tracker https://www.cfr.org/interactive/cyber-operations CFR database (Council of Foreign Relations)

Cyber = read.csv("cyber-operations-incidents.csv", stringsAsFactors = F)

World Map Data

world <- st_as_sf(countries110) %>% 
  filter(sovereignt!="Antarctica") %>% 
  filter(type != "Dependency")  %>% 
  filter(type != "Disputed") %>% 
  filter(type != "Indeterminate")
Lean_database <- Cyber %>% 
  filter(Sponsor!="") %>% 
  filter(Date!="") %>% 
  select(Sponsor, Victims, Type, Title, Description, Date) %>% 
  arrange(Sponsor,Date)

UnknownSponsor<- Cyber %>% 
  filter(Sponsor=="") %>% 
  select(Victims, Type, Description, Title, Date)

SingleSponsor <- Cyber %>% 
  select(Sponsor, Type, Date) %>%
  filter (!Sponsor %in% c(grep(",", Cyber$Sponsor, value=TRUE)), 
          Sponsor!="",
          Type!="") %>% 
  mutate(Year = year(anydate(Date))) %>% 
  mutate(Sponsor=case_when(
    Sponsor=="Iran (Islamic Republic of)" ~ "Iran",
    Sponsor=="Korea (Democratic People's Republic of)" ~ "North Korea",
    Sponsor=="Korea (Republic of)" ~ "South Korea",
    Sponsor=="Russian Federation" ~ "Russia",
    Sponsor=="United States" ~ "United States of America",
    TRUE ~ Sponsor)) %>% 
  select(-Date) %>% 
  arrange(Sponsor, Type, Year)

Tidy_by_year <- SingleSponsor %>% 
  group_by(Sponsor, Year) %>% 
  summarize(Cases=n())

Tidy_total <- SingleSponsor %>% 
  group_by(Sponsor) %>% 
  summarize(Cases=n()) %>% 
  mutate(Cases= case_when(
    Sponsor == "United States of America" ~ Cases+5,
    Sponsor == "Israel" ~ Cases + 3,
    Sponsor == "China" ~ Cases+1,
    Sponsor == "Russia" ~ Cases+1,
    Sponsor == "United Kingdom" ~ Cases+1,
    Sponsor == "Taiwan" ~ Cases+1,
    TRUE ~ Cases+0))

Geo_Cyber <- left_join(world, Tidy_total, by=c("admin"="Sponsor"))

Known Sponsors

datatable(Lean_database, 
          extensions = 'Buttons',  
                        options = list(dom = 'Bfrtip',
                                buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Global 2005-2018

#pallette
pal <- colorNumeric("Greens", domain=Geo_Cyber$Cases)

#popup note
popup_spend <- paste0("<strong>", Geo_Cyber$admin, 
                      "</strong><br /> Known Cyber Operations Since 2005: ", Geo_Cyber$Cases)

Geo_Cyber %>% 
  leaflet() %>%
  addTiles() %>%
  setView(0, 0, zoom = 2) %>% 
  addPolygons(data = Geo_Cyber, 
              fillColor = ~pal(Geo_Cyber$Cases), 
              fillOpacity = 0.5, 
              weight = 0.2, 
              smoothFactor = 0.2, 
              popup = ~popup_spend) %>% 
  addLegend(pal = pal, 
            values = Geo_Cyber$Cases, 
            na.label = "NA",
            bins= 6,
            position = "bottomright", 
            title = "Cyber Operations")

Multiple Sponsors

MultipleSponsors <- Cyber %>% 
  select(Sponsor, Type, Date) %>%
  filter(Sponsor %in% c(grep(",", Cyber$Sponsor, value=TRUE)))
MultipleSponsors
#>                         Sponsor              Type       Date
#> 1     China, Russian Federation         Espionage 2018-06-05
#> 2 United Kingdom, United States         Espionage 2014-11-24
#> 3         United States, Israel  Data destruction 2012-05-28
#> 4         United States, Israel         Espionage 2012-08-09
#> 5         Israel, United States          Sabotage 2010-07-22
#> 6         Taiwan, United States Denial of service 2007-10-23

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.