I am trying to create a line plot with ggplot2.The plot is right but there is an issue with the years on x-axis. I want all years in the data frame given below to be presented in the plot but only few values from years column is present in the plot. Is there any solution?
The data is given below:
year attacks killed
1999 1 2
2000 1 1
2001 3 3
2002 1 1
2003 2 65
2004 1 1
2005 1 1
2006 1 1
2007 1 1
2008 1 1
2009 1 1
2010 4 75
2011 4 61
2012 9 32
2013 2 180
2014 4 70
2015 4 13
2016 3 7
2017 9 25
The code to make the plot is given below:
data <- read.table("data.txt", header = T)
p <- ggplot(moomins,aes(year))+
+ geom_line(aes(y= attacks,color = "Attacks"))+
+ geom_line(aes(y= killed,color = "Killed"))
p + coord_flip(xlim = c(1999,2017 ))
print(p)


dput()into the question.breaks = 1999:2017within thescale_x_continuousargument you should fix it: ggplot2.tidyverse.org/reference/scale_continuous.html