title: create data frame with for loop results
body: <p>I want to create a data frame with the mean of df1 values and mean of df2 values as the columns in a new data frame. I can get the values to print with</p>
  
  <pre><code>for (i in samples) {    
  print(c(with(df1, mean(d18_VSMOW[Sample == i]))))
  }
  </code></pre>
  
  <p>But I can't get the results into a data frame 4</p>
  
  <pre><code>df4=
  Sample Mean1 Mean2
  12adk9  #     #
  12adk12 #     #
  12adk20 #     #
  </code></pre>
  
  <p>I have data that correlates to a sample number as shown in df1</p>
  
  <pre><code>df1=
  Sample  d18_VSMOW
  12adk9  12.27
  12adk9  12.15
  12adk9  11.78
  12adk9  12.21
  12adk9  12.52
  12adk9  12.28
  12adk12 10.7
  12adk12 11.15
  12adk12 11.24
  12adk20 11.16
  12adk20 11.14
  </code></pre>
  
  <p>and more data that shares the sample names, but have different values as in df2 and a different number of rows</p>
  
  <pre><code>df2 = 
  Sample  d18_VSMOW
  12adk9  15.27
  12adk9  15.15
  12adk9  17.78
  12adk9  19.21
  12adk9  20.52
  12adk9  22.28
  12adk12 16.7
  12adk12 15.15
  12adk12 16.24
  12adk20 19.16
  12adk20 19.14
  12adk20 20.02
  12adk20 21.02
  12adk20 22.02
  12adk20 23.02
  12adk20 24.02
  </code></pre>
  
  <p>I have a third dataframe containing all sample names:</p>
  
  <pre><code>samples = 
  Sample
  12adk9
  12adk12
  12adk20
  </code></pre>