Commit ec03006f4cf692cb0759de4f1398de0fd89bdd47
1 parent
7b836dff
Branch to test graphs implementations
Showing
5 changed files
with
67 additions
and
16 deletions
ISO27001effectiveness/R/Hackmageddon_Parser.R
@@ -74,6 +74,10 @@ ProcessHMRaw <- function(dataset.raw, dateOffset){ | @@ -74,6 +74,10 @@ ProcessHMRaw <- function(dataset.raw, dateOffset){ | ||
74 | dataset$Country <- gsub("UAE","AE",dataset$Country) | 74 | dataset$Country <- gsub("UAE","AE",dataset$Country) |
75 | dataset$Country <- gsub("CB","KH",dataset$Country) | 75 | dataset$Country <- gsub("CB","KH",dataset$Country) |
76 | 76 | ||
77 | + CountryNames <- data.frame(countrycode::countrycode_data$country.name, countrycode::countrycode_data$iso2c, countrycode::countrycode_data$continent) | ||
78 | + CountryNames <- setNames(CountryNames, c("Country_large","Country", "Continent")) | ||
79 | + dataset <- merge(x = dataset, y = CountryNames, by = "Country", all.x = TRUE) | ||
80 | + dataset <- dataset[!is.na(dataset$Continent),] | ||
77 | 81 | ||
78 | #Format properly the date | 82 | #Format properly the date |
79 | dataset$Date <- as.POSIXct(dataset$Date*86400, tz = "GMT", origin = dateOffset) | 83 | dataset$Date <- as.POSIXct(dataset$Date*86400, tz = "GMT", origin = dateOffset) |
ISO27001effectiveness/R/ISOSurvey_Parser.R
@@ -96,10 +96,12 @@ ProccesISOSurveyByCountryRaw <- function(dataset.raw, years){ | @@ -96,10 +96,12 @@ ProccesISOSurveyByCountryRaw <- function(dataset.raw, years){ | ||
96 | 96 | ||
97 | 97 | ||
98 | #Translate country names to 2 letter code | 98 | #Translate country names to 2 letter code |
99 | - CountryNames <- data.frame(countrycode::countrycode_data$country.name, countrycode::countrycode_data$iso2c) | ||
100 | - CountryNames <- setNames(CountryNames, c("Country","country_short")) | 99 | + CountryNames <- data.frame(countrycode::countrycode_data$country.name, countrycode::countrycode_data$iso2c, countrycode::countrycode_data$continent) |
100 | + CountryNames <- setNames(CountryNames, c("Country","country_short", "Continent")) | ||
101 | dataset <- merge(x = dataset, y = CountryNames, by = "Country", all.x = TRUE) | 101 | dataset <- merge(x = dataset, y = CountryNames, by = "Country", all.x = TRUE) |
102 | 102 | ||
103 | + dataset <- dataset[!is.na(dataset$Continent),] | ||
104 | + | ||
103 | dataset | 105 | dataset |
104 | } | 106 | } |
105 | 107 |
ISO27001effectiveness/R/ReportGraphs.R
@@ -7,12 +7,15 @@ | @@ -7,12 +7,15 @@ | ||
7 | #' @export | 7 | #' @export |
8 | GetReportGraphs <- function(Cert_PerCountry,Attacks) { | 8 | GetReportGraphs <- function(Cert_PerCountry,Attacks) { |
9 | #2012 | 9 | #2012 |
10 | - graph1 <- ggplot2::qplot(main = "Countries with above average number of companies certified with ISO 27001 (2012)", | 10 | + graph1 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2012)", |
11 | x = reorder(country_short,X2012), | 11 | x = reorder(country_short,X2012), |
12 | y = X2012, | 12 | y = X2012, |
13 | xlab = "Country", | 13 | xlab = "Country", |
14 | ylab = "Number of certifications", | 14 | ylab = "Number of certifications", |
15 | - data = Cert_PerCountry[Cert_PerCountry$X2012 > mean(Cert_PerCountry$X2012),]) | 15 | + data = Cert_PerCountry[Cert_PerCountry$X2012 > mean(Cert_PerCountry$X2012),], |
16 | + geom = "col", | ||
17 | + fill = Continent) | ||
18 | + | ||
16 | attacks2k12 <- Attacks[Attacks$Date < "2013-01-01" & Attacks$Date >= "2012-01-01",] | 19 | attacks2k12 <- Attacks[Attacks$Date < "2013-01-01" & Attacks$Date >= "2012-01-01",] |
17 | frameAttacks2k12 <- as.data.frame(table(attacks2k12$Country)) | 20 | frameAttacks2k12 <- as.data.frame(table(attacks2k12$Country)) |
18 | colnames(frameAttacks2k12) <- c("Country","Attacks") | 21 | colnames(frameAttacks2k12) <- c("Country","Attacks") |
@@ -21,7 +24,9 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | @@ -21,7 +24,9 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | ||
21 | y = Attacks, | 24 | y = Attacks, |
22 | xlab = "Country", | 25 | xlab = "Country", |
23 | ylab = "Number of attacks", | 26 | ylab = "Number of attacks", |
24 | - data = frameAttacks2k12[frameAttacks2k12$Attacks > mean(frameAttacks2k12$Attacks),]) | 27 | + data = frameAttacks2k12[frameAttacks2k12$Attacks > mean(frameAttacks2k12$Attacks),], |
28 | + geom = "col", | ||
29 | + fill = Continent) | ||
25 | 30 | ||
26 | Attacks2012ByMonth <- mutate(attacks2k12, month = format(attacks2k12$Date, "%m")) %>% group_by(month) | 31 | Attacks2012ByMonth <- mutate(attacks2k12, month = format(attacks2k12$Date, "%m")) %>% group_by(month) |
27 | Attack2012FreqByMonth <- as.data.frame(table(Attacks2012ByMonth$month)) | 32 | Attack2012FreqByMonth <- as.data.frame(table(Attacks2012ByMonth$month)) |
@@ -35,12 +40,14 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | @@ -35,12 +40,14 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | ||
35 | xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) | 40 | xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) |
36 | 41 | ||
37 | #2013 | 42 | #2013 |
38 | - graph4 <- ggplot2::qplot(main = "Countries with above average number of companies certified with ISO 27001 (2013)", | 43 | + graph4 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2013)", |
39 | x = reorder(country_short,X2013), | 44 | x = reorder(country_short,X2013), |
40 | y = X2013, | 45 | y = X2013, |
41 | xlab = "Country", | 46 | xlab = "Country", |
42 | ylab = "Number of certifications", | 47 | ylab = "Number of certifications", |
43 | - data = Cert_PerCountry[Cert_PerCountry$X2013 > mean(Cert_PerCountry$X2013),]) | 48 | + data = Cert_PerCountry[Cert_PerCountry$X2013 > mean(Cert_PerCountry$X2013),] |
49 | + , geom = "col", | ||
50 | + fill = Continent) | ||
44 | attacks2k13 <- Attacks[Attacks$Date < "2014-01-01" & Attacks$Date >= "2013-01-01",] | 51 | attacks2k13 <- Attacks[Attacks$Date < "2014-01-01" & Attacks$Date >= "2013-01-01",] |
45 | frameAttacks2k13 <- as.data.frame(table(attacks2k13$Country)) | 52 | frameAttacks2k13 <- as.data.frame(table(attacks2k13$Country)) |
46 | colnames(frameAttacks2k13) <- c("Country","Attacks") | 53 | colnames(frameAttacks2k13) <- c("Country","Attacks") |
@@ -49,7 +56,9 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | @@ -49,7 +56,9 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | ||
49 | y = Attacks, | 56 | y = Attacks, |
50 | xlab = "Country", | 57 | xlab = "Country", |
51 | ylab = "Number of attacks", | 58 | ylab = "Number of attacks", |
52 | - data = frameAttacks2k13[frameAttacks2k13$Attacks > mean(frameAttacks2k13$Attacks),]) | 59 | + data = frameAttacks2k13[frameAttacks2k13$Attacks > mean(frameAttacks2k13$Attacks),] |
60 | + , geom = "col", | ||
61 | + fill = Continent) | ||
53 | 62 | ||
54 | Attacks2013ByMonth <- mutate(attacks2k13, month = format(attacks2k13$Date, "%m")) %>% group_by(month) | 63 | Attacks2013ByMonth <- mutate(attacks2k13, month = format(attacks2k13$Date, "%m")) %>% group_by(month) |
55 | Attack2013FreqByMonth <- as.data.frame(table(Attacks2013ByMonth$month)) | 64 | Attack2013FreqByMonth <- as.data.frame(table(Attacks2013ByMonth$month)) |
@@ -63,12 +72,14 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | @@ -63,12 +72,14 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | ||
63 | xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) | 72 | xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) |
64 | 73 | ||
65 | #2014 | 74 | #2014 |
66 | - graph7 <- ggplot2::qplot(main = "Countries with above average number of companies certified with ISO 27001 (2014)", | 75 | + graph7 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2014)", |
67 | x = reorder(country_short,X2014), | 76 | x = reorder(country_short,X2014), |
68 | y = X2014, | 77 | y = X2014, |
69 | xlab = "Country", | 78 | xlab = "Country", |
70 | ylab = "Number of certifications", | 79 | ylab = "Number of certifications", |
71 | - data = Cert_PerCountry[Cert_PerCountry$X2014 > mean(Cert_PerCountry$X2014),]) | 80 | + data = Cert_PerCountry[Cert_PerCountry$X2014 > mean(Cert_PerCountry$X2014),] |
81 | + , geom = "col", | ||
82 | + fill = Continent) | ||
72 | attacks2k14 <- Attacks[Attacks$Date < "2015-01-01" & Attacks$Date >= "2014-01-01",] | 83 | attacks2k14 <- Attacks[Attacks$Date < "2015-01-01" & Attacks$Date >= "2014-01-01",] |
73 | frameAttacks2k14 <- as.data.frame(table(attacks2k14$Country)) | 84 | frameAttacks2k14 <- as.data.frame(table(attacks2k14$Country)) |
74 | colnames(frameAttacks2k14) <- c("Country","Attacks") | 85 | colnames(frameAttacks2k14) <- c("Country","Attacks") |
@@ -77,7 +88,9 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | @@ -77,7 +88,9 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | ||
77 | y = Attacks, | 88 | y = Attacks, |
78 | xlab = "Country", | 89 | xlab = "Country", |
79 | ylab = "Number of attacks", | 90 | ylab = "Number of attacks", |
80 | - data = frameAttacks2k14[frameAttacks2k14$Attacks > mean(frameAttacks2k14$Attacks),]) | 91 | + data = frameAttacks2k14[frameAttacks2k14$Attacks > mean(frameAttacks2k14$Attacks),] |
92 | + , geom = "col", | ||
93 | + fill = Continent) | ||
81 | 94 | ||
82 | Attacks2014ByMonth <- mutate(attacks2k14, month = format(attacks2k14$Date, "%m")) %>% group_by(month) | 95 | Attacks2014ByMonth <- mutate(attacks2k14, month = format(attacks2k14$Date, "%m")) %>% group_by(month) |
83 | Attack2014FreqByMonth <- as.data.frame(table(Attacks2014ByMonth$month)) | 96 | Attack2014FreqByMonth <- as.data.frame(table(Attacks2014ByMonth$month)) |
@@ -91,12 +104,14 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | @@ -91,12 +104,14 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | ||
91 | xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) | 104 | xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) |
92 | 105 | ||
93 | #2015 | 106 | #2015 |
94 | - graph10 <- ggplot2::qplot(main = "Countries with above average number of companies certified with ISO 27001 (2015)", | 107 | + graph10 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2015)", |
95 | x = reorder(country_short,X2015), | 108 | x = reorder(country_short,X2015), |
96 | y = X2015, | 109 | y = X2015, |
97 | xlab = "Country", | 110 | xlab = "Country", |
98 | ylab = "Number of certifications", | 111 | ylab = "Number of certifications", |
99 | - data = Cert_PerCountry[Cert_PerCountry$X2015 > mean(Cert_PerCountry$X2015),]) | 112 | + data = Cert_PerCountry[Cert_PerCountry$X2015 > mean(Cert_PerCountry$X2015),] |
113 | + , geom = "col", | ||
114 | + fill = Continent) | ||
100 | attacks2k15 <- Attacks[Attacks$Date < "2016-01-01" & Attacks$Date >= "2015-01-01",] | 115 | attacks2k15 <- Attacks[Attacks$Date < "2016-01-01" & Attacks$Date >= "2015-01-01",] |
101 | frameAttacks2k15 <- as.data.frame(table(attacks2k15$Country)) | 116 | frameAttacks2k15 <- as.data.frame(table(attacks2k15$Country)) |
102 | colnames(frameAttacks2k15) <- c("Country","Attacks") | 117 | colnames(frameAttacks2k15) <- c("Country","Attacks") |
@@ -105,7 +120,9 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | @@ -105,7 +120,9 @@ GetReportGraphs <- function(Cert_PerCountry,Attacks) { | ||
105 | y = Attacks, | 120 | y = Attacks, |
106 | xlab = "Country", | 121 | xlab = "Country", |
107 | ylab = "Number of attacks", | 122 | ylab = "Number of attacks", |
108 | - data = frameAttacks2k15[frameAttacks2k15$Attacks > mean(frameAttacks2k15$Attacks),]) | 123 | + data = frameAttacks2k15[frameAttacks2k15$Attacks > mean(frameAttacks2k15$Attacks),] |
124 | + , geom = "col", | ||
125 | + fill = Continent) | ||
109 | 126 | ||
110 | Attacks2015ByMonth <- mutate(attacks2k15, month = format(attacks2k15$Date, "%m")) %>% group_by(month) | 127 | Attacks2015ByMonth <- mutate(attacks2k15, month = format(attacks2k15$Date, "%m")) %>% group_by(month) |
111 | Attack2015FreqByMonth <- as.data.frame(table(Attacks2015ByMonth$month)) | 128 | Attack2015FreqByMonth <- as.data.frame(table(Attacks2015ByMonth$month)) |
ISO27001effectiveness/Report.Rmd
1 | --- | 1 | --- |
2 | title: "ISO 27001 Effectiveness" | 2 | title: "ISO 27001 Effectiveness" |
3 | -output: html_document | 3 | +output: |
4 | + html_document: default | ||
5 | + pdf_document: default | ||
4 | --- | 6 | --- |
5 | 7 | ||
6 | -```{r setup, include=FALSE} | 8 | +```{r setup, include=TRUE} |
7 | knitr::opts_chunk$set(echo = TRUE) | 9 | knitr::opts_chunk$set(echo = TRUE) |
8 | library(ISO27001effectiveness) | 10 | library(ISO27001effectiveness) |
9 | library(xlsx) | 11 | library(xlsx) |
ISO27001effectiveness/Report.html
@@ -120,6 +120,32 @@ $(document).ready(function () { | @@ -120,6 +120,32 @@ $(document).ready(function () { | ||
120 | </div> | 120 | </div> |
121 | 121 | ||
122 | 122 | ||
123 | +<pre class="r"><code>knitr::opts_chunk$set(echo = TRUE) | ||
124 | +library(ISO27001effectiveness) | ||
125 | +library(xlsx)</code></pre> | ||
126 | +<pre><code>## Loading required package: rJava</code></pre> | ||
127 | +<pre><code>## Loading required package: xlsxjars</code></pre> | ||
128 | +<pre class="r"><code>library(ggplot2) | ||
129 | +library(dplyr)</code></pre> | ||
130 | +<pre><code>## | ||
131 | +## Attaching package: 'dplyr'</code></pre> | ||
132 | +<pre><code>## The following objects are masked from 'package:stats': | ||
133 | +## | ||
134 | +## filter, lag</code></pre> | ||
135 | +<pre><code>## The following objects are masked from 'package:base': | ||
136 | +## | ||
137 | +## intersect, setdiff, setequal, union</code></pre> | ||
138 | +<pre class="r"><code>library(countrycode) | ||
139 | + | ||
140 | +source("./Main.R")</code></pre> | ||
141 | +<pre><code>## Scale for 'x' is already present. Adding another scale for 'x', which | ||
142 | +## will replace the existing scale.</code></pre> | ||
143 | +<pre><code>## Scale for 'x' is already present. Adding another scale for 'x', which | ||
144 | +## will replace the existing scale. | ||
145 | +## Scale for 'x' is already present. Adding another scale for 'x', which | ||
146 | +## will replace the existing scale. | ||
147 | +## Scale for 'x' is already present. Adding another scale for 'x', which | ||
148 | +## will replace the existing scale.</code></pre> | ||
123 | <div id="abstract" class="section level2"> | 149 | <div id="abstract" class="section level2"> |
124 | <h2>Abstract</h2> | 150 | <h2>Abstract</h2> |
125 | <p>La creciente preocupación de muchas empresas con infraestructura IT crítica frente a ciberataques ha llevado a algunas de ellas a tomar medidas de seguridad como la creación de departamentos de Seguridad de la Información, llevar a cabo auditorías de seguridad y obtener certificaciones de seguridad entre otras.</p> | 151 | <p>La creciente preocupación de muchas empresas con infraestructura IT crítica frente a ciberataques ha llevado a algunas de ellas a tomar medidas de seguridad como la creación de departamentos de Seguridad de la Información, llevar a cabo auditorías de seguridad y obtener certificaciones de seguridad entre otras.</p> |