Whenever I try to create a line graph in R to display data I have an error with the way I want it to appear as it doesn't seem to use the data given for that axis. the goal is to be able to display it so that have years gone by on the x axis and the amount of deaths that have occurred during those years on the y axis however whenever I try to do that R changes the data of the deaths, but if I invert the data it prints the data correctly.
I have tried to remove some non - essential information and I have tried to swap the data positions.
totals = 21,945 22,321 22,849 22,425 22,856 23,968 23,500 24,514 23,584 24,473 25,801 27,335 26,316 27,289 27,414 28,300 27,901 28,704 29,782 29,690 31,555
years = 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017
plot(totals, years, type="l", xlab = "Years", ylab = "Deaths", main = "Deaths Over the Years")
plot(years, totals, type="l", xlab = "Years", ylab = "Deaths", main = "Deaths Over the Years")
The first line of code shown gives the graph in the form inverted to what I wish it to be and in the wrong style of value, however it uses the correct data:
The second line shows the data in the correct style and is supposed show that data the correct way around however, while it shows the Years axis correctly the data on the deaths axis has been decreased by a significant amount which is not supposed to happen: