title: print list names when iterating lapply
body: <p>I have a time series (x,y,z and a) in a list name called dat.list. I would like to apply a function to this list using <code>lapply</code>. Is there a way that I can print the element names i.e., x,y,z and a after each iteration is completed in lapply. Below is the reproducible example.</p>
  
  <pre><code>## Create Dummy Data
  
  x &lt;- ts(rnorm(40,5), start = c(1961, 1), frequency = 12)
  y &lt;- ts(rnorm(50,20), start = c(1971, 1), frequency = 12)
  z &lt;- ts(rnorm(50,39), start = c(1981, 1), frequency = 12)
  a &lt;- ts(rnorm(50,59), start = c(1991, 1), frequency = 12)
  
  dat.list &lt;- list(x=x,y=y,z=z,a=a)
  
  ## forecast using lapply
  
  abc &lt;- function(x) {
    r &lt;- mean(x)
    print(names(x))
    return(r)
  }
  
  forl &lt;- lapply(dat.list,abc)
  </code></pre>
  
  <p>Basically, I would like to print the element names x,y,z and a every time the function is executed on these elements. when I run the above code, I get null values printed.</p>