title: Replacing NA with lookup value on two columns
body: <p>I have a dataframe that includes date, time of day, and measurement value over a number of days.</p>
  
  <p>Some of the measurements are NA. I'd like to replace these with an imputed value. </p>
  
  <p>To solve this, I created a second dataframe to hold the imputed value:</p>
  
  <pre><code>meanMeasurementByTimeAndDayOfWeek &lt;- 
    ddply(activityData, c('timeofday', 'dayOfWeek'), 
    summarize, avgMeasurement = mean(measurement, na.rm=TRUE))
  </code></pre>
  
  <p>(I think that's right.)</p>
  
  <p>How do I replace the NA's in the measurement column of my activityData dataframe with the avgMeasurement value from the second dataframe based on the timeofday and dayOfWeek values?</p>