Commit ec03006f4cf692cb0759de4f1398de0fd89bdd47

Authored by Miguel Tuñón
1 parent 7b836dff

Branch to test graphs implementations

ISO27001effectiveness/R/Hackmageddon_Parser.R
... ... @@ -74,6 +74,10 @@ ProcessHMRaw <- function(dataset.raw, dateOffset){
74 74 dataset$Country <- gsub("UAE","AE",dataset$Country)
75 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 82 #Format properly the date
79 83 dataset$Date <- as.POSIXct(dataset$Date*86400, tz = "GMT", origin = dateOffset)
... ...
ISO27001effectiveness/R/ISOSurvey_Parser.R
... ... @@ -96,10 +96,12 @@ ProccesISOSurveyByCountryRaw &lt;- function(dataset.raw, years){
96 96  
97 97  
98 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 101 dataset <- merge(x = dataset, y = CountryNames, by = "Country", all.x = TRUE)
102 102  
  103 + dataset <- dataset[!is.na(dataset$Continent),]
  104 +
103 105 dataset
104 106 }
105 107  
... ...
ISO27001effectiveness/R/ReportGraphs.R
... ... @@ -7,12 +7,15 @@
7 7 #' @export
8 8 GetReportGraphs <- function(Cert_PerCountry,Attacks) {
9 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 11 x = reorder(country_short,X2012),
12 12 y = X2012,
13 13 xlab = "Country",
14 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 19 attacks2k12 <- Attacks[Attacks$Date < "2013-01-01" & Attacks$Date >= "2012-01-01",]
17 20 frameAttacks2k12 <- as.data.frame(table(attacks2k12$Country))
18 21 colnames(frameAttacks2k12) <- c("Country","Attacks")
... ... @@ -21,7 +24,9 @@ GetReportGraphs &lt;- function(Cert_PerCountry,Attacks) {
21 24 y = Attacks,
22 25 xlab = "Country",
23 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 31 Attacks2012ByMonth <- mutate(attacks2k12, month = format(attacks2k12$Date, "%m")) %>% group_by(month)
27 32 Attack2012FreqByMonth <- as.data.frame(table(Attacks2012ByMonth$month))
... ... @@ -35,12 +40,14 @@ GetReportGraphs &lt;- function(Cert_PerCountry,Attacks) {
35 40 xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12)
36 41  
37 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 44 x = reorder(country_short,X2013),
40 45 y = X2013,
41 46 xlab = "Country",
42 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 51 attacks2k13 <- Attacks[Attacks$Date < "2014-01-01" & Attacks$Date >= "2013-01-01",]
45 52 frameAttacks2k13 <- as.data.frame(table(attacks2k13$Country))
46 53 colnames(frameAttacks2k13) <- c("Country","Attacks")
... ... @@ -49,7 +56,9 @@ GetReportGraphs &lt;- function(Cert_PerCountry,Attacks) {
49 56 y = Attacks,
50 57 xlab = "Country",
51 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 63 Attacks2013ByMonth <- mutate(attacks2k13, month = format(attacks2k13$Date, "%m")) %>% group_by(month)
55 64 Attack2013FreqByMonth <- as.data.frame(table(Attacks2013ByMonth$month))
... ... @@ -63,12 +72,14 @@ GetReportGraphs &lt;- function(Cert_PerCountry,Attacks) {
63 72 xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12)
64 73  
65 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 76 x = reorder(country_short,X2014),
68 77 y = X2014,
69 78 xlab = "Country",
70 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 83 attacks2k14 <- Attacks[Attacks$Date < "2015-01-01" & Attacks$Date >= "2014-01-01",]
73 84 frameAttacks2k14 <- as.data.frame(table(attacks2k14$Country))
74 85 colnames(frameAttacks2k14) <- c("Country","Attacks")
... ... @@ -77,7 +88,9 @@ GetReportGraphs &lt;- function(Cert_PerCountry,Attacks) {
77 88 y = Attacks,
78 89 xlab = "Country",
79 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 95 Attacks2014ByMonth <- mutate(attacks2k14, month = format(attacks2k14$Date, "%m")) %>% group_by(month)
83 96 Attack2014FreqByMonth <- as.data.frame(table(Attacks2014ByMonth$month))
... ... @@ -91,12 +104,14 @@ GetReportGraphs &lt;- function(Cert_PerCountry,Attacks) {
91 104 xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12)
92 105  
93 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 108 x = reorder(country_short,X2015),
96 109 y = X2015,
97 110 xlab = "Country",
98 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 115 attacks2k15 <- Attacks[Attacks$Date < "2016-01-01" & Attacks$Date >= "2015-01-01",]
101 116 frameAttacks2k15 <- as.data.frame(table(attacks2k15$Country))
102 117 colnames(frameAttacks2k15) <- c("Country","Attacks")
... ... @@ -105,7 +120,9 @@ GetReportGraphs &lt;- function(Cert_PerCountry,Attacks) {
105 120 y = Attacks,
106 121 xlab = "Country",
107 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 127 Attacks2015ByMonth <- mutate(attacks2k15, month = format(attacks2k15$Date, "%m")) %>% group_by(month)
111 128 Attack2015FreqByMonth <- as.data.frame(table(Attacks2015ByMonth$month))
... ...
ISO27001effectiveness/Report.Rmd
1 1 ---
2 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 9 knitr::opts_chunk$set(echo = TRUE)
8 10 library(ISO27001effectiveness)
9 11 library(xlsx)
... ...
ISO27001effectiveness/Report.html
... ... @@ -120,6 +120,32 @@ $(document).ready(function () {
120 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(&quot;./Main.R&quot;)</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 149 <div id="abstract" class="section level2">
124 150 <h2>Abstract</h2>
125 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>
... ...