title: Conditional mutation across rows (by group/id)?
body: <p>I have a large dataset that I would like some help with. An example is given below:</p>
  <pre><code>   id  id_row  material
  1  1     1     1
  2  1     2     1
  3  1     3     1
  4  2     1     1
  5  2     2     2
  6  2     3     1
  7  3     1     1
  8  3     2     1
  9  3     3     1
  10 4     1     1
  11 4     2     2 
  </code></pre>
  <p>I would like to add a new column based on the values in material for the same id (across rows). In the new colum, I would like all id with values 1 and 2 in material (across rows) to be identified (e.g. as value 99) and if not both are present then return either 1 or 2.
  Something like this:</p>
  <pre><code>   id  id_row  material  new_column
  1  1     1     1             1
  2  1     2     1             1
  3  1     3     1             1
  4  2     1     1             99
  5  2     2     2             99
  6  2     3     1             99
  7  3     1     2             2
  8  3     2     2             2
  9  3     3     2             2
  10 4     1     1             99
  11 4     2     2             99
  </code></pre>
  <p>I have been looking online for a solution without any luck as well as tried using dplyr and group_by, mutate and ifelse without any luck. Thank you in advance!</p>