title: Expand the character vector v to 8 bits as follows: swap v[3] and v[4]
body: <p>I have a vector </p>
  
  <pre><code>s &lt;- "111000"
  v &lt;- as.character(unlist(strsplit(s,"")))
  </code></pre>
  
  <p>I need to take vector v, turn into an 8-bit long string, and swap the 3rd and 4th variable.</p>
  
  <p>So for example:
   Input Vector:</p>
  
  <pre><code>1 2 3 4 5 6 
  </code></pre>
  
  <p>Output Vector:</p>
  
  <pre><code>1 2 4 3 4 3 5 6
  </code></pre>
  
  <p>EDIT, so a lot of people misunderstanding the input/output.
  The numbers simply indicated the variable placement and where it is being switched.</p>
  
  <p>As to the actual vector in the problem: "111000".</p>
  
  <pre><code>Input Value: "1" "1" "1" "0" "0" "0"
  Output Value: "1" "1" "0" "1" "0" "1" "0" "0"
  </code></pre>
  
  <p>EDIT: Sorry for the question, it's how it was worded to me. But basically I am trying to do a block expansion. I am trying to create a function to take a 6-bit vector and return an 8 bit-value with the values being the output above. I have added a photo diagraming what is going on: </p>
  
  <p><a href="https://i.stack.imgur.com/xjBDj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xjBDj.png" alt="enter image description here"></a> </p>