title: R - title plots based on nested lists
body: <p>I have 2 lists, and inside each are two more lists containing data frames (in other words, nested lists). I want plot each data frame and title it based on the names of both the primary and nested lists.</p>
  
  <p>For example, say we have:</p>
  
  <pre><code>a=list(
    list(a=data.frame(x=rpois(5,1),y=rpois(5,1)),
         b=data.frame(x=rpois(5,1),y=rpois(5,1))),
    list(c=data.frame(x=rpois(5,1),y=rpois(5,1)),
         d=data.frame(x=rpois(5,1),y=rpois(5,1))))
  </code></pre>
  
  <p>And we have the names of the primary list:</p>
  
  <pre><code>names(a)=c("alpha","bravo")
  </code></pre>
  
  <p>Inside the two primary lists <code>alpha</code> and <code>bravo</code>, we have two more lists, <code>charlie</code> and <code>delta</code>: </p>
  
  <pre><code>for(i in 1:length(a)) {
    names(a[[i]])=c("charlie","delta") }
  </code></pre>
  
  <p>I can use <code>lapply</code> to loop through each list and plot the data frames, but I am having trouble getting the titles to combine the name of the primary list (<code>alpha</code> and <code>bravo</code>) and the nested list (<code>charlie</code> and <code>delta</code>) for each data frame. For instance, in this case, I would like to have four plots called: <code>alpha_charlie</code>, <code>alpha_delta</code>,<code>bravo_charlie</code>, and <code>bravo_delta</code>.</p>
  
  <pre><code>lapply(a,function(i) {
    lapply(names(i), function(j) { 
      ggplot()+
        geom_point(data=i[[j]],aes(x,y))+
        opts(title=paste(names(i),j,sep="_")) #Here is where I am struggling!
      } ) } )
  </code></pre>
  
  <p>Any help would be much appreciated.  Thank you!</p>