How to make union of n sets using R?
<p>I have a list <code>g1</code> which consists of 1000 sublists. I want to make the union of all lists. I can make the manual entry like this-   </p>

<pre><code>union(g1[[1]],g1[[2]],g1[[3]]) and so on  
</code></pre>

<p>But I want to automate the process using loops in R. I tried using this code- </p>

<pre><code>for(i in 1:1000){g2&lt;-union(g1[[i]])}  
</code></pre>

<p>But this gives me final sublist, not the entire union. How it could be done?<br>
Thanks in advance.</p>