Here's my data frame:
2010 2011 2012 2013 2014 2015
A 0 100 164 75 154 110
B 71 77 136 58 138 136
C 0 0 132 53 83 0
I'd like to make a line graph in which the years are plotted along the x-axis and and counts are plotted along the y-axis, with rows A, B, and C each having their own line. Is it possible to do this without melting the years into a single variable?
There is a function for this, matplot
. Try
matplot(yourData, type="l")
来源:https://stackoverflow.com/questions/32254821/r-plot-multiple-columns-as-years-on-x-axis-plot-rows-as-different-lines