[R] Plot a series of plots without using a loop

Ben Harrison harb at student.unimelb.edu.au
Wed Jul 31 01:25:25 CEST 2013


On 30 July 2013 21:35, Rui Barradas <ruipbarradas at sapo.pt> wrote:
> Hello,
>
> Maybe the following does it.
>
> op <- par(mfrow=c(2, 3))
>
> for(i in 1:6){
>         plot(somdata.xyf,
>              type="property",
>              property=somdata.xyf$codes$X[, i],
>              main=colnames(somdata.xyf$codes$X)[i])
> }
>
> par(op)
>
>
> Hope this helps,
>
> Rui Barradas

Thanks Rui,
that does it for sure. I had come to that solution, but just realised
by looking at it again, I could change
for (i in 1:6)
with
for (i in 1:length(dim(somdata.xyf$codes$X)[2]))

I was also wondering if there was a way to do it without a for loop,
but in this case it's a very small number of iterations, so probably
not worth it.

Ben



More information about the R-help mailing list