title: Escaping quotes while calling sed from R
body: <p>When called from the terminal, </p>
  
  <pre><code>sed -i -e 's/^/#\x27 /' file
  </code></pre>
  
  <p>edits <code>file</code> by inserting <code>#'</code> at the beginning of each line.  But I want to do this from within <code>R</code>.  First, I note that executing the string</p>
  
  <pre><code>"sed -i -e \'s/^/#\x27 /\' file"
  </code></pre>
  
  <p>in <code>R</code> returns</p>
  
  <pre><code>"sed -i -e 's/^/#' /' file"
  </code></pre>
  
  <p>The problem is that the <code>\x27</code> got interpreted already, so my desired command</p>
  
  <pre><code>system("sed -i -e \'s/^/#\x27 /\' file")
  </code></pre>
  
  <p>fails with an error message about an unterminated string.  How can I pass the <code>sed</code> command to the command line from within <code>R</code>?</p>