#---------------------------------------------------------------- #-------------------------General evolution---------------------- #---------------------------------------------------------------- GetAttacksEvolution <- function(Attacks){ attacks.evol <- mutate(Attacks, Year = format(Attacks$Date, "%Y")) %>% group_by(Year) attacks.evol <- as.data.frame(table(attacks.evol$Year)) colnames(attacks.evol) <- c("Year","Attacks") graph1 <- ggplot2::qplot(main = "Cyberattacks evolution", x = attacks.evol$Year, y = attacks.evol$Attacks, group = 1, xlab = "Years", ylab = "Attacks", data = attacks.evol, geom = "line") + geom_point() + geom_label(aes(label=attacks.evol$Attacks), vjust=c(1.5, 0, 0, -0.5, -0.5), hjust=c(0.5, -0.5, 1.5, 0, 0))+ theme(plot.title = element_text(hjust = 0.5)) graph1 } GetCertsEvolution <- function(Certs){ Certs.evol <- data.frame(Year = c(2011, 2012, 2013, 2014, 2015), Certs = c(sum(Certs$X2011), sum(Certs$X2012), sum(Certs$X2013), sum(Certs$X2014), sum(Certs$X2015))) graph1 <- ggplot2::qplot(main = "ISO 27001 evolution", x = Certs.evol$Year, y = Certs.evol$Certs, group = 1, xlab = "Years", ylab = "Certifications", data = Certs.evol, geom = "line") + geom_point() + geom_label(aes(label=Certs.evol$Certs), vjust=c(0.2, -0.7, 0, 0, 0.5), hjust=c(-0.6, 1, 1.2, 1.2, 1.2))+ theme(plot.title = element_text(hjust = 0.5)) graph1 } GetAttacksMonthEvolution <- function(Attacks){ attacks.evol <- mutate(Attacks, Year = format(Attacks$Date, "%Y-%m")) %>% group_by(Year) attacks.evol <- as.data.frame(table(attacks.evol$Year)) colnames(attacks.evol) <- c("Year","Attacks") graph1 <- ggplot2::qplot(main = "Cyberattacks evolution", x = attacks.evol$Year, y = attacks.evol$Attacks, group = 1, xlab = "Months", ylab = "Attacks", data = attacks.evol, geom = "line") + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + geom_smooth(method = 'loess') + scale_x_discrete(labels = c("2012", "", "", "", "", "", "", "", "", "", "", "", "2013", "", "", "", "", "", "", "", "", "", "", "", "2014", "", "", "", "", "", "", "", "", "", "", "", "2015", "", "", "", "", "", "", "", "", "", "", "", "2016", "", "", "", "", "", "", "", "", "", "", "")) graph1 } #---------------------------------------------------------------- #-------------------------Attack type evolution------------------ #---------------------------------------------------------------- GetAttackTypePie <- function (Attacks){ attack.pie <- group_by(Attacks, Attack.standar) attack.pie <- as.data.frame(table(attack.pie$Attack.standar)) attack.pie <- setNames(attack.pie, c("Attack", "Count")) attack.pie <- attack.pie[attack.pie$Attack != "",] attack.pie <- attack.pie[attack.pie$Count > (sum(attack.pie$Count) * 0.01),] graph1 <- ggplot(data=attack.pie, aes(x=factor(1), y=Count, fill=Attack)) + geom_col(width = 1, color='black') + # geom_label(aes(label=paste( round(x = 100 - (sum(attack.pie$Count) / attack.pie$Count), digits = 2), "%")), # vjust=c(0), # hjust=c(0)) + coord_polar(theta="y") + scale_x_discrete(labels = c("")) + scale_y_discrete(labels = c("")) + theme(plot.title = element_text(hjust = 0.5), axis.title.x=element_blank(), axis.title.y=element_blank()) + ggtitle("Attacks pie") graph1 } GetAttackTypeEvolution <- function(Attacks){ Attacks.pre <- mutate(Attacks, Year = format(Attacks$Date, "%Y")) %>% group_by(Year, Attack.standar) Attacks.pre <- as.data.frame(table(Attacks.pre$Year, Attacks.pre$Attack.standar)) Attacks.pre <- setNames(Attacks.pre, c("Year", "Attack", "Count")) Attacks.pre <- Attacks.pre[Attacks.pre$Attack != "",] Attacks.pre <- plyr::arrange(Attacks.pre, Year, Attack) b <- as.character(sort(unique(Attacks.pre$Attack))) Attacks.desg <- data.frame(Year = sort(unique(Attacks.pre$Year))) for (i in 1:length(b)) { Attacks.desg <- cbind(Attacks.desg, Attacks.pre[Attacks.pre$Attack == b[i],3]) } Attacks.desg <- setNames(Attacks.desg, c("Year", gsub(" ", ".", b))) Attacks.desg <- select(Attacks.desg, Year, `Account.Hijacking`, `DDoS`, `Defacement`, `DNS`, `Injection`, `Malware`) graph1 <- ggplot(data = Attacks.desg, aes_string(x = colnames(Attacks.desg)[1])) graph1 <- graph1 + #geom_line(aes(y = Zero.day, group = 1, colour = "Zero.day")) + #geom_point(aes(y = Zero.day, group = 1, colour = "Zero.day")) + geom_line(aes(y = `Account.Hijacking`, group = 1, colour = "Account.Hijacking")) + geom_point(aes(y = `Account.Hijacking`, group = 1, colour = "Account.Hijacking")) + geom_line(aes(y = `DDoS`, group = 1, colour = "DDoS")) + geom_point(aes(y = `DDoS`, group = 1, colour = "DDoS")) + geom_line(aes(y = `Defacement`, group = 1, colour = "Defacement")) + geom_point(aes(y = `Defacement`, group = 1, colour = "Defacement")) + geom_line(aes(y = `DNS`, group = 1, colour = "DNS")) + geom_point(aes(y = `DNS`, group = 1, colour = "DNS")) + geom_line(aes(y = `Injection`, group = 1, colour = "Injection")) + geom_point(aes(y = `Injection`, group = 1, colour = "Injection")) + geom_line(aes(y = `Malware`, group = 1, colour = "Malware")) + geom_point(aes(y = `Malware`, group = 1, colour = "Malware")) + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Attack type evolution") + labs(colour = "Attack type") + xlab("Years") + ylab("Attacks") graph1 } GetAttackTypeTopEvolution <- function(Attacks){ Attacks.pre <- mutate(Attacks, Year = format(Attacks$Date, "%Y")) %>% group_by(Year, Attack.standar) Attacks.pre <- as.data.frame(table(Attacks.pre$Year, Attacks.pre$Attack.standar)) Attacks.pre <- setNames(Attacks.pre, c("Year", "Attack", "Count")) Attacks.pre <- Attacks.pre[Attacks.pre$Attack != "",] Attacks.pre <- plyr::arrange(Attacks.pre, Year, Attack) b <- as.character(sort(unique(Attacks.pre$Attack))) Attacks.desg <- data.frame(Year = sort(unique(Attacks.pre$Year))) for (i in 1:length(b)) { Attacks.desg <- cbind(Attacks.desg, Attacks.pre[Attacks.pre$Attack == b[i],3]) } Attacks.desg <- setNames(Attacks.desg, c("Year", b)) Attacks.desg <- select(Attacks.desg, Year, `Account Hijacking`, `DDoS`, `Defacement`, `DNS`, `Injection`, `Malware`) graph1 <- ggplot(data = Attacks.desg, aes(x = Year, y = `DDoS`, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("DDoS") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph2 <- ggplot(data = Attacks.desg, aes(x = Year, y = `Defacement`, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Defacement") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph3 <- ggplot(data = Attacks.desg, aes(x = Year, y = `Injection`, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Injection") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph4 <- ggplot(data = Attacks.desg, aes(x = Year, y = `Account Hijacking`, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Account Hijacking") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph5 <- ggplot(data = Attacks.desg, aes(x = Year, y = `Malware`, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Malware") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph6 <- ggplot(data = Attacks.desg, aes(x = Year, y = `DNS`, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("DNS") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) list(graph1, graph2, graph3, graph4, graph5, graph6) } #---------------------------------------------------------------- #-------------------------Geolocal evolution--------- #---------------------------------------------------------------- GetContinentPie <- function (Attacks, Cert_PerCountry){ attack.pie <- group_by(Attacks, Continent) attack.pie <- as.data.frame(table(attack.pie$Continent)) attack.pie <- setNames(attack.pie, c("Continent", "Count")) attack.pie <- attack.pie[attack.pie$Continent != "",] #attack.pie <- attack.pie[attack.pie$Count > (sum(attack.pie$Count) * 0.01),] graph1 <- ggplot(data=attack.pie, aes(x=factor(1), y=Count, fill=Continent)) + geom_col(width = 1, color='black') + geom_label(aes(label=paste(round(100 * attack.pie$Count / sum(attack.pie$Count), 2), "%")), vjust=c(-2.5, 0, 2, 0, -2.5), hjust=c(1.4, 1, 0.5, 0.5, 0)) + coord_polar(theta="y") + scale_x_discrete(labels = c("")) + scale_y_discrete(labels = c("")) + theme(plot.title = element_text(hjust = 0.5), axis.title.x=element_blank(), axis.title.y=element_blank()) + ggtitle("Attacks") cert.pie <- mutate(Cert_PerCountry, Total = X2011 + X2012 + X2013 + X2014 + X2015) %>% group_by(Continent) cert.pie <- data.frame(Continent = c("Asia", "Europe", "Africa", "Americas", "Oceania"), Count = c(sum((cert.pie[cert.pie$Continent == "Asia",])$Total), sum((cert.pie[cert.pie$Continent == "Europe",])$Total), sum((cert.pie[cert.pie$Continent == "Africa",])$Total), sum((cert.pie[cert.pie$Continent == "Americas",])$Total), sum((cert.pie[cert.pie$Continent == "Oceania",])$Total))) graph2 <- ggplot(data=cert.pie, aes(x=factor(1), y=Count, fill=Continent)) + geom_col(width = 1, color='black') + geom_label(aes(label=paste(round(100 * cert.pie$Count / sum(cert.pie$Count), 2), "%")), vjust=c(0, -1.5, -2.5, -2.5, -2.5), hjust=c(0.5, 0.2, 0.5, 1.8, -0.5)) + coord_polar(theta="y") + scale_x_discrete(labels = c("")) + scale_y_discrete(labels = c("")) + theme(plot.title = element_text(hjust = 0.5), axis.title.x=element_blank(), axis.title.y=element_blank()) + ggtitle("ISO 27001") list(graph1, graph2) } GetContinentAttacksEvolution <- function(Attacks){ attacks.evol <- mutate(Attacks, Year = format(Attacks$Date, "%Y")) %>% group_by(Continent, Year) attacks.evol <- as.data.frame(table(attacks.evol$Continent, attacks.evol$Year)) colnames(attacks.evol) <- c("Continent", "Year","Attacks") attacks.evol <- attacks.evol[attacks.evol$Continent != "Oceania",] attacks.evol <- attacks.evol[attacks.evol$Continent != "Africa",] graph1 <- ggplot2::qplot(main = "Cyberattacks evolution", x = attacks.evol$Year, y = attacks.evol$Attacks, group = Continent, xlab = "Years", ylab = "Attacks", data = attacks.evol, geom = "point", color = Continent) + geom_line() + theme(plot.title = element_text(hjust = 0.5)) graph1 } GetContinentCertsEvolution <- function(Cert_PerCountry){ certs.evol <- gather(Cert_PerCountry, "Year", "Certs", 2:6) %>% group_by(Continent, Year) certs.evol <- summarise(certs.evol, #Continent = Continent, #Year = Year, Certs = sum(Certs)) certs.evol$Year <- substr(certs.evol$Year,2,5) certs.evol <- certs.evol[certs.evol$Continent != "Oceania",] certs.evol <- certs.evol[certs.evol$Continent != "Africa",] graph1 <- ggplot2::qplot(main = "ISO 27001 evolution", x = certs.evol$Year, y = certs.evol$Certs, group = Continent, xlab = "Years", ylab = "Certifications", data = certs.evol, geom = "point", color = Continent) + geom_line() + theme(plot.title = element_text(hjust = 0.5)) graph1 } GetContinentAttacksTopEvolution <- function(Attacks){ attacks.evol <- mutate(Attacks, Year = format(Attacks$Date, "%Y")) %>% group_by(Year, Continent) attacks.evol <- as.data.frame(table(attacks.evol$Year, attacks.evol$Continent)) attacks.evol <- setNames(attacks.evol, c("Year", "Continent", "Count")) attacks.evol <- attacks.evol[attacks.evol$Continent != "",] attacks.evol <- spread(attacks.evol, "Continent", "Count") graph1 <- ggplot(data = attacks.evol, aes(x = Year, y = Americas, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Americas") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph2 <- ggplot(data = attacks.evol, aes(x = Year, y = Asia, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Asia") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph3 <- ggplot(data = attacks.evol, aes(x = Year, y = Europe, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Europe") + xlab("Years") + ylab("Attacks")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) list(graph1, graph2, graph3) } GetContinentCertsTopEvolution <- function(Attacks){ certs.evol <- gather(Cert_PerCountry, "Year", "Certs", 2:6) %>% group_by(Continent, Year) certs.evol <- summarise(certs.evol, #Continent = Continent, #Year = Year, Certs = sum(Certs)) certs.evol$Year <- substr(certs.evol$Year,2,5) certs.evol <- spread(certs.evol, "Continent", "Certs") graph1 <- ggplot(data = certs.evol, aes(x = Year, y = Americas, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Americas") + xlab("Years") + ylab("Certifications")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph2 <- ggplot(data = certs.evol, aes(x = Year, y = Asia, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Asia") + xlab("Years") + ylab("Certifications")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) graph3 <- ggplot(data = certs.evol, aes(x = Year, y = Europe, group = 1)) + geom_line() + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Europe") + xlab("Years") + ylab("Certifications")+ stat_smooth(method = "lm", se = FALSE, aes(outfit=fit<<-..y..)) list(graph1, graph2, graph3) } GetCountriesCol <- function(Attacks, Cert_PerCountry){ certs.evol <- gather(Cert_PerCountry, "Year", "Certs", 2:6) %>% group_by(Continent, country_short) certs.evol <- summarise(certs.evol, Certs = sum(Certs)) graph1 <- ggplot2::ggplot(aes(x = reorder(country_short, Certs), y = Certs), data = certs.evol[certs.evol$Certs > (sum(certs.evol$Certs) * 0.02),]) + geom_col(aes(fill = Continent)) + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("ISO 27001") + xlab("Country") + ylab("Certifications") attacks.evol <- mutate(Attacks, Year = format(Attacks$Date, "%Y")) %>% group_by(Year, Continent, Country) attacks.evol <- as.data.frame(table(attacks.evol$Year, attacks.evol$Continent, attacks.evol$Country)) attacks.evol <- setNames(attacks.evol, c("Year", "Continent", "Country", "Count")) attacks.evol <- attacks.evol[attacks.evol$Continent != "",] attacks.evol <- attacks.evol[attacks.evol$Country != "",] attacks.evol <- attacks.evol[attacks.evol$Country != "AU",] attacks.evol <- attacks.evol[attacks.evol$Count > (sum((attacks.evol[attacks.evol$Country != "US",])$Count) * 0.01),] attacks.evol <- arrange(attacks.evol, Count) graph2 <- ggplot2::ggplot(aes(x = reorder(Country, Count), y = Count), data = attacks.evol) + geom_col(aes(fill = Continent)) + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Attacks") + xlab("Country") + ylab("Attacks") list(graph1, graph2) } #---------------------------------------------------------------- #---------------------------------------------------------------- #---------------------------------------------------------------- GetBaseCertsGraph <- function(Cert_PerCountry, year){ graph1 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2012)", x = reorder(country_short,X2012), y = X2012, xlab = "Country", ylab = "Number of certifications", data = Cert_PerCountry[Cert_PerCountry$X2012 > mean(Cert_PerCountry$X2012),], geom = "col", fill = Continent) graph1 } #' Return every graph used in the report file #' #' @param Cert_PerCountry data.frame with the processed data of ISO 27001 certifications #' @param Attacks data.frame with the processed data of cyberattacks #' #' @return data.frame #' @export GetReportGraphs <- function(Cert_PerCountry,Attacks) { #2012 graph1 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2012)", x = reorder(country_short,X2012), y = X2012, xlab = "Country", ylab = "Number of certifications", data = Cert_PerCountry[Cert_PerCountry$X2012 > mean(Cert_PerCountry$X2012),], geom = "col", fill = Continent) attacks2k12 <- Attacks[Attacks$Date < "2013-01-01" & Attacks$Date >= "2012-01-01",] frameAttacks2k12 <- as.data.frame(table(attacks2k12$Country)) colnames(frameAttacks2k12) <- c("Country","Attacks") graph2 <- ggplot2::qplot(main = "Countries with above average number of cyberattacks (2012)", x = reorder(Country,Attacks), y = Attacks, xlab = "Country", ylab = "Number of attacks", data = frameAttacks2k12[frameAttacks2k12$Attacks > mean(frameAttacks2k12$Attacks),], geom = "col", fill = Continent) Attacks2012ByMonth <- mutate(attacks2k12, month = format(attacks2k12$Date, "%m")) %>% group_by(month) Attack2012FreqByMonth <- as.data.frame(table(Attacks2012ByMonth$month)) colnames(Attack2012FreqByMonth) <- c("Month", "Attacks") graph3 <- ggplot2::qplot(x = as.numeric(Month), y = Attacks, main = "Global cyberattack progression by month (2012)", data = Attack2012FreqByMonth, geom = c("point", "smooth"), xlim = c(1,12), xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) #2013 graph4 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2013)", x = reorder(country_short,X2013), y = X2013, xlab = "Country", ylab = "Number of certifications", data = Cert_PerCountry[Cert_PerCountry$X2013 > mean(Cert_PerCountry$X2013),] , geom = "col", fill = Continent) attacks2k13 <- Attacks[Attacks$Date < "2014-01-01" & Attacks$Date >= "2013-01-01",] frameAttacks2k13 <- as.data.frame(table(attacks2k13$Country)) colnames(frameAttacks2k13) <- c("Country","Attacks") graph5 <- ggplot2::qplot(main = "Countries with above average number of cyberattacks (2013)", x = reorder(Country,Attacks), y = Attacks, xlab = "Country", ylab = "Number of attacks", data = frameAttacks2k13[frameAttacks2k13$Attacks > mean(frameAttacks2k13$Attacks),] , geom = "col", fill = Continent) Attacks2013ByMonth <- mutate(attacks2k13, month = format(attacks2k13$Date, "%m")) %>% group_by(month) Attack2013FreqByMonth <- as.data.frame(table(Attacks2013ByMonth$month)) colnames(Attack2013FreqByMonth) <- c("Month", "Attacks") graph6 <- ggplot2::qplot(x = as.numeric(Month), y = Attacks, main = "Global cyberattack progression by month (2013)", data = Attack2013FreqByMonth, geom = c("point", "smooth"), xlim = c(1,12), xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) #2014 graph7 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2014)", x = reorder(country_short,X2014), y = X2014, xlab = "Country", ylab = "Number of certifications", data = Cert_PerCountry[Cert_PerCountry$X2014 > mean(Cert_PerCountry$X2014),] , geom = "col", fill = Continent) attacks2k14 <- Attacks[Attacks$Date < "2015-01-01" & Attacks$Date >= "2014-01-01",] frameAttacks2k14 <- as.data.frame(table(attacks2k14$Country)) colnames(frameAttacks2k14) <- c("Country","Attacks") graph8 <- ggplot2::qplot(main = "Countries with above average number of cyberattacks (2014)", x = reorder(Country,Attacks), y = Attacks, xlab = "Country", ylab = "Number of attacks", data = frameAttacks2k14[frameAttacks2k14$Attacks > mean(frameAttacks2k14$Attacks),] , geom = "col", fill = Continent) Attacks2014ByMonth <- mutate(attacks2k14, month = format(attacks2k14$Date, "%m")) %>% group_by(month) Attack2014FreqByMonth <- as.data.frame(table(Attacks2014ByMonth$month)) colnames(Attack2014FreqByMonth) <- c("Month", "Attacks") graph9 <- ggplot2::qplot(x = as.numeric(Month), y = Attacks, main = "Global cyberattack progression by month (2014)", data = Attack2014FreqByMonth, geom = c("point", "smooth"), xlim = c(1,12), xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) #2015 graph10 <- ggplot2::qplot(main = "Countries with above average number of companies certified with 27001 (2015)", x = reorder(country_short,X2015), y = X2015, xlab = "Country", ylab = "Number of certifications", data = Cert_PerCountry[Cert_PerCountry$X2015 > mean(Cert_PerCountry$X2015),] , geom = "col", fill = Continent) attacks2k15 <- Attacks[Attacks$Date < "2016-01-01" & Attacks$Date >= "2015-01-01",] frameAttacks2k15 <- as.data.frame(table(attacks2k15$Country)) colnames(frameAttacks2k15) <- c("Country","Attacks") graph11 <- ggplot2::qplot(main = "Countries with above average number of cyberattacks (2015)", x = reorder(Country,Attacks), y = Attacks, xlab = "Country", ylab = "Number of attacks", data = frameAttacks2k15[frameAttacks2k15$Attacks > mean(frameAttacks2k15$Attacks),] , geom = "col", fill = Continent) Attacks2015ByMonth <- mutate(attacks2k15, month = format(attacks2k15$Date, "%m")) %>% group_by(month) Attack2015FreqByMonth <- as.data.frame(table(Attacks2015ByMonth$month)) colnames(Attack2015FreqByMonth) <- c("Month", "Attacks") graph12 <- ggplot2::qplot(x = as.numeric(Month), y = Attacks, main = "Global cyberattack progression by month (2015)", data = Attack2015FreqByMonth, geom = c("point", "smooth"), xlim = c(1,12), xlab = "Month") + ggplot2::scale_x_continuous(breaks = 1:12) list(graph1,graph2,graph3,graph4,graph5,graph6,graph7,graph8,graph9,graph10,graph11,graph12) }