title: Expected value of X for each value of Y (R)
body: <p>So, I have a dataset of baseball players and am trying to calculate the expected value of their height, given their weight. I know how to calculate expected values within one variable, but I'm not quite sure how to do it using another?</p>
  
  <p>I have included my dataset below. Using a dput command, I guess at the moment I've played around with various mutate commands but I don't know how to code something that works like expectedheight = mean(heightunches) if weightpounds = weightpounds. Because the expected value needs to take into consideration weightpounds.</p>
  
  <pre><code>structure(
    list(Name = structure(1:3, .Label = c("Adam_Donachie", "Paul_Bako", "Ramon_Hernandez"), class = "factor"), 
         Team = structure(c(1L, 1L, 1L), .Label ="BAL", class = "factor"), 
         Position = structure(c(1L, 1L, 1L), .Label = "Catcher",class = "factor"), 
         Heightinches = c(74L, 74L, 72L), Weightpounds =c(180L, 215L, 210L), 
         Age = c(22.98999977, 34.68999863, 30.78000069)), row.names = c(NA, -3L), 
    .Names = c("Name", "Team", "Position", "Heightinches", "Weightpounds", "Age"), 
    class = "data.frame")
  </code></pre>