I'm incredibly new to R and I'm having to use it for my dissertation. Anyway, I have a dataset of samples ranging from 2001 to 2021, but not all years have data associated with them i.e., only years 2001-2010, and 2017-2021 do, however the geom_line() function includes the years 2011-2016, despite the fact that my data frame doesn't even include those years; presumably it has intuitively included them. Is there a way to remove 2011-2016 from my x axis, as my data looks messy?
Here is my graphing code if you need it:
plot <- ggplot(df, aes(x=Year)) +
geom_line(aes(y=var1), color = "black", size=1) +
geom_line(aes(y=var2), color="red", size=1) +
geom_line(aes(y=var3), color="green", size=1) +
geom_line(aes(y=var4), color="yellow", size=1) +
geom_line(aes(y=var5), color="blue", size=1) +
geom_line(aes(y=var6), color="pink", size=1)
and my data.frame "Year" column is as follows: 2021, 2020, 2019, 2018, 2017, 2011, 2010, 2009, 2007, 2006, 2005, 2004, 2003, 2002, 2001 in decending order (I wasn't sure how to make a mock up, as I can barely use this as it is, so I apologise if this isn't enough)
Thank you!