title: How to programmatically extract / unzip a .7z (7-zip) file with R
body: <p>I'm trying to automate the extraction of a number of files compressed with 7-zip.  I need to automate this process, because a) there are many years of data I'd like to unlock and b) I'd like to share my code with others and prevent them from repeating the process by hand.</p>
  
  <p>I have both WinRAR and 7-zip installed on my computer, and I can individually open these files easily with either program.</p>
  
  <p>I've looked around at the <code>unzip</code> <code>untar</code> and <code>unz</code> commands, but I don't believe any of them do what I need.</p>
  
  <p>I don't know anything about compression, but if it makes any difference: each of these files only contains <em>one</em> file and it's <em>just a text file</em>.</p>
  
  <p>I would strongly prefer a solution that does not require the user to install additional software (like WinRAR or 7-Zip) and execute a command with <code>shell</code>, although I acknowledge this task might be impossible with just R and CRAN packages.  I actually believe running <code>shell.exec</code> on these files with additional parameters might work on computers with WinRAR installed, but again, I'd like to avoid that installation if possible.  :)</p>
  
  <p>Running the code below will load the files I am trying to extract -- the .7z files in <code>files.data</code> are what needs to be unlocked.</p>
  
  <pre><code># create a temporary file and temporary directory, download the file, extract the file to the temporary directory
  tf &lt;- tempfile() ; td &lt;- tempdir()
  file.path &lt;- "ftp://ftp.ibge.gov.br/Orcamentos_Familiares/Pesquisa_de_Orcamentos_Familiares_2008_2009/Microdados/Dados.zip"
  download.file( file.path , tf , mode = "wb" )
  files.data &lt;- unzip( tf , exdir = td )
  
  # how do i unzip ANY of these .7z files?
  files.data
  </code></pre>
  
  <p>Thanks!!! :)</p>