title: Apply function to NA matrix in R
body: <p>I want to use the apply to use a function that I used to pull data via regular expressions and fill a matrix with it.</p>
  
  <pre><code>planetdata = function(dline) {
    new_line = unlist(strsplit(as.character(dline),"&lt;/td&gt;&lt;td&gt;"))
    new_first_value = substring(new_line[1],9)
    new_last_value =substring(new_line[11],1,nchar(new_line[11])-10) 
    new_line[1] &lt;- new_first_value
    new_line[11] &lt;- new_last_value 
    new_data &lt;- new_line
    return(new_data)
  
  }
  
  
  new.dt = dt[21:1912]
  exo.mat = matrix(data = NA, nrow=1892, ncol = 11)
  colnames(exo.mat) &lt;- c(exo.col.names)
  apply(exo.mat,2,function(new.dt) planetdata(new.dt))
  </code></pre>
  
  <p>However, my matrix does not change and all the values are still NA. 
  Why is this happening?</p>