title: R: Changing the names in a named vector
body: <p>R's named vectors are incredibly handy, however, I want to combine two vectors which contain the estimates of coefficients and the standard errors for those estimates, and both vectors have the same names:</p>
  
  <pre><code>&gt; coefficients_estimated
       y0         Xit  (Intercept) 
      1.1         2.2          3.3 
  
  &gt; ses_estimated
       y0         Xit  (Intercept) 
      .04         .11         .007
  </code></pre>
  
  <p>This would be easy to solve if I knew what order the elements were in for sure, but this isn't guaranteed in my script, so I can't simply do <code>names(ses_estimated) &lt;- whatever</code>. All I want to do is add either "coef" or "se" to the end of each name, and to do this, I've come up with what I think is a pretty ugly hack:</p>
  
  <pre><code>names(coefficients_estimated) &lt;- sapply(names(coefficients_estimated),
                                          function(name)return(paste(name,"coef",sep=""))
                                          )
  names(ses_estimated) &lt;- sapply(names(ses_estimated),
                                 function(name)return(paste(name,"se",sep=""))
                                 )
  </code></pre>
  
  <p>Is there an idomatic way to do this? Or am I going to have to stick with what I've written?</p>