title: How to extract column names properly?
body: <p>I would like to extract the column names after some data manipulation:</p>
  
  <p>data:</p>
  
  <pre><code>dates &lt;- seq(as.Date("2015-09-04"), as.Date("2015-09-13"), by = "days")
  b&lt;-c(1000,2,3,4,5,6,7,8,9,10)
  c&lt;-c(10,11,12,13,14,15,15,1,18,1000)
  d&lt;-c(1,0,1,0,1,0,1,0,0,0)
  e&lt;-seq(5,14,1)
  df&lt;-data.frame(dates,b,c,d,e)
  </code></pre>
  
  <p>here I would like to use a function for outlier detection <a href="https://stats.stackexchange.com/questions/1142/simple-algorithm-for-online-outlier-detection-of-a-generic-time-series">anomaly detection</a>:</p>
  
  <pre><code>tsoutliers &lt;- function(x,plot=FALSE)
  {
    x &lt;- as.ts(x)
    if(frequency(x)&gt;1)
      resid &lt;- stl(x,s.window="periodic",robust=TRUE)$time.series[,3]
    else
    {
      tt &lt;- 1:length(x)
      resid &lt;- residuals(loess(x ~ tt))
    }
    resid.q &lt;- quantile(resid,prob=c(0.25,0.75))
    iqr &lt;- diff(resid.q)
    limits &lt;- resid.q + 1.5*iqr*c(-1,1)
    score &lt;- abs(pmin((resid-limits[1])/iqr,0) + pmax((resid - limits[2])/iqr,0))
    if(plot)
    {
      plot(x)
      x2 &lt;- ts(rep(NA,length(x)))
      x2[score&gt;0] &lt;- x[score&gt;0]
      tsp(x2) &lt;- tsp(x)
      points(x2,pch=19,col="red")
      return(invisible(score))
    }
    else
      return(score)
  }
  
  
  
  
  
  data&lt;-lapply(df[,2:5],tsoutliers )
  
  names(data)
  [1] "b" "c" "d" "e"
  </code></pre>
  
  <p>here I use the</p>
  
  <pre><code>library(stringi)
  </code></pre>
  
  <p>in order to have the opportunity to bind lists with differing rows:</p>
  
  <pre><code>res &lt;- as.data.frame((stri_list2matrix(data)))
  res
  
                    V1                V2 V3                V4
  1  15178354561080816                0  0                 0
  2  33856330254037544                0  0                 0
  3   4033168544496767                0  0                 0
  4                  0                0  0                 0
  5                  0                0  0                 0
  6                  0                0  0                 0
  7                  0                0  0                 0
  8                  0 4.47011310645824  0                 0
  9                  0 76.7919635157679  0                 0
  10                 0 32.7413708467736  0 0.409090909090909
  </code></pre>
  
  <p>rename columns</p>
  
  <pre><code>colnames(res) &lt;- unique(unlist(sapply(data, names)))
  </code></pre>