R - Plot multiple columns as years on x-axis, plot rows as different lines

天涯浪子 提交于 2019-12-02 06:48:42

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!