title: How to group data by date by an operation (mean) without affecting the existing dimensions of the data frame in R?
body: <p>Given the following dataset:</p>
  
  <pre><code>Hours&lt;-c(2,3,4,2,1,1,3)
  Project&lt;-c("a","b","b","a","a","b","a")
  Period&lt;-c("2014-11-22","2014-11-23","2014-11-24","2014-11-22", "2014-11-23", "2014-11-23", "2014-11-24")
  cd=data.frame(Project,Hours,Period)
  </code></pre>
  
  <p>My goal is to group the hours by mean by date <strong><em>without</em></strong> compromising the data frame structure. See goal:</p>
  
  <pre><code>Hours_goal&lt;-c(2,1.6,3.5,2,1.6,1.6,3.5)
  Project_goal&lt;-c("a","b","b","a","a","b","a")
  Period_goal&lt;-c("2014-11-22","2014-11-23","2014-11-24","2014-11-22", "2014-11-23", "2014-11-23", "2014-11-24")
  cd_goal=data.frame(Project_goal,Hours_goal,Period_goal)
  </code></pre>
  
  <p>As you can see above, the project and period columns do not change, but the end goal is to contain mean hours by a single day. For example, for 2014-11-23, the original data have values 3,1, and 1. But the mean of these values is 1.6. Therefore, 1.6 has been inserted in place of all these values for this date in this column. </p>