title: Iteratively print plots in R
body: <p>I have a series of vectors and I want to print them iteratively (so far i did it hardcoding it but i want to avoid doing it one by one again). 
  the names of the variables that hold the names of the vectors are stored in "genes" (char), while i can see the variables using ls() (ok nothing new so far)
  each vector is of variable length and i want to print the index (x axis) against the value (y axis). 
  the data i'm downloading come from the TCGA database and can be accessible with their R package.
  what i have so far is:</p>
  
  <pre><code>library(cgdsr)
  
  #create object
  
  mycgds = CGDS("http://www.cbioportal.org/public-portal/")
  genes &lt;- c("AGPAT1", "CDIPT", "CDS1", "CEL", "CEPT1", "DGKA", "LCAT", "LCLAT1", "LPCAT3", "LPIN1", "LPL", "MOGAT3", "PEMT", "PISD", "PLA2G4B", "PLD1","PTDSS1", "PTDSS2", "ATX", "PLA2") # list of my gene names
  
  # get z score about these genes for kidney cancer
  data &lt;- getProfileData(mycgds, genes, "kirc_tcga_pub_rna_seq_v2_mrna_median_Zscores", "kirc_tcga_pub_3way_complete" )
  
  data &lt;- t(data)
  
  #set z-value cutoff (equivalent to p&lt;0.05)
  i &lt;- -1.96
  j &lt;- 1.96
  
  # select only samples that have values lower than i and higher than j
  
  AGPAT1 &lt;- data[1,which(data[1,] &lt; i | data[1,] &gt; j)]
  CDIPT &lt;- data[2,which(data[2,] &lt; i | data[2,] &gt; j)]
  CDS1 &lt;- data[3,which(data[3,] &lt; i | data[3,] &gt; j)]
  CEL &lt;- data[4,which(data[4,] &lt; i | data[4,] &gt; j)]
  CEPT1 &lt;- data[5,which(data[5,] &lt; i | data[5,] &gt; j)]
  DGKA &lt;- data[6,which(data[6,] &lt; i | data[6,] &gt; j)]
  LCAT &lt;- data[7,which(data[7,] &lt; i | data[7,] &gt; j)]
  LCLAT1 &lt;- data[8,which(data[8,] &lt; i | data[8,] &gt; j)]
  LPCAT3 &lt;- data[9,which(data[9,] &lt; i | data[9,] &gt; j)]
  LPIN1 &lt;- data[10,which(data[10,] &lt; i | data[10,] &gt; j)]
  LPL &lt;- data[11,which(data[11,] &lt; i | data[11,] &gt; j)]
  MOGAT3 &lt;- data[12,which(data[12,] &lt; i | data[12,] &gt; j)]
  PEMT &lt;- data[13,which(data[13,] &lt; i | data[13,] &gt; j)]
  PISD &lt;- data[14,which(data[14,] &lt; i | data[14,] &gt; j)]
  PLA2G4B &lt;- data[15,which(data[15,] &lt; i | data[15,] &gt; j)]
  PLD1 &lt;- data[16,which(data[16,] &lt; i | data[16,] &gt; j)]
  PTDSS1 &lt;- data[17,which(data[17,] &lt; i | data[17,] &gt; j)]
  PTDSS2 &lt;- data[18,which(data[18,] &lt; i | data[18,] &gt; j)]
  ATX &lt;- data[19,which(data[19,] &lt; i | data[19,] &gt; j)]
  PLA2 &lt;- data[20,which(data[20,] &lt; i | data[20,] &gt; j)]
  
  #setup page for the 18graphs, not 20 cause there are no values for the last two
   par(mfrow= c(3,6)) 
  
     color &lt;- function(x){
        ifelse(x &gt; 1.96, "red", "green")
      }
  
      for (k in seq(1,length(ls()),1)) #iterate through ls()
        for(z in seq(1, length(genes),1)) #iterate through my list of genes
          if(genes[z] == ls()[k]) #if they match print them out
            plot(ls()[k], pch=15, col=color(ls()[k]), main =genes[z], ylim=c(-3,30))
  </code></pre>
  
  <p>the "color" function is to assign a color based on the value</p>
  
  <p>however, i can't get this to work. it does not print the all the graphs but just a few and it does not apply the right colors.</p>
  
  <p>thanks :)</p>