p>It costs only one bit per element</p>

<pre><code class="r">object.size(b1)/n
#&gt; 0.1 bytes
</code></pre>

<p>A couple of standard methods work </p>

<pre><code class="r">b1[10:30] &lt;- TRUE
summary(b1)
#&gt;    FALSE     TRUE     Min.     Max. 
#&gt; 99999979       21       10       30
</code></pre>

<p>Create a another boolean vector with TRUE in some different positions</p>

<pre><code class="r">b2 &lt;- bit(n)
b2[20:40] &lt;- TRUE
b2
#&gt; bit length=100000000 occupying only 3125000 int32
#&gt;    