title: How to modify the values in a group based on the presance of some other value in the group using dplyr?
body: <p>This is my data</p>
  <pre><code>structure(list(group = c(&quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;C&quot;, &quot;C&quot;, 
  &quot;C&quot;, &quot;D&quot;, &quot;D&quot;, &quot;D&quot;), type = c(&quot;T1&quot;, &quot;T2&quot;, &quot;T3&quot;, &quot;T1&quot;, &quot;T2&quot;, &quot;T3&quot;, 
  &quot;T1&quot;, &quot;T2&quot;, &quot;T3&quot;, &quot;T1&quot;, &quot;T2&quot;, &quot;T3&quot;), value = c(&quot;MC&quot;, &quot;C&quot;, NA, 
  &quot;C&quot;, &quot;C&quot;, NA, &quot;MA&quot;, &quot;A&quot;, &quot;A&quot;, NA, &quot;MA&quot;, &quot;MA&quot;)), row.names = c(NA, 
  -12L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;))
  </code></pre>
  <pre><code># A tibble: 12 x 3
     group type  value
     &lt;chr&gt; &lt;chr&gt; &lt;chr&gt;
   1 A     T1    MC   
   2 A     T2    C    
   3 A     T3    NA   
   4 B     T1    C    
   5 B     T2    C    
   6 B     T3    NA   
   7 C     T1    MA   
   8 C     T2    A    
   9 C     T3    A    
  10 D     T1    NA   
  11 D     T2    MA   
  12 D     T3    MA 
  </code></pre>
  <p>For each group there are 3 types. When there is a 'M' value in the group (MC or MA) then the rest of the values in the group should be changed to that value but the NA should remain as NA.</p>
  <p>This is my expected output:</p>
  <pre><code># A tibble: 12 x 3
     group type  value
     &lt;chr&gt; &lt;chr&gt; &lt;chr&gt;
   1 A     T1    MC   
   2 A     T2    MC    
   3 A     T3    NA   
   4 B     T1    C    
   5 B     T2    C    
   6 B     T3    NA   
   7 C     T1    MA   
   8 C     T2    MA    
   9 C     T3    MA    
  10 D     T1    NA   
  11 D     T2    MA   
  12 D     T3    MA 
  </code></pre>