Generate multiple graphs in one loop using x11 () and two different indices in R

1

Personal this is my list.

mylist=list(list(a = c(2, 3, 4, 5), b = c(3, 4, 5, 5), c = c(3, 7, 5, 
5), d = c(3, 4, 9, 5), e = c(3, 4, 5, 9), f = c(3, 4, 1, 9), 
    g = c(3, 1, 5, 9), h = c(3, 3, 5, 9), i = c(3, 17, 3, 9), 
    j = c(3, 17, 3, 9)), list(a = c(2, 5, 48, 4), b = c(7, 4, 
5, 5), c = c(3, 7, 35, 5), d = c(3, 843, 9, 5), e = c(3, 43, 
5, 9), f = c(3, 4, 31, 39), g = c(3, 1, 5, 9), h = c(3, 3, 5, 
9), i = c(3, 17, 3, 9), j = c(3, 17, 3, 9)), list(a = c(2, 3, 
4, 35), b = c(3, 34, 5, 5), c = c(3, 37, 5, 5), d = c(38, 4, 
39, 5), e = c(3, 34, 5, 9), f = c(33, 4, 1, 9), g = c(3, 1, 5, 
9), h = c(3, 3, 35, 9), i = c(3, 17, 33, 9), j = c(3, 137, 3, 
9)), list(a = c(23, 3, 4, 85), b = c(3, 4, 53, 5), c = c(3, 7, 
5, 5), d = c(3, 4, 9, 5), e = c(3, 4, 5, 9), f = c(3, 34, 1, 
9), g = c(38, 1, 5, 9), h = c(3, 3, 5, 9), i = c(3, 137, 3, 9
), j = c(3, 17, 3, 9)), list(a = c(2, 3, 48, 5), b = c(3, 4, 
5, 53), c = c(3, 73, 53, 5), d = c(3, 43, 9, 5), e = c(33, 4, 
5, 9), f = c(33, 4, 13, 9), g = c(3, 81, 5, 9), h = c(3, 3, 5, 
9), i = c(3, 137, 3, 9), j = c(3, 173, 3, 9)))

For each command x11() I want to fill with 5 graphics until it is open. As j=1:10 I'll need to call x11() 10 times.

And that's when I'm messing around.

The only way I was able to generate the 10 graphs was by changing the value of j from 1 to 10.

That is:

The first graphic is this:

x11()
par(mfrow=c(3,2))

for (i in 1:5) {      
  #for (j in 1:10){   
    plot.ts(mylist[[i]][[1]])
  #}

}

The second graphic is this:

x11()
par(mfrow=c(3,2))

for (i in 1:5) { 
  #for (j in 1:10){
    plot.ts(mylist[[i]][[2]])
  #}
}

Up to j = 10. So 10 graphs, each containing 5 graphs.

Notice that I have to generate one by one, "in the hand". Substituting j from 1 to 10.

How do I automate this right? Where do I put the commands x11() ; par(mfrow=c(3,2)) ?

    
asked by anonymous 24.08.2018 / 04:35

2 answers

1

Each x11() is a new graphical window. So just open a new window whenever the previous graphics are all plotted.

The same goes for par(mfrow=c(3,2)) . This command is only used to define the internal configuration of the graphs within each x11 . Therefore, it makes more sense to set this setting right after the graph window is created.

for (j in 1:10) { 

  x11()
  par(mfrow=c(3,2))

  for (i in 1:5){
    plot.ts(mylist[[i]][[j]])
  }
}

I'm not going to put all the graphics here, but see that my computer was able to generate all 10 of the desired windows, indexed from 4 to 13.

    
24.08.2018 / 20:46
1

Only loop for with j before x11() :

    for(j in 1:10) {

      x11()
      par(mfrow=c(3,2))

      for (i in 1:5) { 
          plot.ts(mylist[[i]][[j]])
      }
    }
    
24.08.2018 / 20:44