[R] Line Graph greater than 2 variables on plot

Waseq Ziaie waseq_ziaie007 at hotmail.com
Thu Aug 21 00:54:55 CEST 2014


Hi all,

I was wondering if anyone knew how to construct a multiple line graph on R, where there  are 2 (or more) sets of data points plotted against some x axis of
data, and you can draw a line on the graph connecting each set of data points.
for example:
  time..years. 		incidence	 rural	 urban
1         2004     	295.4 		19.01 	 9.50
2         2005     	824.1 		19.95 	 9.98
3         2006    	1078.0		 20.70 	10.35
4         2007    	1258.0  		 21.26 	10.63
5         2008    	1800.0 		 21.83	 10.91
6         2009   		 1890.0		 18.93 	  9.47
7         2010   		 1999.0 		  19.41	  9.71
8         2011 		   2261.0 	 19.89 	  9.95
9         2012    	   2321.0		   20.28 	  10.14

Idea:
a) I am planning plot a graph of data illustrated above where on Y-axis we can have data in sets INCIDENCE, RURAL and URBAN and on X-axis the points in set TIME..YEARS.
b) Would like to be able to draw three lines ,connecting the points for each set of INCIDENCE, RURAL and URBAN over TIME..YEARS.

I have tried really hard to find something but wasn't successful, the latest information I received after doing the command shown underneath was:

> plot(data1$time..years.,data1$incidence,main="Plot illustrating diarrhoeal incidence over time", xlab="Time(years)",ylab="Diarrhoeal incidence",ylim=range(data[c("incidence","rural","urban")]),type"l", col=2)
Error: unexpected string constant in "plot(data1$time..years.,data1$incidence,main="Plot illustrating diarrhoeal incidence over time", xlab="Time(years)",ylab="Diarrhoeal incidence",ylim=range(data[c("incidence","rural","urban")])"

Many thanks,
W
	[[alternative HTML version deleted]]



More information about the R-help mailing list