[R] Alternate looping

Luis Ridao Cruz Luisr at frs.fo
Tue Jan 6 17:27:19 CET 2009


R-help,

I'm using the "for" control flow to graph plots continuously:

par(mfrow=c(3,5), mar=c(0.6,.2,1.2,.2),yaxt="n",xaxt="n")   
for(j in 1:11)  
{
for(i in 1:15)  
{

species <- spAldur[spAldur$ar == 1993+i & spAldur$aldur == j,]

plot(species at coords[,1], species at coords[,2], xlim=c(-10,-3.5),
ylim=c(60.1,63)
, col=3,type="n",xlab="",ylab="")
points(geoFeatures[["dyp100"]],pch=".",cex=1.2,col="blue")
.....
.....
.....
}}

This will plot a map of "something" in the following way:

(j=1, i=1), (j=1, i=2),(i=1, i=3),,,,,,,
(j=2, i=1), (j=2, i=2),(i=2, i=3),,,,,,,
(j=3, i=1), (j=3, i=2),(i=3, i=3),,,,,,,

and so on but I wish to have it like this:

(j=1, i=1), (j=2,i=2),(i=3,i=3),,,,,,,


Thanks in advance




More information about the R-help mailing list