From 270b040bb687253758e60f68683f40a99eec7145 Mon Sep 17 00:00:00 2001 From: master4_cs22 Date: Tue, 20 Dec 2016 21:33:08 +0100 Subject: [PATCH] Defining [FilterMultiRow] function to add in hackmaggedon parser --- ISO27001effectiveness/R/Hackmageddon_Parser.R | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/ISO27001effectiveness/R/Hackmageddon_Parser.R b/ISO27001effectiveness/R/Hackmageddon_Parser.R index c407e7b..c0a3bd8 100644 --- a/ISO27001effectiveness/R/Hackmageddon_Parser.R +++ b/ISO27001effectiveness/R/Hackmageddon_Parser.R @@ -66,9 +66,28 @@ ProcessHMRaw <- function(dataset.raw, dateOffset){ dataset } -FilterMultiCountry <- function(dataset) { - multi <- dataset[grepl(" ",Attacks$Country),] - #TODO +FilterMultiCountry <- function(dataset.pre) { + multi <- dataset.pre[grepl(" ",dataset.pre$Country),] + + dataset <- dataset.pre[!grepl(" ",dataset.pre$Country),] + + for (i in 1:nrow(multi)) { + crow <- multi[i,] + + country_s <- strsplit(toString(crow$Country), " ") + + for (j in 1:length(country_s)) { + Date <- crow[1] + Attack <- crow[2] + Target <- crow[3] + Country <- country_s[[1]][j] + new.row <- data.frame(Date, Attack, Target, Country) + print(new.row) + dataset <- rbind(dataset, new.row) + } + } + + dataset } #' Parse every excel file into a folder -- libgit2 0.22.2