I am having troubling using the gridextra library, and specifically the grid.arrange feature to stack to time series plots on top of each other. I want to compare military during 1992-2016 and cyber attacks during 1992-2016...but with my data, military attacks data stop in 2010, and cyber attacks do not start until 2000. I wanted to stack these two plots on top of each other to not only show this gap in data, but also to show the different trends going on.
Using the code I provide below, does anyone have any tips on how to correctly use grid.arrange to arrange both of these two plots on top of each other? ... or perhaps a different way to do the same thing?
# Aggregated Cyber Attacks
plot1 <- plot(allmerged$yearinitiated, allmerged$cyberattacks,
col="black",
xlab = "Year",
ylab = "# of Cyber Attacks",
main = "Cyber Attacks over Time",
type = "l")
# Aggregated MID Attacks
plot2 <- plot(allmerged$yearinitiated, allmerged$midaction,
col="black",
xlab = "Year",
ylab = "# of MIDs",
main = "MIDs Attacks over Time",
type = "l")
Below is an example of what my code looks like. As you will see, my "y" will differ, but for both plots, they should both have an "x" of 1992-2016.
yearinitiated midaction cyberattacks
1995 81 NA
1996 75 NA
1997 81 NA
1998 264 NA
1999 363 NA
2000 98 1
2001 105 7
2002 83 NA
2003 79 3
2004 52 2
2005 50 4
2006 35 8
2007 26 18
2008 39 27
2009 31 28
2010 73 15
2011 NA 27