title: Finding and Filling Missing Observations (Whole Rows not NA Values) with Mean Values
body: <p>I am hoping to get some help identifying:</p>
  <ol>
  <li>The location of missing observations when no NA values are present
  (entire row is missing).</li>
  <li>Create a row for the missing data with mean values based on mean values from certain categories.</li>
  </ol>
  <p>My df:</p>
  <ul>
  <li><p>Numerical load data from hockey players during practices over the season</p>
  </li>
  <li><p>Occasionally the accelerometers do not work during practice even though the player practiced. So to make sure we can still track the work they did during practice, I would like to insert the average mean value from their position (forward, defense, or goalie) from that practice. (i.e. if a goalie’s accelerometer does not work I would like to take the average loads of the other goalies and insert it into that player’s observational row for the practice).</p>
  </li>
  <li><p>This would be a simpler task if there were rows ALL players each practice and NA values for loads when the accelerometer doesn’t work BUT when I download the data in a csv from the online cloud there are only rows for players who had working units. So that part is out of my control.</p>
  </li>
  </ul>
  <pre><code>&gt; head(DummyLoads)  
   Name       Date Load Position    
  1   Jim 2019-10-19  900    2.100  Forward 
  2   Bob 2019-10-19  900    2.100  Forward 
  3  Dave 2019-10-19  900    2.100  Forward 
  4 Steve 2019-10-19  850    2.312  Forward 
  5  Fred 2019-10-19  850    2.312  Defense 
  6   Ray 2019-10-19  850    2.312  Defense
  </code></pre>
  <pre><code>DummyLoads &lt;- structure(list(Name = structure(c(4L, 1L, 2L, 6L, 3L, 5L, 4L, 1L, 2L, 3L, 5L, 4L, 1L, 2L, 6L, 3L, 5L, 2L, 6L, 3L, 5L),
   .Label = c(&quot;Bob&quot;,  &quot;Dave&quot;, &quot;Fred&quot;, &quot;Jim&quot;, &quot;Ray&quot;, &quot;Steve&quot;), 
  class = &quot;factor&quot;), 
  Date = structure(c(1L,  1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,  4L, 4L, 4L, 4L), 
  .Label = c(&quot;2019-10-19&quot;, &quot;2019-10-20&quot;, &quot;2019-10-21&quot;,  &quot;2019-10-22&quot;), class = &quot;factor&quot;), 
  Load = c(900L, 900L, 900L,  850L, 850L, 850L, 789L, 789L, 789L, 960L, 960L, 909L, 909L, 909L,  991L, 991L, 991L, 720L, 717L, 717L, 717L), 
  Load.Min = c(2.1,  2.1, 2.1, 2.312, 2.312, 2.312, 2.22, 2.22, 2.22, 2, 2, 1.88,  1.88, 1.88, 1.99, 1.99, 1.99, 2.1, 2.3, 2.3, 2.3), Position = structure(c(2L,  2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,  2L, 2L, 1L, 1L), 
  .Label = c(&quot;Defense&quot;, &quot;Forward&quot;), class = &quot;factor&quot;)), class = &quot;data.frame&quot;, row.names = c(NA,  -21L))
  </code></pre>
  <pre><code>ggplot(DummyLoads, aes(x = Name, y = Load, fill = Position))+
    geom_bar(stat = &quot;identity&quot;)+
    facet_grid(~Date)
  </code></pre>
  <p>Here is a chart showing players with missing data.</p>
  <p><a href="https://i.stack.imgur.com/JxyMe.png" rel="nofollow noreferrer">Missing Player Loads</a></p>
  <p>Ideally I would like to be able to identify those missing data points without having to plot it first. I also want to avoid having to manually calculate means each time and then input. Hoping to find an automated solution because I will have a full season of practices to do this with, but understand that might be tricky!</p>
  <p>Thank you in advance for any suggestions. I apologize if I didn’t explain things clearly.</p>