title: Paste together two data frames element by element in R
body: <p>I need to paste, element by element, the contents of two data frames for input to another program. I have a data frame of means and a data frame of standard errors of the mean. </p>
  
  <p>I tried using the R paste() function, but it doesn't seem to be able to cope with data frames. When using a vector, it seems to concatenate all the elements of the first vector into a string and all the elements of the second into a separate string. Instead, I need each reciprocal element in the two data frames to be concatenated together.</p>
  
  <p>Any suggestions for how to approach this? I've included dummy input data (datMean and datSE) and my desired output (datNew). My real data frames are about 10 rows by 150 columns in size.</p>
  
  <pre><code># means and SEM
  datMean &lt;- data.frame(a=rnorm(10, 3), b=rnorm(10, 3), d=rnorm(10, 3))
  datSE &lt;- data.frame(a=rnorm(10, 3)/100, b=rnorm(10, 3)/100, d=rnorm(10, 3)/100)
  
  # what the output should look like
  # i've chosen some arbitrary values here, and show only the first row. 
  datNew &lt;- data.frame(a="2.889-2.926", b="1.342-1.389", d="2.569-2.576")
  </code></pre>
  
  <p>The idea is for each element in datNew to be a range consisting of 'mean - se' and 'mean + se', separated by a dash '-' . The paste() function can do this for one element, how to do this over the whole dataframe?</p>
  
  <pre><code>paste(datMean[1,1] - datSE[1,1], datMean[1,1] + datSE[1,1], sep="-")
  </code></pre>
  
  <p>EDIT 1:
  Looking at some of the answers I realize I left out an important bit of information in the question. Each row of the original data frames is named, and I need to reconstitute the final data frame with these names. For example:</p>
  
  <pre><code>rownames(datMean) &lt;- LETTERS[1:10]
  rownames(datSE) &lt;- LETTERS[1:10]
  </code></pre>
  
  <p>I need datNew to eventually have these 10 rownames again. This could be problematic with some of the solutions using melt().</p>