title: How to generate all possible strings given variable characters at given locations in R?
body: <p>Given an ordered vector of strings where each string shows the possible characters in that position, how can I get all possible combinations of strings?</p>
  <p>For example, given the vector:</p>
  <pre><code>vec &lt;- c(&quot;A&quot;, &quot;A&quot;, &quot;T&quot;, &quot;C&quot;, &quot;AG&quot;, &quot;ACG&quot;, &quot;T&quot;, &quot;A&quot;, &quot;A&quot;)
  </code></pre>
  <p>The possible string combinations, given positions 5 can be either &quot;A&quot; or &quot;G&quot;, and 6 can be &quot;A&quot;, &quot;C&quot;, or &quot;G&quot; are:</p>
  <pre><code>strings &lt;- c(&quot;AATCAATAA&quot;
               &quot;AATCACTAA&quot;
               &quot;AATCAGTAA&quot;
               &quot;AATCGATAA&quot;
               &quot;AATCGCTAA&quot;
               &quot;AATCGGTAA&quot;)
  </code></pre>