Commit 270b040bb687253758e60f68683f40a99eec7145

Authored by master4_cs22
1 parent 9282ab31

Defining [FilterMultiRow] function to add in hackmaggedon parser

ISO27001effectiveness/R/Hackmageddon_Parser.R
@@ -66,9 +66,28 @@ ProcessHMRaw <- function(dataset.raw, dateOffset){ @@ -66,9 +66,28 @@ ProcessHMRaw <- function(dataset.raw, dateOffset){
66 dataset 66 dataset
67 } 67 }
68 68
69 -FilterMultiCountry <- function(dataset) {  
70 - multi <- dataset[grepl(" ",Attacks$Country),]  
71 - #TODO 69 +FilterMultiCountry <- function(dataset.pre) {
  70 + multi <- dataset.pre[grepl(" ",dataset.pre$Country),]
  71 +
  72 + dataset <- dataset.pre[!grepl(" ",dataset.pre$Country),]
  73 +
  74 + for (i in 1:nrow(multi)) {
  75 + crow <- multi[i,]
  76 +
  77 + country_s <- strsplit(toString(crow$Country), " ")
  78 +
  79 + for (j in 1:length(country_s)) {
  80 + Date <- crow[1]
  81 + Attack <- crow[2]
  82 + Target <- crow[3]
  83 + Country <- country_s[[1]][j]
  84 + new.row <- data.frame(Date, Attack, Target, Country)
  85 + print(new.row)
  86 + dataset <- rbind(dataset, new.row)
  87 + }
  88 + }
  89 +
  90 + dataset
72 } 91 }
73 92
74 #' Parse every excel file into a folder 93 #' Parse every excel file into a folder