title: Check if all the elements in the Vector are available in the groups in R data frame
body: <p>I am having a data frame in R as follows:</p>
  <pre><code>df &lt;- data.frame(&quot;location&quot; = c(&quot;IND&quot;,&quot;IND&quot;,&quot;IND&quot;,&quot;US&quot;,&quot;US&quot;,&quot;US&quot;), type = c(&quot;butter&quot;,&quot;milk&quot;,&quot;cheese&quot;,&quot;milk&quot;,&quot;cheese&quot;,&quot;yogurt&quot;), quantity = c(2,3,4,5,6,7))
  </code></pre>
  <p>I am having a vector as follows:</p>
  <pre><code>typeVector &lt;- c(&quot;butter&quot;,&quot;milk&quot;,&quot;cheese&quot;,&quot;yogurt&quot;)
  </code></pre>
  <p>I need to check if all the 4 types mentioned in the vector are available in the data frame for each group based on the location. If any of the types are missing in a group, I need to add a row with the missing element and the corresponding location with the quantity as 0 in the data frame.</p>
  <p>This is my expected output</p>
  <pre><code>dfOutput &lt;- data.frame(&quot;location&quot; = c(&quot;IND&quot;,&quot;IND&quot;,&quot;IND&quot;,&quot;IND&quot;,&quot;US&quot;,&quot;US&quot;,&quot;US&quot;,&quot;US&quot;), type = c(&quot;butter&quot;,&quot;milk&quot;,&quot;cheese&quot;,&quot;yogurt&quot;,&quot;butter&quot;,&quot;milk&quot;,&quot;cheese&quot;,&quot;yogurt&quot;), quantity = c(2,3,4,0,0,5,6,7))
  </code></pre>
  <p>How can I achieve this in R using <code>dplyr</code> package?</p>