title: use of double brackets unclear
body: <p>I'm new to R. Reading Book Of R by Tilman Davies. An example is provided for how to use an externally defined helper function which incidentally utilizes double square brackets [[]]. Please explain what helper.call[[1]] and helper.call[[2]] are doing and use of double brackets here.</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>multiples_helper_ext &lt;- function(x=foo,matrix.flags,mat=diag(2){
    indexes &lt;- which(matrix.flags)
    counter &lt;- 0
    result &lt;- list()
    for(i in indexes){
      temp &lt;- x[[i]]
      if(ncol(temp)==nrow(mat)){
        counter &lt;- counter+1
        result[[counter]] &lt;- temp%*%mat
      }
    }
    return(list(result,counter))
  }
  
  multiples4 &lt;- function(x,mat=diag(2),str1="no valid matrices",str2=str1){
    matrix.flags &lt;- sapply(x,FUN=is.matrix)
  
    if(!any(matrix.flags)){
      return(str1)
    }
  
    helper.call &lt;- multiples_helper_ext(x,matrix.flags,mat=diag(2)
    result &lt;- helper.call[[1]] #I dont understand this use of double bracket
    counter &lt;- helper.call[[2]] #and here either
  
    if(counter==0){
      return(str2)
    } else {
      return(result)
    }
  }
  </code></pre>
  
  
  
  <pre class="lang-html prettyprint-override"><code>foo &lt;- list(matrix(1:4,2,2),"not a matrix","definitely not a matrix",matrix(1:8,2,4),matrix(1:8,4,2))
  </code></pre>