title: Converting the argument name of a function into string
body: <p>I have developed a function which will take a list of files and will do some statistical tests and will generate a excel file. In the last line of function (return object) I want the function will return a excel file with same names as input file names. In my example it will give list_file.xlsx. IF I enter another file let's say tslist_file it should automatically return tslist_file.xlsx. The function is properly working. Suggest me how I code last line of the function so that I can generalise it.</p>
  <pre><code> newey&lt;-function(list_files){
  tsmom&lt;-do.call(cbind,lapply(list_files,function(x) read_excel(x)[,2]))
  tsmom&lt;-xts(tsmom[,1:5],order.by = seq(as.Date(&quot;2005-02-01&quot;),length=183,by=&quot;months&quot;)-1)
  names(tsmom)&lt;-c(&quot;tsmom121&quot;,&quot;tsmom123&quot;,&quot;tsmom126&quot;,&quot;tsmom129&quot;,&quot;tsmom1212&quot;)
  ## newey west
  newey_west&lt;-function(x){
    model&lt;-lm(x~1)
    newey_west&lt;-coeftest(model,vcov=NeweyWest(model,verbose=T))
    newey_west[c(1,3,4)]
  }
  
  ## running newey west 
  cs_nw_full&lt;-do.call(cbind,lapply(tsmom,newey_west))
  library(gtools)
  p_values&lt;-cs_nw_full[3,]
  cs_nw_full[2,]&lt;-paste0(cs_nw_full[2,],stars.pval(p_values))
  write.xlsx(cs_nw_full,&quot;list_file.xlsx&quot;)
  }
  </code></pre>