title: How to store results from a function inside the loop to the same excel sheet?
body: <p>I have for-loop listing multiple excel sheets , reading them, doing some processing and ideally I would like to store the resulting outputs into the same excel file/sheet.</p>
  
  <p>the desired output is qs</p>
  
  <pre><code>files &lt;- list.files(path = "V:/_190718AA_ascii", pattern = 
                        "*.xlsx", full.names = T)
  df.list &lt;- lapply(files, read_excel,col_names=FALSE)
  kClusters=5
  for (m in df.list) {
  
    qs[m]&lt;- quantile(m[px[,,1,1]],probs=c(0,0.025,0.05,0.1,0.25,0.5,0.75,0.9,0.95,0.975,1))
  
    write.xlsx(qs[m],"V:/_ORG/080-DOZP/BO-P2/DOZPLL/Esma/uqs.xlsx",sheet=m)
    m &lt;- m+1      
  }
  </code></pre>
  
  <p>it gives only the result from one m instead of 4.</p>